public void AddRobot(Robot robot) { if (this.Robots == null) { this.Robots = new List<Robot>(); } robot.SetCurrentHexagon(GetStartHexOnBottomRow(robot)); this.Robots.Add(robot); robot.LookAround += new EventHandler(OnRobotLookAround); robot.TryMove += new EventHandler(OnRobotTryMove); }
public MoveResult TryMove(HexUtils.eMoveDirection direction, Robot robot) { MoveResult result = new MoveResult(MoveResult.eMoveResult.DNE, ""); Hexagon targethex = GetAdjacentHexagon(robot.CurrentHexagon, direction); if (targethex != null) { result = HexUtils.isMoveAllowed(robot.CurrentHexagon, targethex, robot.UpJump, robot.DownJump); if (result.MoveResultStatus == MoveResult.eMoveResult.Success) { robot.SetCurrentHexagon(targethex); if (targethex.NE.Y == toprowy) { result.MoveResultStatus = MoveResult.eMoveResult.Complete; result.ResultMessage = string.Format("The robot {0} made it across!", robot.SerialNumber.ToString()); } } } return result; }