public void ResetState() { if (currentState == swimmingState) { CurtailSnakeBody(); } CurrentState = normalState; }
public void InitializeSnake() { _shouldStop = false; body.Clear(); directionChangeOps.Clear(); body.Enqueue(gameConsole.GetCoordinate(10, 1)); body.Enqueue(gameConsole.GetCoordinate(10, 2)); body.Enqueue(gameConsole.GetCoordinate(10, 3)); direction = Direction.Right; normalState = new NormalState(this); swimmingState = new SwimmingState(this); breakingState = new BreakingState(this); fanaticState = new FanaticState(this); ResetState(); PaintSnake(Color.Black); gameConsole.UpdateSnakeLength(body.Count()); }
void ChangeState(FruitType fruitType) { switch (fruitType) { case FruitType.Strawberry: CurrentState = fanaticState; break; case FruitType.Banana: CurrentState = breakingState; break; case FruitType.Blueberry: CurrentState = swimmingState; break; default: // When an orange is eaten, state shouldn't change. // Snake color needs to remain break; } }