// Use this for initialization void Start() { transform.position = Vector3.zero; tc = GetComponentInChildren <TornadoController> (); ecc = GetComponentInChildren <EmptyCarController> (); esc = GetComponentInChildren <EmptySharkController> (); sc = GetComponentInChildren <SharkController> (); cc = GetComponentInChildren <CowController> (); ebc = GetComponentInChildren <EmptyBarnController> (); sbc = GetComponentInChildren <SpinBarnController> (); tornado = GameObject.Find("Tornado"); car = GameObject.Find("Car"); emptyCar = GameObject.Find("EmptyCar"); shark = GameObject.Find("Shark"); emptyShark = GameObject.Find("EmptyShark"); emptySpin = GameObject.Find("EmptySpin"); emptyBarn = GameObject.Find("EmptyBarn"); tornadoOldSpeed = 0; carOldSpeed = 0; sharkOldSpeed = 0; sharkOldOsciSpeed = 0; barnOldSpeed = 0; barnOldSpinSpeed = 0; cowOldSpeed = 0; allPaused = false; barnPaused = false; sharkPaused = false; carPaused = false; windowRect = new Rect(0, 0, 600, 200); tornadoScale = 1.0F; barnRotateSpeed = 40.0f; barnSpinSpeed = 100.0F; sharkRotateSpeed = 60.0f; sharkOsciSpeed = 30.0f; sharkOsciRange = 8.0F; carRotateSpeed = 30.0F; carDirection = 180.0F; }
void FireMissile() { if (!isPaused) { for (int i = 0; i < sharkAmount; i++) { if (sharkPool [i].activeInHierarchy == false) { sharkPool [i].transform.position = gameObject.transform.position; sharkCon = sharkPool [i].GetComponent<SharkController>(); sharkCon.lifetime = 10f; //birdCon.missileVelocity = 4f; sharkCon.startTime = Time.time; sharkCon.hit = false; sharkPool [i].SetActive(true); sharkCon.baconSpot = targetBacon; sharkCon.boatEdge = boatEdge; sharkCon.screenEdge = screenEdge; sharkCon.playerHitArea = playerArea; //print("something"); if (boatEdge == null) { // print("boat edge is null"); } if ((sharkCon.boatEdge != null) && (sharkCon.screenEdge != null)) { sharkCon.hasobjects = true; } sharkCon.Fire(); return; } } } }
void pauseActiveEnemies() { for (int i = 0; i < sharkAmount; i++) { if (sharkPool [i].activeInHierarchy == true) { sharkCon = sharkPool [i].GetComponent<SharkController>(); if(isPaused){ sharkCon.isPaused = true; } else { sharkCon.isPaused = false; } } } }
public float EncounterDistance; //How close to get to target befor circling void Start() { SController = GetComponent <SharkController>(); Anim = GetComponentInChildren <Animator>(); CurrentLocation = Boat; }
void OnTriggerEnter2D(Collider2D other) { //If player collided with coin, increase the instance point by 10 if (other.gameObject.tag == "Coin") { Player.Instance.Points += 10; Debug.Log("Collision with" + other.gameObject.tag); CoinController coin = other.gameObject.GetComponent <CoinController>(); if (coin != null) { GameObject st = Instantiate(star); st.transform.position = coin.transform.position; coin.Reset(); } } //If player collided with PowerCoin, increase the instance health by 10 if (other.gameObject.tag == "PowerCoin") { Player.Instance.Health += 10; Debug.Log("Collision with" + other.gameObject.tag); PowerCoinController powerCoin = other.gameObject.GetComponent <PowerCoinController>(); if (powerCoin != null) { GameObject sw = Instantiate(sword); sw.transform.position = powerCoin.transform.position; powerCoin.destroy(); } } //If player collided with shark, game over if (other.gameObject.tag == "Shark") { Player.Instance.Health -= 20; Debug.Log("Collision with" + other.gameObject.tag); SharkController shark = other.gameObject.GetComponent <SharkController>(); if (shark != null) { GameObject bl = Instantiate(blood); bl.transform.position = shark.transform.position; } } //If player collided with octopus, decrease the instance health by 10 else if (other.gameObject.tag == "Octopus") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health -= 10; OctopusController octopus = other.gameObject.GetComponent <OctopusController>(); if (octopus != null) { GameObject bl = Instantiate(blood); bl.transform.position = octopus.transform.position; octopus.Reset(); } } //If player collided with submarine, game over else if (other.gameObject.tag == "Submarine") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health -= 30; SubmarineController submarine = other.gameObject.GetComponent <SubmarineController>(); if (submarine != null) { GameObject bl = Instantiate(blood); bl.transform.position = submarine.transform.position; } } //If player collided with submarine, game end else if (other.gameObject.tag == "Bullet") { Debug.Log("Collision with" + other.gameObject.tag); Player.Instance.Health = 0; BulletController bullet = other.gameObject.GetComponent <BulletController>(); if (bullet != null) { GameObject bl = Instantiate(blood); bl.transform.position = bullet.transform.position; bullet.destroy(); } } }