private static void ReadXmlWaypointDatas(XmlReader reader) { int x, z; int ownerUniqueID; Direction orientation; WaypointManagerData manager = null; WaypointData waypoint; if (reader.ReadToDescendant(PStrings.waypointData) == true) { do { x = int.Parse(reader.GetAttribute(PStrings.xCoordinate)); z = int.Parse(reader.GetAttribute(PStrings.zCoordinate)); orientation = (Direction)int.Parse(reader.GetAttribute(PStrings.orientation)); ownerUniqueID = int.Parse(reader.GetAttribute(PStrings.uniqueID)); if (obstacles.ContainsKey(ownerUniqueID) == true) { manager = (WaypointManagerData)obstacles[ownerUniqueID].GetExtension(PStrings.waypointManager); } if (items.ContainsKey(ownerUniqueID) == true) { manager = (WaypointManagerData)items[ownerUniqueID].GetExtension(PStrings.waypointManager); } if (entities.ContainsKey(ownerUniqueID) == true) { manager = (WaypointManagerData)entities[ownerUniqueID].GetExtension(PStrings.waypointManager); } waypoint = WaypointData.Instantiate(Metrics.GetCell(new Coordinates(x, z)), manager); waypoint.SetOrientation(orientation); } while (reader.ReadToNextSibling(PStrings.waypointData)); } }
private void SetSelectedWaypoint(CellData cellData) { Metrics.WaypointVisuals(false); WaypointManagerData waypointManager = null; bool isValidPlacement = false; if (selectedObstacle != null) { waypointManager = (WaypointManagerData)selectedObstacle.GetExtension(PStrings.waypointManager); } else if (selectedItem != null) { waypointManager = (WaypointManagerData)selectedItem.GetExtension(PStrings.waypointManager); } else if (selectedEntity != null) { waypointManager = (WaypointManagerData)selectedEntity.GetExtension(PStrings.waypointManager); } if (waypointManager == null) { return; } if (inputMode == InputMode.Constructive) { selectedWaypoint = waypointManager.GetWaypointAt(cellData); if (selectedWaypoint == null) { if (selectedObstacle != null) { isValidPlacement = selectedObstacle.Validation(cellData, activeDirection); } else if (selectedItem != null) { isValidPlacement = selectedItem.Validation(cellData); } else if (selectedEntity != null) { isValidPlacement = selectedEntity.Validation(cellData); } if (isValidPlacement == true) { selectedWaypoint = WaypointData.Instantiate(cellData, waypointManager); } } else { editorUI.SetSelectWaypoint(); } if (selectedWaypoint != null) { editorUI.waypointSelectionUI.SetUIBasedOn(waypointManager, selectedWaypoint); } } else if (inputMode == InputMode.Destructive) { WaypointData.Destroy(cellData, waypointManager); } }