private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { nextState = new RobotIdleState(robot); } else if (beatStartedSignal.BeatType == BeatType.ROBOT_MOVE) { Command frontCommand = CommandRegister.Inst.GetCommand(); if (frontCommand.GetType() == typeof(GoStraightCommand)) { nextState = new RobotWalkForwardState(robot); } else if (frontCommand.GetType() == typeof(TurnLeftCommand)) { nextState = new RobotTurnLeftState(robot); } else if (frontCommand.GetType() == typeof(TurnRightCommand)) { nextState = new RobotTurnRightState(robot); } } }
private void onBeatStarted(Signal signal) { if (gameIsOver) { nextState = new ItemIconGameOverState(itemIcon); return; } BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.INTRO) { return; } if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { if (itemIcon.currentSlot.Next != null) { nextState = new ItemIconSlideState(itemIcon); } else { nextState = new ItemIconPoolState(itemIcon); } } }
private void onBeatStarted(Signal signal) { if (gameIsOver) { nextState = new CommandGameOverState(command); return; } BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.INTRO) { return; } if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { if (command.currentSlot.Next != null) { nextState = new CommandSlideState(command); } else { nextState = new CommandPoolState(command); } } }
private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { nextState = new SpringBoardSpringState(springBoardTile); } }
private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { nextState = new TurnLeftTileSpinState(turnLeftTile); } }
private void onBeatStarted(Signal signal) { if (!gameIsOver) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.ROBOT_MOVE) { ItemIcon newItemIcon = ItemIconPool.Inst.GetRandomItemIcon(); newItemIcon.Activate(this); } } }
private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; Debug.Assert(beatStartedSignal.BeatType == BeatType.ROBOT_MOVE, "Wrong BeatType during robot left trn table state. Left turn table State expects to be ended by ROBOT_MOVE beat"); switch (robot.currentHeading) { case Heading.NORTH: robot.currentZ += 2; break; case Heading.EAST: robot.currentX += 2; break; case Heading.SOUTH: robot.currentZ -= 2; break; case Heading.WEST: robot.currentX -= 2; break; default: Debug.Assert(false, "Unknown heading: " + robot.currentHeading.ToString()); break; } Tile newTile = TileGrid.Inst.GetTileAt(robot.currentX, robot.currentZ); if (newTile == null) { nextState = new RobotFallState(robot); } else { Command frontCommand = CommandRegister.Inst.GetCommand(); if (frontCommand.GetType() == typeof(GoStraightCommand)) { nextState = new RobotWalkForwardState(robot); } else if (frontCommand.GetType() == typeof(TurnLeftCommand)) { nextState = new RobotTurnLeftState(robot); } else if (frontCommand.GetType() == typeof(TurnRightCommand)) { nextState = new RobotTurnRightState(robot); } } }
private void onBeatStarted(Signal signal) { if (gameIsOver) { nextState = new ItemIconGameOverState(itemIcon); return; } BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; Debug.Assert(beatStartedSignal.BeatType == BeatType.ROBOT_MOVE, "wrong BeatType started while command in Slide state. Slide state expects to end on ROBOT_MOVE beat."); nextState = new ItemIconIdleState(itemIcon); }
void Update() { BeatTimer += Time.deltaTime; if (BeatTimer > secondsPerBeat) { currentBeatType = nextBeatType(currentBeatType); BeatStartedSignal beatStartedSignal = new BeatStartedSignal(currentBeatType); if (currentBeatType == BeatType.ROBOT_MOVE && !gameIsOver) { MoveCompleted++; } GameSceneSignalManager.Inst.FireSignal(beatStartedSignal); BeatTimer = BeatTimer - secondsPerBeat; } }
private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; Debug.Assert(beatStartedSignal.BeatType == BeatType.BOARD_MOVE, "Wrong BeatType during robot walk forward state. Walk forward State expects to be ended by BOARD_MOVE beat"); switch (robot.currentHeading) { case Heading.NORTH: robot.currentZ++; break; case Heading.EAST: robot.currentX++; break; case Heading.SOUTH: robot.currentZ--; break; case Heading.WEST: robot.currentX--; break; default: Debug.Assert(false, "Unknown heading: " + robot.currentHeading.ToString()); break; } Tile newTile = TileGrid.Inst.GetTileAt(robot.currentX, robot.currentZ); if (newTile == null) { nextState = new RobotFallState(robot); } else if (newTile.GetType() == typeof(TurnLeftTile)) { nextState = new RobotLeftTurnTableState(robot); } else if (newTile.GetType() == typeof(SpringBoardTile)) { nextState = new RobotSpringState(robot); } else { nextState = new RobotIdleState(robot); } }
private void onBeatStarted(Signal signal) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; Debug.Assert(beatStartedSignal.BeatType == BeatType.ROBOT_MOVE, "Wrong BeatType during robot idle state. Idle State expects to be ended by ROBOT_MOVE beat"); Command frontCommand = CommandRegister.Inst.GetCommand(); if (frontCommand.GetType() == typeof(GoStraightCommand)) { nextState = new RobotWalkForwardState(robot); } else if (frontCommand.GetType() == typeof(TurnLeftCommand)) { nextState = new RobotTurnLeftState(robot); } else if (frontCommand.GetType() == typeof(TurnRightCommand)) { nextState = new RobotTurnRightState(robot); } }
private void onBeatStarted(Signal signal) { if (!gameIsOver) { BeatStartedSignal beatStartedSignal = (BeatStartedSignal)signal; if (beatStartedSignal.BeatType == BeatType.BOARD_MOVE) { if (lastCommandWasTurn) { Command newCommand = CommandPool.Inst.GetCommand <GoStraightCommand>(); newCommand.Activate(this); lastCommandWasTurn = false; } else { Command newCommand = CommandPool.Inst.GetRandomCommand(); newCommand.Activate(this); lastCommandWasTurn = (newCommand.GetType() != typeof(GoStraightCommand)); } } } }