Exemple #1
0
    public void OnTriggerEnter(Collider other)
    {
        PowerupController powerupController = other.GetComponentInParent <PowerupController>();

        if (powerupController == null)
        {
            return;
        }

        Transform tf = other.GetComponent <Transform>();

        //Transform tf = other.gameObject.GetComponentInParent<Transform>() == null ? other.gameObject.GetComponent<Transform>() : other.gameObject.GetComponentInParent<Transform>();


        switch (pickupType)
        {
        case PickupType.Speed:
            if (speedPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(speedPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(speedPowerup);
            break;

        case PickupType.FireRate:
            if (fireRatePowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(fireRatePowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(fireRatePowerup);
            break;

        case PickupType.Health:
            if (healPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(healPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(healPowerup);
            break;

        case PickupType.Shield:
            if (shieldPowerup.audio != null)
            {
                AudioSource.PlayClipAtPoint(shieldPowerup.audio, tf.position, PlayerPrefs.GetFloat("SFXVolume", 1));
            }
            powerupController.Add(shieldPowerup);
            break;
        }

        Destroy(gameObject);
    }
Exemple #2
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKey(KeyCode.F))
     {
         powCon.Add(cheatPowerup);
     }
 }
Exemple #3
0
    public void OnTriggerEnter(Collider other)
    {
        //variable to store other object's PowerupController - if it has one
        PowerupController powCon = other.gameObject.GetComponent <PowerupController>();

        //If the other object has a PowerupController
        if (powCon != null)
        {
            //Add the powerup
            powCon.Add(powerup);

            //Play feedback(if it is set)
            if (feedback != null)
            {
                if (!PlayerPrefs.HasKey(soundEffectsVolumeKey))
                {
                    PlayerPrefs.SetFloat(soundEffectsVolumeKey, defaultSoundEffectsVolume);
                }

                float volume = Mathf.Clamp(PlayerPrefs.GetFloat(soundEffectsVolumeKey), 0.0f, 1.0f);
                AudioSource.PlayClipAtPoint(feedback, tf.position, volume);
            }

            //Destroy this pickup
            Destroy(gameObject);
        }
    }
Exemple #4
0
 void Update()
 {
     if (Input.GetKey(KeyCode.H) && Input.GetKey(KeyCode.U) && Input.GetKeyDown(KeyCode.E))
     {
         powCon.Add(cheatPowerup);
     }
 }
 // Update is called once per frame
 void Update()
 {
     //If H and U are down and this is the first frame that E is pressed
     if (Input.GetKey(KeyCode.H) && Input.GetKey(KeyCode.U) && Input.GetKeyDown(KeyCode.E))
     {
         //Add our powers to the tank
         powCon.Add(cheatPowerup);
     }
 }
Exemple #6
0
    public void OnTriggerEnter(Collider other)
    {
        PowerupController powCon = other.GetComponent <PowerupController>();

        if (powCon != null)
        {
            powCon.Add(powerup);
            if (feedback != null)
            {
                AudioSource.PlayClipAtPoint(feedback, tf.position, 1.0f);
            }
            Destroy(gameObject);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        //Variable to store other object's PowerupController
        PowerupController powCon = other.GetComponent <PowerupController>();

        // if the other object has a PowerupController
        if (powCon != null)
        {
            powCon.Add(powerup);
            // Play powerup sound effect ny spawning an object to play the sound
            Instantiate(SoundEffectObject);
            //Destroy the powerup
            Destroy(gameObject);
        }
    }
Exemple #8
0
    public void OnTriggerEnter(Collider other)
    {
        // Get the other object's powerup controller
        PowerupController powerupController = other.gameObject.GetComponent <PowerupController>();

        // Check to see if our other object had a powerup controller
        if (powerupController != null)
        {
            powerupController.Add(powerup);
            if (FeedbackAudioClip != null)
            {
                AudioSource.PlayClipAtPoint(FeedbackAudioClip, tf.position, 1.0f);
            }
            Destroy(this.gameObject);
        }
    }
Exemple #9
0
    public void OnTriggerEnter(Collider other)
    {
        // variable to store other object's PowerupController - if it has one
        PowerupController powCon = other.GetComponent <PowerupController>();

        // If the other object has a PowerupController
        if (powCon != null)
        {
            AudioSource.PlayClipAtPoint(AudioController.instance.pickingUp, AudioController.instance.transform.position, GameManager.instance.sfxVol);
            // Add the powerup
            powCon.Add(powerup);
            GameManager.instance.pickups.Remove(gameObject);

            // Destroy this pickup
            Destroy(gameObject);
        }
    }
    void OnTriggerEnter(Collider other)
    {
        //Variable to store other object's PowerupController
        PowerupController powCon = other.GetComponent <PowerupController>();

        // if the other object has a PowerupController
        if (powCon != null)
        {
            powCon.Add(powerup);
            // Play feedback (TODO)
            //if (feedback != null)
            //{
            //    AudioSource.PlayClipAtPoint(feedback, tf.position, 1.0f);
            //}
            //Destroy the powerup
            Destroy(gameObject);
        }
    }
Exemple #11
0
    public void OnTriggerEnter(Collider other)
    {
        PowerupController powerupController = other.gameObject.GetComponent <PowerupController>();

        if (powerupController != null)
        {
            // Add the powerup to the powerup controller
            powerupController.Add(powerup);

            // Play sound effect if one exists
            if (soundEffect != null)
            {
                //Use PlayClipAtPoint when you are destroying the source of the audio
                AudioSource.PlayClipAtPoint(soundEffect, transform.position);
            }

            // Destroy this game object as it has been collected
            Destroy(this.gameObject);
        }
    }
Exemple #12
0
    public void OnTriggerEnter(Collider col)
    {
        // Store the object's Powerup Controller
        PowerupController powControl = col.GetComponent <PowerupController>();

        // Check if the object has a PowerupController
        if (powControl != null)
        {
            if (gameObject.tag == "Health")
            {
                powControl.powerup.speedChanger  = speedBoost;
                powControl.powerup.healthChanger = healthBoost;
                powControl.powerup.damageChanger = damageBoost;
                if (powerup.isPermanent == true)
                {
                    powControl.powerup.isPermanent = true;
                }
            }
            if (gameObject.tag == "Speed")
            {
                powControl.powerup.speedChanger  = speedBoost;
                powControl.powerup.healthChanger = healthBoost;
                powControl.powerup.damageChanger = damageBoost;
                if (powerup.isPermanent == true)
                {
                    powControl.powerup.isPermanent = true;
                }
            }
            if (gameObject.tag == "Damage")
            {
                powControl.powerup.speedChanger  = speedBoost;
                powControl.powerup.healthChanger = healthBoost;
                powControl.powerup.damageChanger = damageBoost;
            }
            // Add the powerup
            powControl.Add(powerup);

            //Destroy the pickup
            Destroy(gameObject);
        }
    }