private void CreateElement(IncidentHistoryElement element, float offset, bool isCurrent = true) { var go = Instantiate(IncidentHistoryElement); var setup = go.GetComponent <IncidentHistoryUISetup>(); var rectTransform = go.GetComponent <RectTransform>(); go.transform.SetParent(this.transform); rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; rectTransform.localScale = Vector3.one; var sprite = setup.Icon.sprite; if (!isCurrent) { setup.Icon.gameObject.SetActive(true); switch (element.PlayerDecision) { case global::IncidentHistoryElement.Decision.Ignore: sprite = WaitSprite; break; case global::IncidentHistoryElement.Decision.Citizen: sprite = CitizenSprite; break; case global::IncidentHistoryElement.Decision.Officer: sprite = OfficerSprite; break; } } else { setup.Icon.gameObject.SetActive(false); setup.DropDownImage.localRotation = Quaternion.Euler(0f, 0f, 270f); } if (_incidentManager == null) { _incidentManager = GameObject.Find("TurnManager").GetComponent <IncidentManager>(); } setup.Setup(element.Type, element.Description, sprite, _totalElements, _incidentManager.GetSeverityColor(element.Severity)); setup.Header.anchoredPosition3D = new Vector3(0f, offset, 0f); _setupObjects.Add(setup); _offset -= setup.Header.rect.height; }
private void UpdateHistory(Incident incident, IncidentHistoryElement element) { var incidentHistory = new IncidentHistory(); if (_incidentHistories.ContainsKey(incident.Scenario.Id)) { _incidentHistories.TryGetValue(incident.Scenario.Id, out incidentHistory); } if (incidentHistory != null) { incidentHistory.IncidentHistoryElements.Add(element); _incidentHistories[incident.Scenario.Id] = incidentHistory; } }
public void Show(List <IncidentHistoryElement> elements, IncidentHistoryElement currentElement, int severity) { ClearChildren(); _totalElements = 0; _offset = 0f; foreach (var incidentHistory in elements) { CreateElement(incidentHistory, _offset, false); _totalElements++; } CreateElement(currentElement, _offset); _totalElements++; _shownElement = _totalElements - 1; }
private void AddIncidentHistory(Incident incident, IncidentHistoryElement.Decision decision) { var type = incident.IncidentContent.Title; var feedbackRating = 1; var feedback = ""; var historyElement = new IncidentHistoryElement { Type = type, Description = incident.IncidentContent.Description + "\n\n" + "<color=yellow>" + m_dialogBox.GetTip() + "</color>", Feedback = feedback, FeedbackRating = feedbackRating, Severity = incident.IncidentContent.Severity, PlayerDecision = decision }; UpdateHistory(incident, historyElement); }
public void AddHistoryElement(IncidentHistoryElement incidentHistoryElement) { IncidentHistoryElements.Add(incidentHistoryElement); }
public IEnumerator ShowIncident(Incident zIncident) { //check if this is a resolution, ie. no buttons will lead anywhere var endCase = zIncident.IsEndCase(); var history = _incidentManager.GetIncidentHistory(zIncident.Scenario.Id); var currentInformation = new IncidentHistoryElement() { Type = zIncident.IncidentContent.Title, Description = zIncident.IncidentContent.Description, Feedback = "", FeedbackRating = 0, Severity = zIncident.IncidentContent.Severity, PlayerDecision = IncidentHistoryElement.Decision.Ignore }; IncidentInformationDisplay.Show(history, currentInformation, currentInformation.Severity); _caseNum = zIncident.Scenario.Id; OfficerButtonTurns.text = "x" + (zIncident.IncidentContent.TurnReq > 0 ? zIncident.IncidentContent.TurnReq.ToString() : "0"); OfficerButtonRequired.text = "x" + (zIncident.IncidentContent.OfficerReq > 0 ? zIncident.IncidentContent.OfficerReq.ToString() : "0"); RightButton.text = zIncident.IncidentContent.OfficerReq == 1 ? Localization.Get("BASIC_TEXT_SEND_ONE") : RightButton.text = Localization.Get("BASIC_TEXT_SEND_MANY"); //wait for anim to finish yield return(EmailAnim(-1f, "EmailShow")); if (endCase) { // populate the button with feedback elements float satisfaction = zIncident.IncidentContent.SatisfactionImpact; var ratingPanel = _caseClosedButton.transform.Find("RatingPanel").transform; DestroyChildren(ratingPanel); _ratingTransforms = new List <Transform>(); // satisfaction ranges from +3 to -3 var spriteToUse = satisfaction > 0 ? PlusSprite : MinusSprite; var increment = satisfaction > 0 ? 1 : -1; for (int i = 0; i != satisfaction; i += increment) { var go = new GameObject(); go.transform.SetParent(ratingPanel.transform); var img = go.AddComponent <Image>(); img.sprite = spriteToUse; img.preserveAspect = true; _ratingTransforms.Add(go.transform); go.GetComponent <RectTransform>().localScale = Vector3.one; var ratingPanelHeight = ratingPanel.GetComponent <RectTransform>().rect.height; ratingPanel.GetComponent <GridLayoutGroup>().cellSize = new Vector2(ratingPanelHeight, ratingPanelHeight); } if (satisfaction > 0) { satisfaction *= 0.4f; } _incidentManager.ShowSatisfactionImpact(satisfaction, true); } //yield return new WaitForSeconds(0.25f); //now set which buttons should be active if (endCase) { DisableButtons(); } else { SetButtonActive(_waitButton, zIncident.GetChoiceContent("Ignore") != null); SetButtonActive(_sendOfficerButton, zIncident.GetChoiceContent("Officer") != null); SetButtonActive(_citizenHelpButton, zIncident.GetChoiceContent("Citizen") != null); } //_waitButton.SetActive(zIncident.GetChoiceContent("Ignore") != null); //_sendOfficerButton.SetActive(zIncident.GetChoiceContent("Officer") != null); //_citizenHelpButton.SetActive(zIncident.GetChoiceContent("Citizen") != null); _caseClosedButton.SetActive(endCase); }