public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; this.target = target; t = 0; start = target.transform.position; end = start; switch (moveDirection) { case Directions.Up: end += new Vector3(0, 1, 0); break; case Directions.Down: end += new Vector3(0, -1, 0); break; case Directions.Left: end += new Vector3(-1, 0, 0); break; case Directions.Right: end += new Vector3(1, 0, 0); break; } moving = true; }
public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; robot = target; executeNext = false; var currentX = robot.X; var currentZ = robot.Z; switch (moveDirection) { case Directions.Up: currentX++; break; case Directions.Down: currentX--; break; case Directions.Left: currentZ++; break; case Directions.Right: currentZ--; break; } // Find object at the given direction var obj = softwareLevelGenerator.GetObject(currentX, currentZ); if (obj == null) { throw new InstructionException("Could not find object " + moveDirection.ToString()); return; } var arrayElement = obj.GetComponent <IndexElement>(); if (arrayElement == null) { throw new InstructionException("Could not find object " + moveDirection.ToString()); return; } // Jump to the index of the object adjacent targetPos = softwareLevelGenerator.IndexLocation("a" + arrayElement.Value); var didMove = robot.MoveTo(Vector3.zero, "a" + arrayElement.Value); if (!didMove) { throw new InstructionException("Could not move to " + arrayElement.Value); } // Increment index element arrayElement.Value++; }
public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; robot = target; var didMove = false; // Try to swap didMove = robot.SwapItem(moveDirection); if (!didMove) { throw new InstructionException("Could not swap"); } }
public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; robot = target; var didMove = false; // Try to pickup didMove = robot.PickUpItem(moveDirection); if (!didMove) { throw new InstructionException("Could not pick up in the " + moveDirection.ToString() + " direction"); } }
public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; robot = target; executeNext = false; if (selectedObj == null) { throw new InstructionException("No Move target selected"); } var didMove = robot.MoveTo(targetPos, null); if (!didMove) { throw new InstructionException("Could not move to selected target"); } }
// Called once each time the instruction starts to be executed public abstract void Execute(RobotController target, InstructionExecutor executor);
public override void Execute(RobotController target, InstructionExecutor executor) { instructionExecutor = executor; robot = target; }