Esempio n. 1
0
        private static void On_Tick(object sender, TickEventArgs args)
        {
            GameClock gameClock = null;
            if (sender is GameClock)
                gameClock = (GameClock)sender;

            if (gameClock != null)
            {

                //Update all players
                foreach (Player p in Players.Values)
                {
                    p.Do_Tick(gameClock);
                }

                //After all players have updated, write it to the DB
                foreach (Player p in Players.Values)
                {
                    p.Save_Database_Values();
                }
            }
            else
            {
                //todo: handle error here, something invoked the tick that was not a gameclock
            }
            //TODO Back up Database file
        }
Esempio n. 2
0
 void gameClock_TickEvent(object sender, TickEventArgs args)
 {
     outputTickStamp(args.CurrentTick);
 }
Esempio n. 3
0
        //Private functions
        private void OnTickEvent(object sender, ElapsedEventArgs e)
        {
            //protected code while modifying object state
            mut.WaitOne();

            this.tick += 1;

            //restart the tick countdown
            this.currentTickCountdown = this.tickDurationUsed;

            TickEventArgs eventArgs = new TickEventArgs();
            eventArgs.CurrentTick = this.CurrentTick;
            eventArgs.RunningTime = this.RunningTime;

            mut.ReleaseMutex();

            //the user callbacks are not in protected code
            if (this.TickEvent != null)
            {
                this.TickEvent(this, eventArgs);
            }
        }