コード例 #1
0
ファイル: Run.cs プロジェクト: aahriman/RobotBattlefield
        /// <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();
        }
コード例 #2
0
ファイル: config.cs プロジェクト: woshiduanli/DLLResouce
    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();
    }
コード例 #3
0
 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.");
     }
 }
コード例 #4
0
ファイル: AServer.cs プロジェクト: aahriman/RobotBattlefield
        /// <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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
ファイル: AServer.cs プロジェクト: aahriman/RobotBattlefield
 /// <summary>
 /// Create battlefield with config (used from GetBattlefield)
 /// </summary>
 /// <param name="battlefieldConfig"></param>
 /// <returns></returns>
 protected abstract Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig);
コード例 #7
0
 /// <inheritdoc />
 public Deadmatch(BattlefieldConfig battlefieldConfig)  : base(battlefieldConfig)
 {
 }
コード例 #8
0
ファイル: Server.cs プロジェクト: aahriman/RobotBattlefield
 protected override Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig)
 {
     return(new battlefield.BaseCaptureBattlefield(BaseCaptureBattlefieldConfig.ConvertFromBattlefieldConfig(battlefieldConfig)));
 }
コード例 #9
0
 /// <inheritdoc />
 /// Create Deadmatch
 /// </summary>
 protected override Battlefield NewBattlefield(BattlefieldConfig battlefieldConfig)
 {
     return(new Deadmatch(battlefieldConfig));
 }