Пример #1
0
 public WorldPresenter(GraphicsDevice GraphicsDevice)
 {
     labyrinthCastle         = new LabyrinthCastle();
     labyrinthForest         = new LabyrinthForest();
     labyrinth               = labyrinthCastle;
     player                  = new Player(labyrinth.GetStartPosition());
     camera1                 = new Camera(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
     nrCamera                = 1;
     lightColor              = new Color(1, 1, 1);
     isTurn                  = true;
     nrLabyrinth             = 1;
     nrEffect                = 0;
     effects                 = new Effect[2, 3];
     MediaPlayer.IsRepeating = true;
     flat = false;
 }
Пример #2
0
        public void Update(GameTime gameTime)
        {
            Vector3 moveVector     = new Vector3(0, 0, 0);
            float   timeDifference = (float)gameTime.ElapsedGameTime.TotalMilliseconds / 400.0f;

            labyrinth.Update(timeDifference);

            KeyboardState keyState = Keyboard.GetState();

            if (keyState.IsKeyDown(Keys.Up) || keyState.IsKeyDown(Keys.W))
            {
                moveVector += new Vector3(0, 0, 1);
            }
            if (keyState.IsKeyDown(Keys.Down) || keyState.IsKeyDown(Keys.S))
            {
                moveVector += new Vector3(0, 0, -1);
            }
            if (keyState.IsKeyDown(Keys.Right) || keyState.IsKeyDown(Keys.D))
            {
                moveVector += new Vector3(-1, 0, 0);
            }
            if (keyState.IsKeyDown(Keys.Left) || keyState.IsKeyDown(Keys.A))
            {
                moveVector += new Vector3(1, 0, 0);
            }
            if (keyState.IsKeyDown(Keys.NumPad1))
            {
                nrCamera = 1;
            }
            if (keyState.IsKeyDown(Keys.NumPad2))
            {
                nrCamera = 2;
            }
            if (keyState.IsKeyDown(Keys.NumPad3))
            {
                nrCamera = 3;
            }
            if (keyState.IsKeyDown(Keys.L))
            {
                isTurn = false;
            }
            if (keyState.IsKeyDown(Keys.O))
            {
                isTurn = true;
            }
            if (keyState.IsKeyDown(Keys.X))
            {
                labyrinth = labyrinthCastle;
                player.SetPosition(labyrinth.GetStartPosition());
                nrLabyrinth = 1;
            }
            if (keyState.IsKeyDown(Keys.Z))
            {
                labyrinth = labyrinthForest;
                player.SetPosition(labyrinth.GetStartPosition());
                nrLabyrinth = 0;
            }
            if (keyState.IsKeyDown(Keys.P))
            {
                nrEffect = 0;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.B))
            {
                nrEffect = 1;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.G))
            {
                nrEffect = 2;
                flat     = false;
            }
            if (keyState.IsKeyDown(Keys.F))
            {
                nrEffect = 2;
                flat     = true;
            }

            bool move = labyrinth.IsCollision(player.GetPosition(moveVector, timeDifference));

            player.Move(moveVector, timeDifference, move);
            view = camera1.GetView(timeDifference, player.Position, move);

            if (labyrinth.IsEnd(player.Position))
            {
                player.SetPosition(labyrinth.GetStartPosition());
            }
        }