Advertisement
Guest User

BaseTimedEntity.cs

a guest
Aug 6th, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.65 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class BaseTimedEntity : MonoBehaviour
  4. {
  5.     public bool isActivated;
  6.  
  7.     public virtual void OnEnable()
  8.     {
  9.         Messenger<bool>.AddListener(GAME_CONST.BCAST_DAYNIGHT_LIGHT_EVENT, OnDayNightEvent);
  10.     }
  11.  
  12.     public virtual void OnDiable()
  13.     {
  14.         Messenger<bool>.RemoveListener(GAME_CONST.BCAST_DAYNIGHT_LIGHT_EVENT, OnDayNightEvent);
  15.     }
  16.  
  17.     public virtual void OnDayNightEvent(bool isDay)
  18.     {
  19.         if(isDay)
  20.         {
  21.             isActivated = true;
  22.             enabled = true;
  23.         }
  24.         else
  25.         {
  26.             isActivated = false;
  27.             enabled = false;
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement