Exemple #1
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            MouseState mouse = Mouse.GetState();

            Ray     _castRay        = ((BasicCamera)Director.InstanceDirector.Camera).CalculateCursorRay(mouse.X, mouse.Y);
            Vector3 positionOnPlane = PlaneControll.IntersectPoint(_castRay.Direction, _castRay.Position, Vector3.Up, new Vector3(1, 0, 1));


            if (TEST == false)
            {
                if (mouse.LeftButton == ButtonState.Pressed && OldPushed == false)
                {
                    _map.MapLayers[1].LayerClick((((int)positionOnPlane.X / 32)) * 32, (((int)positionOnPlane.Z / 32)) * 32);
                    OldPushed = true;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F1))
                {
                    // _map.PutElementOnMap(StandardElements.SpawnPiont, new Vector2(positionOnPlane.X, positionOnPlane.Z));
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F2))
                {
                    //_map.PutElementOnMap(StandardElements.FinishPoint, new Vector2(positionOnPlane.X, positionOnPlane.Z));
                }

                if (mouse.LeftButton == ButtonState.Released && OldPushed == true)
                {
                    OldPushed = false;
                }

                if (Keyboard.GetState().IsKeyDown(Keys.F12))
                {
                    TEST = true;
                    _map.SaveMe();
                    _map.InitTestGame(player);
                }
            }
            else
            {
                if (mouse.RightButton == ButtonState.Pressed && player.AliveBoiiii == false)
                {
                    player.AliveBoiiii = true;
                    _map.InitTestGame(player);
                }

                player.Update(gameTime, positionOnPlane);
            }


            Director.InstanceDirector.Camera.Update(gameTime);

            base.Update(gameTime);
        }