示例#1
0
    //deactivate player and trigger game over
    private void Destroy()
    {
        pool.ActivateEffect(transform, effectIndex);

        //disabling vibration until able to control duration and intensity
        //Handheld.Vibrate();

        GameControl.control.gameOver = true;
        gameObject.SetActive(false);
    }
示例#2
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //tag of collided object
        string otherTag = other.gameObject.tag;

        if (otherTag == "Player")
        {
            if (thisTag == "Collectible")
            {
                GameControl.control.IncreaseScore(value);
                if (heal)
                {
                    GameControl.control.ChangeHealth(value);
                }
                if (immune)
                {
                    GameControl.control.ActivateImmunity();
                }
            }
            else if (thisTag == "Enemy")
            {
                //only damage player if player is alive
                if (!GameControl.control.destroyed)
                {
                    if (!GameControl.control.GetImmunity())
                    {
                        GameControl.control.ChangeHealth(-value);
                        GameControl.control.IsDamaged();
                    }
                    else
                    {
                        GameControl.control.IncreaseScore(value);
                    }
                }
            }

            //only create final effect (explosion) on contact with player
            pool.ActivateEffect(transform, effectIndex);
        }

        //prevent objects from destroying one another
        if (otherTag != "Collectible" & otherTag != "Enemy")
        {
            gameObject.SetActive(false);
        }
    }