public List <Item> GetItemsUnlockAtNextLevel() { int nextLevel = LevelLogic.Instance.NextLevel; List <Item> itemsUnlock = new List <Item>(); List <Item> retList; foreach (Item item in FoodList) { if (!item.IsSecretItem && item.UnlockAtLevel == nextLevel) { itemsUnlock.Add(item); } } foreach (Item item in DecorationList) { if (!item.IsSecretItem && item.UnlockAtLevel == nextLevel) { itemsUnlock.Add(item); } } //check how many items are selected //select only 3 by random if (itemsUnlock.Count > 3) { retList = ListUtils.GetRandomElements <Item>(itemsUnlock, 3); } else { retList = itemsUnlock; } return(retList); }
/// <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); } }
protected override void SpawnObjects(List <string> listObjects) { // get a number of random, non-repeating spawn points List <float> listSpawnLocs = ListUtils.GetRandomElements <float>(listLocations, listObjects.Count); // and then spawn the objects! SpawnObjects(listObjects, listSpawnLocs); }
private IEnumerator MakeMoves_(int i_nMoves) { // how long should the AI wait between moves? float fWait = Constants.GetConstant <float>("MonsterWaitTime"); // wait before making first move yield return(new WaitForSeconds(fWait)); // for now, just pick randomly from amongst available pieces List <GamePiece_Draft> listAvailablePieces = Gameboard_Draft.Instance.GetAvailablePieces(); List <GamePiece_Draft> listPickedPieces = ListUtils.GetRandomElements <GamePiece_Draft>(listAvailablePieces, i_nMoves); foreach (GamePiece_Draft piece in listPickedPieces) { // pick a piece piece.PickPice(); // wait a bit yield return(new WaitForSeconds(fWait)); } }