Exemple #1
0
 /// <summary>
 /// Sent when another object enters a trigger collider attached to this
 /// object (2D physics only).
 /// </summary>
 /// <param name="other">The other Collider2D involved in this collision.</param>
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.layer == LayerMask.NameToLayer("Consumable"))
     {
         Consumable con = other.gameObject.GetComponent <Consumable>();
         if (con.type.Equals(typeof(ResRegenConsumable)))
         {
             HandleResRegenConsumable(con.GetComponent <ResRegenConsumable>());
         }
         else if (con.type.Equals(typeof(EnergyConsumable)))
         {
             HandleEnergyConsumable(con.GetComponent <EnergyConsumable>());
         }
     }
     else if (other.gameObject.layer == LayerMask.NameToLayer("Obstacle"))
     {
         Bumper bumper = other.gameObject.GetComponent <Bumper>();
         if (bumper)
         {
             HandleBumper(bumper);
         }
     }
 }
Exemple #2
0
 public void OnConsume(GameObject interactor, Consumable consumable, Interaction interaction)
 {
     startColor = consumable.GetComponent <SpriteRenderer>().color;
     startScale = consumable.transform.localScale;
 }
 public static void Init <T>(this Consumable consumable, ConsumableItemMaster master) where T : MonoBehaviour
 {
     consumable.consumableMaster = master;
     consumable.gameObject.AddComponent <T>();
     consumable._stack = consumable.GetComponent <ItemStack>();
 }