Ejemplo n.º 1
0
        public MUIButton(MultiplayerHUD owner, Vector2 pos, string labelString)
        {
            Debug.Log($"creating MUIBUTTON {pos}");

            this.owner = owner;

            box = new MUIBox(owner, pos, new Vector2(110f, 30f));

            label = new MUILabel(owner, labelString, Color.white, pos + new Vector2(0, -MUIBox.lineHeight - 5f));

            size     = box.drawSize;
            this.pos = pos - new Vector2(box.drawSize.x, 0);
        }
Ejemplo n.º 2
0
        // private Vector2 size;

        public MUIPlayerList(MultiplayerHUD owner, Vector2 pos)
        {
            Debug.Log("Added MUIPlayer list");

            float longestSteamNameX = 0;
            float yPos = -MUIBox.lineHeight + 5f;

            foreach (ulong s in MonklandSteamManager.connectedPlayers)
            {
                yPos -= MUIBox.lineHeight;
                string steamName = SteamFriends.GetFriendPersonaName((CSteamID)s);

                Color bodyColor = Color.white;
                try
                {
                    bodyColor = MonklandSteamManager.GameManager.playerColors[MonklandSteamManager.connectedPlayers.IndexOf(s)];
                }
                catch (Exception e)
                {
                    Debug.Log($"Error while trying to get color: {e.Message}");
                }
                MUILabel newLabel = new MUILabel(owner, steamName, bodyColor, pos + new Vector2(0, yPos));
                playerLabels.Add(s, newLabel);
                if (newLabel.label.textRect.xMax >= longestSteamNameX)
                {
                    longestSteamNameX = newLabel.label.textRect.xMax;
                }
            }

            box = new MUIBox(owner, pos, (int)longestSteamNameX, playerLabels.Count);

            foreach (KeyValuePair <ulong, MUILabel> kvp in playerLabels)
            {
                MUILabel item = kvp.Value;
                item.pos.y += 15f;
                //item.color = MonklandSteamManager.GameManager.readiedPlayers.Contains(kvp.Key) ? Color.green : Color.red;

                //i++;
            }
        }