private Area CreateArea(AreaData data, IList<Province> provinces) { Area area = new Area(data); // 勢力の設定 var provNo = _root.SelectedScenario.AreaOwner[data.No - 1]; switch (provNo) { case -1: break; case 0: // 中立 area.Province = provinces.Single(p => p.No == provNo); break; default: // 通常 area.Province = provinces.Single(p => p.No == provNo); break; } // 固有ユニットのセット var locs = _root.SelectedScenario.Locates; var units = _root.SelectedGame.Units; var locates = from l in locs where l.AreaNo == area.No join unit in units on l.UnitID equals unit.ID let rank = (UnitRank)l.Rank select new Unit(unit, rank); area.Units.AddRange(locates); while (area.Units.Count > 20) area.Units.RemoveAt(area.Units.Count - 1); // 街、道路、城壁の値をセット switch (provNo) { case -1: case 0: area.NumCity100 = area.MaxCity * 10; area.NumRoad100 = area.MaxRoad * 10; area.NumWall100 = area.MaxWall * data.DefautlWallRate; break; default: area.NumCity100 = area.MaxCity / 6 * 100; area.NumRoad100 = area.MaxRoad / 6 * 100; area.NumWall100 = area.MaxWall * (data.DefautlWallRate + 40); // マスターのいる拠点だったばあい if (area.Units.Any(u => u.ID == area.Province.Master.ID)) { area.NumCity100 *= 2; area.NumRoad100 *= 2; area.NumWall100 = area.MaxWall * 100; } break; } return area; }
/// <summary> /// アプリケーションのメイン エントリ ポイントです。 /// </summary> public static void Main2() { // アプリケーションの初期設定 //Application.EnableVisualStyles(); //Application.SetCompatibleTextRenderingDefault(false); var scenarioDir = GetScenarioDir(); Global.ScenarioDir = scenarioDir; var unitDataes = UnitDataLoader.LoadList(new[] { Path.Combine(scenarioDir, "DefChar"), Path.Combine(scenarioDir, "Element") }); var conquerArea1 = new Area(new AreaData(23)); var conquerArea2 = new Area(new AreaData(25)); var conquerList = new List<Tuple<int, IList<Unit>, Area>>(); conquerList.Add(new Tuple<int, IList<Unit>, Area>(2, new Unit[] { new Unit(unitDataes[0]), new Unit(unitDataes[50]) }, conquerArea1)); conquerList.Add(new Tuple<int, IList<Unit>, Area>(1, new Unit[] { new Unit(unitDataes[60]), new Unit(unitDataes[55]) }, conquerArea2)); var battleAreaData = new AreaData(24); var battleArea = new Area(battleAreaData); battleArea.Units.Add(new Unit(unitDataes[10])); battleArea.Units.Add(new Unit(unitDataes[70])); battleArea.Units.Add(new Unit(unitDataes[30])); battleArea.Units.Add(new Unit(unitDataes[80])); var freMaster = new UnitData(); var eneMaster = new UnitData(); //コンパイルエラーがでるので、コメント中 //Province friPro = new Province(10, "TestFriendProvince", fresurface); //Province enePro = new Province(11, "TestEnemyProvince", enesurface); //area.Province = enePro; var phaseCreator = new AutoDeployPhaseCreator(battleArea, null, () => Environment.Exit(0)); new WarInitializer(unitDataes, battleArea, conquerList, phaseCreator, scenarioDir).Initialize(); }
// ----- ----- ----- Method ----- ----- ----- public Area(AreaData data) { Contract.Requires(data != null, "data"); _data = data; _defIncome = Data.DefaultIncome; }