void Start() { gameSys = GetComponent <GameSystem>(); playerSP = GetComponent <PlayerSP>(); enemyMan = GetComponent <EnemyMan>(); playerHealth = GetComponent <PlayerHealth>(); costDestroy = 5; costHardening = 15; costFreeze = 25; costAnnihilate = 45; costHeal = 50; }
// Use this for initialization void Start() { playerSP = GetComponent <PlayerSP>(); if (PlayerPrefs.HasKey("manaCharge1")) { potion1Txt.text = PlayerPrefs.GetInt("manaCharge1").ToString(); } if (PlayerPrefs.HasKey("manaCharge2")) { potion2Txt.text = PlayerPrefs.GetInt("manaCharge2").ToString(); } if (PlayerPrefs.HasKey("manaCharge3")) { potion3Txt.text = PlayerPrefs.GetInt("manaCharge3").ToString(); } }
public void OnTriggerEnter(Collider other) { //print(other.tag); if (other.CompareTag("Player")) { PlayerSP playerObject = other.gameObject.GetComponent <PlayerSP>(); if (playerObject != null) { playerObject.applyPowerup(powerupType); DestroyOrRespawn(); } } if (other.CompareTag("Explosion") && invulnTimer <= 0) { //Maybe create some custom explosion effect? DestroyOrRespawn(); } }
public void TakeDamage(int amount, bool canGenerateDrop = true) { if (alreadyDead) { return; } if (currentInvulnTime > 0) { return; } print("I will now take damage." + amount); if (hudForPlayer != null) { //Players will not take any damage if the level has completed. if (hudForPlayer.gameOver) { return; } } currentHealth -= amount; print("Current HP: " + currentHealth); if (hudForPlayer != null) { hudForPlayer.UpdateLives(); } if (currentHealth <= 0) { //Play death sound if it has one. if (AUDIO != null || dieSound != null) { AUDIO.pitch = 1f; AUDIO.timeSamples = 0; AUDIO.clip = dieSound; AUDIO.Play(); } alreadyDead = true; //This bool is set to make sure that the death scripting isn't run more than once. //This is important for objects that spawn things when destroyed, such as powerups. if (isAPlayer) { //Reset all the player's stats. PlayerSP playerScript = GetComponent <PlayerSP>(); if (playerScript != null) { playerScript.currentLives--; if (hudForPlayer != null) { hudForPlayer.UpdateLives(); } print("reduced to " + playerScript.currentLives + " lives."); playerScript.DIE(); /* * if (playerScript.currentLives > 0) * Respawn(); * else * { * gameObject.SetActive(false); * } */ } } else if (canGenerateDrop) { ItemSpawnDestroy(); } else { EnemyBaseEntity enemyScript = GetComponent <EnemyBaseEntity>(); if (enemyScript != null) { enemyScript.DeathAnimation(); } } if (isAnEnemy) { hudForPlayer.AddOrRemoveEnemy(-1); } } else { looksInvuln = true; if (invulnEffect != null) { invulnEffect.SetActive(true); } currentInvulnTime = invulnTime; } }