public void SetWaypointsEndHold(bool toggle) { WaypointManagerData data = (WaypointManagerData)GetSelectedExtension(PStrings.waypointManager); if (data == null) { return; } data.endHold = toggle; }
public void SetWaypointsEndHoldFor(float value) { WaypointManagerData data = (WaypointManagerData)GetSelectedExtension(PStrings.waypointManager); if (data == null) { return; } data.endHoldFor = value; }
public void SetWaypointsCircular(bool toggle) { Metrics.WaypointVisuals(false); WaypointManagerData data = (WaypointManagerData)GetSelectedExtension(PStrings.waypointManager); if (data == null) { return; } data.SetCircular(toggle); }
public override void Initialize(int ownerUniqueID) { this.ownerUniqueID = ownerUniqueID; identifier = PStrings.entityController; input = new EntityInput(); input.InitializeDefaults(); attributes = new EntityAttributes(); attributes.InitializeDefaults(); state = new EntityState(); state.InitializeDefaults(); entityData = (EntityData)GridData.GetExtensible(ownerUniqueID); rigidbody = entityData.gameObject.GetComponent <Rigidbody>(); weaponController = entityData.gameObject.GetComponent <WeaponController>(); if (weaponController != null) { weaponController.Initialize(entityData); } waypointManager = (WaypointManagerData)entityData.GetExtension(PStrings.waypointManager); pathfindManager = (PathfindManagerData)entityData.GetExtension(PStrings.pathfindManager); state.rotationCurrent = Metrics.OrientationFromDirection[(int)entityData.orientation]; }
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); } }
public static ItemData Instantiate(ItemData prototype, CellData cell, int uniqueID) { if (prototype != null) { ItemData instance = new ItemData(); instance.uniqueID = uniqueID; instance.instructionSetID = prototype.instructionSetID; instance.prefab = prototype.prefab; instance.amount = prototype.amount; instance.cellData = cell; instance.cellData.item = instance; instance.lightMode = prototype.lightMode; instance.useVFX = prototype.useVFX; instance.gameObject = GameObject.Instantiate(instance.prefab); instance.gameObject.name = instance.instructionSetID; instance.gameObject.transform.SetParent(Metrics.itemContainer.transform, true); instance.gameObject.transform.eulerAngles = new Vector3(0, 180, 0); instance.gameObject.transform.position = Coordinates.ToWorldSpace(instance.cellData.coordinates); instance.extensions = new Dictionary <string, ExtensionData>(); instance.extensions.Add(PStrings.waypointManager, new WaypointManagerData()); instance.extensions.Add(PStrings.pathfindManager, new PathfindManagerData()); if (instance.lightMode != LightMode.Null) { instance.extensions.Add(PStrings.light, new LightData()); } if (instance.useVFX == true) { instance.extensions.Add(PStrings.visualEffects, new VisualEffectData()); } GridData.ItemInstanciated(instance); foreach (ExtensionData extension in instance.extensions.Values) { extension.Initialize(uniqueID); } return(instance); } if (cell.item != null) { ItemData instance = cell.item; cell.item = null; GameObject.Destroy(instance.gameObject); WaypointManagerData waypointManager = (WaypointManagerData)instance.extensions[PStrings.waypointManager]; waypointManager.Purge(); GridData.ItemDestroyed(instance); return(instance); } return(null); }
public static ObstacleData Instantiate(ObstacleData prototype, CellData cell, Direction orientation, int uniqueID) { if (prototype != null) { ObstacleData instance = new ObstacleData(); instance.cells = new List <CellData>(); instance.uniqueID = uniqueID; instance.instructionSetID = prototype.instructionSetID; instance.prefab = prototype.prefab; instance.width = prototype.width; instance.length = prototype.length; instance.lightMode = prototype.lightMode; instance.doorMode = prototype.doorMode; instance.isInteractable = prototype.isInteractable; instance.useVFX = prototype.useVFX; instance.cellData = cell; instance.orientation = orientation; CellData occupiedCell; int zStart = Metrics.zFirstCoordinate(instance.cellData, instance.orientation, instance.width, instance.length); int zEnd = Metrics.zLastCoordinate(instance.cellData, instance.orientation, instance.width, instance.length); int xStart = Metrics.xFirstCoordinate(instance.cellData, instance.orientation, instance.width, instance.length); int xEnd = Metrics.xLastCoordinate(instance.cellData, instance.orientation, instance.width, instance.length); for (int z = zStart; z < zEnd; z++) { for (int x = xStart; x < xEnd; x++) { occupiedCell = Metrics.GetCell(x, z); occupiedCell.obstacle = instance; instance.cells.Add(occupiedCell); } } instance.gameObject = GameObject.Instantiate(instance.prefab); instance.gameObject.name = instance.instructionSetID; instance.gameObject.transform.SetParent(Metrics.obstacleContainer.transform, true); instance.gameObject.transform.eulerAngles = new Vector3(-90, 0, Metrics.OrientationFromDirection[(int)instance.orientation]); instance.gameObject.transform.position = Coordinates.ToWorldSpace(instance.cellData.coordinates); instance.extensions = new Dictionary <string, ExtensionData>(); instance.extensions.Add(PStrings.waypointManager, new WaypointManagerData()); instance.extensions.Add(PStrings.pathfindManager, new PathfindManagerData()); if (instance.lightMode != LightMode.Null) { instance.extensions.Add(PStrings.light, new LightData()); } if (instance.doorMode != DoorMode.Null) { instance.extensions.Add(PStrings.door, new DoorData()); } if (instance.isInteractable == true) { instance.extensions.Add(PStrings.interactable, new InteractableData()); } if (instance.useVFX == true) { instance.extensions.Add(PStrings.visualEffects, new VisualEffectData()); } GridData.ObstacleInstanciated(instance); foreach (ExtensionData extension in instance.extensions.Values) { extension.Initialize(uniqueID); } return(instance); } if (cell.obstacle != null) { ObstacleData instance = cell.obstacle; for (int i = 0; i < instance.cells.Count; i++) { instance.cells[i].obstacle = null; } instance.cells.Clear(); GameObject.Destroy(instance.gameObject); WaypointManagerData waypointManager = (WaypointManagerData)instance.extensions[PStrings.waypointManager]; waypointManager.Purge(); GridData.ObstacleDestroyed(instance); return(instance); } return(null); }
public static EntityData Instantiate(EntityData prototype, CellData cell, Direction orientation, int uniqueID) { if (prototype != null) { EntityData instance = new EntityData(); instance.uniqueID = uniqueID; instance.instructionSetID = prototype.instructionSetID; instance.prefab = prototype.prefab; instance.orientation = orientation; instance.cellData = cell; instance.cellData.entity = instance; instance.lightMode = prototype.lightMode; instance.useVFX = prototype.useVFX; instance.gameObject = GameObject.Instantiate(instance.prefab); instance.gameObject.name = instance.instructionSetID; instance.gameObject.transform.SetParent(Metrics.entityContainer.transform, true); instance.gameObject.transform.eulerAngles = new Vector3(0, Metrics.OrientationFromDirection[(int)instance.orientation], 0); instance.gameObject.transform.position = Coordinates.ToWorldSpace(instance.cellData.coordinates); GridData.DamageableInstantiated(instance.gameObject, instance); instance.extensions = new Dictionary <string, ExtensionData>(); if (instance.instructionSetID == PStrings.playerSpawn) { instance.extensions.Add(PStrings.entityController, new PlayerController()); } else if (instance.instructionSetID == PStrings.zombie) { instance.extensions.Add(PStrings.entityController, new ZombieController()); } else if (instance.instructionSetID == PStrings.imp) { instance.extensions.Add(PStrings.entityController, new ImpController()); } instance.controller = (EntityController)instance.GetExtension(PStrings.entityController); instance.extensions.Add(PStrings.waypointManager, new WaypointManagerData()); instance.extensions.Add(PStrings.pathfindManager, new PathfindManagerData()); if (instance.lightMode != LightMode.Null) { instance.extensions.Add(PStrings.light, new LightData()); } if (instance.useVFX == true) { instance.extensions.Add(PStrings.visualEffects, new VisualEffectData()); } GridData.EntityInstanciated(instance); foreach (ExtensionData extension in instance.extensions.Values) { extension.Initialize(uniqueID); } return(instance); } if (cell.entity != null) { EntityData instance = cell.entity; cell.entity = null; GridData.DamageableDestroyed(instance.gameObject, instance); WaypointManagerData waypointManager = (WaypointManagerData)instance.GetExtension(PStrings.waypointManager); waypointManager.Purge(); GameObject.Destroy(instance.gameObject); GridData.EntityDestroyed(instance); return(instance); } return(null); }