Beispiel #1
0
    public void SetStatuses(List <Status> statuses)
    {
        // Loop through all statuses
        List <Status> displayedStatuses = new List <Status>();

        int swarmResistCount = 0;

        foreach (Status s in statuses)
        {
            // Only display a relevant number of SwarmResist icons
            if (s.statusType == StatusType.SwarmResist)
            {
                swarmResistCount++;

                if (swarmResistCount > gameRules.STATswarmResistMaxStacks)
                {
                    continue;
                }
            }

            if (StatusUtils.ShouldDisplay(s.statusType))
            {
                displayedStatuses.Add(s);
            }
        }

        // For each status icon, enable or disable, apply colors, and set inner icon
        for (int i = 0; i < statusBkgs.Length; i++)
        {
            if (i < displayedStatuses.Count)
            {
                statusBkgs[i].gameObject.SetActive(true);

                StatusType type   = displayedStatuses[i].statusType;
                Color[]    colors = StatusUtils.GetDisplayColors(type);
                statusBkgs[i].color = colors[0];

                // TODO:
                //string timeLeft = StatusUtils.ShouldCountDownDuration(type) ? string.Format(" ({0:0.0}s)", displayedStatuses[i].GetTimeLeft()) : "";
                statusBkgs[i].GetComponent <UI_TooltipSource>().SetText(StatusUtils.GetDisplayName(type) + "\n" + StatusUtils.GetDisplayDesc(type));

                Image icon = statusBkgs[i].GetComponentsInChildren <Image>()[1];
                icon.color  = colors[1];
                icon.sprite = StatusUtils.GetDisplayIcon(type);
            }
            else
            {
                statusBkgs[i].gameObject.SetActive(false);
            }
        }
    }