/// <summary> /// Displays the outcome of the case. /// </summary> /// <param name="hasWon"></param> public void DisplayOutcome(bool hasWon, bool load) { _load = load; if (TutorialManager.Instance._doTutorial && TutorialManager.Instance.currentState == TutorialManager.TutorialState.SolveCaseTwo) { if (hasWon) { TutorialManager.Instance.ScoreTutorial(true); } else { TutorialManager.Instance.ScoreTutorial(false); return; } } if (hasWon) { winLossPopUps[0].SetActive(true); winLossPopUps[1].SetActive(false); } else { winLossPopUps[1].SetActive(true); winLossPopUps[0].SetActive(false); } MissionManager misMan = FindObjectOfType <MissionManager>(); misMan.FindAndAddMission(); EmailInbox inBox = FindObjectOfType <EmailInbox>(); foreach (var email in inBox.GetEmails()) { if (email.caseNumber == caseNumber) { email.currentStatus = EmailListing.CaseStatus.Conclusion; email.SetVisuals(); break; } } for (var index = 0; index < BrowserManager.Instance.tabList.Count; index++) // this is a for loop because we consecutively delete from the list, foreach loops do NOT like that { var tab = BrowserManager.Instance.tabList[index]; if (tab.caseNumber == caseNumber) { BrowserManager.Instance.CloseTab(tab); } } _solvedOutcome = hasWon; _solved = true; }
/** Sets up the missionManager after boot */ private IEnumerator WaitForBoot() { yield return(new WaitForEndOfFrame()); GameObject monitorObject = GameObject.FindWithTag("VSCMonitor"); _hoverMonitor = monitorObject.GetComponent <HoverOverObject>(); _virtualScreenSpaceCanvaser = monitorObject.GetComponent <VirtualScreenSpaceCanvaser>(); _missionCases = FindObjectOfType <SaveManager>().GetComponent <SaveManager>().mailDictList; _emailInbox = FindObjectOfType <EmailInbox>(); Debug.Log("While loading inbox has " + -_emailInbox.GetEmails().Count); _createdMissions = new List <EmailListing>(); _virtualScreenSpaceCanvaser.ToggleCanvas(); _virtualScreenSpaceCanvaser.ToggleCanvas(); }
/// <summary> /// Adds a new mission based on the player's level /// </summary> public void FindAndAddMission() { _virtualScreenSpaceCanvaser.ToggleCanvas(); //get currentlistofMissions List <EmailListing> listings = _emailInbox.GetEmails(); // check how many of each level there are ( dictionary<diff, amount>) Dictionary <int, int> currentAmountBasedOnDifficulty = this.GetAmountOfMissionsPerDifficulty(listings); bool lowerDisabled = false; int lower = 0; if (Mathf.RoundToInt(playerLevel) == 1) { //disables lower when the player level is 1 because there are no difficulty 0 missions lowerDisabled = true; } else { lower = Mathf.RoundToInt(playerLevel - 1); } // current level int currentLevel = Mathf.RoundToInt(playerLevel); // 1 level higher than current level int higher = Mathf.RoundToInt(playerLevel + 1); // amount of missions in emailbox with difficulty playerlevel -1 int amountDown = 0; // amount of missions in emailbox with difficulty playerlevel int amountAt = 0; // amount of missions in emailbox with difficulty playerlevel + 1 int amountUp = 0; if (_emailInbox.GetEmails().Count >= maxAmountOfCasesOnDisplay) { Debug.Log("Max amount of missions in box reached"); } else { // goes through each difficulty key and set the value of the amount of difficulty missions in the email boxing foreach (var dif in currentAmountBasedOnDifficulty) { if (!lowerDisabled && dif.Key == lower) { amountDown = dif.Value; } else if (dif.Key == currentLevel) { amountAt = dif.Value; } else if (dif.Key == higher) { amountUp = dif.Value; } else { Debug.Log(" no same key found"); } } //add mission with diff lower if (!lowerDisabled && amountDown < 1) { AddMissionBasedOnDifficulty(lower); } // add mission with diff same as playerlevel; else if (amountAt < 2) { AddMissionBasedOnDifficulty(currentLevel); } // add mission based on diff 1 up; else if (amountUp < 1) { AddMissionBasedOnDifficulty(higher); } //When there is no available difficulty to add. Get the first available mission and add it. else { Debug.Log("Getting`leftover "); AddNextInLineMission(); } } _virtualScreenSpaceCanvaser.ToggleCanvas(); }