/// <summary> /// Sets up triggers. /// This function just SETS UP the triggers and /// where they should spawn. The actual triggers are /// spawned from the DegradationUIManager. /// </summary> private void SetUpTriggers() { Debug.Log("SETTING UP TRIGGERS"); // get list of available locations to spawn triggers List <ImmutableDataTriggerLocation> listAvailable = DataLoaderTriggerLocations.GetAvailableTriggerLocations("Bedroom"); // get the number of triggers to spawn based on the previously uncleaned triggers and the new ones to spawn, with a max int numToSpawn = GetNumTriggersToSpawn(); DataManager.Instance.GameData.Degradation.UncleanedTriggers = numToSpawn; List <ImmutableDataTriggerLocation> listChosen = ListUtils.GetRandomElements(listAvailable, numToSpawn); //create trigger data to be spawned for (int i = 0; i < listChosen.Count; i++) { ImmutableDataTriggerLocation location = listChosen[i]; ImmutableDataTrigger randomTrigger = DataLoaderTriggers.GetRandomSceneTrigger("Bedroom"); //spawn them at a pre defined location ID is the order in which the data are created degradationTriggers.Add(new DegradData(randomTrigger.ID, location.Partition, location.Position)); } if (degradationTriggers.Count > 0) { AudioManager.Instance.backgroundMusic = "bgClinic"; AudioManager.Instance.StartCoroutine("PlayBackground"); } if (OnRefreshTriggers != null) { OnRefreshTriggers(this, EventArgs.Empty); } }
/// <summary> /// Gets the trigger location. /// </summary> /// <returns>The trigger location.</returns> /// <param name="id">Identifier.</param> /// <param name="scene">Scene.</param> public static ImmutableDataTriggerLocation GetTriggerLocation(string id, string scene) { instance.InitXMLLoader(); ImmutableDataTriggerLocation data = null; Hashtable hashScene = instance.GetData <Hashtable>(scene); if (hashScene.ContainsKey(id)) { data = (ImmutableDataTriggerLocation)hashScene[id]; } else { Debug.LogError("No such trigger id " + id + " for scene " + scene); } return(data); }
protected override void XMLNodeHandler(string id, IXMLNode xmlNode, Hashtable hashData, string errorMessage) { ImmutableDataTriggerLocation data = new ImmutableDataTriggerLocation(id, xmlNode, errorMessage); string scene = data.Scene; if (!hashData.ContainsKey(scene)) { hashData[scene] = new Hashtable(); } Hashtable hashScenes = (Hashtable)hashData[scene]; if (hashScenes.ContainsKey(id)) { Debug.LogError("Duplicate trigger location id: " + id + " for " + scene); } else { hashScenes[id] = data; } }
/// <summary> /// Gets the available trigger locations for a scene. /// </summary> /// <returns>The available trigger locations.</returns> /// <param name="scene">Scene.</param> public static List <ImmutableDataTriggerLocation> GetAvailableTriggerLocations(string scene) { instance.InitXMLLoader(); List <ImmutableDataTriggerLocation> list = new List <ImmutableDataTriggerLocation>(); Hashtable hashScene = instance.GetData <Hashtable>(scene); foreach (DictionaryEntry entry in hashScene) { ImmutableDataTriggerLocation location = (ImmutableDataTriggerLocation)entry.Value; // check to make sure the partition of this trigger is unlocked; if it is, it's okay to add to the list int partition = location.Partition; if (GatingManager.Instance.HasActiveGate(partition) == false) { list.Add(location); } } return(list); }