Пример #1
0
    public void Setup(string id, State zState = State.New, int zSeverity = 1)
    {
        if (_incidentManager == null)
        {
            _incidentManager = GameObject.Find("TurnManager").GetComponent <IncidentManager>();
        }
        //set up the case to show the relevant info
        caseNumber     = id;
        m_state        = zState;
        severityNumber = zSeverity;

        CaseImage.color = m_state == State.New
            ? _incidentManager.GetSeverityColor(0)
            : _incidentManager.GetSeverityColor(severityNumber);

        highlightObject.SetActive(false);
    }
    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;
    }