Пример #1
0
 public FlagCaptureBattlefield(FlagCaptureBattlefieldConfig battlefieldConfig) : base(battlefieldConfig)
 {
     foreach (var flagPlace in battlefieldConfig.FLAGS_PLACES)
     {
         if (!flagPlacesByTeamId.TryGetValue(flagPlace.TEAM_ID, out List <FlagPlace> flagPlaces))
         {
             flagPlaces = new List <FlagPlace>();
             flagPlacesByTeamId.Add(flagPlace.TEAM_ID, flagPlaces);
         }
         flagPlaces.Add(flagPlace);
         flagPlacesById.Add(flagPlace.ID, flagPlace);
         flags.Add(new Flag(flagPlace.ID));
     }
     check();
 }
        public static FlagCaptureBattlefieldConfig ConvertFromBattlefieldConfig(BattlefieldConfig bc)
        {
            FlagCaptureBattlefieldConfig config = bc as FlagCaptureBattlefieldConfig;

            if (config == null)
            {
                FlagPlace[] flagPlaces = fromMoreToFlags(bc.MORE);
                if (flagPlaces.Length > 0)
                {
                    config = new FlagCaptureBattlefieldConfig(bc.MAX_TURN, bc.MAX_LAP, bc.TEAMS, bc.ROBOTS_IN_TEAM, bc.RESPAWN_TIMEOUT, bc.RESPAWN_ALLOWED, bc.MATCH_SAVE_FILE, bc.EQUIPMENT_CONFIG_FILE, bc.OBSTACLE_CONFIG_FILE, bc.WAITING_TIME_BETWEEN_TURNS, bc.GUI, bc.RANDOM_SEED, flagPlaces);
                }
                else
                {
                    throw new ArgumentException(nameof(bc) + "have to have same flags in more.");
                }
            }
            return(config);
        }