Update README.md
[BattleCats.git] / Assets / Scripts / BossScripts / BossController.cs
blobe0ec11d54c557bacea4be83e53fd284052a057bc
1 using System.Collections;
2 using System.Collections.Generic;
3 using UnityEngine;
5 public class BossController : MonoBehaviour {
7 private CanRotatorFire rightCanScript;
8 private CanRotatorFire leftCanScript;
9 private BossMovement bossMovementScript;
11 private bool grenadeStart;
12 private bool chooseOnce;
13 private bool shootStart;
14 private bool strikeAttackOn;
15 public bool shoot;
16 public bool grenade;
17 public bool strikeAttack;
18 public bool automated;
19 public bool onceIdleTimer;
21 private float grenadeTimestamp;
22 private float grenadeTimer;
23 public float idleTimer;
24 private float idleTimestamp;
25 private float shootTimestamp;
26 public float shootTimer;
28 // Use this for initialization
29 void Start () {
30 shoot = false;
31 grenade = false;
32 grenadeStart = true;
33 shootStart = true;
34 automated = false;
35 onceIdleTimer = true;
36 chooseOnce = true;
37 idleTimer = 5f;
38 idleTimestamp = 0f;
40 grenadeTimer = 11f;
41 shootTimer = 10f;
43 bossMovementScript = GameObject.FindGameObjectWithTag ("TanukiSensei").GetComponent<BossMovement> ();
44 leftCanScript = GameObject.FindGameObjectWithTag ("BossLeftCan").GetComponent<CanRotatorFire> ();
45 rightCanScript = GameObject.FindGameObjectWithTag ("BossRightCan").GetComponent<CanRotatorFire> ();
46 rightCanScript.isRightCan = true;
50 // Update is called once per frame
51 void Update () {
52 if (automated) {
53 if (onceIdleTimer)
55 setIdleTimestamp ();
57 if (Time.time - idleTimestamp >= idleTimer)
59 if (chooseOnce) {
60 chooseOnce = false;
61 switch (Random.Range (0, 3)){
62 case 0:
63 shoot = true;
64 break;
65 case 1:
66 grenade = true;
67 break;
68 case 2:
69 strikeAttack = true;
70 break;
77 if (shoot)
79 if (shootStart)
81 setShootTimestamp ();
83 Shoot ();
84 if (Time.time - shootTimestamp >= shootTimer)
86 leftCanScript.noAimSequence = false;
87 rightCanScript.noAimSequence = false;
88 shoot = false;
89 shootStart = true;
90 onceIdleTimer = true;
94 if (grenade)
96 if (grenadeStart) {
97 setGrenadeTimestamp ();
99 Grenade ();
100 if (Time.time - grenadeTimestamp >= grenadeTimer) {
101 grenade = false;
102 grenadeStart = true;
103 rightCanScript.grenadeSequence = false;
104 leftCanScript.grenadeSequence = false;
105 bossMovementScript.fig8Path = false;
106 bossMovementScript.hoverPath = true;
107 onceIdleTimer = true;
111 if (strikeAttack)
113 bossMovementScript.hoverPath = false;
114 StrikeAttack ();
116 if (strikeAttackOn) {
117 if (!bossMovementScript.strikeAttack)
119 onceIdleTimer = true;
120 strikeAttackOn = false;
125 void Shoot()
127 //if boss is to the left of the yarn, fire with right can -on
128 if (bossMovementScript.currentHoverPath == 0) {
129 leftCanScript.noAimSequence = false;
130 rightCanScript.noAimSequence = true;
131 } else
133 leftCanScript.noAimSequence = true;
134 rightCanScript.noAimSequence = false;
138 void Grenade ()
140 bossMovementScript.hoverPath = false;
141 bossMovementScript.hover = false;
142 bossMovementScript.fig8Path = true;
143 leftCanScript.grenadeSequence = true;
144 rightCanScript.grenadeSequence = true;
147 void setGrenadeTimestamp()
149 grenadeStart = false;
150 grenadeTimestamp = Time.time;
153 void StrikeAttack()
155 bossMovementScript.strikeAttack = true;
156 strikeAttackOn = true;
157 strikeAttack = false;
160 void setIdleTimestamp(){
161 idleTimestamp = Time.time;
162 onceIdleTimer = false;
163 chooseOnce = true;
166 void setShootTimestamp()
168 shootTimestamp = Time.time;
169 shootStart = false;