Exemplo n.º 1
0
        void OnTriggerEnter2D(Collider2D other)
        {
            if (other.gameObject.layer == 4)
            {
                inWater = true;
            }
            else if (other.gameObject.layer == 8)
            {
                canStore = true;
                CollectionContainer collectionContainer = other.GetComponent <CollectionContainer>();

                Debug.Assert(collectionContainer, "failed to acquire CollectionContainer component on from a trigger specified as a container.");
                nearbyContainer = collectionContainer;
            }
            else if (other.gameObject.layer == 9)
            {
                canCollect = true;
                Collectible collectible = other.GetComponent <Collectible>();
                Debug.Assert(collectible, "failed to acquire Collectible component on from a trigger specified as a Collectible.");
                nearbyCollectible = collectible;
            }
            if (other.gameObject.layer == 11)
            {
                if (takeDamage())
                {
                    Destroy(other.gameObject);
                }
            }
        }
Exemplo n.º 2
0
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.gameObject.layer == 4)
     {
         inWater     = false;
         velocity.y += gravity * Time.deltaTime;
     }
     else if (other.gameObject.layer == 8)
     {
         canStore        = false;
         nearbyContainer = null;
     }
     else if (other.gameObject.layer == 9)
     {
         canCollect        = false;
         nearbyCollectible = null;
     }
 }