Repository navigation
Expand file tree
/
Copy pathGrassCollision.cs
More file actions
133 lines (119 loc) · 3.66 KB
/
Copy pathGrassCollision.cs
File metadata and controls
133 lines (119 loc) · 3.66 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GrassCollision : MonoBehaviour
{
public GameObject routePannel;
public GameObject nightScreen;
public GameObject playerObj;
public Sprite nightSprite;
public Sprite daySprite;
public Sprite townSprite;
public Image routeImage;
public Text routeText;
public Transform player;
public GameObject battleScene;
public string whatPKMN;
public string whatLevel;
int route;
int hour;
int randomEncounter, randomPokemon, randomLevel;
bool isNight;
string pokemon;
// Start is called before the first frame update
void Start()
{
playerObj = GameObject.FindGameObjectWithTag("Player");
whatPKMN = null;
}
// Update is called once per frame
void Update()
{
hour = System.DateTime.Now.Hour;
if ((hour >= 18 || hour <= 5) && (playerObj.transform.position.x < 800f && playerObj.transform.position.y < 800f))
{
nightScreen.SetActive(true);
isNight = true;
} else if ((hour < 18 || hour > 5) || (playerObj.transform.position.x >= 800f && playerObj.transform.position.y >= 800f))
{
nightScreen.SetActive(false);
isNight = false;
}
}
void HideText ()
{
routePannel.SetActive(false);
}
void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.tag == "Grass")
{
Encounters();
}
if (collision.gameObject.tag == "Route 1")
{
CheckNight();
if (route == 0)
{
routeText.text = "Route 1";
routePannel.SetActive(true);
Invoke("HideText", 2.0f);
route++;
} else
{
routeImage.sprite = townSprite;
routeText.color = Color.black;
routeText.text = "Starting Town";
routePannel.SetActive(true);
Invoke("HideText", 2.0f);
route--;
}
}
}
void CheckNight()
{
if (isNight)
{
nightScreen.SetActive(true);
routeImage.sprite = nightSprite;
routeText.color = Color.white;
}
}
public void Encounters ()
{
if (route == 1)
{
randomEncounter = (int)Random.Range(1f, 6f);
if (randomEncounter == 1f)
{
randomPokemon = (int)Random.Range(1f, 101f);
if (randomPokemon >= 1 && randomPokemon <= 45)
{
pokemon += "Wurmple";
} else if (randomPokemon > 45 && randomPokemon <= 90)
{
pokemon += "Poochyena";
} else
{
pokemon += "Zigzagoon";
}
randomLevel = (int)Random.Range(1f, 3f);
if (randomLevel == 1)
{
whatLevel = "Lvl 2 ";
} else
{
whatLevel = "Lvl 3 ";
}
//Debug.Log(pokemon);
whatPKMN = pokemon;
battleScene.SetActive(true);
/*dialouge = "A wild " + whatPKMN + " approaches...";
Encounter.text = dialouge*/
pokemon = "";
Time.timeScale = 0f;
}
}
}
}