public virtual void OnCollisionEnter2D(Collision2D coll) { if (coll.collider.tag == "Ground") { groundController.DestroyGround(destructionCircle); Explode(); MakeSoundExplosion(); // Destroy (this.gameObject); // Instantiate (boom); // boom.Play (); } else if (coll.collider.tag == "Tank" || coll.collider.tag == "Hitable") { // Destroy (gameObject); Explode(); MakeSoundExplosion(); // Instantiate (boom); // boom.Play (); //health.TakeDamage(20); if (coll.gameObject.GetComponent <Player_Health> () != null) { // print ("folgender Tank wurde getroffen: " + coll.gameObject); p_health = coll.gameObject.GetComponent <Player_Health> (); p_health.SetHealth(10f); } } }
public IEnumerator RespawnPlayer(GameObject player) { Camera.main.GetComponent <CameraController> ().TurnOnShake(); int playerId = player.GetComponent <PlayerTag> ().Id; respawnTicks [playerId] = 41; /*Time.timeScale = .1f; * for (int i = 0; i < 9; i++) { * yield return new WaitForSeconds (.1f); * Time.timeScale += .1f; * if (Time.timeScale > 1f) Time.timeScale=1f; * }*/ while (respawnTicks[playerId] > 0) { yield return(new WaitForSeconds(.5f)); respawnTicks[playerId] -= 5; } player.SetActive(true); Base_WeaponManager weaponManager = player.GetComponent <Base_WeaponManager> (); Player_Health healthScript = player.GetComponent <Player_Health> (); Base_Player_Movement movementScript = player.GetComponent <Base_Player_Movement> (); PlayerController playerController = player.GetComponent <PlayerController> (); weaponManager.RefreshWeapons(); float tempHealth = healthScript.Health_Max; tempHealth = Mathf.Ceil(tempHealth * 1.33f); healthScript.SetHealth(tempHealth, tempHealth, 0f); movementScript.ResetMovementValues(); playerController.SetInputActive(true); playerController.RefreshCanSwitch(); player.transform.position = spawnPoints [playerId].position; healthScript.StartCoroutine(healthScript.InvincibilityRoutine(60f)); healthScript.ResetHarsh(); //PowerupManager powMan = player.GetComponent<PowerupManager> (); //powMan.Reset (); TODO if (gameMode != GAMEMODE.PVE || gameMode != GAMEMODE.PVP_GUNS) { player.GetComponent <PlayerEnemyHandler> ().GiveEnemy(1); } }
public void TakeDamage(int damage) { currentHealth -= damage; player_Health.SetHealth(currentHealth); }