// Update is called on fixed time intervals. // We'll use it for user controls, calculation for movement and animation, since we want to make it consistent over time (same speed on different time frames). private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. CalculateMoveSprite(); } } }
// Update is called on fixed time intervals. private void FixedUpdate() { // Should elevator start counting and not started counting yet? if (GameManager.ElevatorCounting == true && _ElevatorStartedCounting == false) { // Yes. _ElevatorStartedCounting = true; _TickerCounter.ReSetTickCounter(1); } // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Decrease the oxigen, if above zero. if (GameManager.CurrentAirBubbles > 0) { // Is elevator counting? if (GameManager.ElevatorCounting == true) { // Yes. GameManager.CurrentAirBubbles -= 2; GameManager.AddAirScore(); } else { GameManager.CurrentAirBubbles--; } _IsTimeToDraw = true; } else { // Is elevator counting? if (GameManager.ElevatorCounting == true) { // Yes. // Chage state to level compete. GameManager.LevelCompleted = true; } else { // No. // In this case, player died. _SoundSource.PlayOneShot(_DeathSound); GameManager.PlayerIsDead = true; } } } }
// Update is called on fixed time intervals. // For animation caclulation. private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. // Is elevator active? if (GameManager.ElevatorIsActive == true) { // Yes. _IsTimeToDraw = true; } } } }
// Fixed update is called on fixed time intervals. private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. // Get random sunbeam: 1 to 7. _NextSunbeam = Mathf.FloorToInt(Random.Range(1.0f, 7.99f)); // Get random tick count: from 4 to 45. _TickerCounter.ReSetTickCounter(Mathf.FloorToInt(Random.Range(4.0f, 45.99f))); _IsTimeToDraw = true; } } }
// Update is called on fixed time intervals. // We'll use it for user controls, calculation for movement and animation, since we want to make it consistent over time (same speed on different time frames). private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is the first lever activated (there are two of them)? if (GameManager.ElevatorIsActive == true && _IsElevatorActivated == false) { // Yes, mark elevator activated. _IsElevatorActivated = true; } // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. CalculateMoveSprite(); } } }
private void FixedUpdate() { // Is game in demo mode? if (GameManager.IsGameInDemoMode == true) { // Yes. // Is time to resetCountdown? if (_TickerCounterForDemoMode.IsItTimeToCalculate() == true) { // Yes. GameManager.RunNextLevel(); } } else { // No. // Is player dead? if (GameManager.PlayerIsDead == true) { // Yes. // Is time to resetCountdown? if (_TickerCounterForDeath.IsItTimeToCalculate() == true) { // Yes. GameManager.CurrentPlayerLives--; // Do player still has lives? if (GameManager.CurrentPlayerLives > 0) { // Yes. // Start level from beggining. GameManager.ReloadLevel(); } else { // No. // Load menu screen. GameManager.RunMenu(); } } } } }
// Update is called on fixed time intervals. // For animation caclulation. private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. _ColorIndex++; // Is it over last color? if (_ColorIndex == ResourceManager.PickupColors.Length) { // Yes. _ColorIndex = 0; } _IsTimeToDraw = true; } } }
// Update is called on fixed time intervals. private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. if (_SpriteIndex == 7) { _SpriteIndex = 4; } else { _SpriteIndex++; } _IsTimeToDraw = true; } } }
// Update is called on fixed time intervals. // We'll use it for user controls, calculation for movement and animation, since we want to make it consistent over time (same speed on different time frames). private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is the first lever activated (there are two of them)? if (GameManager.CurrentLeversToBeActivated == 1 && _IsHiddenDoorOpened == false) { // Yes, means hidden door is opened, use wider bounds for movement. _IsHiddenDoorOpened = true; _LeftBound = _LeftWiderBound; _RightBound = _RightWiderBound; } // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. CalculateMoveSprite(); } } }
// Update is called on fixed time intervals. // For animation caclulation. private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true && _IsMudSliding == true) { // Yes. _SpriteIndex++; // Is it over last frame? if (_SpriteIndex == _SpriteLastIndex + 1) { // Yes. Destroy(gameObject); } else { // No. _IsTimeToDraw = true; } } } }
// Update is called on fixed time intervals. // We'll use it for user controls, calculation for movement and animation, since we want to make it consistent over time (same speed on different time frames). private void FixedUpdate() { if (GameManager.IsGamePaused == false) { // Is time to resetCountdown? if (_TickerCounter.IsItTimeToCalculate() == true) { // Yes. // Is elevator active, and not counting? if (GameManager.ElevatorIsActive == true && GameManager.ElevatorCounting == false) { // Yes. CheckElevatorHits(); } // Is player not dead, and elevator is not counting? if (GameManager.PlayerIsDead == false && GameManager.ElevatorCounting == false) { _SpritePositionIncrement = Vector2.zero; // Do key transformations. TransformKeyInput(); // Is player in the jump phase? if (_IsPlayerInJumpPhase == true) { // Yes. CalculateJump(); } else { // No. // Is player in the fall phase? if (_IsPlayerInFallPhase == true) { // Yes. CalculateFall(); } else { // No. // Is player in the drop phase? if (_IsPlayerInDropPhase == true) { // Yes. CalculateDrop(); } else { // No. RaycastHit2D[] groundContacts = GetCollidersOnSide(_CollisionSide.Bottom, _MaskWithGround); //Is player grounded? if (groundContacts.Length > 0) { // Yes. // Do mud and threadmill calculations. CalculateThreadmillAndMudInteraction(groundContacts); // Are we forced to move on threadmill? if (_ForceMovingOnThreadmill == true) { // Yes. _PressedKeyDirection = (GameManager.ThreadmillIsRotatingRight == true) ? 1 : -1; } // Was player just finished jump or drop phase? if (_JustWasPlayerInJumpOrDropPhase == true) { // Yes. _JustWasPlayerInJumpOrDropPhase = false; // Is he stepping over mud? if (GetCollidersOnSide(_CollisionSide.Bottom, _MaskWithMud).Length > 0) { // Yes, he cannot jump right away. _PressedKeyForJump = 0f; } } // Is the jump button pressed? if (_PressedKeyForJump > 0) { // Yes. // Is player not hitting the ceiling? if (GetCollidersOnSide(_CollisionSide.Top, _MaskWithWalls).Length == 0) { // Yes, initialize jump. _SpriteJumpDirection = _PressedKeyDirection; _IsPlayerInJumpPhase = true; _UnitsToJumpOrDropIndex = 0; _JumpSoundsIndex = 0; CalculateJump(); // Is there a jump direction? if (_SpriteJumpDirection != 0) { // Yes. CalculateMoveSprite(); } // Reset mud and threadmill calculations. CalculateThreadmillAndMudInteraction(null); } } else { // No. // Is direction button pressed? if (_PressedKeyDirection != 0) { //Yes, is player changing direction? if ((_PressedKeyDirection < 0 && _IsPlayerFacingRight == true) || (_PressedKeyDirection > 0 && _IsPlayerFacingRight == false)) { // Yes. _IsPlayerFacingRight = !_IsPlayerFacingRight; _SpriteAnimator.ChangeDirection(); } else { // No. CalculateMoveSprite(); } } } } else { // No, initialize drop. _SpriteAltitudeBeforeFallOrDrop = new Vector2(transform.position.x, transform.position.y); _IsPlayerInDropPhase = true; _UnitsToJumpOrDropIndex = 0; _JumpSoundsIndex = 18; CalculateDrop(); // Reset mud and threadmill calculations. CalculateThreadmillAndMudInteraction(null); } } } } // Is player in the air? if (_IsPlayerInJumpPhase == true || _IsPlayerInFallPhase == true || _IsPlayerInDropPhase == true) { // Yes. PlayMovementInAirSound(); } // Checking out on the end of movement phases, so will include projected position into calculation. CheckPickupHits(); CheckLeverHits(); CheckEnemyHits(); } } } }