Пример #1
0
        public override void Execute(INotification notification)
        {
            EffectInfoProxy effectInfoProxy =
                Facade.RetrieveProxy(EffectInfoProxy.NAME) as EffectInfoProxy;
            PlayerGroupProxy playerGroupProxy =
                Facade.RetrieveProxy(PlayerGroupProxy.NAME) as PlayerGroupProxy;
            OperateSystemProxy operateSystemProxy =
                Facade.RetrieveProxy(OperateSystemProxy.NAME) as OperateSystemProxy;
            QuestStageCircuitProxy questStageCircuitProxy =
                Facade.RetrieveProxy(QuestStageCircuitProxy.NAME) as QuestStageCircuitProxy;
            GameContainerProxy gameContainerProxy =
                Facade.RetrieveProxy(GameContainerProxy.NAME) as GameContainerProxy;

            //待执行的卡牌
            CardEntry exeEffectCard = null;

            switch (notification.Type)
            {
            //执行一张卡
            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_EXE_CARD:
                exeEffectCard = notification.Body as CardEntry;
                operateSystemProxy.IntoModeByType(exeEffectCard, exeEffectCard.controllerPlayerItem, OperateSystemItem.OperateType.CardIsReleasing);
                //提取待执行的卡牌效果
                List <EffectInfo> oneExeEffectCardEffects = new List <EffectInfo>();
                //遍历卡牌的效果
                foreach (string effectCode in exeEffectCard.effectCodeList)
                {
                    EffectInfo oneEffectInfo = effectInfoProxy.GetDepthCloneEffectByName(effectCode);
                    if (oneEffectInfo.impactTimeTriggers == null)
                    {
                        //设置状态
                        oneEffectInfo.effectInfoStage = EffectInfoStage.UnStart;
                        //设置所有者,手牌操作模式,所有者是当前玩家
                        oneEffectInfo.player = exeEffectCard.controllerPlayerItem;
                        //设置所属卡牌
                        oneEffectInfo.cardEntry = exeEffectCard;
                        //是否有预先选定的目标对象
                        if (exeEffectCard.targetBasicGameDto != null)
                        {
                            if (exeEffectCard.targetBasicGameDto.dtoType == "Minion")
                            {
                                foreach (TargetSet targetSet in oneEffectInfo.operationalTarget.selectTargetList)
                                {
                                    if (targetSet.target == "Minion")
                                    {
                                        targetSet.targetMinionCellItems.Add(exeEffectCard.targetBasicGameDto as CardEntry);
                                    }
                                }
                            }
                        }
                        oneExeEffectCardEffects.Add(oneEffectInfo);
                    }
                }
                //存入效果,进行结算
                effectInfoProxy.IntoModeCardSettle(exeEffectCard, oneExeEffectCardEffects);
                break;

            //执行一张已经触发效果的卡
            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_EXE_TRIGGERED_CARD:
                exeEffectCard = notification.Body as CardEntry;
                //提取待执行的卡牌效果
                List <EffectInfo> oneTriggeredEffectCardEffects = new List <EffectInfo>();
                oneTriggeredEffectCardEffects.Add(exeEffectCard.triggeredEffectInfo);
                effectInfoProxy.IntoModeCardSettle(exeEffectCard, oneTriggeredEffectCardEffects);
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_FIND_TARGET:
                for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                {
                    EffectInfo effect = effectInfoProxy.effectSysItem.effectInfos[n];
                    if (effect.effectType == "Independent")
                    {
                        bool hasTarget = ExecutionEffectFindTarget(effect, effectInfoProxy, playerGroupProxy, questStageCircuitProxy, gameContainerProxy);
                        //没能正确的寻找到目标,防止循环继续执行下去导致效果执行两边,直接返回
                        if (!hasTarget)
                        {
                            return;
                        }
                    }
                    else if (effect.effectType == "BeforeAndAfter")
                    {
                        bool allHasTarget = ExecutionEffectFindTargetForBeforeAndAfter(effect, playerGroupProxy, questStageCircuitProxy, effectInfoProxy, gameContainerProxy);
                        if (!allHasTarget)
                        {
                            return;
                        }
                    }
                }
                //判断是否所有效果都存在了目标
                bool allEffectHasTarget = true;
                for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                {
                    if (effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.UnStart ||
                        effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.ConfirmingTarget)
                    {
                        allEffectHasTarget = false;
                    }
                }
                //询问是否需要用户操作
                if (allEffectHasTarget)
                {
                    SendNotification(EffectExecutionEvent.EFFECT_EXECUTION_SYS, null, EffectExecutionEvent.EFFECT_EXECUTION_SYS_ASK_THE_USER);
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_ASK_THE_USER:
                for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                {
                    EffectInfo effect = effectInfoProxy.effectSysItem.effectInfos[n];
                    if (effect.effectInfoStage == EffectInfoStage.ConfirmedTarget)
                    {
                        AskTheUserOperating(effect,
                                            playerGroupProxy,
                                            questStageCircuitProxy,
                                            effectInfoProxy,
                                            gameContainerProxy
                                            );
                    }
                }
                //判断是否所有效果都进行了用户选择
                bool allEffectHasUserSelect = true;
                for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                {
                    if (effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.UnStart ||
                        effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.ConfirmingTarget ||
                        effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.ConfirmedTarget ||
                        effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage == EffectInfoStage.AskTheUser
                        )
                    {
                        allEffectHasUserSelect = false;
                    }
                }
                if (allEffectHasUserSelect)
                {
                    //执行效果
                    SendNotification(EffectExecutionEvent.EFFECT_EXECUTION_SYS, null, EffectExecutionEvent.EFFECT_EXECUTION_SYS_EXE_EFFECT);
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_EFFECT_SHOW_OVER:
                effectInfoProxy.effectSysItem.showEffectNum--;
                if (effectInfoProxy.effectSysItem.effectSysItemStage == EffectSysItemStage.UnStart)
                {
                    if (effectInfoProxy.effectSysItem.cardEntryQueue.Count == 0)
                    {
                        if (effectInfoProxy.effectSysItem.showEffectNum == 0)
                        {
                            UtilityLog.Log("所有效果展示完毕" + System.Guid.NewGuid().ToString("N"), LogUtType.Effect);
                            //通知回合控制器当前堆叠已经全部执行完毕
                            SendNotification(UIViewSystemEvent.UI_QUEST_TURN_STAGE, null, UIViewSystemEvent.UI_QUEST_TURN_STAGE_NEED_CHECK_END_STAGE_STATE);
                        }
                    }
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_MINION_BUFF_NEED_REMOVE:
                CardEntry needRemoveBuffMinionCellItem = notification.Body as CardEntry;
                UtilityLog.Log("生物【" + needRemoveBuffMinionCellItem.name + "】的buff需要被清除", LogUtType.Effect);
                foreach (EffectInfo oneEffectInfoBuffCheck in needRemoveBuffMinionCellItem.effectBuffInfoList)
                {
                    if (oneEffectInfoBuffCheck.effectiveTime.ContinuousRound == 0)
                    {
                        //提取待执行的卡牌效果
                        List <EffectInfo> oneBuffCleanEffectCardEffects = new List <EffectInfo>();
                        UtilityLog.Log("生物【" + needRemoveBuffMinionCellItem.name + "】的buff【" + oneEffectInfoBuffCheck.code + "】需要被清除", LogUtType.Special);
                        EffectInfo oneReverseEffectInfo = effectInfoProxy.GetDepthCloneEffectByName(oneEffectInfoBuffCheck.code);
                        foreach (TargetSet targetSet in oneReverseEffectInfo.operationalTarget.selectTargetList)
                        {
                            targetSet.targetMinionCellItems.Add(needRemoveBuffMinionCellItem);
                        }
                        oneReverseEffectInfo.effectInfoStage = EffectInfoStage.ConfirmedTarget;
                        oneReverseEffectInfo.whetherToshow   = "N";
                        oneReverseEffectInfo.isReverse       = true;

                        CardEntry cardEntry = new CardEntry();
                        cardEntry.name = "BuffClean";
                        cardEntry.controllerPlayerItem = needRemoveBuffMinionCellItem.controllerPlayerItem;
                        oneReverseEffectInfo.cardEntry = cardEntry;
                        oneBuffCleanEffectCardEffects.Add(oneReverseEffectInfo);
                        effectInfoProxy.IntoModeCardSettle(cardEntry, oneBuffCleanEffectCardEffects);
                    }
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_EXE_EFFECT:
                ExecutionEffectContentList(effectInfoProxy, gameContainerProxy);
                //判断是否所有效果都执行完毕了
                bool allEffectHasFinished = true;
                for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                {
                    if (effectInfoProxy.effectSysItem.effectInfos[n].effectInfoStage != EffectInfoStage.Finished)
                    {
                        allEffectHasFinished = false;
                    }
                }
                if (allEffectHasFinished)
                {
                    for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                    {
                        if (effectInfoProxy.effectSysItem.effectInfos[n].impactTimeTriggertMonitorListWhenOver != null)
                        {
                            //把效果结算完毕的时点都发送出去
                            foreach (string impactTimeTriggertMonitor in effectInfoProxy.effectSysItem.effectInfos[n].impactTimeTriggertMonitorListWhenOver)
                            {
                                SendNotification(TimeTriggerEvent.TIME_TRIGGER_SYS, null, StringUtil.GetNTByNotificationTypeAndPlayerCode(impactTimeTriggertMonitor, effectInfoProxy.effectSysItem.effectInfos[n].player.playerCode));
                            }
                        }
                    }
                    //判断这一组效果是不是都是一张卡的,逻辑上来说都是一张卡
                    CardEntry cardCheck     = new CardEntry();
                    bool      cardCheckOver = true;
                    for (int n = 0; n < effectInfoProxy.effectSysItem.effectInfos.Count; n++)
                    {
                        if (n == 0)
                        {
                            cardCheck = effectInfoProxy.effectSysItem.effectInfos[n].cardEntry;
                        }
                        else
                        {
                            if (effectInfoProxy.effectSysItem.effectInfos[n].cardEntry.uuid != cardCheck.uuid)
                            {
                                cardCheckOver = false;
                                break;
                            }
                            else
                            {
                                cardCheck = effectInfoProxy.effectSysItem.effectInfos[n].cardEntry;
                            }
                        }
                    }
                    if (effectInfoProxy.effectSysItem.effectInfos.Count == 0)
                    {
                        cardCheck = effectInfoProxy.effectSysItem.cardEntry;
                    }
                    if (!cardCheckOver)
                    {
                        UtilityLog.LogError("同一个效果组来源多余一个实体");
                    }
                    else
                    {
                        if (cardCheck.lastGameContainerType == "CardHand")
                        {
                            SendNotification(OperateSystemEvent.OPERATE_SYS, null, OperateSystemEvent.OPERATE_SYS_HAND_CHOOSE_EXE_OVER);
                        }
                    }
                    //执行下一组效果
                    effectInfoProxy.effectSysItem.effectSysItemStage = EffectSysItemStage.UnStart;
                    //通知时点触发器这一组效果执行完毕了
                    SendNotification(TimeTriggerEvent.TIME_TRIGGER_SYS, null, TimeTriggerEvent.TIME_TRIGGER_EXE_NEXT_DELAY_NOTIFICATION);
                    effectInfoProxy.ExeEffectQueue();
                }
                else
                {
                    UtilityLog.LogError("效果执行失败");
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_LAUNCH_AN_ATTACK:
                CardEntry      attackMinionCellItem = notification.Body as CardEntry;
                PlayerItem     playerItemAttack     = attackMinionCellItem.controllerPlayerItem;
                HexCoordinates vectorHexCoordinates = new HexCoordinates(playerItemAttack.playerSiteOne.attackDefaultDirection.x, playerItemAttack.playerSiteOne.attackDefaultDirection.z);
                HexCoordinates targetHexCoordinates = HexUtil.GetTargetHexCoordinatesByStartPointAndVector(attackMinionCellItem.nowIndex, vectorHexCoordinates);

                CardEntry defensiveMinionCellItem = gameContainerProxy.CheckHasCardEntryByGameContainerTypeAndHexCoordinates("CardBattlefield", targetHexCoordinates);

                //判断目标单元格上有没有生物
                if (defensiveMinionCellItem != null)
                {
                    //如果有生物,需要再判断是自己的生物还是对手的生物
                    if (defensiveMinionCellItem.controllerPlayerItem != attackMinionCellItem.controllerPlayerItem)
                    {
                        UtilityLog.Log("【" + attackMinionCellItem.name + "】进行攻击", LogUtType.Attack);
                        //攻击
                        effectInfoProxy.effectSysItem.showEffectNum++;
                        attackMinionCellItem.AttackTargetMinion(defensiveMinionCellItem);
                        //反击
                        effectInfoProxy.effectSysItem.showEffectNum++;
                        defensiveMinionCellItem.CounterAttackTargetMinion(attackMinionCellItem);
                    }
                }
                break;

            case EffectExecutionEvent.EFFECT_EXECUTION_SYS_LAUNCH_AN_MOVE:
                CardEntry      moveMinionCellItem       = notification.Body as CardEntry;
                PlayerItem     playerItemMove           = moveMinionCellItem.controllerPlayerItem;
                HexCoordinates vectorHexCoordinatesMove = new HexCoordinates(playerItemMove.playerSiteOne.attackDefaultDirection.x, playerItemMove.playerSiteOne.attackDefaultDirection.z);
                HexCoordinates targetMoveHexCoordinates = HexUtil.GetTargetHexCoordinatesByStartPointAndVector(moveMinionCellItem.nowIndex, vectorHexCoordinatesMove);
                //判断目标单元格是否在可移动范围内
                if (playerItemMove.CheckOneHexCanMove(targetMoveHexCoordinates))
                {
                    CardEntry moveHexCoordinatesCard = gameContainerProxy.CheckHasCardEntryByGameContainerTypeAndHexCoordinates("CardBattlefield", targetMoveHexCoordinates);
                    //判断目标单元格上有没有生物,没有生物才能移动
                    if (moveHexCoordinatesCard == null)
                    {
                        effectInfoProxy.effectSysItem.showEffectNum++;
                        moveMinionCellItem.MoveToTargetHexCoordinates(targetMoveHexCoordinates);
                    }
                }
                break;
                //case EffectExecutionEvent.EFFECT_EXECUTION_SYS_MINION_ENTER_THE_BATTLEFIELD:
                //    CardEntry enterTBFMinionCellItem = notification.Body as CardEntry;
                //    exeEffectCard = enterTBFMinionCellItem;
                //    提取待执行的卡牌效果
                //    List<EffectInfo> oneMinionEffectCardEffects = new List<EffectInfo>();
                //    遍历卡牌的效果
                //    foreach (string effectCode in exeEffectCard.effectCodeList)
                //    {
                //        EffectInfo oneEffectInfo = effectInfoProxy.GetDepthCloneEffectByName(effectCode);
                //        bool canExe = false;
                //        foreach (string impactTimeTrigger in oneEffectInfo.impactTimeTriggers) {
                //            if (impactTimeTrigger == "MyselfEnterTheBattlefield") {
                //                canExe = true;
                //                break;
                //            }
                //        }
                //        if (canExe) {
                //            设置状态
                //            oneEffectInfo.effectInfoStage = EffectInfoStage.UnStart;
                //            设置所有者,手牌操作模式,所有者是当前玩家
                //            oneEffectInfo.player = exeEffectCard.controllerPlayerItem;
                //            设置所属卡牌
                //            oneEffectInfo.cardEntry = exeEffectCard;

                //            oneMinionEffectCardEffects.Add(oneEffectInfo);
                //        }

                //    }
                //    存入效果,进行结算
                //    effectInfoProxy.IntoModeCardSettle(exeEffectCard, oneMinionEffectCardEffects);
                //    break;
            }
        }