-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketController.cs
More file actions
65 lines (45 loc) · 1.59 KB
/
SocketController.cs
File metadata and controls
65 lines (45 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System.Collections;
using System.Collections.Generic;
using XInputDotNetPure;
using UnityEngine;
public class SocketController : MonoBehaviour {
int playersTouchingSocket = 0;
bool playerOneTouchingSocket = false;
bool playerTwoTouchingSocket = false;
public AudioSource source;
public SpriteRenderer spriteRend;
public GameObject connectedParticles;
public AudioClip connectSound;
public Sprite connectedSprite;
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player") {
collision.gameObject.GetComponent<PlayerController>().Finished();
if (collision.gameObject.transform.position.x > 0) {
SocketConnected(2);
} else {
SocketConnected(1);
}
//Destroy(gameObject);
//playersTouchingSocket++;
}
}
/*private void OnTriggerExit2D(Collider2D collision)
{
if (collision.gameObject.tag == "Player") {
if (collision.gameObject.transform.position.x > 0) {
playerOneTouchingSocket = false;
} else {
playerTwoTouchingSocket = false;
}
// playersTouchingSocket++;
}
}*/
void SocketConnected(int winner)
{
connectedParticles.SetActive(false);
spriteRend.sprite = connectedSprite;
source.PlayOneShot(connectSound, 1f);
GameManager.instance.WinGame(winner);
}
}