Example #1
0
    protected virtual void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag("Player"))
        {
            // SFX
            pickUPeffect.Play();

            // If player enters the level - power up should stay
            DontDestroyOnLoad(gameObject);
            StopCoroutine(destroy);
            OnPickUP?.Invoke();
            AudioManager.instance.PlaySound("PowerUPPickUP");
            StartCoroutine(Pickup(other));
        }
    }
Example #2
0
    protected virtual void PickUP()
    {
        StopCoroutine(destroy);

        AudioManager.instance.PlaySound("AmmoPickUP");
        OnPickUP?.Invoke();

        // If player has this type of weapon - add ammo
        if (playerInventory.availableGuns[weaponID])
        {
            playerInventory.availableGuns[weaponID].RefillAmmo();
        }

        // Destroy a ammo box object
        Destroy(gameObject);
    }