UserInput.Update C# (CSharp) Method

Update() public method

public Update ( ) : void
return void
    void Update()
    {
        if (player && player.human)
        {
            if (Input.GetKeyDown(KeyCode.Escape)) OpenPauseMenu(); //Activar o desactivar modo Pausa
            //if (Input.GetKey (KeyCode.Space)) gamePause(); //Activar o desactivar modo Pausa opcion 2
            //Comprueva si el modo pausa esta activado
            if(isPaused){
                Time.timeScale = 0.0f; //Para el juego
            }else{
                Time.timeScale = 1.0f; //Continua jugando
            }
            bool leftClick = Input.GetMouseButtonDown(0);
            bool rightClick = Input.GetMouseButtonDown(1);
            bool middleClick = Input.GetMouseButtonDown(2);
            if (leftClick || rightClick || middleClick)
                HandleMouseClick(leftClick, rightClick, middleClick);

            if (Input.GetKey (KeyCode.M)) morirEnemigos();
            if (Input.GetKey (KeyCode.P)) morirJugador();
            if (Input.GetKeyUp("k")) demolishBuildings();
            if (Input.GetKey (KeyCode.Space))
                cameraToSelectedObject ();
            if (Input.GetKey(KeyCode.Alpha1)) increaseFood();
            if (Input.GetKey(KeyCode.Alpha2)) increaseWood();
            if (Input.GetKey(KeyCode.Alpha3)) increaseGold();
            if (Input.GetKey(KeyCode.Alpha4)) rotate = true;

        if (rotate == true && player.SelectedObject && player.SelectedObject.GetComponent<CivilUnit>()
           		 	&& player.SelectedObject.GetComponent<CivilUnit>().waitingForBuildingLocationSelection)
           		 {
           			player.SelectedObject.GetComponent<CivilUnit>().RotateBuilding();
           		 }

           	    rotate=false;

            MoveCamera();
            RotateCamera();
            MouseActivity();
        }
    }

Usage Example

Beispiel #1
0
        internal void Update(GameTime gameTime)
        {
            if (IsMouseVisible != Game.IsMouseVisible)
            {
                Game.IsMouseVisible = IsMouseVisible;
            }

            Cursor.Current = ActualCursor;

            if (ToggleFullScreenRequested)
            {
                SynchronizeGraphicsDeviceManager();
                ToggleFullScreenRequested = false;
                Viewer.DefaultViewport    = GraphicsDevice.Viewport;
            }

            if (gameTime.TotalRealTime.TotalSeconds > 0.001)
            {
                Game.UpdaterProcess.WaitTillFinished();

                // Must be done in XNA Game thread.
                UserInput.Update(Game);

                // Swap frames and start the next update (non-threaded updater does the whole update).
                SwapFrames(ref CurrentFrame, ref NextFrame);
                Game.UpdaterProcess.StartUpdate(NextFrame, gameTime.TotalRealTime.TotalSeconds);
            }
        }
All Usage Examples Of UserInput::Update