示例#1
0
    private void RefreshPlayers()
    {
        allSuccess = true;

        for (int i = 0; i < playerInfoSlots.Length; i++)
        {
            PlayerLobbyGUI plg = playerInfoSlots[i].GetComponent <PlayerLobbyGUI>();
            plg.usernameLabel.text = "";
            plg.rankLabel.text     = "";
            plg.transform.parent   = transform;
        }

        if (Topan.Network.isConnected)
        {
            for (int p = 0; p < Topan.Network.connectedPlayers.Length; p++)
            {
                Topan.NetworkPlayer player = Topan.Network.connectedPlayers[p];
                byte team = (byte)player.GetPlayerData("team", (byte)0);
                AddPlayerToList(team, player, null);
            }

            if (GeneralVariables.gameModeHasTeams)
            {
                BotPlayer[] redBots = NetworkingGeneral.GetBotParticipants(0);
                for (int i = 0; i < redBots.Length; i++)
                {
                    AddPlayerToList(0, null, redBots[i]);
                }

                BotPlayer[] blueBots = NetworkingGeneral.GetBotParticipants(1);
                for (int i = 0; i < blueBots.Length; i++)
                {
                    AddPlayerToList(0, null, blueBots[i]);
                }
            }
            else if (BotManager.allBotPlayers != null)
            {
                for (int i = 0; i < BotManager.allBotPlayers.Length && i < GeneralVariables.Networking.botCount; i++)
                {
                    AddPlayerToList(2, null, BotManager.allBotPlayers[i]);
                }
            }
        }

        for (int i = 0; i < playerInfoSlots.Length; i++)
        {
            PlayerLobbyGUI plg = playerInfoSlots[i].GetComponent <PlayerLobbyGUI>();
            if (plg.usernameLabel.text == "")
            {
                plg.rankIcon.enabled = false;
            }
        }
    }
示例#2
0
    private void PopulatePlayerSlots()
    {
        playerInfoSlots = new GameObject[16];

        for (int i = 0; i < playerInfoSlots.Length; i++)
        {
            playerInfoSlots[i] = (GameObject)Instantiate(playerInfoPrefab);
            playerInfoSlots[i].transform.parent = transform;

            PlayerLobbyGUI plg = playerInfoSlots[i].GetComponent <PlayerLobbyGUI>();
            plg.rankIcon.enabled   = false;
            plg.usernameLabel.text = "";
            plg.rankLabel.text     = "";
        }
    }
示例#3
0
    private void AddPlayerToList(int team, Topan.NetworkPlayer player, BotPlayer bot = null)
    {
        int realTeamNum = team;

        if (player != null && !player.HasPlayerData("team"))
        {
            allSuccess = false;
            return;
        }

        bool thisIsBot = (player == null && bot != null);

        if (thisIsBot && team < 2)
        {
            realTeamNum = (int)bot.team;
        }

        GameObject info = GetAvailableSlot();

        if (info == null)
        {
            return;
        }

        bool showInfo = true;
        int  index    = 0;

        if (!GeneralVariables.gameModeHasTeams)
        {
            index = unassignedIndex;

            if (realTeamNum == 2)
            {
                if (index < 8)
                {
                    info.transform.parent = redPanel;
                }
                else
                {
                    info.transform.parent = bluePanel;
                }
            }
            else
            {
                showInfo = false;
            }

            info.transform.localPosition = new Vector3(0f, -(index % 8) * spacing, 0f);
        }
        else
        {
            if (realTeamNum == 0 && redIndex < 8)
            {
                index = redIndex;
                info.transform.parent = redPanel;
            }
            else if (realTeamNum == 1 && blueIndex < 8)
            {
                index = blueIndex;
                info.transform.parent = bluePanel;
            }
            else
            {
                showInfo = false;
            }

            info.transform.localPosition = new Vector3(0f, -index * spacing, 0f);
        }

        info.SetActive(showInfo);
        info.transform.localRotation = Quaternion.identity;
        info.transform.localScale    = Vector3.one;

        PlayerLobbyGUI plg = info.GetComponent <PlayerLobbyGUI>();

        CombatantInfo pInfo = null;

        if (thisIsBot)
        {
            pInfo = bot.botInfo;
        }
        else
        {
            pInfo = (CombatantInfo)player.GetInitialData("dat");
        }

        plg.rankIcon.enabled   = true;
        plg.usernameLabel.text = ((pInfo.clan != "") ? (((thisIsBot) ? (DarkRef.ClanColor(true) + "(" + pInfo.clan + ")") : (DarkRef.ClanColor(false) + "[" + pInfo.clan + "]")) + "[-] ") : "") + pInfo.username;
        plg.rankLabel.text     = pInfo.rank.ToString();

        index++;
        if (!GeneralVariables.gameModeHasTeams)
        {
            if (realTeamNum == 2)
            {
                unassignedIndex = index;
            }
        }
        else
        {
            if (realTeamNum == 0)
            {
                redIndex = index;
            }
            else if (realTeamNum == 1)
            {
                blueIndex = index;
            }
        }
    }