public void PauseGame(bool isPaused) { //stop/start timer timerStarted = !isPaused; //stop/move tiles tileSpawner.IsMovingTiles(!isPaused); //stop/move player player.Move(!isPaused); //open pause UI if (isPaused) uIManager.PauseGame(); }
IEnumerator Locomotion() { period = 1f * Time.fixedDeltaTime; float timeUntilNextMovementCalc = 0; MovementRule[] rules = new MovementRule[] { new AvoidBullets(this, 6f), new MoveTowardsRandTarget(this, 1f), new AvoidBorders(this, 4f), new SeekHealthPack(this, 8f), new AvoidOtherPlayerAttacks(this, 8f) }; while (GameManager.S.gameState == GameStates.playing) { //Add different influences for movement direction Vector3 moveDirection = Vector3.zero; for (int i = 0; i < rules.Length; i++) { moveDirection += rules[i].Apply() * rules[i].weight; } //Reapply last movement vector every frame until we need to recalculate while (timeUntilNextMovementCalc > 0) { timeUntilNextMovementCalc -= Time.deltaTime; movement.Move(WithinUnitSphere(moveDirection)); yield return(null); } timeUntilNextMovementCalc = period; } }
// Update is called once per frame void Update() { shipMovement.Move(Vector3.up); }
public static void Move(string input, string startDirection, int expected) { Assert.Equal(expected, ShipMovement.Move(input, startDirection)); }