Ejemplo n.º 1
0
 public ChatMessage(CNMPlayer emisor, string text)
 {
     this.emisor = emisor;
     this.text   = text;
     this.time   = DateTime.Now;
     this.color  = emisor.GetColor();
 }
Ejemplo n.º 2
0
        public void OnRoleChanged(DualGamePlayer player, int oldRole)
        {
            int newRole = player.role;

            if (oldRole == newRole)
            {
                //Debug.LogWarning("It didn't change!");
                return;
            }

            if (oldRole < maxPlayers)
            {
                bool alreadyReplaced = false;

                for (int i = 0; i < playerContainer.childCount; i++)
                {
                    CNMPlayer p = playerContainer.GetChild(i).GetComponent <CNMPlayer>();

                    //Debug.Log("Checking one...");
                    if (p != null)
                    {
                        if (p.role == oldRole)
                        {
                            //Debug.Log("Already replaced");

                            alreadyReplaced = true;
                            break;
                        }

                        /*else if(p.role > oldRole)
                         * {
                         *  Debug.Log("Breaking here");
                         *  break;
                         * }*/
                    }
                }

                if (!alreadyReplaced)
                {
                    ShowWildcard(oldRole);
                }
            }

            int oldCount = playerContainer.childCount;

            player.transform.SetParent(null, false);
            int newCount = playerContainer.childCount;

            if (newCount != oldCount - 1)
            {
                Debug.LogError("Wrong 1");
            }

            AddPlayerToList(player);

            RedrawMoveButtons();
        }
Ejemplo n.º 3
0
        public override void OnStartClient()
        {
            CNManager manager = CNManager.Instance;
            //CNMPlayer player = (CNMPlayer)manager.GetPlayer(playerId);
            CNMPlayer player = ClientScene.objects[playerNetId].GetComponent <CNMPlayer>();
            Color     color  = manager.colors[player.playerColorNum];

            SetColor(color);
        }
Ejemplo n.º 4
0
        private CNMPlayer NewPlayer(PlayerData model)
        {
            CNMPlayer ret = NewPlayer();

            ret.playerName     = model.playerName;
            ret.playerType     = model.playerType;
            ret.playerColorNum = model.playerColorNumber;

            return(ret);
        }
Ejemplo n.º 5
0
        public void DisplayPlayer(CNMPlayer player)
        {
            this.lastDisplayedPlayer = player;

            string name  = "(waiting)";
            Sprite icon  = CNManager.Instance.nullIcon;
            Color  color = Color.black;

            bool isLocal = false;

            if (player != null)
            {
                isLocal = player.isLocalPlayer;
                name    = player.playerName;
                color   = player.GetColor();

                if (isLocal)
                {
                    switch (player.playerType)
                    {
                    case PlayerType.KeyboardPlayer:
                        icon = CNManager.Instance.keyboardIcon;
                        break;

                    case PlayerType.JoystickPlayer:
                        icon = CNManager.Instance.joystickIcon;
                        break;

                    case PlayerType.CpuPlayer:
                        icon = CNManager.Instance.cpuIcon;
                        break;
                    }

                    nameInput.interactable = true;
                }
                else
                {
                    icon = CNManager.Instance.remoteIcon;
                }
            }

            nameInput.interactable = isLocal;
            nameInput.text         = name;
            iconImage.sprite       = icon;
            coloredImage.color     = color;
        }
Ejemplo n.º 6
0
        private void RedrawMoveButtons()
        {
            int lastRole = -1;

            int offset = 0; // could be used for dummy objects

            for (int i = offset; i < playerContainer.childCount; i++)
            {
                Transform child = playerContainer.GetChild(i);

                CNMPlayer player = child.GetComponent <CNMPlayer>();

                if (player != null)
                {
                    // Debug.Log("++++++++++++++ Is a player");
                    int thisRole = player.role;

                    if (thisRole <= lastRole)
                    {
                        // Debug.LogError("Invalid role order");
                        return;
                    }

                    lastRole = thisRole;

                    if (NetworkServer.active)
                    {
                        bool isFirst = i == offset;
                        player.moveUp.gameObject.SetActive(!isFirst);

                        bool showDown = thisRole < maxPlayers || i < playerContainer.childCount - 1;
                        //player.moveDown.interactable = !isLast;
                        player.moveDown.gameObject.SetActive(showDown);
                    }

                    // TODO
                }
                else
                {
                    //Debug.Log("-------------- Is a wildcard");
                }
            }
        }