Esempio n. 1
0
    public void OnTriggerEnter(Collider other)
    {
        //When gun pickup is touched
        foreach (Gun _gun in possibleGuns)
        {
            if (_gun.name == other.gameObject.tag)
            {
                SpawnObject spawner = other.transform.parent.GetComponent <SpawnObject>();
                spawner.Invoke("CreateNewObject", spawner.coolDown);

                timeBetweenShots = _gun.timeToNextShot;

                currentGun = _gun;


                Destroy(other.gameObject);

                Debug.Log("Item collected");
            }
        }

        //When ammo is touched
        if (other.gameObject.tag == "Ammo")
        {
            SpawnObject spawner = other.transform.parent.GetComponent <SpawnObject>();
            spawner.Invoke("CreateNewObject", spawner.coolDown);

            ammoLeft += other.gameObject.GetComponent <GiveAmmo>().ammoToGive;

            Destroy(other.gameObject);
        }
    }