/// <summary> /// 游戏初始化,卡组玩家生成 /// </summary> public void Init(GameOptions options = null) { EventSystem = new SeatByEventSystem(); EventSystem.game = this; EventHelper.RegisterEvent(this); this.options = options; if (RequestManager != null) { RequestManager.Game = this; } //初始化牌库 if (options != null && options.Cards != null && Database != null) { foreach (var id in options.Cards) { switch (CreatCard(id)) { case EventCard eventCard: EventDeck.Add(eventCard); break; case ActionCard actionCard: ActionDeck.Add(actionCard); break; case ThemeCard themeCard: ThemeDeck.Add(themeCard); break; case HeroCard heroCard: characterDeck.Add(heroCard); break; } } } else { //for (int i = 0; i < 7; i++) //{ // characterDeck.Add(new Cards.CR_CM001()); // characterDeck.Add(new Cards.CR_CP001()); // characterDeck.Add(new Cards.CR_IM001()); // characterDeck.Add(new Cards.CR_IP001()); //} characterDeck.AddRange(createCards(113, 7).Cast <HeroCard>()); characterDeck.AddRange(createCards(119, 7).Cast <HeroCard>()); characterDeck.AddRange(createCards(107, 7).Cast <HeroCard>()); characterDeck.AddRange(createCards(101, 7).Cast <HeroCard>()); ActionDeck.AddRange(createCards <Cards.AT_N001>(5)); ActionDeck.AddRange(createCards <Cards.AT_N002>(5)); ActionDeck.AddRange(createCards <Cards.AT_N003>(3)); ActionDeck.AddRange(createCards <Cards.AT_N004>(3)); ActionDeck.AddRange(createCards <Cards.AT_N006>(3)); ActionDeck.AddRange(createCards <Cards.AT_D009>(5)); ActionDeck.AddRange(createCards <Cards.AT_N012>(5)); ActionDeck.AddRange(createCards <Cards.AT_G013>(1)); ActionDeck.AddRange(createCards <Cards.AT_N014>(1)); ActionDeck.AddRange(createCards <Cards.AT_N020>(3)); ActionDeck.AddRange(createCards <Cards.AT_N023>(1)); ThemeDeck.AddRange(createCards(new Cards.G_001(), 20)); EventDeck.AddRange(createCards <Cards.EV_E001>(7)); EventDeck.AddRange(createCards <Cards.EV_E002>(3)); //characterDeck = new List<HeroCard>(types.Where(t => t.IsSubclassOf(typeof(HeroCard))) // .Select(t => Activator.CreateInstance(t) as HeroCard)); } if (options == null || options.shuffle) { Reshuffle(characterDeck); Reshuffle(ActionDeck); Reshuffle(ThemeDeck); Reshuffle(EventDeck); } //初始化玩家 if (options != null && options.PlayerInfos != null) { for (int i = 0; i < options.PlayerInfos.Length; i++) { GameOptions.PlayerInfo info = options.PlayerInfos[i]; Player p; if (info.Id < 0) { p = new AI(this, i); } else { p = new Player(i); } p.Name = info.Name; p.PlayerId = info.Id; Players.Add(p); } } else { for (int i = 0; i < 8; i++) { Player p; if (i == 1) { p = new Player(i); } else { p = new AI(this, i); } p.Name = "玩家" + i; //p.Hero = new Cards.CR_CP001(); Players.Add(p); } } EventSystem.MaxSeat = Players.Count; foreach (Player player in Players) { player.SetSize(options != null ? options.initInfluence : 0); } //初始化游戏结束条件 endingOfficialCardCount = options != null && options.endingOfficialCardCount > 0 ? options.endingOfficialCardCount : 12 - Players.Count; responses = new List <TaskCompletionSource <Response> > [Players.Count]; Requests = new List <Request> [Players.Count]; for (int i = 0; i < responses.Length; i++) { responses[i] = new List <TaskCompletionSource <Response> >(); Requests[i] = new List <Request>(); } }