void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Power") { powerCounter = 0f; speed = 2; anim.SetBool("isPower", true); } if (collision.gameObject.tag == "1Up") { Parent = transform.parent.GetComponent <PlayerHealth>(); Parent.LifePool += 1; if (Parent.PlayerCount == 1) { newPos = Random.Range(-9.0f, 9.0f); Instantiate(OtherP, new Vector3(spawnPos, newPos, 0f), transform.rotation); Parent.PlayerCount += 1; } } if (collision.gameObject.tag == "Enemy" && invCounter == -1) { // play death sound audio.Play(); newPos = Random.Range(-9.0f, 9.0f); Parent = transform.parent.GetComponent <PlayerHealth>(); SharkRef = GameObject.Find("Shark").GetComponent <SharkHealth>(); if (Parent.LifePool > 0) { transform.position = new Vector2(spawnPos, newPos); Parent.LifePool -= 1; invCounter = 0f; } else { Parent.PlayerCount -= 1; if (Parent.PlayerCount > 0) { Destroy(gameObject); } else { if (SharkRef.SharkHPCur == 0) { Application.LoadLevel("Draw Screen"); } else { Application.LoadLevel("Shark Win"); } } } } }
// Use this for initialization void Start() { sharkHealthRef = GameObject.Find("Shark").GetComponent <SharkHealth>(); fullHP = sharkHealthRef.SharkHPMax; healthBarRef = GameObject.Find("Health Bar Foreground"); healthBarFullSize = healthBarRef.transform.localScale; sharkControlRef = sharkHealthRef.GetComponent <SharkControl>(); fullEnergy = sharkControlRef.maximumEnergy; energyBarRef = GameObject.Find("Energy Bar Foreground"); energyBarFullSize = energyBarRef.transform.localScale; playerHealthRef = GameObject.Find("Players").GetComponent <PlayerHealth>(); fullLives = playerHealthRef.LifePool; }
// Use this for initialization void Start() { sharkHealthRef = GameObject.Find("Shark").GetComponent<SharkHealth>(); fullHP = sharkHealthRef.SharkHPMax; healthBarRef = GameObject.Find("Health Bar Foreground"); healthBarFullSize = healthBarRef.transform.localScale; sharkControlRef = sharkHealthRef.GetComponent<SharkControl>(); fullEnergy = sharkControlRef.maximumEnergy; energyBarRef = GameObject.Find("Energy Bar Foreground"); energyBarFullSize = energyBarRef.transform.localScale; playerHealthRef = GameObject.Find("Players").GetComponent<PlayerHealth>(); fullLives = playerHealthRef.LifePool; }
public void SetBossHealth(string bossName) { GameObject boss = GameObject.Find(bossName); if (bossName == "PenguBoss" || bossName == "PenguBoss(Clone)") { bossHealth = boss.GetComponent <Health>(); bossHealth.SetHealthBar(bossHealth.health, true); } else { bossHealthS = boss.GetComponent <SharkHealth>(); bossHealthS.SetHealthBar(bossHealthS.health, true); } SetBossName(bossName); }
void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.tag == "Power") { powerCounter = 0f; speed = 2; anim.SetBool("isPower", true); } if (collision.gameObject.tag == "1Up") { Parent = transform.parent.GetComponent<PlayerHealth>(); Parent.LifePool += 1; if(Parent.PlayerCount == 1){ newPos = Random.Range (-9.0f, 9.0f); Instantiate(OtherP, new Vector3 (spawnPos, newPos, 0f), transform.rotation); Parent.PlayerCount += 1; } } if (collision.gameObject.tag == "Enemy" && invCounter == -1) { // play death sound audio.Play(); newPos = Random.Range (-9.0f, 9.0f); Parent = transform.parent.GetComponent<PlayerHealth>(); SharkRef = GameObject.Find("Shark").GetComponent<SharkHealth>(); if (Parent.LifePool > 0) { transform.position = new Vector2 (spawnPos, newPos); Parent.LifePool -= 1; invCounter = 0f; } else { Parent.PlayerCount -= 1; if(Parent.PlayerCount > 0){ Destroy(gameObject); } else { if (SharkRef.SharkHPCur == 0){ Application.LoadLevel ("Draw Screen"); } else { Application.LoadLevel ("Shark Win"); } } } } }
private void Awake() { currentSharkState = SharkState.Roaming; sharkHealth = this.GetComponent <SharkHealth>(); }