This repository has been archived by the owner on Dec 24, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBonusGenerator.boo
51 lines (42 loc) · 2.15 KB
/
BonusGenerator.boo
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
import UnityEngine
class BonusGenerator (MonoBehaviour):
public health as GameObject
public missAmmo as GameObject
public nukeAmmo as GameObject
private speed as double
private maxBonusSpeed = 50.0f
private minBonusSpeed = 5.0f
private bonusTimer = 15.0
private bonusCoolDown as double
private bonusHeight = 4.0 // Bonus objects travel above the game's plane
// at a height of "bonusHeight", so that they
// remain in front of other objects in the game view.
def Start ():
bonusCoolDown = bonusTimer // sets a cool down time of "bonusCoolDown" between each instance
// of bonus object generation.
def Update ():
if bonusCoolDown > 0: bonusCoolDown -= Time.deltaTime
if bonusCoolDown <= 0:
bonusCoolDown = 0
if AsteroidGenerator.startScreen == false: BonusGen() // to prevent generation of bonus items during the start screen
def BonusGen():
x = Random.Range(GameData.maxHorizScreen + GameData.astGenExt, GameData.maxHorizObj)
z = Random.Range(GameData.minVertScreen, GameData.maxVertScreen)
speed = Random.Range(minBonusSpeed, maxBonusSpeed)
select = Random.Range(0,100) //to determine which Bonus is generated
if select <= 15:
healthClone = Instantiate(health, Vector3(x, bonusHeight, z), Quaternion.identity) as GameObject
healthClone.transform.Rotate(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360))
healthClone.GetComponent[of Rigidbody]().velocity = Vector3.left * speed
healthClone.tag = ("healthPack")
elif select <= 40:
nukeClone = Instantiate(nukeAmmo, Vector3(x, bonusHeight, z), Quaternion.identity) as GameObject
nukeClone.transform.Rotate(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360))
nukeClone.GetComponent[of Rigidbody]().velocity = Vector3.left * speed
nukeClone.tag = ("nukeAmmo")
elif select <= 85:
missClone = Instantiate(missAmmo, Vector3(x, bonusHeight, z), Quaternion.identity) as GameObject
missClone.transform.Rotate(Random.Range(0, 360), Random.Range(0, 360), Random.Range(0, 360))
missClone.GetComponent[of Rigidbody]().velocity = Vector3.left * speed
missClone.tag = ("missileAmmo")
bonusCoolDown = bonusTimer