Пример #1
0
 void OnTriggerEnter(Collider other)
 {
     if (tag == "Bullet")
     {
         if (other.tag == "Hostile")
         {
             Destroy(other.gameObject);
             Destroy(gameObject);
             Debug.Log(other.gameObject.name + " destroyed " + gameObject.name, this);
             score.AddKill();
         }
         else if (other.tag == "Friendly")
         {
             Destroy(other.gameObject);
             Destroy(gameObject);
             Debug.Log(other.gameObject.name + " destroyed " + gameObject.name, this);
             score.AddFriendKill();
         }
     }
     else if (tag == "Player")
     {
         if (other.tag == "Hostile" || other.tag == "HostileBullet" || other.tag == "Friendly")
         {
             game.Lose();
         }
         else if (other.tag == "Target")
         {
             game.Win();
         }
     }
 }
Пример #2
0
    // When the enemy dies
    void OnDeath()
    {
        scoreManager.AddKill();               // add a kill to the score
        currencyManager.AddSouls(soulsValue); // add souls
        popuptext.SetPopUpText(transform.position, "+" + soulsValue, PopUpText.Types.Souls, new Color(255, 255, 255));

        waveManager.EnemyKilled();

        if (gameModeManager.gameMode == "staying-alive")
        {
            playerEntity.Heal(5, true);
        }

        Vector3    pos       = new Vector3(transform.position.x, transform.position.y + 2f, transform.position.z);
        GameObject particles = Instantiate(deathEffect, pos, Quaternion.identity) as GameObject;

        if (livingEntity.lastHitBy != null && livingEntity.lastHitBy.GetComponent <GunController>().EquippedGun != null)
        {
            particles.transform.rotation = livingEntity.lastHitBy.GetComponent <GunController> ().EquippedGun.transform.rotation;
        }
        else if (GameObject.Find("Player").GetComponent <GunController>().EquippedGun != null)
        {
            particles.transform.rotation = GameObject.Find("Player").GetComponent <GunController> ().EquippedGun.transform.rotation;
        }

        if (drops.IsHoldingItem())
        {
            GameObject weapon = Instantiate(drops.GetHeldItem(), transform.position, Quaternion.identity) as GameObject;
            weapon.GetComponent <ItemObject> ().DropItem();
        }

        unit.target = null;
        Destroy(gameObject);
    }