private void PlayerDamageHandler() { if (HealthBarScript.health + HealthBarScript.shieldPoints < damage) { player.GetComponent <PlayerGetsHit>().TakeDamage(HealthBarScript.health, this.gameObject.tag); HealthBarScript.health = 0; } else { if (PowerUpActivation.powerupEnablers[1]) { if (HealthBarScript.shieldPoints >= damage) { HealthBarScript.shieldPoints -= damage; GameController.ShowTextEffect(-damage, shieldText, player.transform); } else { HealthBarScript.health -= damage - HealthBarScript.shieldPoints; GameController.ShowTextEffect(-HealthBarScript.shieldPoints, shieldText, player.transform); player.GetComponent <PlayerGetsHit>().TakeDamage(damage - HealthBarScript.shieldPoints, this.gameObject.tag); HealthBarScript.shieldPoints = 0; PowerUpActivation.FreeCooldownBarPositions(PowerUpActivation.instances[1]); } } else { HealthBarScript.health -= damage; player.GetComponent <PlayerGetsHit>().TakeDamage(damage, this.gameObject.tag); } } canTrigger = false; }
private void Awake() { player = GameObject.Find("Player"); activation = GameObject.Find("GameController").GetComponent <PowerUpActivation>(); shieldPoints = HealthBarScript.shieldPoints; shieldGain = HealthBarScript.shieldGain; maxHealth = HealthBarScript.maxHealth; }
void EndGame() { canScore = false; //canSpawn = false; gameRunning = false; //ShootMissle.canShoot = false; PowerUpActivation.NullOrderedBarsList(); PlayerPrefs.SetInt("Loot", CoinScript.coinCount); StartCoroutine(GameEndWait()); }
void Update() { if (health <= 0) { health = 0; canTakeDamage = false; } else { canTakeDamage = true; } if (health > maxHealth) { health = maxHealth; } if (PowerUpActivation.powerupEnablers[1] && shieldPoints > 0) { canBreakShield = true; shieldText.SetActive(true); shieldText.GetComponent <TextMesh>().text = "+ " + shieldPoints.ToString(); if (shieldPoints + health >= maxHealth) { shieldBar.fillAmount = 1; healthBar.fillAmount = health / (maxHealth + shieldPoints); } else { healthBar.fillAmount = health / maxHealth; shieldBar.fillAmount = (health + shieldPoints) / maxHealth; } } else { healthBar.fillAmount = health / maxHealth; shieldBar.fillAmount = 0; shieldPoints = 0; PowerUpActivation.powerupEnablers[1] = false; Destroy(PowerUpActivation.instances[1]); shieldText.SetActive(false); if (canBreakShield) { GameController.ShowPowerUpAnimation(disappearingAnimation, player.transform); PowerUpActivation.FreeCooldownBarPositions(PowerUpActivation.instances[1]); canBreakShield = false; } } }
public void RestartGame() { PowerUpActivation.NullOrderedBarsList(); // null powerup cooldown placers ctrlScript.resetMoveSpeed(); SceneManager.LoadScene(SceneManager.GetActiveScene().name); ShootMissle.canShoot = true; //spellButton.SetEnabled(); HealthBarScript.shieldPoints = 0; HealthBarScript.canBreakShield = false; CoinScript.coinCount = 0; ctrlScript.cooldown = 3.0f; ctrlScript.savedSpeed = 0.5f; Time.timeScale = 1f; ctrlScript.canSpawn = true; ctrlScript.gameRunning = true; }