private void handleOnShipDestroyed() { //unregister from event that don't happen again PlayerShipHealth.OnShipDestroyed -= handleOnShipDestroyed; state = ShipStates.dying; }
private void handleOnPlayStart() { //unregister from event that don't happen again GameManager.OnPlayStart -= handleOnPlayStart; state = ShipStates.controllable; }
public void ChangeState(ShipStates state) { if (_state != null) { _state.Stop(); } _state = _stateFactory.CreateState(state); _state.Start(); }
public void ChangeState(ShipStates state, params object[] constructorArgs) { if (_state != null) { _state.Stop(); } _state = _stateFactory.Create(state, constructorArgs); _state.Start(); }
private void handleOnVictory() { //unregister from event that don't happen again GameManager.OnVictory -= handleOnVictory; state = ShipStates.victorious; //Anim animator.SetFloat("Vertical Speed", 0f); }
// Use this for initialization void Awake() { state = ShipStates.init; isFiring = false; currWeapon = weapons[0]; currLvl = 0; currGuns = currWeapon.lvls[currLvl].guns; InitFireTimes(); }
public void OnLevelChange(Vector3 initialPos) { transform.position = initialPos; transform.rotation = Quaternion.identity; rb.velocity = Vector3.zero; rb.angularVelocity = 0.0f; if (ShipState != ShipStates.freeFall) { ShipState = ShipStates.freeFall; ChangeSprite(); } InitialImpulse(); }
private void UpdateState(ShipStates desiredShipState) { ShipState = desiredShipState; switch (desiredShipState) { case ShipStates.WaitingForIdInventory: SetStateWaitingForIdInventory(); break; case ShipStates.WaitingForWeight: SetStateWaitingForWeight(); break; } }
public ShipState Create(ShipStates state, params object[] constructorArgs) { switch (state) { case ShipStates.Dead: return _instantiator.Instantiate<ShipStateDead>(constructorArgs); case ShipStates.Moving: return _instantiator.Instantiate<ShipStateMoving>(constructorArgs); case ShipStates.WaitingToStart: return _instantiator.Instantiate<ShipStateWaitingToStart>(constructorArgs); } Assert.That(false); return null; }
public ShipState Create(ShipStates state, params object[] constructorArgs) { switch (state) { case ShipStates.Dead: return(_container.Instantiate <ShipStateDead>(constructorArgs)); case ShipStates.Moving: return(_container.Instantiate <ShipStateMoving>(constructorArgs)); case ShipStates.WaitingToStart: return(_container.Instantiate <ShipStateWaitingToStart>(constructorArgs)); } Assert.That(false); return(null); }
void OnCrash() { if (fuel > 0) { fuel -= fuelLostOnCrash; if (fuel < 0) { fuel = 0; } } ShipState = ShipStates.destroyed; ChangeSprite(); ShowLandResultScreen(false); if (!displayingResults) { OnResultsScreenEnter(); } }
private void Update() { if (rb.gravityScale != gravityScale) { rb.gravityScale = gravityScale; } if (Input.GetKey(KeyCode.Space) && ableToMove) { Impulse(); } else if (ShipState == ShipStates.impulse) { ShipState = ShipStates.freeFall; ChangeSprite(); } float rotate = -Input.GetAxisRaw("Horizontal"); if (ableToMove) { transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 0, rotate * rotationSpeed * Time.deltaTime)); } hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance); if (hit.collider != null) { altitude = (int)(hit.distance * 10) - spriteOffset; if (altitude < 0) { altitude = 0; } } if (onLandingAltitude && altitude > landingAltitude) { SetCameraZoom(false); onLandingAltitude = false; } else if (!onLandingAltitude && altitude < landingAltitude) { SetCameraZoom(true); onLandingAltitude = true; } }
public ShipState CreateState(ShipStates state) { switch (state) { case ShipStates.Dead: { return(_deadFactory.Create()); } case ShipStates.WaitingToStart: { return(_waitingFactory.Create()); } case ShipStates.Moving: { return(_movingFactory.Create()); } } throw Assert.CreateException(); }
public ShipState CreateState(ShipStates state) { switch (state) { case ShipStates.Dead: { return _deadFactory.Create(); } case ShipStates.WaitingToStart: { return _waitingFactory.Create(); } case ShipStates.Moving: { return _movingFactory.Create(); } } throw Assert.CreateException(); }
void Impulse() { rb.AddForce(transform.up * impulseForce); if (fuel > 0) { fuel -= Time.deltaTime * fuelLosingSpeed; if (fuel < 0) { fuel = 0; } } if (fuel == 0) { ableToMove = false; } if (ShipState != ShipStates.impulse) { ShipState = ShipStates.impulse; ChangeSprite(); } }
void Awake() { Me = this; state = ShipStates.init; }
private void HandleOnShipDestroyed() { state = ShipStates.dying; StopFiring(); }
private void HandleOnVictory() { state = ShipStates.victorious; StopFiring(); }
private void HandleOnPlayStart() { state = ShipStates.controllable; }