示例#1
0
        public override void Update()
        {
            //Update everything here.
            //F.e. get input, move objects, etc...
            bool B_Input_Space;

            //For example:
            // float deltaTime = GAME_ENGINE.GetDeltaTime();

            //met hulp van mark
            if (GAME_ENGINE.GetKey(Key.Space))
            {
                B_Input_Space = true;
            }
            else
            {
                B_Input_Space = false;
            }
        }
        public override void Update()
        {
            missileLauncher.ForwardCollision();
            if (GAME_ENGINE.GetKey(Key.Escape))
            {
                if (Registers.gameState == GameState.Error)
                {
                    GAME_ENGINE.Quit();
                }
                if (Registers.gameState == GameState.Running)
                {
                    Registers.gameState = GameState.Paused;
                }
                if (Registers.gameState == GameState.Stopped)
                {
                    GAME_ENGINE.Quit();
                }
            }
            if (GAME_ENGINE.GetKey(Key.ShiftKey))
            {
                Registers.sprint = true;
            }
            else
            {
                Registers.sprint = false;
            }
            if (GAME_ENGINE.GetMouseButtonDown(0) && Registers.gameState == GameState.Paused)
            {
            }
            if (Registers.gameState == GameState.Running)
            {
                if (GAME_ENGINE.GetKeyDown(Key.Space))
                {
                    Registers.fireNow = true;
                }
                //make the crosshair move faster when shift is held
                if (Registers.sprint == false)
                {
                    float speedMultiplier = 1.1f;
                    if (GAME_ENGINE.GetKey(Key.W))
                    {
                        Registers.CrosshairY -= aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.S) && Registers.CrosshairY < Alignment.Y.Down - 70)
                    {
                        Registers.CrosshairY += aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.D))
                    {
                        Registers.CrosshairX += aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.A))
                    {
                        Registers.CrosshairX -= aimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                }
                else
                {
                    float speedMultiplier = 1.3f;
                    if (GAME_ENGINE.GetKey(Key.W))
                    {
                        Registers.CrosshairY -= shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.S) && Registers.CrosshairY < Alignment.Y.Down - 70)
                    {
                        Registers.CrosshairY += shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.D))
                    {
                        Registers.CrosshairX += shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                    if (GAME_ENGINE.GetKey(Key.A))
                    {
                        Registers.CrosshairX -= shiftAimspeed * GAME_ENGINE.GetDeltaTime() * speedMultiplier;
                    }
                }
            }

            //Trigger the error screen by force
            if (GAME_ENGINE.GetKeyDown(Key.F12))
            {
                Registers.gameState = GameState.Error;
            }
            if (GAME_ENGINE.GetKeyUp(Key.F12))
            {
                Registers.gameState = GameState.Running;
            }


            //RESETING THE GAME CAN CAUSE PROBLEMS
            if (GAME_ENGINE.GetKeyDown(Key.R) && Registers.gameState == GameState.Stopped)
            {
                Registers.gameState = GameState.Reseting;

                Registers.CrosshairX = Alignment.X.Center;
                Registers.CrosshairY = Alignment.Y.Center;

                cities.Clear();
                for (int i = 0; i < 6; i++)
                {
                    cities.Add(new Building(this, i));
                }
                GC.Collect();
                destroyedCities     = 0;
                Registers.gameState = GameState.Running;
            }

            //Force lose the game
            if (GAME_ENGINE.GetKeyDown(Key.F2))
            {
                destroyedCities = 6;
            }

            //Enable all cities
            if (GAME_ENGINE.GetKeyDown(Key.F3))
            {
                destroyedCities     = 0;
                Registers.gameState = GameState.Running;
            }
        }