Beispiel #1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == "Shotgun")
        {
            print(GameManager.instance.AllGuns["Shotgun"].Name);
            gunController.EquipGun(GameManager.instance.AllGuns["Shotgun"]);
            gunController.AddSHotgunAmmo(ShotgunAmmo);
            Destroy(other.gameObject);
        }
        else if (other.gameObject.tag == "ShotgunAmmo")
        {
            int ammo = other.GetComponent <AmmoPickUp>().AmmoAmount;
            ShotgunAmmo += ammo;
            if (gunController.GetGunName() == "Shotgun")
            {
                gunController.AddSHotgunAmmo(ShotgunAmmo);
            }

            AudioClip audio = other.GetComponent <AmmoPickUp>().PickUpSound;
            if (audio != null)
            {
                AudioManager.instance.PlayCLipAtPlayer(audio);
            }
            Destroy(other.gameObject);
        }
        else if (other.gameObject.tag == "MedKit")
        {
            if (player.Health < player.StartingHealth)
            {
                int health = other.GetComponent <MedKit>().HealthAmount;
                player.Health += health;
                AudioClip audio = other.GetComponent <MedKit>().PickUpSound;
                if (audio != null)
                {
                    AudioManager.instance.PlayCLipAtPlayer(audio);
                }
                Destroy(other.gameObject);
            }
        }
        else if (other.gameObject.tag == "EndGame")
        {
            GameManager.instance.EndGame();
        }
    }