Пример #1
0
    private Dictionary <object, List <TimeUp> > GetRelevantTimebook(Timebook timebookType)
    {
        Dictionary <object, List <TimeUp> > book;

        switch (timebookType)
        {
        case Timebook.Global:
            book = TimeBookGlobal;
            break;

        case Timebook.InGame:
            book = TimeBookGame;
            break;

        case Timebook.InMenu:
            book = TimeBookMenu;
            break;

        default:
            book = null;
            break;
        }

        if (book == null)
        {
            Debug.Log("Timebook ERROR - TimerManager need update");
        }

        return(book);
    }
Пример #2
0
    /// <summary>
    /// Best way is to init your timer in the start, then add it when you need it
    /// But if you want create and add in the same time, you can use it
    /// </summary>
    /// <param name="from"> Always "this"</param>
    /// <param name="timebook">
    /// Choose the timebook :
    /// Global -> Always update
    /// Game -> update only in Game
    /// Menu -> update only in menu
    /// <returns>The Chronos just created</returns>
    public Chronos CreateSimpleChronos(object from, Timebook timebook = Timebook.Global)
    {
        Chronos newOne = new Chronos();

        Dictionary <object, List <TimeUp> > revelantTimebook = GetRelevantTimebook(timebook);

        if (revelantTimebook.ContainsKey(from))
        {
            revelantTimebook[from].Add(newOne);
        }
        else
        {
            List <TimeUp> list = new List <TimeUp>();
            list.Add(newOne);
            revelantTimebook.Add(from, list);
        }

        return(newOne);
    }
Пример #3
0
    /// <summary>
    /// Best way is to init your timer in the start, then add it when you need it
    /// But if you want creat and add in the same time, you can use it
    /// </summary>
    /// <param name="from"> Alwayse "this"</param>
    /// <param name="time"> Explicit </param>
    /// <param name="handler"> What you whant to call at the end of the timer</param>
    /// <param name="timebook">
    /// Choose the timebook :
    /// Global -> Alwayse update
    /// Game -> update only in Game
    /// Menu -> update only in menu
    /// <returns>Timer just created</returns>
    public Timer CreateSimpleTimer(object from, float time, Timer.toCall handler, Timebook timebook = Timebook.Global)
    {
        Timer newOne = new Timer(time, handler);

        Dictionary <object, List <TimeUp> > revelantTimebook = GetRelevantTimebook(timebook);

        if (revelantTimebook.ContainsKey(from))
        {
            revelantTimebook[from].Add(newOne);
        }
        else
        {
            List <TimeUp> list = new List <TimeUp>();
            list.Add(newOne);
            revelantTimebook.Add(from, list);
        }

        return(newOne);
    }
Пример #4
0
    /// <summary>
    /// Explicit
    /// </summary>
    /// <param name="from"> write just "this" here </param>
    /// <param name="timer"></param>
    /// <param name="timebook">
    /// Choose the timebook :
    /// Global -> Alwayse update
    /// Game -> update only in Game
    /// Menu -> update only in menu
    /// </param>

    public void AddTimer(object from, TimeUp timer, Timebook timebook = Timebook.Global)
    {
        ToAdd.Push(new Utils.Tuple <object, TimeUp, Timebook>(from, timer, timebook));
    }