Esempio n. 1
0
        /// <summary>
        /// Triggered when a token is removed from the board.
        /// </summary>
        public void OnTokenRemoved(
            object sender,
            TokenArgs args)
        {
            // Check to see if the token above is burning
            Token token = args.Token;

            if (args.IsBurnt)
            {
                // Show the burning state with a new sprite (which we
                // remove when it is done).
                BurntSprite bt = new BurntSprite(GetTokenSprite(token));
                sprites.Add(bt);
            }

            // Get the token sprite
            ContainerSprite ms = GetContainerSprite(token);

            // Remove the sprites from the list
            sprites.Remove(ms);

            // Redraw the entire screen
            QueueDraw();
            log.Debug("TokenRemoved: {0} count {1}", args.Token, sprites.Count);
        }
Esempio n. 2
0
        /// <summary>
        /// Triggered when a token is removed from the board.
        /// </summary>
        public void OnTokenRemoved(
			object sender,
			TokenArgs args)
        {
            // Check to see if the token above is burning
            Token token = args.Token;

            if (args.IsBurnt)
            {
                // Show the burning state with a new sprite (which we
                // remove when it is done).
                BurntSprite bt = new BurntSprite(GetTokenSprite(token));
                sprites.Add(bt);
            }

            // Get the token sprite
            ContainerSprite ms = GetContainerSprite(token);

            // Remove the sprites from the list
            sprites.Remove(ms);

            // Redraw the entire screen
            QueueDraw();
            log.Debug("TokenRemoved: {0} count {1}", args.Token, sprites.Count);
        }
Esempio n. 3
0
        /// <summary>
        /// Triggered on the animation loop.
        /// </summary>
        private bool OnTick()
        {
            // Check state
            if (Game.State == GameState.Started)
            {
                Game.State = GameState.InProgress;
            }

            if (lastState != Game.State)
            {
                // Check for game over
                if (Game.State == GameState.Completed)
                {
                    // Wipe everything
                    sprites.Clear();

                    // Add game over screen
                    AddGameOver();
                }

                // Save the state
                lastState = Game.State;
            }

            // Update the sprites
            sprites.Update();

            // Remove any completed animations
            LinkedList <BurntSprite> list = new LinkedList <BurntSprite>();

            foreach (ISprite sprite in sprites)
            {
                BurntSprite bs = sprite as BurntSprite;

                if (bs != null && bs.CanRemove)
                {
                    list.Add(bs);
                }
            }

            foreach (BurntSprite bs in list)
            {
                sprites.Remove(bs);
            }

            // Render the pane
            viewport.FireQueueDraw(this);

            // Handle the tick updating
            tickCount++;

            if (tickCount % 100 == 0)
            {
                int    fps  = (int)Game.Config.FramesPerSecond;
                double diff = (DateTime.UtcNow.Ticks - start) / 10000000.0;
                double efps = exposeCount / diff;
                double tfps = tickCount / diff;
                Console.WriteLine(
                    "FPS: Exposed {0:N1} FPS ({3:N1}%), " + "Ticks {1:N1} FPS ({4:N1}%), " +
                    "Maximum {2:N0} FPS",
                    efps,
                    tfps,
                    fps,
                    efps * 100 / fps,
                    tfps * 100 / fps);
                start       = DateTime.UtcNow.Ticks;
                exposeCount = tickCount = 0;
            }

            // Re-request the animation
            Timeout.Add(1000 / Game.Config.FramesPerSecond, OnTick);
            return(false);
        }