Esempio n. 1
0
        private void AddPlayersAndBombsToGrid()
        {
            //List<Player> CurrentPlayers = context.Players.ToList();
            Explosive prototype = new Explosive();

            context.Players.Copy().CreateIterator().ForEach(player =>
            {
                if (!player.Bomb.Droped)
                {
                    player.Bomb.Droped = true;
                    if (IsBombValid(player) && player.BombLimit > player.BombCount)
                    {
                        Console.WriteLine(string.Format("addBombsToGrid x:{0}y:{1}", player.Bomb.GetCords().X, player.Bomb.GetCords().Y));
                        var copy = prototype.Clone();
                        copy.SetCords((Coordinates)player.Bomb.GetCords().Clone());
                        copy.Radius = player.Bomb.Radius;
                        context.AddGameObject(copy);
                        player.BombCount++;
                        RemoveBomb(copy, player);
                    }
                }
                int playerX          = player.xy.X;
                int playerY          = player.xy.Y;
                List <int> cleanTile = new List <int>();
                cleanTile.Add(player.User.Id);
                context.grid.UpdateTile(playerX, playerY, cleanTile);
            });
        }