Esempio n. 1
0
        public void Move(Player me, World world, Game game, Move move)
        {
            VehicleRegistry.Update(world, me, game);
            if (world.TickIndex == 0)
            {
                InitFormations(world, me);
            }
#if DEBUG
            RewindClient.Instance.Message($"=== Commands queue size: {CommandManager.GetCurrentQueueSize()} ===");
            RewindClient.Instance.Message($"=== My points: {world.GetMyPlayer().Score} ===");
            RewindClient.Instance.Message($"=== Opponent points: {world.GetOpponentPlayer().Score} ===");
            if (!isGridDrawn)
            {
                DrawGrid(world);
                isGridDrawn = true;
            }
#endif
            if (CommandManager.PlayCommandIfPossible(VehicleRegistry, me, move, world.TickIndex))
            {
                return;
            }
            var unusedFacilities = VehicleRegistry.GetUnusedFacilities(world, me).ToList();
            if (unusedFacilities.Any())
            {
                var facility = unusedFacilities.First();
                if (!AnyVehiclesNearFacility(facility, VehicleRegistry.MyVehicles(me), game))
                {
                    CommandManager.EnqueueCommand(new SetProductionCommand(facility.Id, VehicleType.Tank));
                    return;
                }
            }
            var nextTickFormations = new List <IVehicleFormation>();
            foreach (var formation in formations)
            {
                var result = formation.PerformAction(world, me, game);
                nextTickFormations.AddRange(result.NewFormations);
            }
            formations = nextTickFormations;
            TryIntroduceNewFormations();
        }