public async Task ShowRollingAsync(CustomBasicList <CustomBasicList <bool> > thisCol)
        {
            bool isLast = false;

            AsyncDelayer.SetDelayer(this, ref _delay !); //has to be here to learn lesson from other dice games.
            await thisCol.ForEachAsync(async firstList =>
            {
                if (thisCol.Last() == firstList)
                {
                    isLast = true;
                }
                int x;
                x = 0;
                firstList.ForEach(items =>
                {
                    SingleDiceInfo thisDice = FindNextPin(ref x);
                    thisDice.Populate(items);
                    thisDice.Index = DiceList.IndexOf(thisDice) + 1;
                    if (isLast == true) //animations has to show value
                    {
                        thisDice.DidHit = items;
                    }
                });
                await _delay.DelayMilli(50); //decided to have here less performance problem when rolling bowling dice.
            });

            if (isLast == false)
            {
                throw new BasicBlankException("Was never last for showing rolling.  Rethink");
            }
        }
 public async Task StartUpAsync()
 {
     await _mines.ForEachAsync(async x =>
     {
         await Task.CompletedTask;
         x.StartUp();
     });
 }
Exemplo n.º 3
0
 public async Task ShowRollingAsync(CustomBasicList <int> thisCol)
 {
     Visible = true;
     await thisCol.ForEachAsync(async items =>
     {
         Populate(items);
         await _gameContainer.Delay.DelaySeconds(.07); //i had .05 before so keep that
     });
 }
Exemplo n.º 4
0
        public async Task ShowRollingAsync(CustomBasicList <string> thisCol)
        {
            if (Hold == true)
            {
                throw new BasicBlankException("Can't show it rolling because you held on to the dice");
            }

            Visible = true;
            //AsyncDelayer.SetDelayer(this, ref _gameContainer.Delay!);
            await thisCol.ForEachAsync(async Items =>
            {
                Populate(Items);
                await _gameContainer.Delay.DelaySeconds(.07); //i had .05 before so keep that
            });
        }
        public async Task SendMessageAsync(string tempMessage)
        {
            string         errorMessage = "";
            ConnectionInfo thisInfo;
            NetworkMessage thisMessage = await js.DeserializeObjectAsync <NetworkMessage>(tempMessage);

            if (_playerList.Count == 0)
            {
                await SendErrorAsync("There are no players to send messages to");

                return;
            }
            if (thisMessage.SpecificPlayer != "")
            {
                if (_playerList.ContainsKey(thisMessage.SpecificPlayer) == false)
                {
                    errorMessage = $"{thisMessage.SpecificPlayer} was not even registered to receive messages";
                }
                thisInfo = _playerList[thisMessage.SpecificPlayer];
                if (thisInfo.IsConnected == false)
                {
                    errorMessage = $"{thisMessage.SpecificPlayer} was disconnected even though it showed it was registered";
                }
                if (errorMessage != "")
                {
                    await SendErrorAsync(errorMessage);

                    return;
                }
                await Clients.Client(thisInfo.ConnectionID).SendAsync("ReceiveMessage", thisMessage.Message);

                return; //i think
            }
            CustomBasicList <ConnectionInfo> SendTo = _playerList.Where(Items => Items.Key != thisMessage.YourNickName).Select(Temps => Temps.Value).ToCustomBasicList();

            if (SendTo.Any(Items => Items.IsConnected == false))
            {
                await SendErrorAsync("Somebody got disconnected when trying to send a message.");

                return;
            }
            await SendTo.ForEachAsync(async Items =>
            {
                await Clients.Client(Items.ConnectionID).SendAsync("ReceiveMessage", thisMessage.Message);
            });
        }
Exemplo n.º 6
0
 public async Task ShowRollingAsync(CustomBasicList <CustomBasicList <D> > diceCollection, bool showVisible)
 {
     CanShowDice = showVisible;
     AsyncDelayer.SetDelayer(this, ref _delay !); //because for multiplayer, they do this part but not the other.
     await diceCollection.ForEachAsync(async firsts =>
     {
         DiceList.ReplaceDiceRange(firsts);
         int tempCount = DiceList.Count;
         if (DiceList.Any(Items => Items.Index > tempCount || Items.Index <= 0))
         {
             throw new BasicBlankException("Index cannot be higher than the dicecount or less than 1");
         }
         HasDice = true;
         if (CanShowDice == true)
         {
             Visible = true;
             await _delay.DelayMilli(50);
         }
     });
 }