コード例 #1
0
    void OnTriggerEnter2D(Collider2D other)
    {
        ControlScript yeti = other.gameObject.GetComponent <ControlScript>();

        if (yeti != null)
        {
            // this is the yeti, heal him
            yeti.ActivateShelter(this);
        }
        else
        {
            // convert to meal
            VictimScript victim = other.gameObject.GetComponent <VictimScript>();
            if (victim != null)
            {
                meal       += victim.meal;
                victim.meal = 0.0f;
                Destroy(other.gameObject);
            }
        }
    }