-
Notifications
You must be signed in to change notification settings - Fork 0
/
UpdateManger.cs
138 lines (110 loc) · 3.89 KB
/
UpdateManger.cs
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
134
135
136
137
138
using System.Collections;
using UnityEngine;
public class UpdateManger : MonoBehaviour
{
public LifeManager Life;
public SCore score;
public BallMotor Player;
public GameObject spawnPart;
public GameObject BluePart;
//Use for Player spawning
public int PlayerNo;
public GameObject Hatter;
public GameObject EggNULL;
public GameObject EggHelmet;
public GameObject EggHat;
//gameobject for Yolk spawning
public GameObject spawnObj;
public GameObject spawnObj2;
public GameObject imageT;
public GameObject costume;
public GameObject spawnpoint;
public GameObject spawnpoint2;
public int Delay = 20;
// Use this for initialization
void Start()
{
Life = FindObjectOfType<LifeManager>();
score = FindObjectOfType<SCore>();
Player = FindObjectOfType<BallMotor>();
PlayerNo = PlayerPrefs.GetInt("PlayerNO");
StartCoroutine("LessLifeCo");
if (PlayerNo == 1)
{
GameObject obnew = (GameObject)Instantiate(EggHelmet, Hatter.transform.position, Player.transform.rotation);
obnew.transform.parent = costume.gameObject.transform;
Debug.Log("Helmet Spawned");
}
else if (PlayerNo == 2)
{
GameObject obnew = (GameObject)Instantiate(EggHat, Hatter.transform.position, Player.transform.rotation);
obnew.transform.parent = costume.gameObject.transform;
Debug.Log("HAt Spawned");
}
else
{
GameObject obnew = (GameObject)Instantiate(EggNULL, Player.transform.position, Player.transform.rotation);
obnew.transform.parent = costume.gameObject.transform;
Debug.Log("Null Spawned");
}
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "grow")
{
score.AddPoints();
GetComponent<AudioSource>().Play();
SpawnCo();
Life.FillLife();
Destroy(other.gameObject);
Instantiate(spawnPart, other.transform.position, other.transform.rotation);
}
if (other.tag == "speed")
{
score.AddPoints();
Life.GetComponent<AudioSource>().Play();
BlueSpawnCo();
Life.TwoLife();
Destroy(other.gameObject);
Instantiate(BluePart, other.transform.position, other.transform.rotation);
}
}
void SpawnCo()
{
Instantiate(spawnPart, spawnpoint.transform.position, spawnpoint.transform.rotation);
GameObject obnew = (GameObject)Instantiate(spawnObj, spawnpoint.transform.position, spawnpoint.transform.rotation);
obnew.transform.parent = imageT.gameObject.transform;
Debug.Log("Yellow Spawned");
}
void BlueSpawnCo()
{
StartCoroutine("speedCo");
}
public IEnumerator speedCo()
{
Player.moveSpeed = 50;
yield return new WaitForSeconds(Delay);
Player.moveSpeed = 30;
score.GetComponent<AudioSource>().Play();
Instantiate(BluePart, spawnpoint2.transform.position, spawnpoint2.transform.rotation);
GameObject obnew2 = (GameObject)Instantiate(spawnObj2, spawnpoint2.transform.position, spawnpoint2.transform.rotation);
obnew2.transform.parent = imageT.gameObject.transform;
Debug.Log("Blue Spawned");
}
//Start reducing FullLIfe Value;
public IEnumerator LessLifeCo()
{
yield return new WaitForSeconds(180);
Life.FullLife = 5;
StartCoroutine("LessLife2Co");
}
public IEnumerator LessLife2Co()
{
yield return new WaitForSeconds(120);
Life.FullLife = 4;
}
}