Esempio n. 1
0
    public virtual void AddBots()
    {
        if (!HasOptionBotCount)
        {
            return;
        }
        int addAmount = BotCount;
        // Adjust bot count
        int maxPlayers = PhotonNetwork.CurrentRoom.MaxPlayers;

        if (networkManager.isConnectOffline)
        {
            maxPlayers = networkManager.maxConnections;
        }
        if (PhotonNetwork.CurrentRoom.PlayerCount + addAmount > maxPlayers)
        {
            addAmount = maxPlayers - PhotonNetwork.CurrentRoom.PlayerCount;
        }
        for (var i = 0; i < addAmount; ++i)
        {
            var character = NewBot();
            if (IsTeamGameplay)
            {
                int countA;
                int countB;
                networkManager.CountTeamPlayers(out countA, out countB);
                character.playerTeam = (byte)(countA > countB ? 2 : 1);
            }
            networkManager.RegisterCharacter(character);
        }
    }
Esempio n. 2
0
    public virtual void AddBots()
    {
        if (!HasOptionBotCount)
        {
            return;
        }
        int addAmount = BotCount;

        Bots.Clear();
        // Adjust bot count
        int maxPlayers = PhotonNetwork.room.MaxPlayers;

        if (networkManager.isConnectOffline)
        {
            maxPlayers = networkManager.maxConnections;
        }
        if (PhotonNetwork.room.PlayerCount + addAmount > maxPlayers)
        {
            addAmount = maxPlayers - PhotonNetwork.room.PlayerCount;
        }
        for (var i = 0; i < addAmount; ++i)
        {
            var character = NewBot();
            if (IsTeamGameplay)
            {
                character.playerTeam = tempTeam = (tempTeam == PunTeams.Team.red ? PunTeams.Team.blue : PunTeams.Team.red);
            }
            networkManager.RegisterCharacter(character);
            Bots.Add(character);
        }
    }
    public virtual void AddBots()
    {
        if (!HasOptionBotCount)
        {
            return;
        }

        for (var i = 0; i < botCount; ++i)
        {
            var character = NewBot();
            if (character == null)
            {
                continue;
            }
            NetworkServer.Spawn(character.gameObject);
            networkManager.RegisterCharacter(character);
        }
    }