void TakeDamage(int damage) { currentHealth += damage; healthBar.SetHealth(currentHealth); if (currentHealth <= 0) { currentHealth = 100; death += 1; } }
void HealthCounter(int num) { currentHeath += num; health.SetHealth(currentHeath); if (currentHeath <= 0) { currentHeath = 100; } }
void Update() { // game stops and shows leaderboard if (GameTimer <= 0) { board.SetActive(true); Time.timeScale = 0F; Endgame(); } // runs kill and end game script to input kills and death values //Endgame(); healthBar = GameObject.Find("OsledShip(Clone)/PirateShip(Clone)/Canvas/Health").GetComponent <shiphealth>(); healthBar1 = GameObject.Find("PataShip(Clone)/PirateShip(Clone)/Canvas/Health").GetComponent <shiphealth>(); healthBar2 = GameObject.Find("JeroenShip(Clone)/PirateShip(Clone)/Canvas/Health").GetComponent <shiphealth>(); // gets the health of the AIs Osledhealth = healthBar.health; Patahealth = healthBar1.health; Jeroenhealth = healthBar2.health; // checks the AIs health and respawn on death and reset their health and cannons if (Osledhealth <= 0) { int I = Random.Range(0, 3); Debug.Log("f**k i respawned with now caps" + "ahha"); GameObject.Find("OsledShip(Clone)").transform.position = SpawnPoints[I].transform.position; OsledDeath += 1; healthBar.health = 100; healthBar.SetHealth(100); } if (Patahealth <= 0) { int I = Random.Range(0, 3); GameObject.Find("PataShip(Clone)").transform.position = SpawnPoints[I].transform.position; PataDeath += 1; healthBar1.health = 100; healthBar1.SetHealth(100); } if (Jeroenhealth <= 0) { JeroenDeath += 1; int I = Random.Range(0, 3); GameObject.Find("JeroenShip(Clone)").transform.position = SpawnPoints[I].transform.position; healthBar2.health = 100; healthBar2.SetHealth(100); } }
//take damage function, is activated on trigger enter and sets how much damage a ship can take void TakeDamage(int damage) { currentHealth += damage; healthBar.SetHealth(currentHealth); if (currentHealth <= 0) { GameObject.Find("OsledShip(Clone)/PirateShip(Clone)/Lookout/Sphere").GetComponent <Lookoutosled>().cannons = 20; currentHealth = 100; death += 1; sails[0].SetActive(true); sails[1].SetActive(true); sails[2].SetActive(true); particles.Stop(); } }
/* * Checks if the ship was damaged. */ private void Damaged(int damage) { currentHP += damage; healthBar.SetHealth(currentHP); }
void TakeDamage(int damage) { currentHealth += damage; healthBar.SetHealth(currentHealth); }