/// <summary> /// Whether or not the supplied room type is applicable to this event /// </summary> /// <param name="thisRoom"></param> /// <returns></returns> public bool MatchesRoomType(RoomStats.RoomType thisRoom) { foreach (RoomStats.RoomType type in roomTypes) { if (type == thisRoom) { return(true); } } return(false); }
/// <summary> /// Generates a new character event. Does nothing /// </summary> /// <param name="possibleEvents"></param> /// <returns></returns> public IEnumerator StartNewCharacterEvent(RoomStats.RoomType room) { chatting = true; FindObjectOfType <RoomPanelToggle>()?.ClosePanel(); GameObject newEvent = RandomizeCharacterEvent(room); daysSinceChat = 0; if (newEvent != null) { asm.LoadSceneMerged("Event_CharacterFocused"); yield return(new WaitUntil(() => SceneManager.GetSceneByName("Event_CharacterFocused").isLoaded)); CreateEvent(newEvent); } }
private bool HasPossibleCharacterEvent(RoomStats.RoomType room) { for (int i = 0; i < campMan.GetCharacterEvents().Count; i++) { GameObject charEvent = campMan.GetCharacterEvents()[i]; CharacterEvent eventDriver = charEvent.GetComponent <CharacterEvent>(); if (eventDriver.MatchesRoomType(room) && /*&& !eventDriver.playedOnce*/ HasRequiredStats(eventDriver.requiredStats, true)) { return(true); //end function as soon as one is found } } return(false); }
public bool CanChat(RoomStats.RoomType myRoom) { //If chat has cooleddown if (daysSinceChat < chatCooldown) { print("Only " + daysSinceChat + " days since last chat"); return(false); } //if no possible events are found if (!HasPossibleCharacterEvent(myRoom)) { print("No character events available"); return(false); } return(true); }
private GameObject RandomizeCharacterEvent(RoomStats.RoomType roomName) { List <GameObject> eligibleEvents = new List <GameObject>(); for (int i = 0; i < campMan.GetCharacterEvents().Count; i++) { CharacterEvent charEvent = campMan.GetCharacterEvents()[i].GetComponent <CharacterEvent>(); if (charEvent.MatchesRoomType(roomName) && /*&& charEvent.playedOnce == false*/ HasRequiredStats(charEvent.requiredStats, true)) { eligibleEvents.Add(campMan.GetCharacterEvents()[i]); } } int randNum = Random.Range(0, eligibleEvents.Count); GameObject thisEvent = eligibleEvents[randNum]; campMan.playedEvents.Add(thisEvent); campMan.charEvents.Remove(thisEvent); //campMan.RemoveFromCharEvents(thisEvent); return(thisEvent); }