Beispiel #1
0
    public static void UpdateTokensIndicator(Ship.GenericShip thisShip, System.Type type)
    {
        List <GameObject> keys = new List <GameObject>();

        foreach (Transform icon in thisShip.InfoPanel.transform.Find("ShipInfo/TokensBar").transform)
        {
            keys.Add(icon.gameObject);
        }
        foreach (GameObject icon in keys)
        {
            icon.gameObject.SetActive(false);
            MonoBehaviour.Destroy(icon);
        }

        float offset = 0;
        float row    = 0;

        foreach (var token in thisShip.GetAssignedTokens())
        {
            for (int i = 0; i < token.Count; i++)
            {
                GameObject tokenPanel = MonoBehaviour.Instantiate(Game.PrefabsList.PanelToken, thisShip.InfoPanel.transform.Find("ShipInfo").Find("TokensBar"));
                tokenPanel.GetComponent <RectTransform>().localPosition = Vector3.zero;
                tokenPanel.name = token.Name;
                Tooltips.AddTooltip(tokenPanel, token.Tooltip);
                tokenPanel.transform.Find(token.Name).gameObject.SetActive(true);

                if (token.GetType().BaseType == typeof(Tokens.GenericTargetLockToken))
                {
                    tokenPanel.transform.Find(token.Name).Find("Letter").GetComponent <Text>().text = (token as Tokens.GenericTargetLockToken).Letter.ToString();
                }

                tokenPanel.SetActive(true);
                tokenPanel.GetComponent <RectTransform>().localPosition = new Vector3(offset, tokenPanel.GetComponent <RectTransform>().localPosition.y + 35 * row, tokenPanel.GetComponent <RectTransform>().localPosition.z);
                if (i > (row * 5) + 3)
                {
                    row++;
                    offset = 0;
                }
                else
                {
                    offset += 32 + 3;
                }
            }
        }

        OrganizeRosters();
    }