protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage) { ImmutableDataPartitionLocation data = new ImmutableDataPartitionLocation(id, xmlNode, errorMessage); // store the data if (hashData.ContainsKey(id)) { Debug.LogError(errorMessage + "Duplicate keys!"); } else { hashData.Add(id, data); } }
/// <summary> /// Gets the unused position next to minigame /// NOTE: GetRandomUnlockedMinigameType() does not keep track of local, if picked already /// </summary> /// <returns>The unused position next to minigame.</returns> public LgTuple<Vector3, string> GetPositionNextToMinigame(MinigameTypes minigameType){ CheckInitializeOpenLocations(); // Converting to the MinigameTypes to a PartitionLocationType PartitionLocationTypes locationType = PartitionLocationTypes.None; switch(minigameType){ case MinigameTypes.Clinic: locationType = PartitionLocationTypes.Clinic; break; case MinigameTypes.Memory: locationType = PartitionLocationTypes.Memory; break; case MinigameTypes.Runner: locationType = PartitionLocationTypes.Runner; break; case MinigameTypes.Shooter: locationType = PartitionLocationTypes.Shooter; break; case MinigameTypes.TriggerNinja: locationType = PartitionLocationTypes.TriggerNinja; break; case MinigameTypes.MicroMix: locationType = PartitionLocationTypes.MicroMix; break; default: return null; } // Initialize all to null first LgTuple<Vector3, string> tupleToReturn = null; ImmutableDataPartitionLocation locationToDelete = null; // Loop through available list and keep track if found foreach(ImmutableDataPartitionLocation location in openMinipetLocationsList){ if(location.Attribute == locationType){ tupleToReturn = new LgTuple<Vector3, string>(location.Offset, location.Id); locationToDelete = location; break; } } // Remove the tuple from the list if is exists, outside foreach iteration if(locationToDelete != null){ openMinipetLocationsList.Remove(locationToDelete); } return tupleToReturn; }
/// <summary> /// Gets a random unused position in partition from availablePartitionLocationList /// </summary> /// <returns>Used position in partition, zero if none exists</returns> /// <param name="partitionNumber">Partition number.</param> public LgTuple<Vector3, string> GetRandomUnusedPosition(){ CheckInitializeOpenLocations(); // Initialize all to null first LgTuple<Vector3, string> tupleToReturn = null; ImmutableDataPartitionLocation locationToDelete = null; if(openMinipetLocationsList.Count > 0){ // Choose a random index and designate it int randomIndex = UnityEngine.Random.Range(0, openMinipetLocationsList.Count); locationToDelete = openMinipetLocationsList[randomIndex]; tupleToReturn = new LgTuple<Vector3, string>(locationToDelete.Offset, locationToDelete.Id); // Remove the tuple from the list if is exists, outside foreach iteration if(locationToDelete != null){ openMinipetLocationsList.Remove(locationToDelete); } } return tupleToReturn; }
public LgTuple<Vector3, string> GetBasePositionInBedroom(){ CheckInitializeOpenLocations(); // Initialize all to null first LgTuple<Vector3, string> tupleToReturn = null; ImmutableDataPartitionLocation locationToDelete = null; // Loop through available list and keep track if found foreach(ImmutableDataPartitionLocation location in openMinipetLocationsList){ if(location.Attribute == PartitionLocationTypes.Base){ tupleToReturn = new LgTuple<Vector3, string>(location.Offset, location.Id); locationToDelete = location; break; } } // Remove the tuple from the list if is exists, outside foreach iteration if(locationToDelete != null){ openMinipetLocationsList.Remove(locationToDelete); } return tupleToReturn; }