public void InitializeExploreNode(RobotResultCode curType, ExploreNode parentNode, MovementCommandEnum enterDir) { parentNode.AssignMovementNode(this, enterDir); MovementCommandEnum exitDir = RepairBot.GetOppositeCommand(enterDir); AssignMovementNode(parentNode, exitDir); nodeType = curType; }
void ProcessRobotResult(RobotResultCode resultCode) { Vector2 posToUpdate = GetNewPosition(curPos, curDir); if ((resultCode == RobotResultCode.MOVE_SUCCESFUL) || (resultCode == RobotResultCode.MOVE_SUCCESFUL_OXYGEN)) { // do nothing // found a new node int curIndex = Helpers.GetIndexFromCoordinate(posToUpdate, xSize); if (curMap[curIndex] == null) { // ALL NEW NEW NEW! ExploreNode newNode = new ExploreNode(); curMap[curIndex] = newNode; } curMap[curIndex].InitializeExploreNode(resultCode, curNode, curDir); // otherwise we've already been here. curNode = curMap[curIndex]; if (!isBackTracking) { fromStartCommands.Push(curDir); } curPos = posToUpdate; return; } else if (resultCode == RobotResultCode.WALL) { if (isBackTracking) { // errro int t = 9; } // make a new node, but don't move. Go backwards one. int curIndex = Helpers.GetIndexFromCoordinate(posToUpdate, xSize); if (curMap[curIndex] == null) { // ALL NEW NEW NEW! ExploreNode newNode = new ExploreNode(); curMap[curIndex] = newNode; } curMap[curIndex].InitializeExploreNode(RobotResultCode.WALL, curNode, curDir); // otherwise we've already been here. // curpos does not change return; } }