-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTileSwapTrigger.cs
More file actions
102 lines (67 loc) · 2.59 KB
/
TileSwapTrigger.cs
File metadata and controls
102 lines (67 loc) · 2.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TileSwapTrigger : MonoBehaviour
{
public GameObject inside;
public GameObject outside;
public GameObject barrierIn;
public GameObject barrierOut;
public bool isTriggered;
public bool off;
public bool oneWay;
public bool IN;
// Start is called before the first frame update
void Start()
{
isTriggered = false;
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.gameObject.tag == ("Player") && off == false)
{
isTriggered = true;
if (!oneWay)
{
if (GameObject.Find("Player").GetComponent<PlayerBehaviour>().outCave == true)
{
col.gameObject.GetComponent<PlayerBehaviour>().ChangeTile(false);
barrierOut.SetActive(false);
barrierIn.SetActive(true);
LeanTween.move(col.gameObject, inside.transform.position, 0.18f);
}
else if (GameObject.Find("Player").GetComponent<PlayerBehaviour>().outCave == false)
{
col.gameObject.GetComponent<PlayerBehaviour>().ChangeTile(true);
barrierIn.SetActive(false);
barrierOut.SetActive(true);
LeanTween.move(col.gameObject, outside.transform.position, 0.18f);
}
}
if (oneWay)
{
if (GameObject.Find("Player").GetComponent<PlayerBehaviour>().outCave == true && IN)
{
col.gameObject.GetComponent<PlayerBehaviour>().ChangeTile(false);
LeanTween.move(col.gameObject, inside.transform.position, 0.18f);
}
else if (GameObject.Find("Player").GetComponent<PlayerBehaviour>().outCave == false && !IN)
{
col.gameObject.GetComponent<PlayerBehaviour>().ChangeTile(true);
LeanTween.move(col.gameObject, outside.transform.position, 0.18f);
}
}
}
}
void OnTriggerExit2D(Collider2D col)
{
if (col.gameObject.tag == ("Player"))
{
isTriggered = false;
}
}
}