public Location GetLocationFromEnum(worldLocations loc) { for (int i = 0; i < locations.Count; i++) { // get the world location for this enum. Probably should use a dictionary, but those aren't serializable by unity out of the box if (locations[i].worldLocationEnumValue == loc) { return(locations[i]); } } Debug.LogError("Unable to find location from enum: " + loc); return(null); // this should never happen as long as all of the locs are setup, but bugs happen! }
Character GetRandomCharacter(worldLocations loc) { // get a random character that spawns at that location // if no character spawns then make the game better, you managed to break it List <Character> possible = new List <Character>(); for (int i = 0; i < characters.Count; i++) { worldLocations[] locs = characters[i].spawnLocations; for (int j = 0; j < locs.Length; j++) { if (locs[j] == loc || locs[j] == worldLocations.ALL) { // then they're a possible character possible.Add(characters[i]); break; // stop checking this character we know they're possible. } } } return(possible[Random.Range(0, possible.Count)]); // return a random character }
public void LookAtLocation(worldLocations loc) { Location l = GetLocationFromEnum(loc); pointCamera.SetTarget(l.cameraTarget); }