예제 #1
0
        public static EventTimer Get(GameObject go)
        {
            EventTimer et = go.GetComponent <EventTimer>();

            if (et == null)
            {
                et = go.AddComponent <EventTimer>();
            }
            return(et);
        }
예제 #2
0
        public static void AddTimer(float time, System.Action callback, object param, bool useTimeScale)
        {
            BroadcastInfo bi = new BroadcastInfo();

            bi.callback     = callback;
            bi.delayTime    = time;
            bi.useTimeScale = useTimeScale;
            EventTimer et = EventTimer.Get(GetGameObject(null));

            if (et != null)
            {
                et.AddTimerInternal(bi);
            }
        }
예제 #3
0
        // Send Global Event
        public static void Broadcast(EventMessage em, ref object paramRef)
        {
            // delay
            if (em.delayTime.x > 0 && em.delayTime.y > 0)
            {
                EventTimer.AddTimer(em, em.delayTime, em.useTimeScale);
            }
            else
            {
                // clear delay
                em.delayTime = Vector2.zero;

                EventInfo ei = GetEventInfo(em.eventID);
                if (ei != null && ei.m_delegate != null)
                {
                    ei.m_delegate(em, ref paramRef);
                }
            }
            return;
        }
예제 #4
0
        public static void AddTimer(EventMessage em, Vector2 delayTime, bool useTimeScale)
        {
            // Get GameObject from Object
            GameObject attachObj = GetGameObject(em.origSrc);

            BroadcastInfo bi = new BroadcastInfo();

            bi.em = em;

            // Calculate delay time
            bi.delayTime    = Random.Range(Mathf.Min(delayTime[0], delayTime[1]), Mathf.Max(delayTime[0], delayTime[1]));
            bi.useTimeScale = useTimeScale;

            EventTimer et = EventTimer.Get(attachObj);

            if (et != null)
            {
                et.AddTimerInternal(bi);
            }
        }
예제 #5
0
        // Send Object Event

        public static void SendObjectEvent(EventMessage em, ref object paramRef)
        {
            if (em.targetObj)
            {
                if (em.delayTime.x > 0 && em.delayTime.y > 0)
                {
                    EventTimer.AddTimer(em, em.delayTime, em.useTimeScale);
                }
                else
                {
                    // clear delay
                    em.delayTime = Vector2.zero;

                    // Send to object event manager
                    ObjectEventManager[] objManagers = em.targetObj.GetComponentsInChildren <ObjectEventManager>(true);
                    foreach (ObjectEventManager objManager in objManagers)
                    {
                        objManager.SendObjectEvent(em, ref paramRef);
                    }
                }
            }
            return;
        }