Exemple #1
0
    public void OnTriggerEnter(Collider other)
    {
        Controller_Powerup buffController = other.GetComponent <Controller_Powerup>();

        if (buffController != null)
        {
            switch (currentPowerupType)
            {
            case PowerupType.powerupHealth:
            {
                buffController.add(healthPowerup);
                break;
            }

            case PowerupType.powerupSpeed:
            {
                buffController.add(speedPowerup);
                break;
            }

            case PowerupType.firerate:
            {
                buffController.add(firerate);
                break;
            }
            }
            Destroy(gameObject);
        }
    }
Exemple #2
0
    public void OnTriggerEnter(Collider other)
    {
        Controller_Powerup buffController = other.GetComponent <Controller_Powerup>();

        if (buffController != null)
        {
            switch (currentPowerupType)
            {
            case PowerupType.powerupHealth:
            {
                buffController.add(healthPowerup);
                break;
            }

            case PowerupType.powerupSpeed:
            {
                buffController.add(speedPowerup);
                break;
            }

            case PowerupType.firerate:
            {
                buffController.add(firerate);
                break;
            }
            }
            if (sound != null)
            {
                AudioSource.PlayClipAtPoint(sound, transform.position, 1.0f);
            }
            Destroy(gameObject);
        }
    }
Exemple #3
0
    public void OnTriggerEnter(Collider other)
    {
        // pick a powerup type
        // add powerup to list
        // spawn particle effect
        Controller_Powerup buffController = other.GetComponent <Controller_Powerup>();

        if (buffController != null)
        {
            switch (currentPowerupType)
            {
            case PowerupType.powerupHealth:
            {
                buffController.add(healthPowerup);
                GameObject tempEffect = Instantiate(healthEffect, transform.position + offset, healthEffect.transform.rotation);
                Destroy(tempEffect, destroyDelay);
                break;
            }

            case PowerupType.powerupSpeed:
            {
                buffController.add(speedPowerup);
                GameObject tempEffect = Instantiate(speedEffect, transform.position + offset, speedEffect.transform.rotation);
                Destroy(tempEffect, destroyDelay);
                break;
            }

            case PowerupType.powerupMissileCDReduction:
            {
                buffController.add(missileCDPowerup);
                GameObject tempEffect = Instantiate(missileCDEffect, transform.position + offset, missileCDEffect.transform.rotation);
                Destroy(tempEffect, destroyDelay);
                break;
            }
            }
            // if sound is set play it
            if (pickupSound != null)
            {
                AudioSource.PlayClipAtPoint(pickupSound, transform.position, (GameManager.instance.sfxVol + 80) / 80);
            }
            // Destroy gameObject
            Destroy(gameObject);
        }
    }
    //When a tank collides with the powerup it will activate there powerup.

    public void OnTriggerEnter(Collider other)
    {
        Controller_Powerup buffController = other.GetComponent <Controller_Powerup>();

        if (buffController != null)
        {
            switch (currentPowerupType)
            {
            //If the tank collides with Powerup Health then it will increase the health.
            case PowerupType.powerupHealth:
            {
                buffController.add(healthPowerup);
                break;
            }

            //If the tank collides with Powerup Speed then it will increase the tanks speed.
            case PowerupType.powerupSpeed:
            {
                buffController.add(speedPowerup);
                break;
            }

            //If the tank collides with the Powerup Firerate then it will increase the tanks firerate.
            case PowerupType.firerate:
            {
                buffController.add(firerate);
                break;
            }
            }
            //When the powerup is collected then a clip will play.
            if (sound != null)
            {
                AudioSource.PlayClipAtPoint(sound, transform.position, 1.0f);
            }
            //When the powerup is collected then it will destroy the object.
            Destroy(gameObject);
        }
    }