Ejemplo n.º 1
0
        private IEnumerator PlayMsgAction(MsgAction msgAction)
        {
            //遍历所有战斗动作
            for (int i = 0; i < msgAction.battleActions.Count; ++i)
            {
                if (msgAction.battleActions[i] == null)
                {
                    UtilityHelper.LogError(string.Format("Play action error. Action is none or type is none, index = {0}", i));
                    continue;
                }

                BattleHeroAction heroAction = null;
                //一个英雄动作
                if (msgAction.battleActions[i] is BattleHeroAction)
                {
                    heroAction = (BattleHeroAction)msgAction.battleActions[i];

                    //有对应的战斗单位,且这个战斗单位已经连接了战斗单位渲染器
                    if (heroAction.actionUnit != null && heroAction.actionUnit.battleUnitRenderer != null)
                    {
                        yield return(heroAction.actionUnit.battleUnitRenderer.RunHeroAction(heroAction));
                    }
                }
            }

            UtilityHelper.Log("Play Msg Action fin");
        }
Ejemplo n.º 2
0
        //运行英雄动作
        public IEnumerator RunHeroAction(BattleHeroAction heroAction)
        {
            if (heroAction == null)
            {
                yield break;
            }

            switch (heroAction.actionType)
            {
            //进入战场
            case MsgBattleHeroActionType.EnterBattleField:
                yield return(PlayEnterBattleFieldAction(heroAction as BattleHeroEnterBattleFieldAction));

                break;

            //切换目标
            case MsgBattleHeroActionType.ChangeTarget:
                yield return(PlayChangeTargetAction(heroAction as BattleHeroChangeTargetAction));

                break;

            //移动
            case MsgBattleHeroActionType.MotionAction:
                yield return(PlayMotionAction(heroAction as BattleHeroMotionAction));

                break;

            //使用技能
            case MsgBattleHeroActionType.SkillAction:
                yield return(PlaySkillAction(heroAction as BattleHeroSkillAction));

                break;

            //角色被击败
            case MsgBattleHeroActionType.Defeated:
                yield return(PlayDefeatedAction(heroAction as BattleHerodDefeatedAction));

                break;

            //一个警告,用于调试,不应该出现这种问题
            case MsgBattleHeroActionType.Warning:
                Debug.LogWarning(heroAction.ToString());
                yield return(EGameConstL.WaitForTouchScreen);

                break;

            //等待玩家手动操作
            case MsgBattleHeroActionType.Manual:
                yield return(PlayManualAction(heroAction as BattleHeroManualAction));

                break;

            default:
                UtilityHelper.LogError("Error type of hero action:" + heroAction.actionType);
                break;
            }
            yield return(null);
        }
Ejemplo n.º 3
0
        //播放战场动作
        public IEnumerator PlayBattleByCoroutine(System.Action callback)
        {
            if (battleField == null ||
                battleField.msgAction.battleActions == null ||
                battleField.msgAction.battleActions.Count == 0)
            {
                UtilityHelper.LogError(string.Format("Play battle action failed. -> {0}", battleField.battleID));
                yield break;
            }

            UtilityHelper.Log("Play battle actions");

            //遍历所有战斗动作
            var msgAction = battleField.msgAction;

            while (battleField.currentIndex < msgAction.battleActions.Count)
            {
                if (msgAction.battleActions[battleField.currentIndex] == null)
                {
                    UtilityHelper.LogError(string.Format("Play action error. Action is none or type is none, index = {0}", battleField.currentIndex));
                    continue;
                }

                BattleHeroAction heroAction = null;
                //一个英雄动作
                if (msgAction.battleActions[battleField.currentIndex] is BattleHeroAction)
                {
                    heroAction = (BattleHeroAction)msgAction.battleActions[battleField.currentIndex];

                    //有对应的战斗单位,且这个战斗单位已经连接了战斗单位渲染器
                    if (heroAction.actionUnit != null && heroAction.actionUnit.battleUnitRenderer != null)
                    {
                        yield return(heroAction.actionUnit.battleUnitRenderer.RunHeroAction(heroAction));
                    }
                }
                ++battleField.currentIndex;
            }

            UtilityHelper.Log("Play Msg Action fin");

            if (callback != null)
            {
                callback();
            }
        }