Пример #1
0
        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;
            }
        }