Exemple #1
0
        static uint Update(TimerEventArgs e, IntPtr param)
        {
            var handler = OnUpdate;

            if (handler != null)
            {
                handler(null, e);
            }

            return(e.Interval);
        }
Exemple #2
0
        public static void Start()
        {
            if (OnMainLoopStart != null)
            {
                OnMainLoopStart();
            }

            uint dt  = 0;
            var  arg = new TimerEventArgs();

            try
            {
                while (!Exit)
                {
                    Window.DispatchEvents();

                    if (OnMainLoop != null)
                    {
                        OnMainLoop();
                    }

                    Update(arg, IntPtr.Zero);
                    Animate(arg, IntPtr.Zero);

                    Render();

                    dt           = FixedDT ? 16 : (uint)Clock.Restart().AsMilliseconds();
                    arg.Interval = dt;
                }
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            if (OnMainLoopFinish != null)
            {
                OnMainLoopFinish();
            }
        }
Exemple #3
0
        public void Update(object sender, TimerEventArgs e)
        {
            Time += e.Interval * Speed;

            // Automating
            if (Time >= Pos[CurrentPos])
            {
                CurrentPos++;
                if (CurrentPos >= Pos.Count)
                {
                    if (Loop)
                    {
                        CurrentPos = 0;
                        Time      -= Pos[Pos.Count - 1];
                    }
                    else
                    {
                        if (OnFinish != null)
                        {
                            OnFinish(this);
                        }
                        Active = false;
                        return;
                    }
                }
            }

            // Calculating current value and sending it to clients
            int prevPos = CurrentPos == 0 ? 0 : Pos[CurrentPos - 1];

            CalculateValue((Time - prevPos) / (Pos[CurrentPos] - prevPos));
            foreach (C client in Clients)
            {
                AutomateClient(client);
            }
        }