///<summary>The main game coroutine - repeatedly moves the snake and checks for apples until the snake can't move.</summary> private IEnumerator runGame() { int[] next = this.snake.nextMove(); while (this.validMove(next)) { float timeToMove = this.timeInterval(); if (this.aboutToEatApple(next) && this.shouldGrow()) // after a certain point, the snake shouldn't grow every time { this.snake.grow(timeToMove, DataAndSettingsManager.getSmoothMovementState()); } else { int[] old = this.snake.move(timeToMove, DataAndSettingsManager.getSmoothMovementState()); this.setValueAtCoordinates(old, SPACE_EMPTY); } yield return(StartCoroutine(this.pausableWait(timeToMove))); // the player may pause during this time this.lookForApples(next); // by now, the snake has finished moving for the turn this.setValueAtCoordinates(next, SPACE_SNAKE); next = this.snake.nextMove(); } if (this.isTutorial) { this.stopTutorial(); } else { this.stopGame(); } yield break; }
void OnEnable() { this.closeColorSchemeListAction(); // switch to the correct panel this.colorblindModeToggle.isOn = DataAndSettingsManager.getColorblindModeState(); this.smoothMovementToggle.isOn = DataAndSettingsManager.getSmoothMovementState(); this.musicToggle.isOn = DataAndSettingsManager.getMusicEnabledState(); this.soundsToggle.isOn = DataAndSettingsManager.getSoundsEnabledState(); }