public override void Execute(INotification notification) { MainUI mainUI = notification.Body as MainUI; if (null == mainUI) { throw new Exception("程序启动失败.."); } //数据信息代理 CardDbProxy cardDbProxy = new CardDbProxy(); Facade.RegisterProxy(cardDbProxy); EffectInfoProxy effectInfoProxy = new EffectInfoProxy(); Facade.RegisterProxy(effectInfoProxy); TestCaseProxy testCaseProxy = new TestCaseProxy(); Facade.RegisterProxy(testCaseProxy); //游戏模式代理 GameModelProxy gameModelProxy = new GameModelProxy(); Facade.RegisterProxy(gameModelProxy); //UI层代理 UIControllerListMediator uIControllerListMediator = new UIControllerListMediator(mainUI.UIControllerListView); Facade.RegisterMediator(uIControllerListMediator); //玩家组代理 PlayerGroupProxy playerGroupProxy = new PlayerGroupProxy(); Facade.RegisterProxy(playerGroupProxy); //游戏容器代理 GameContainerProxy gameContainerProxy = new GameContainerProxy(); Facade.RegisterProxy(gameContainerProxy); //选择阶段进程代理 ChooseStageCircuitProxy chooseStageCircuitProxy = new ChooseStageCircuitProxy(); Facade.RegisterProxy(chooseStageCircuitProxy); SendNotification(OrderSystemEvent.START_CIRCUIT, mainUI, OrderSystemEvent.START_CIRCUIT_MAIN); }
public override void Execute(INotification notification) { PlayerGroupProxy playerGroupProxy = Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy; ChooseStageCircuitProxy chooseStageCircuitProxy = Facade.RetrieveProxy(ChooseStageCircuitProxy.NAME) as ChooseStageCircuitProxy; CardDbProxy cardDbProxy = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy; GameContainerProxy gameContainerProxy = Facade.RetrieveProxy(GameContainerProxy.NAME) as GameContainerProxy; switch (notification.Type) { case UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_ONE_CARD: CardEntry card = notification.Body as CardEntry; string playerCodeChoose = chooseStageCircuitProxy.GetNowPlayerCode(); PlayerItem playerItemNow = playerGroupProxy.getPlayerByPlayerCode(playerCodeChoose); //如果能成功购买,该玩家的购买费用减少,否则返回购买力不够 if (playerItemNow.shipCard.cost >= card.cost) { //添加到卡组 gameContainerProxy.AddCardByPlayerItemAndGameContainerType(playerItemNow, "CardDeck", card); // cardDbProxy.RemoveOneCardEntry(card); playerItemNow.shipCard.cost -= card.cost; SendNotification(UIViewSystemEvent.UI_CARD_DECK_LIST, playerItemNow, UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD); card.isBuyed = true; SendNotification(UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE, card, UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_ONE_CARD_SUCCESS); //判断是否大于6回合 if (chooseStageCircuitProxy.chooseStageCircuitItem.chooseIndex == 7) { SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, UIViewConfig.getNameStrByUIViewName(UIViewName.ViewChooseMakeStage), UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW); SendNotification(UIViewSystemEvent.UI_QUEST_STAGE, null, UIViewSystemEvent.UI_QUEST_STAGE_START); } else { //下一回合 chooseStageCircuitProxy.IntoNextTurn(); SendNotification(UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE, cardDbProxy.GetOneCardListForPool(), UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_LOAD_NEXT_LIST); } } else { SendNotification(UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE, card, UIViewSystemEvent.UI_CHOOSE_MAKE_STAGE_ONE_CARD_FAILURE); } break; } }
public override void Execute(INotification notification) { OperateSystemProxy operateSystemProxy = Facade.RetrieveProxy(OperateSystemProxy.NAME) as OperateSystemProxy; QuestStageCircuitProxy circuitProxy = Facade.RetrieveProxy(QuestStageCircuitProxy.NAME) as QuestStageCircuitProxy; PlayerGroupProxy playerGroupProxy = Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy; ChooseStageCircuitProxy chooseStageCircuitProxy = Facade.RetrieveProxy(ChooseStageCircuitProxy.NAME) as ChooseStageCircuitProxy; EffectInfoProxy effectInfoProxy = Facade.RetrieveProxy(EffectInfoProxy.NAME) as EffectInfoProxy; HexGridProxy hexGridProxy = Facade.RetrieveProxy(HexGridProxy.NAME) as HexGridProxy; GameContainerProxy gameContainerProxy = Facade.RetrieveProxy(GameContainerProxy.NAME) as GameContainerProxy; CardDbProxy cardDbProxy = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy; PlayerItem playerItem = null; switch (notification.Type) { //选择船只逻辑处理 case LogicalSysEvent.LOGICAL_SYS_CHOOSE_SHIP_CARD: string playerCode = notification.Body as string; playerItem = playerGroupProxy.getPlayerByPlayerCode(playerCode); //如果是玩家 if (playerItem.playerType == PlayerType.HumanPlayer) { SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, chooseStageCircuitProxy.chooseStageCircuitItem.playerShipCardMap[playerCode], StringUtil.GetNTByNotificationTypeAndPlayerCode(UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY, playerCode)); } //AI玩家 else if (playerItem.playerType == PlayerType.AIPlayer) { //AI进行船只渲染 SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, chooseStageCircuitProxy.chooseStageCircuitItem.playerShipCardMap[playerCode], StringUtil.GetNTByNotificationTypeAndPlayerCode(UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY, playerCode)); //AI选择船只 CardEntry shipCardEntry = chooseStageCircuitProxy.chooseStageCircuitItem.playerShipCardMap[playerCode][0]; SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, shipCardEntry, UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_CARD); } //网络用户 else if (playerItem.playerType == PlayerType.NetPlayer) { } break; case LogicalSysEvent.LOGICAL_SYS_NEED_PLAYER_CHOOSE: EffectInfo effectInfo = notification.Body as EffectInfo; playerItem = effectInfo.chooseByPlayer; //如果是玩家 if (playerItem.playerType == PlayerType.HumanPlayer) { if (effectInfo.needPlayerToChooseTargetSet.target == "ChooseEffect") { //整理好效果内容,弹出选择框让玩家选择 //把这些效果实例化成卡片 List <CardEntry> cardEntries = new List <CardEntry>(); foreach (string effectName in effectInfo.chooseEffectList) { EffectInfo oneEffectInfo = effectInfoProxy.GetDepthCloneEffectByName(effectName); CardEntry oneCardEntry = cardDbProxy.GetCardEntryBCardInfo(effectInfo.cardEntry.cardInfo); oneCardEntry.InitializeByEffectInfo(oneEffectInfo); cardEntries.Add(oneCardEntry); } //将需要进行选择的内容发送给玩家 SendNotification( UIViewSystemEvent.UI_VIEW_CURRENT, cardEntries, StringUtil.GetNTByNotificationTypeAndUIViewNameAndMaskLayerAndPlayerCode( UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.ChooseStage), playerItem.playerCode, "Y" ) ); } else if (effectInfo.needPlayerToChooseTargetSet.target == "Minion") { //传入效果,根据效果目标进行筛选渲染 SendNotification(MinionSystemEvent.MINION_SYS, effectInfo.needPlayerToChooseTargetSet, MinionSystemEvent.MINION_SYS_EFFECT_HIGHLIGHT_BECOME_TARGET); } } //AI玩家 else if (playerItem.playerType == PlayerType.AIPlayer) { UtilityLog.Log("AI玩家【" + playerItem.playerCode + "】开始选择卡牌效果", LogUtType.Operate); //先直接选择第一种 EffectInfo oneEffectInfo = effectInfoProxy.GetDepthCloneEffectByName(effectInfo.chooseEffectList[0]); CardEntry oneCardEntry = cardDbProxy.GetCardEntryBCardInfo(effectInfo.cardEntry.cardInfo); oneCardEntry.InitializeByEffectInfo(oneEffectInfo); SendNotification(OperateSystemEvent.OPERATE_SYS, oneCardEntry, OperateSystemEvent.OPERATE_SYS_CHOOSE_ONE_EFFECT); } //网络用户 else if (playerItem.playerType == PlayerType.NetPlayer) { } break; case LogicalSysEvent.LOGICAL_SYS_ACTIVE_PHASE_ACTION: //获取当前进行游戏的玩家进行接管 string playerCodeNow = circuitProxy.GetNowHaveStagePlayerCode(); PlayerItem playerItemNow = playerGroupProxy.getPlayerByPlayerCode(playerCodeNow); UtilityLog.Log("AI玩家" + playerCodeNow + "开始操作:", LogUtType.Operate); //无法操作了结束回合 bool canContinueOperation = true; //判断是否使用过资源牌 if (playerItemNow.CheckResourceCardCanUse()) { UtilityLog.Log("AI玩家" + playerCodeNow + "可以使用资源牌:", LogUtType.Operate); GameContainerItem gameContainerItem = gameContainerProxy.GetGameContainerItemByPlayerItemAndGameContainerType(playerItemNow, "CardHand"); CardEntry getHand = gameContainerItem.GetOneCardTypeCard(CardType.ResourceCard); //检查手牌里是否存在资源牌 if (getHand != null) { //使用这张手牌 operateSystemProxy.IntoModeByType(getHand, playerItemNow, OperateSystemItem.OperateType.HandUse); HexCellItem hexCellItem = new HexCellItem(1, 1); SendNotification(OperateSystemEvent.OPERATE_SYS, hexCellItem, OperateSystemEvent.OPERATE_SYS_DRAW_END_HEX); } else { canContinueOperation = false; } } else { UtilityLog.Log("AI玩家" + playerCodeNow + "不可以使用资源牌:", LogUtType.Operate); canContinueOperation = false; } if (!canContinueOperation) { //结束回合 SendNotification(UIViewSystemEvent.UI_QUEST_TURN_STAGE, null, UIViewSystemEvent.UI_QUEST_TURN_STAGE_END_OF_STAGE); } else { circuitProxy.circuitItem.autoNextStage = false; } break; } }
//开始流程 public override void Execute(INotification notification) { if (notification.Type == OrderSystemEvent.START_CIRCUIT_MAIN) { MainUI mainUI = notification.Body as MainUI; if (null == mainUI) { throw new Exception("程序启动失败.."); } //地图代理(需要放在操作层之前) HexGridProxy hexGridProxyCreate = new HexGridProxy(); Facade.RegisterProxy(hexGridProxyCreate); HexGridMediator hexGridMediator = new HexGridMediator(mainUI.HexGridView); Facade.RegisterMediator(hexGridMediator); //生物层代理 MinionGridMediator minionGridMediator = new MinionGridMediator(mainUI.minionGridView); Facade.RegisterMediator(minionGridMediator); //进程代理 QuestStageCircuitProxy createCircuitProxy = new QuestStageCircuitProxy(); Facade.RegisterProxy(createCircuitProxy); QuestStageCircuitMediator circuitMediator = new QuestStageCircuitMediator(mainUI.circuitButton); Facade.RegisterMediator(circuitMediator); //操作系统代理 OperateSystemProxy operateSystemProxy = new OperateSystemProxy(); Facade.RegisterProxy(operateSystemProxy); OperateSystemMediator operateSystemMediator = new OperateSystemMediator(mainUI.operateSystemView); Facade.RegisterMediator(operateSystemMediator); //选择页面代理 ChooseGridMediator chooseGridMediator = new ChooseGridMediator(mainUI.chooseGridView); Facade.RegisterMediator(chooseGridMediator); //手牌区代理(需要放在操作系统后) HandViewMediator handGridMediator = new HandViewMediator(mainUI.HandControlView); Facade.RegisterMediator(handGridMediator); } PlayerGroupProxy playerGroupProxy = Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy; HexGridProxy hexGridProxy = Facade.RetrieveProxy(HexGridProxy.NAME) as HexGridProxy; CardDbProxy cardDbProxy = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy; GameModelProxy gameModelProxy = Facade.RetrieveProxy(GameModelProxy.NAME) as GameModelProxy; switch (notification.Type) { case OrderSystemEvent.START_CIRCUIT_MAIN: SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, null, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.StartMain))); SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, null, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.CardMoveAnimation))); break; case OrderSystemEvent.START_CIRCUIT_START: //CardDbProxy cardDbProxy = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy; //玩家信息初始化 playerGroupProxy.AddPlayer("TEST1", PlayerType.HumanPlayer); playerGroupProxy.AddPlayer("TEST2", PlayerType.AIPlayer); //设定UI段显示为玩家TEST1 SendNotification(OrderSystemEvent.CLINET_SYS, "TEST1", OrderSystemEvent.CLINET_SYS_OWNER_CHANGE); ChooseStageCircuitProxy chooseStageCircuitProxy = Facade.RetrieveProxy(ChooseStageCircuitProxy.NAME) as ChooseStageCircuitProxy; chooseStageCircuitProxy.CircuitStart(playerGroupProxy.playerGroup.playerItems); //开启卡组列渲染 foreach (PlayerItem playerItem in playerGroupProxy.playerGroup.playerItems.Values) { SendNotification( UIViewSystemEvent.UI_VIEW_CURRENT, playerItem, StringUtil.GetNTByNotificationTypeAndPlayerCodeAndUIViewName( UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, playerItem.playerCode, UIViewConfig.getNameStrByUIViewName(UIViewName.CardDeckList) ) ); } //开启选择阶段 SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, null, UIViewSystemEvent.UI_CHOOSE_STAGE_START); break; case OrderSystemEvent.START_CIRCUIT_TEST_CASE: TestCaseProxy testCaseProxy = Facade.RetrieveProxy(TestCaseProxy.NAME) as TestCaseProxy; List <TestCaseInfo> testCaseInfoList = testCaseProxy.testCaseInfoMap.Values.ToList(); SendNotification( UIViewSystemEvent.UI_VIEW_CURRENT, testCaseInfoList, StringUtil.GetNTByNotificationTypeAndUIViewName( UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.TestCaseView) ) ); break; //开始一个测试 case OrderSystemEvent.START_CIRCUIT_TEST_CASE_START_ONE: //玩家信息初始化 playerGroupProxy.AddPlayer("TEST1", PlayerType.HumanPlayer); playerGroupProxy.AddPlayer("TEST2", PlayerType.AIPlayer); //设定UI段显示为玩家TEST1 SendNotification(OrderSystemEvent.CLINET_SYS, "TEST1", OrderSystemEvent.CLINET_SYS_OWNER_CHANGE); TestCaseInfo chooseOneTestCase = notification.Body as TestCaseInfo; SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, UIViewConfig.getNameStrByUIViewName(UIViewName.TestCaseView), UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW); SendNotification(UIViewSystemEvent.UI_QUEST_STAGE, notification.Body, UIViewSystemEvent.UI_QUEST_STAGE_START_SPECIAL); SendNotification(OperateSystemEvent.OPERATE_TRAIL_DRAW, null, OperateSystemEvent.OPERATE_TRAIL_DRAW_CREATE); break; //开始测试地图 case OrderSystemEvent.START_CIRCUIT_TEST_MAP: //获取当前模式有多少个玩家 //目前只考虑有两个玩家的情况 int num = gameModelProxy.gameModelNow.playerNum; //玩家信息初始化 playerGroupProxy.AddPlayer("TEST1", PlayerType.HumanPlayer); playerGroupProxy.AddPlayer("TEST2", PlayerType.AIPlayer); //设定UI段显示为玩家TEST1 SendNotification(OrderSystemEvent.CLINET_SYS, "TEST1", OrderSystemEvent.CLINET_SYS_OWNER_CHANGE); SendNotification(UIViewSystemEvent.UI_QUEST_STAGE, null, UIViewSystemEvent.UI_QUEST_STAGE_START); SendNotification(OperateSystemEvent.OPERATE_TRAIL_DRAW, null, OperateSystemEvent.OPERATE_TRAIL_DRAW_CREATE); break; } }
public override void Execute(INotification notification) { PlayerGroupProxy playerGroupProxy = Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy; ChooseStageCircuitProxy chooseStageCircuitProxy = Facade.RetrieveProxy(ChooseStageCircuitProxy.NAME) as ChooseStageCircuitProxy; CardDbProxy cardDbProxy = Facade.RetrieveProxy(CardDbProxy.NAME) as CardDbProxy; //当前回合玩家 string playerCodeChoose = chooseStageCircuitProxy.GetNowPlayerCode(); PlayerItem playerItemNow = playerGroupProxy.getPlayerByPlayerCode(playerCodeChoose); switch (notification.Type) { case UIViewSystemEvent.UI_CHOOSE_STAGE_START: List <CardInfo> shipCardList = cardDbProxy.GetCardInfoByType(CardMetrics.CARD_TYPE_SHIP); //随机序列 List <int> randomList = RandomUtil.GetRandom(0, 5, 6, false); List <string> playerCodeList = new List <string>(); foreach (string playerCode in playerGroupProxy.playerGroup.playerItems.Keys) { playerCodeList.Add(playerCode); } //为每个玩家分配不同的船 for (int rnum = 0; rnum < randomList.Count; rnum++) { string playerCode = playerCodeList[rnum % playerCodeList.Count]; CardEntry fpCardShip = cardDbProxy.GetCardEntryBCardInfo(shipCardList[randomList[rnum]]); chooseStageCircuitProxy.chooseStageCircuitItem.playerShipCardMap[playerCode].Add(fpCardShip); } string playerCodeNow = chooseStageCircuitProxy.GetNowPlayerCode(); SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, null, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.ChooseStage))); SendNotification(LogicalSysEvent.LOGICAL_SYS, playerCodeNow, LogicalSysEvent.LOGICAL_SYS_CHOOSE_SHIP_CARD); break; case UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_CARD: CardEntry card = notification.Body as CardEntry; if (card.WhichCard == CardType.ShipCard) { //确认选择,然后返回选择动画 playerItemNow.shipCard = card; SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, card, StringUtil.GetNTByNotificationTypeAndPlayerCode(UIViewSystemEvent.UI_CHOOSE_STAGE_ONE_SHIP_CARD_ANIMATION, playerItemNow.playerCode)); SendNotification(UIViewSystemEvent.UI_CARD_DECK_LIST, playerItemNow, UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD); chooseStageCircuitProxy.IntoNextTurn(); playerCodeChoose = chooseStageCircuitProxy.GetNowPlayerCode(); //查看是否所有玩家都选择了船 if (playerGroupProxy.checkAllPlayerHasShip()) { //渲染卡池 // List<CardEntry> cardEntries = cardDbProxy.GetSameCardEntry(3); SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, UIViewConfig.getNameStrByUIViewName(UIViewName.ChooseStage), UIViewSystemEvent.UI_VIEW_CURRENT_CLOSE_ONE_VIEW); //第一次发牌,发三组 List <List <CardEntry> > cardEntries = new List <List <CardEntry> >(); cardEntries.Add(cardDbProxy.GetOneCardListForPool()); cardEntries.Add(cardDbProxy.GetOneCardListForPool()); cardEntries.Add(cardDbProxy.GetOneCardListForPool()); SendNotification(UIViewSystemEvent.UI_VIEW_CURRENT, cardEntries, StringUtil.GetNTByNotificationTypeAndUIViewName(UIViewSystemEvent.UI_VIEW_CURRENT_OPEN_ONE_VIEW, UIViewConfig.getNameStrByUIViewName(UIViewName.ViewChooseMakeStage))); //SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, cardEntries, UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY); } else { //渲染下一位玩家的船只选择 SendNotification(LogicalSysEvent.LOGICAL_SYS, playerCodeChoose, LogicalSysEvent.LOGICAL_SYS_CHOOSE_SHIP_CARD); } } else { //添加到卡组 //playerItemNow.cardDeck.PutOneCard(card); cardDbProxy.RemoveOneCardEntry(card); //该玩家的购买费用减少 playerItemNow.shipCard.cost -= card.cost; SendNotification(UIViewSystemEvent.UI_CARD_DECK_LIST, playerItemNow, UIViewSystemEvent.UI_CARD_DECK_LIST_LOAD); //下一回合 chooseStageCircuitProxy.IntoNextTurn(); List <CardEntry> cardEntries = cardDbProxy.GetSameCardEntry(3); SendNotification(UIViewSystemEvent.UI_CHOOSE_STAGE, cardEntries, UIViewSystemEvent.UI_CHOOSE_STAGE_LOAD_CARD_ENTRY); } break; } }