コード例 #1
0
    // called by the lobby button master when we create a team
    public bool TeamRemoveEntry()
    {
        lobbySlotMaster  = FindObjectOfType <LobbySlotMaster>();
        gamestateTracker = FindObjectOfType <GamestateTracker>();

        TeamEntry teamEntry = gamestateTracker.teams.Get((short)teamId);


        bool canRemove = true;
        // look for the corresponding players in the team

        // get driver player (if they exist)
        short driverId = teamEntry.driverId;

        if (driverId != 0)
        {
            PlayerEntry driverEntry = gamestateTracker.players.Get((short)driverId);

            // if they are bots, then kick them
            if (driverEntry.isBot)
            {
                driverEntry.Delete();
            }
            // unready and unselect them
            else
            {
                canRemove = false;
                driverEntry.Release();
            }
        }



        // get gunner player (if they exist)
        short gunnerId = teamEntry.gunnerId;

        if (gunnerId != 0)
        {
            PlayerEntry gunnerEntry = gamestateTracker.players.Get((short)gunnerId);


            if (gunnerEntry.isBot)
            {
                gunnerEntry.Delete();
            }
            // unready and unselect them
            else
            {
                canRemove = false;
                gunnerEntry.Release();
            }
        }



        if (canRemove)
        {
            Debug.Log("Deleting team entry");
            teamEntry.Delete();
        }
        else
        {
            teamEntry.Release();
        }

        return(canRemove);
    }