Ejemplo n.º 1
0
        public Player(int id)
        {
            Id = id;
            PlayersManager.AddPlayer(Id, this);

            foodCount = 0;
            foodMax   = 0;
        }
Ejemplo n.º 2
0
    //Adicionar os players na Scene AddPlayers e na lista do PlayersManager
    public void AddPlayer()
    {
        if (playersManager.PlayersCount < 10)
        {
            if (!string.IsNullOrWhiteSpace(nameInput.text))
            {
                if (color != null)
                {
                    //Adiciona os players na lista do Script gerenciador
                    playersManager.AddPlayer(nameInput.text, color, true);
                    //Cria um objeto na Scene de AddPlayers, muda sua posição, sua imagem e seu texto
                    GameObject player = Instantiate(playerPrefab, playerListTransform);
                    player.GetComponentInChildren <Text>().text = nameInput.text;
                    if (playersManager.PlayersCount != 0)
                    {
                        player.transform.localPosition = new Vector3(playersManager.PlayerList[playersManager.PlayersCount - 1].x, playersManager.PlayerList[playersManager.PlayersCount - 1].y - 200);
                    }
                    //Muda a imagem do player e desativa seu botão para outro player nao escolher
                    foreach (IconColorButton button in colorButton)
                    {
                        if (button.colorName.Equals(color))
                        {
                            player.GetComponentInChildren <Image>().sprite = button.image;
                            button.iconButton.gameObject.SetActive(false);
                            break;
                        }
                    }
                    //Seta o x e y do player dentro de sua lista, para ser referenciado durante a Scene AddPlayers
                    playersManager.SetXY(player.transform.localPosition.x, player.transform.localPosition.y);


                    playersManager.IncrementCounter();
                    nameInput.text = "";
                    color          = null;
                    chooseColorButton.image.sprite = huePlayerIcon;
                    if (playersManager.PlayersCount > 5)
                    {
                        movableComponents.sizeDelta = new Vector2(1080, 1920 + ((playersManager.PlayersCount - 5) * 200));
                    }
                }
                else
                {
                    //Colocar um aviso pra escolher uma cor pro player
                    Debug.Log("escolha uma cor");
                }
            }
            else
            {
                //Colocar um aviso pra escrever um nome pro player
                Debug.Log("escreva um nome");
            }
        }
        else
        {
            //Colocar um aviso de que o número máximo de Players é de 10
            Debug.Log("full bitch");
        }
    }
Ejemplo n.º 3
0
    public void TestPlayersManagerAddPlayer()
    {
        PlayersManager.ClearPlayers();
        Player player = new Player();

        PlayersManager.AddPlayer(player);
        System.Collections.ObjectModel.ReadOnlyCollection <Player> players = PlayersManager.GetPlayers();
        Assert.AreEqual(1, players.Count);
        Assert.AreEqual(player, players[0]);
    }
Ejemplo n.º 4
0
        public Player()
        {
            Id = last;
            last++;

            PlayersManager.AddPlayer(Id, this);

            foodCount = 0;
            foodMax   = 0;
        }
Ejemplo n.º 5
0
 public void InitTeam()
 {
     PlayersManager.ActivePlayers.Clear();
     for (int i = 0; i < this.data.Length; i++)
     {
         if (this.data[i].Enqueue)
         {
             PlayersManager.AddPlayer(this.data[i].mCharacterID, true);
         }
     }
     PlayersManager.SetPlayer(0, true);
     //PlayersManager.SetPlayerPosByDestObj("SceneEnter");
     PlayerCtrlManager.Reset();
 }
Ejemplo n.º 6
0
    public void TestPlayersManagerRemovePlayer()
    {
        PlayersManager.ClearPlayers();
        Player player1 = new Player();
        Player player2 = new Player();
        Player player3 = new Player();

        PlayersManager.AddPlayer(player1);
        PlayersManager.AddPlayer(player2);
        PlayersManager.AddPlayer(player3);
        PlayersManager.RemovePlayer(player2);
        System.Collections.ObjectModel.ReadOnlyCollection <Player> players = PlayersManager.GetPlayers();
        Assert.AreEqual(2, players.Count);
        Assert.AreEqual(player1, players[0]);
        Assert.AreEqual(player3, players[1]);
    }
Ejemplo n.º 7
0
    public static GameObject AddPlayer(int ID, bool bSetLevel = true)
    {
        GameObject player = PlayersManager.GetPlayer(ID);

        if (player != null)
        {
            Debug.Log("PlayersManager.AddPlayer 已经存在" + ID.ToString());
            return(player);
        }

        GameObject gameObject = PlayersManager.FindMainChar(ID, true);

        if (gameObject != null && gameObject.GetComponent <PalNPC>() != null)
        {
            PlayersManager.AddPlayer(gameObject, bSetLevel);
            if (PlayersManager.ActivePlayers.Count == 1)
            {
                PlayersManager.SetPlayer(ID, false);
            }
            if (ID != 6 && PlayersManager.OnAddPlayer != null)
            {
                PlayersManager.OnAddPlayer(ID);
            }
            return(gameObject);
        }

        GameObject gameObject2 = PlayersManager.LoadPlayer(ID);

        if (gameObject2 != null)
        {
            if (PlayersManager.AllPlayers.Count > ID + 1 && PlayersManager.AllPlayers[ID] == null)
            {
                PlayersManager.AllPlayers[ID] = gameObject2;
            }
            PlayersManager.AddPlayer(gameObject2, bSetLevel);
            if (ID == 4)
            {
                PlayersManager.AddPlayer(6, true);
            }
        }
        if (ID != 6 && PlayersManager.OnAddPlayer != null)
        {
            PlayersManager.OnAddPlayer(ID);
        }
        return(gameObject2);
    }
Ejemplo n.º 8
0
        public void AddPlayerToLobby(int playerId, string playerName, PlayerColor playerColor, Vector2 playerPosition, bool isPlayerHost)
        {
            bool isControlledPlayerConnecting = playerId == connectionToServer.myPlayerId;

            GameObject   chosenPlayerPrefab = isControlledPlayerConnecting ? clientControllablePlayerPrefab : playerPrefab;
            ClientPlayer clientPlayer       = Instantiate(chosenPlayerPrefab, playerPosition, Quaternion.identity).GetComponent <ClientPlayer>();

            clientPlayer.name = isControlledPlayerConnecting ? $"Player{playerId} (ClientControllable)" : $"Player{playerId}";
            clientPlayer.Initialize(playerId, playerName, playerColor, isPlayerHost);
            clientPlayer.transform.parent        = lobby.playersContainer.transform;
            clientPlayer.animator.isLookingRight = playerId < 5;

            playersManager.AddPlayer(playerId, clientPlayer);

            if (isControlledPlayerConnecting)
            {
                InitializeControlledPlayer(playersManager.players[playerId].GetComponent <ClientControllablePlayer>());
            }
        }