Potion.as 702 B

12345678910111213141516171819202122232425262728293031
  1. #include "Scripts/NinjaSnowWar/GameObject.as"
  2. const int potionHealAmount = 5;
  3. class Potion : GameObject
  4. {
  5. int healAmount;
  6. Potion()
  7. {
  8. healAmount = potionHealAmount;
  9. }
  10. void Start()
  11. {
  12. SubscribeToEvent(node, "NodeCollision", "HandleNodeCollision");
  13. }
  14. void ObjectCollision(GameObject@ otherObject, VariantMap& eventData)
  15. {
  16. if (healAmount > 0)
  17. {
  18. if (otherObject.Heal(healAmount))
  19. {
  20. // Could also remove the potion directly, but this way it gets removed on next update
  21. healAmount = 0;
  22. duration = 0;
  23. }
  24. }
  25. }
  26. }