/// <summary> /// Start server with specific arguments /// </summary> /// <param name="args">[0] => port, [2] => config file </param> public static void Main(string[] args) { Console.WriteLine("Arena start."); int port; if (args.Length < 1 || !int.TryParse(args[0], out port)) { port = GameProperties.DEFAULT_PORT; } Server server = new Server(port); BattlefieldConfig battlefieldConfig; if (args.Length >= 2) { battlefieldConfig = BattlefieldConfig.DeserializeFromFile(args[1]); } else { battlefieldConfig = new BattlefieldConfig(MAX_TURN: ServerConfig.MAX_TURN, MAX_LAP: 1, TEAMS: 2, ROBOTS_IN_TEAM: 2, RESPAWN_TIMEOUT: 20, RESPAWN_ALLOWED: true, MATCH_SAVE_FILE: "arena_match" + port + ".txt", EQUIPMENT_CONFIG_FILE: null, obstacleConfigFile: null, WAITING_TIME_BETWEEN_TURNS: -1, GUI: true, RANDOM_SEED: null, more: new [] { new Base(500, 100, 100), new Base(500, 900, 100) }); } Battlefield arena = server.GetBattlefield(battlefieldConfig); arena.RunEvent.WaitOne(); arena.RunThread.Join(); }
public GameConfig() { kill_point_30_60 = new IntArray(); kill_point_60 = new IntArray(); delta_level_exp = new IntArray(); carriage_list = new IntArray(); best_carriage_list = new IntArray(); clear_cd_skill_list = new IntArray(); pickup_item_notice = new IntArray(); learn_skill = new LearnSkillConfig(); equip_endure_cost = new EquipEndureCost(); strings = new ConstString(); battlefield = new BattlefieldConfig(); jizhou_battlefield = new JiZhouBattlefieldConfig(); huangjin_battlefield = new HuangJinBattlefieldConfig(); card_mgr = new CardMgr(); group_setting = new GroupSetting(); store_setting = new IBStoreSettings(); relationship = new RelationshipConfig(); OfflineExpItems = new OfflineExpItemCfgArray(); OfflineExpPerLevels = new OfflineExpPerLevelArray(); group_league = new GroupLeagueConfig(); country = new CountryConfig(); auto_equip_when_enter_map_config = new AutoEquipWhenEnterMapConfig(); sign_manager = new SignManager(); }
public static BaseCaptureBattlefieldConfig ConvertFromBattlefieldConfig(BattlefieldConfig bc) { Base[] bases = basesFromMore(bc.MORE); if (bases.Length > 0) { return(new BaseCaptureBattlefieldConfig(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, bases)); } else { throw new ArgumentException("Config have to have some bases in more."); } }
/// <summary> /// Create battlefield at server with config. /// </summary> /// <param name="battlefieldConfig"></param> /// <returns></returns> public Battlefield GetBattlefield(BattlefieldConfig battlefieldConfig) { Battlefield = NewBattlefield(battlefieldConfig); Socket socketIPv6 = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); Socket socketIPv4 = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); myBindSocket(socketIPv4, IPAddress.Any, port); myBindSocket(socketIPv6, IPAddress.IPv6Any, port); Console.WriteLine("Arena runs on ip " + String.Join(" or ", (IEnumerable <IPAddress>)Dns.GetHostAddresses(Dns.GetHostName()).Where(a => a.AddressFamily == AddressFamily.InterNetwork || a.IsIPv6LinkLocal)) + " and port " + port); return(Battlefield); }
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); }
/// <summary> /// Create battlefield with config (used from GetBattlefield) /// </summary> /// <param name="battlefieldConfig"></param> /// <returns></returns> protected abstract Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig);
/// <inheritdoc /> public Deadmatch(BattlefieldConfig battlefieldConfig) : base(battlefieldConfig) { }
protected override Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig) { return(new battlefield.BaseCaptureBattlefield(BaseCaptureBattlefieldConfig.ConvertFromBattlefieldConfig(battlefieldConfig))); }
/// <inheritdoc /> /// Create Deadmatch /// </summary> protected override Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig) { return(new Deadmatch(battlefieldConfig)); }