示例#1
0
    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);
    }