public InputManager() { _controls = new PlayerInput(); #region Game _controls.Game.Movement.started += ctx => ShipMove.Invoke(true); _controls.Game.Movement.canceled += ctx => ShipMove.Invoke(false); _controls.Game.Rotation.performed += ctx => ShipRotate.Invoke(ctx.ReadValue <float>()); _controls.Game.Rotation.canceled += ctx => ShipRotate.Invoke(0); _controls.Game.Fire.started += ctx => ShipFire.Invoke(true); _controls.Game.Fire.canceled += ctx => ShipFire.Invoke(false); _controls.Game.Pause.started += ctx => GamePause.Invoke(); _controls.Game.Restart.started += ctx => GameRestart.Invoke(); #endregion #region Pause _controls.Pause.Exit.started += ctx => PauseExit.Invoke(); _controls.Pause.Resume.started += ctx => PauseResume.Invoke(); #endregion #region Game Over _controls.GameOver.Restart.started += ctx => GameOverRestart.Invoke(); _controls.GameOver.Exit.started += ctx => GameOverExit.Invoke(); #endregion GameManager.Instance.OnGameStateChanged += SwitchInputType; }
public static ShipController GetShip(Game gameView, ShipModel shipModel) { IView shipView = gameView.CreateView(shipModel.Name); IShipMove shipMove = new ShipMove(shipView.Rigidbody2D, shipModel.MoveForce); IShipRotate shipRotate = new ShipRotate(shipView.Rigidbody2D, shipModel.Torque); IShipHealth shipHealth = new ShipHealth(shipModel.MaxHealth); IShipCollided shipCollided = new ShipCollided(shipView, shipHealth); IShipFire shipFire = new ShipFire(); FireLock fireLock = new FireLock(); IShipFire shipLockableFire = new ShipLockableFire(shipFire, fireLock); return(new ShipController(shipModel, shipView, shipMove, shipRotate, shipCollided, shipHealth, shipLockableFire, fireLock)); }
/* Methods */ // Use this for initialization void Start() { //Find and assign associated behaviours bank = gameObject.GetComponentInChildren <ShipBank>(); roll = gameObject.GetComponentInChildren <ShipRoll>(); wings = gameObject.GetComponentsInChildren <ShipWing>(); boost = gameObject.GetComponent <ShipBoost>(); rotate = gameObject.GetComponent <ShipRotate>(); move = gameObject.GetComponent <ShipMove>(); // // //Set camera's boundaries based on player's boundaries cameraPan.SetPanMaxDistance(5.0f, 5.0f); // // //Assign associated values to ensure animations sync up properly wings[0].wingDestroyed = false; wings[1].wingDestroyed = false; }
public void OnEnable() { //Ensure there is a reference to the actual manager shipRotate = (ShipRotate)target; }