Esempio n. 1
0
        /// <summary>
        /// Add the new player
        /// </summary>
        private void AddPlayer(string playerName = "Игрок {0}")
        {
            if (playersCount == MAX_PLAYERS_COUNT - 1)
            {
                AddPlayerBtn.Visibility = Visibility.Collapsed;
            }

            if (playersCount == 0)
            {
                Players.Add(new Player(string.Format(playerName, playersCount + 1), Color.FromRgb(79, 185, 159), playersCount, pointBarsContainerWidth / maxPoint));
            }
            else if (playersCount == 1)
            {
                Players.Add(new Player(string.Format(playerName, playersCount + 1), Color.FromRgb(242, 177, 52), playersCount, pointBarsContainerWidth / maxPoint));
            }
            else if (playersCount == 2)
            {
                Players.Add(new Player(string.Format(playerName, playersCount + 1), Color.FromRgb(237, 85, 89), playersCount, pointBarsContainerWidth / maxPoint));
            }

            if (playersCount < defaultColors.Count)
            {
            }
            else
            {
                Players.Add(new Player(string.Format(playerName, playersCount + 1), Color.FromRgb(48, 59, 63), playersCount, pointBarsContainerWidth / maxPoint));
            }

            if (!isRegistrationActive && isModuleConnect)
            {
                isRegistrationActive = true;
                Players.Last().ChangeStatus(PlayerStatus.Registrating);
                registrationManager.RegisterNext();
            }

            playersCount++;

            PlayerBarHeight  = playersNameContainerHeight / playersCount;
            PlayerNameMargin = new Thickness(0);
            if (PlayerBarHeight > 140)
            {
                PlayerBarHeight = 140;

                double margins = (playersNameContainerHeight - playersCount * PlayerBarHeight) / ((playersCount - 1) * 2 + 2);
                PlayerNameMargin = new Thickness(0, margins, 0, margins);
            }
        }