Example #1
0
        public override void Update(GameTime gameTime)
        {
            if (InputManager.Pressed("back"))
            {
                ScreenManager.RemoveScreen();
            }

            if (InputManager.KeyPressed(Keys.F1))
            {
                debugMode = !debugMode;
            }

            if (InputManager.Pressed("reset"))
            {
                Reset();
            }

            if (InputManager.Pressed("undo"))
            {
                Undo();
            }

            if (currentAnim != null)
            {
                currentAnim.Update(gameTime);
                playerPos  = currentAnim.Position;
                playerTile = currentAnim.TileId;
                if (currentAnim.Finished)
                {
                    currentAnim = null;

                    if (map.Room.IsSolved())
                    {
                        ScreenManager.AddScreen(new FinishedScreen(Level));
                        return;
                    }
                }
            }

            if (currentAnim == null && movements.Count > 0)
            {
                IntVec move     = movements.Dequeue();
                var    nextAnim = map.Room.Update(move);
                if (nextAnim != null)
                {
                    currentAnim         = nextAnim;
                    currentAnim.MoveDir = move.ToMovementDir();
                }
            }

            if (InputManager.Pressed("up"))
            {
                movements.Enqueue(new IntVec(0, -1));
            }
            else if (InputManager.Pressed("down"))
            {
                movements.Enqueue(new IntVec(0, 1));
            }
            else if (InputManager.Pressed("left"))
            {
                movements.Enqueue(new IntVec(-1, 0));
            }
            else if (InputManager.Pressed("right"))
            {
                movements.Enqueue(new IntVec(1, 0));
            }
        }