コード例 #1
0
ファイル: EngineService.cs プロジェクト: juan-db/2021-Galaxio
        private async Task ProcessGameTick()
        {
            Logger.LogInfo("Engine", $"Tick: {worldStateService.GetState().World.CurrentTick}, Player Count: {worldStateService.GetPlayerCount()}");
            IList <BotObject> bots = worldStateService.GetPlayerBots();

            SimulateTickForBots(bots);

            IList <BotObject>       aliveBots      = worldStateService.GetPlayerBots();
            IEnumerable <BotObject> botsForRemoval = bots.Where(bot => !aliveBots.Contains(bot));

            foreach (var bot in botsForRemoval)
            {
                await hubConnection.InvokeAsync("PlayerConsumed", bot.Id);
            }

            foreach (var bot in aliveBots)
            {
                Logger.LogDebug(bot.Id, "Size", bot.Size);
                Logger.LogDebug(bot.Id, "Speed", bot.Speed);
                Logger.LogDebug(bot.Id, "Position", $"{bot.Position.X}:{bot.Position.Y}");
            }

            worldStateService.ApplyAfterTickStateChanges();
            CheckWinConditions();
        }