Beispiel #1
0
    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);
            }
        }
    }
Beispiel #2
0
    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);
        }
    }
Beispiel #3
0
 public void TakeDamage(int damage)
 {
     currentHealth -= damage;
     player_Health.SetHealth(currentHealth);
 }