Пример #1
0
    public void OnlineRemovePlayer(string control)
    {
        if (PlayerList.All(player => player.Control != control))
        {
            return;
        }
        Player playerToRemove = PlayerList.First(p => p.Control == control);

        if (stage == SelectStages.Chosen)
        {
            stage           = SelectStages.Browse;
            kCanHorizontal  = true;
            j1CanHorizontal = true;
            j2CanHorizontal = true;
            j3CanHorizontal = true;
            j4CanHorizontal = true;
        }

        if (playerToRemove.Set)
        {
            pickedClasses.Remove(playerToRemove.Class);
            playerToRemove.Set = false;
        }
        else
        {
            PlayerList.Remove(playerToRemove);
        }

        UpdateSelect(PlayerList);
    }
Пример #2
0
        internal bool RemovePlayer(IClient client)
        {
            if (PlayerList.All(p => p.Id != client.ID) && !Clients.Contains(client))
            {
                return(false);
            }

            PlayerList.Remove(PlayerList.Find(p => p.Id == client.ID));
            Clients.Remove(client);
            return(true);
        }
Пример #3
0
        /// <summary>
        /// Starts the game...begins by iterating over the players and picking
        /// their dominos.
        /// </summary>
        public void StartGame()
        {
            while (_playerList.All(s => s.DominosOnHand < 12))
            {
                foreach (Player player in _playerList)
                {
                    if (player.DominosOnHand < 12)
                    {
                        player.Pick();
                    }
                }
            }

            foreach (Player player in _playerList)
            {
                player.Begin();
            }
        }
        private async Task FinalAnalAsync()
        {
            _command.ManuelFinish = true;
            if (BasicData !.MultiPlayer == false)
            {
                throw new BasicBlankException("Single player cannot figure out the turns");
            }
            if (PlayerList.Any(items => items.TookTurn == false))
            {
                SingleInfo = PlayerList !.GetSelf();
                if (SingleInfo.TookTurn == false)
                {
                    throw new BasicBlankException($"I think the player {SingleInfo.NickName} should have taken your turn before going through the last step");
                }
                Check !.IsEnabled = true; //waiting for others to show they took their turns
                return;
            }
            if (PlayerList.Any(Items => Items.TimeToGetWord == 0))
            {
                throw new BasicBlankException("Must have taken longer than 0 to get a word");
            }
            if (PlayerList.All(Items => Items.TimeToGetWord == -1))
            {
                await UIPlatform.ShowMessageAsync("Nobody found any words.  Therefore; going to the next one");
                await NextOneAsync();

                return;
            }
            if (BasicData.Client == true)
            {
                Check !.IsEnabled = true;
                return; //has to wait for host.
            }
            SingleInfo = PlayerList.Where(items => items.TimeToGetWord > -1).OrderBy
                             (Items => Items.TimeToGetWord).Take(1).Single();
            WhoTurn = SingleInfo.Id;
            await Network !.SendAllAsync("whowon", WhoTurn);

            await ClientResultsAsync(WhoTurn);
        }
Пример #5
0
        private async Task OnTick()
        {
            try {
                if (Client.Menu.CurrentMenu != this)
                {
                    await BaseScript.Delay(100);

                    return;
                }

                var players = new PlayerList();
                var all     = this.OfType <MpPlayerMenu>().ToList();
                var list    = all.Where(pm => pm.Player == null || players.All(pl => pl.ServerId != pm.Player.ServerId)).ToList();
                foreach (var player in new List <MpPlayerMenu>(list))
                {
                    if (Client.Menu.CurrentMenu != null && Client.Menu.CurrentMenu == player.Child)
                    {
                        Client.Menu.CurrentMenu = player.Menu;
                    }
                    Remove(player);
                }

                foreach (var player in players)
                {
                    if (all.Any(p => p.ServerId == player.ServerId))
                    {
                        continue;
                    }

                    Add(new MpPlayerMenu(Client, player, this));
                }
                await BaseScript.Delay(1000);
            }
            catch (Exception ex) {
                Log.Error(ex);
                await BaseScript.Delay(1000);
            }
        }
Пример #6
0
    public void OnlineChangePlayer(string control, int dir, bool delay, string playerId)
    {
        if (PlayerList.All(player => player.Control != playerId) || delay)
        {
            return;
        }

        int classPos = _classes.FindIndex(c => c == PlayerList.First(p => p.Control == playerId).Class);

        if (classPos == 0 && dir == -1)
        {
            classPos = _classes.Count;
        }
        if (classPos == _classes.Count - 1 && dir == 1)
        {
            classPos = -1;
        }

        PlayerList.Find(p => p.Control == playerId).Class = _classes[classPos + dir];

        PlayPlayersAudio(DirClip, control);

        UpdateSelect(PlayerList);
    }