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; }
void Toggle_Shoot() { // var so player cant shoot when paused GameObject ship = GameObject.FindWithTag("Ship"); if (ship != null) { // get scripts for each type of shot ShipFire shootScript = ship.GetComponent <ShipFire>(); ShipDoubleShot doubleScript = ship.GetComponent <ShipDoubleShot>(); ShipLongShot longScript = ship.GetComponent <ShipLongShot>(); // then toggle them if (shootScript.ToggleShot == true && doubleScript.ToggleShot == true && longScript.ToggleShot == true) { shootScript.ToggleShot = false; doubleScript.ToggleShot = false; longScript.ToggleShot = false; } else if (shootScript.ToggleShot == false && doubleScript.ToggleShot == false && longScript.ToggleShot == false) { shootScript.ToggleShot = true; doubleScript.ToggleShot = true; longScript.ToggleShot = true; } } }
// Use this for initialization protected override void Start() { _rb = gameObject.GetComponent <Rigidbody2D>(); if (!_rb) { Debug.LogError("No rigidbody found on pawn!"); } _sf = gameObject.GetComponentInChildren <ShipFire>(); }
void RemovePowerup() { // reove only double shot at the moment ShipFire fireScript = Ship.GetComponent <ShipFire>(); fireScript.enabled = true; ShipDoubleShot doubleShotScript = Ship.GetComponent <ShipDoubleShot>(); doubleShotScript.enabled = false; }
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)); }
// Long Shot public void Power4() { // find the ship GameObject ship = GameObject.FindWithTag("Ship"); // get the shoot scripts ShipFire singleFire = ship.GetComponent <ShipFire> (); ShipDoubleShot doubleShot = ship.GetComponent <ShipDoubleShot> (); ShipLongShot longShot = ship.GetComponent <ShipLongShot> (); // Disable single fire and doubleshot singleFire.enabled = false; doubleShot.enabled = false; // Enable longshot longShot.enabled = true; }
void RemovePowerup() { GameObject gameManager = GameObject.Find("GameManager"); LoadSettings script = gameManager.GetComponent <LoadSettings> (); switch (script.shipNumber) { case 1: ShipFire fireScript = Ship.GetComponent <ShipFire>(); fireScript.enabled = true; ShipDoubleShot doubleShotScript = Ship.GetComponent <ShipDoubleShot>(); doubleShotScript.enabled = false; break; case 2: ShipShield shieldScript = Ship.GetComponent <ShipShield>(); shieldScript.SpawnShield = false; break; } }
private void LoadObjects() { shipCollisionStatus = gameObject.GetComponent <ShipCollision> (); shipFire = gameObject.GetComponent <ShipFire> (); shipMove = gameObject.GetComponent <ShipMove> (); }