示例#1
0
    public void AddTimer(string name, TIMERTYPE type, float inval, TimerCallback cb, int counter = 0, float delay = 0.0f)
    {
        if (string.IsNullOrEmpty(name))
        {
            Debug.LogError("Add Timer Name is Null");
        }

        TimerData data = new TimerData();

        data.timerName    = name;
        data.timerType    = type;
        data.timerInval   = inval;
        data.timerEndTime = Time.realtimeSinceStartup + inval;
        data.timerCounter = counter;
        data.timerDelay   = delay;
        data.timerCB      = cb;

        if (timerAddDic.ContainsKey(name))
        {
            Debug.LogError("Repeat Add Timer " + name);
            return;
        }

        timerAddDic.Add(name, data);
    }
示例#2
0
    public void Refresh(TIMERTYPE type)
    {
        switch (type)
        {
        case TIMERTYPE.FREEZE:
            counter = 0.0f;
            break;

        case TIMERTYPE.SPEEDUP:
            //speedup可以累积
            counter -= 7.0f;
            break;
        }
    }
示例#3
0
    public void Setup(TIMERTYPE type, UnityAction action)
    {
        switch (type)
        {
        case TIMERTYPE.FREEZE:
            this.type = type;
            time      = 10.0f;
            timesUp.AddListener(action);
            break;

        case TIMERTYPE.SPEEDUP:
            this.type = type;
            time      = 7.0f;
            timesUp.AddListener(action);
            break;
        }
    }