Ejemplo n.º 1
0
    private void checkEvent(LinkedList <TimerEvent> list, float totalTime)
    {
        LinkedListNode <TimerEvent> node     = list.First;
        List <TimerEvent>           tempList = new List <TimerEvent>();

        while (node != null)
        {
            TimerEvent e = node.Value;
            if (e._isDelete)
            {
                node = node.Next;
            }
            else
            {
                if (e._targetTime > totalTime)
                {
                    break;
                }
                e._offsetTime = totalTime - e._targetTime;
                e._callBack.onTimeUp(e._id, e._offsetTime);
                if (e._isLoop)
                {
                    int multi = (int)(e._offsetTime / e._nextTime);
                    e._offsetTime -= e._nextTime * multi;
                    tempList.Add(e.clone());
                }
                e.delete();
                node = node.Next;
            }
        }
        foreach (TimerEvent te in tempList)
        {
            register(te, list, totalTime);
        }
    }
Ejemplo n.º 2
0
    private void removeAllOfOne(TimerCallBack callBack, LinkedList <TimerEvent> list)
    {
        LinkedListNode <TimerEvent> node = list.First;

        while (node != null)
        {
            TimerEvent e = node.Value;
            if (e._callBack == callBack)
            {
                e._callBack = null;
                e.delete();
            }
            node = node.Next;
        }
    }
Ejemplo n.º 3
0
    //return the remained time
    private float removeEvent(TimerCallBack callBack, int id, LinkedList <TimerEvent> list, float totalTime)
    {
        LinkedListNode <TimerEvent> node = list.First;

        while (node != null)
        {
            TimerEvent e = node.Value;
            if (e._callBack == callBack && e._id == id)
            {
                e._callBack = null;
                e.delete();
                return(e._targetTime - totalTime);
            }
            node = node.Next;
        }
        return(0);
    }