Example #1
0
 private void EnqueueWaitingFleets(Guid userId, PlayerGameState player)
 {
     foreach (var fleet in player.WaitingFleets)
     {
         var route       = _map.GenerateRoute(fleet.From, fleet.To);
         var movingFleet = new MovingFleetData(userId, fleet, route);
         player.MovingFleets.Add(movingFleet);
     }
     player.WaitingFleets.Clear();
 }
Example #2
0
 private void EnqueueWaitingFleets(PlayerGameState player)
 {
     foreach (var fleet in player.WaitingFleets)
     {
         var movingFleet = new MovingFleetData
         {
             Route    = _map.GenerateRoute(fleet.From, fleet.To),
             Fleet    = fleet,
             Position = fleet.From
         };
         player.MovingFleets.Add(movingFleet);
     }
     player.WaitingFleets.Clear();
 }
Example #3
0
        private async Task MoveFleets(PlayerGameState player)
        {
            var arrived = new HashSet <MovingFleetData>();

            foreach (var movingFleet in player.MovingFleets)
            {
                movingFleet.Position = movingFleet.Route
                                       .SkipWhile(x => x != movingFleet.Position)
                                       .Skip(1)
                                       .First();
                var destination = movingFleet.Fleet.To;
                if (movingFleet.Position != destination)
                {
                    continue;
                }
                arrived.Add(movingFleet);
                await HandleFleetArrival(movingFleet);
            }
            player.MovingFleets = player.MovingFleets
                                  .Where(x => !arrived.Contains(x))
                                  .ToList();
        }