Exemple #1
0
 int  findLastSkill(BattleInfoErlang info)
 {
     for (int i = info.battleSkill.Count - 1; i >= 0; i--)
     {
         if (info.battleSkill [i].skillMsg.operationType != BattleReportService.ATTR_CHANGE && info.battleSkill [i].skillMsg.operationType != BattleReportService.BUFFER_ADD &&
             info.battleSkill [i].skillMsg.operationType != BattleReportService.BUFFER_REPLACE && info.battleSkill [i].skillMsg.operationType != BattleReportService.BUFFER_REMOVE &&
             info.battleSkill [i].skillMsg.operationType != BattleReportService.BUFFER_ABILITY)
         {
             return(i);
         }
     }
     return(-1);
 }
    void loadInfoFromClip(int index)
    {
        //检测回合开始时有没剧情对话
        if (BattleManager.Instance.activeInfoIndex == 0)
        {
            BattleManager.Instance.talkSid = getTurnStartPlotSid(getClipFrame());
        }

        //战斗结束
        if (battleData.battleClip [index].isWinnerClip)
        {
            battleOver();
//]			MonoBase.print ("battle over!!!");
            return;
        }

        if (battleInfoList == null)
        {
            battleInfoList = new List <BattleInfo> ();
        }
        else
        {
            battleInfoList.Clear();
        }

        if (index >= battleData.battleClip.Count)
        {
            //Debug.LogError ("clip over index=" + index + "   battleData.battleClip.Count= " + battleData.battleClip.Count);
            return;
        }
        for (int i = 0; i < battleData.battleClip[index].battleInfo.Count; i++)
        {
            BattleInfoErlang each = battleData.battleClip [index].battleInfo [i];
            if (each.battleSkill.Count != 0)
            {
                if (index + 1 < BattleManager.battleData.battleClip.Count && BattleManager.battleData.battleClip [index + 1].isWinnerClip && i == battleData.battleClip [index].battleInfo.Count - 1)
                {
                    battleInfoList.Add(new BattleInfo(each, true));
                }
                else
                {
                    battleInfoList.Add(new BattleInfo(each, false));
                }
            }
        }
        if (battleInfoList.Count == 0)
        {
            nextClip();
        }
    }
    private void createRoundBuffer(BattleDataErlang battleData, ErlList el, int frame)
    {
        // 处理回合开始buffer
//		[{"15",{9,27003,34}},
//                                        {"5",{9,1,-258}},
//                                        {"15",{15,27003,33}},
//                                        {"5",{15,1,-266}},
//                                        {"14",{15,27003,33}}]
        //建立每一个战斗回合
        BattleClipErlang battleClip = new BattleClipErlang();

        battleClip.frame = frame;
        battleData.battleClip.Add(battleClip);
        //建立每个战斗条目
        BattleInfoErlang battleInfo = new BattleInfoErlang();

        battleClip.battleInfo.Add(battleInfo);

        BattleSkillErlang skillerlang = new BattleSkillErlang();

        battleInfo.battleSkill.Add(skillerlang);

        BattleSkillMsg msg = new BattleSkillMsg();

        skillerlang.skillMsg = msg;
        msg.operationType    = BUFFER_CHECK;

        List <BuffAttrChange>   bcs = new List <BuffAttrChange> ();
        BuffAttrChange          bc;
        List <BattleAttrChange> acs;
        BattleAttrChange        ac;
        ErlArray ea1;
        ErlArray ea2;
        string   type;       //类型
        int      length = el.Value.Length;

        for (int i = 0; i < length; i++)
        {
            ea1  = el.Value [i] as ErlArray;
            type = (ea1.Value [0] as ErlString).Value;
            if (type == BUFFER_ABILITY)              //buffer生效
            {
                bc  = new BuffAttrChange();
                ea2 = ea1.Value [1] as ErlArray;
                bc.operationType = type;
                bc.skillSID      = StringKit.toInt(ea2.Value [1].getValueString());
//				MonoBase. print("bc.skillID "+bc.skillID );
                bc.skillID = StringKit.toInt(ea2.Value [2].getValueString());
                acs        = new List <BattleAttrChange> ();        //装在效果
                do
                {
                    ea1           = el.Value [++i] as ErlArray;
                    ea2           = ea1.Value [1] as ErlArray;
                    ac            = new BattleAttrChange();
                    ac.damageType = StringKit.toInt(ea2.Value [1].getValueString());
                    ac.damage     = StringKit.toInt(ea2.Value [2].getValueString());
                    //BattleDataErlang battleDate=BattleManager.battleData;
                    BattleHpInfo info = null;
                    if (battleData.hpMap.ContainsKey(StringKit.toInt(ea2.Value [0].getValueString())))
                    {
                        info = battleData.hpMap [StringKit.toInt(ea2.Value [0].getValueString())];
                    }
                    else
                    {
                        info = new BattleHpInfo();
                        battleData.hpMap.Add(StringKit.toInt(ea2.Value [0].getValueString()), info);
                    }
                    info.hp += ac.damage;
                    acs.Add(ac);
                } while(i < length - 1 &&
                        ((el.Value[i + 1] as ErlArray).Value[0] as ErlString).Value != BUFFER_ABILITY &&
                        ((el.Value[i + 1] as ErlArray).Value[0] as ErlString).Value != BUFFER_REMOVE);
                bc.changes = acs.ToArray();
                bcs.Add(bc);
            }
            else if (type == BUFFER_REMOVE)                //移除buffer
            {
                bc  = new BuffAttrChange();
                ea2 = ea1.Value [1] as ErlArray;
                bc.operationType = type;
                bc.skillSID      = StringKit.toInt(ea2.Value [1].getValueString());
                bc.skillID       = StringKit.toInt(ea2.Value [2].getValueString());
                bcs.Add(bc);
            }
            else
            {
            }
        }
        msg.changes = bcs.ToArray();
    }
    public void createFight(BattleDataErlang battleData, ErlList el, int frame)
    {
        BattleClipErlang battleClip = new BattleClipErlang();

        battleClip.frame = frame;
        battleData.battleClip.Add(battleClip);

        //建立每个战斗条目
        BattleInfoErlang battleInfo;
        ErlList          el2;

        BattleSkillErlang skillerlang;
        BattleSkillMsg    msg;

        for (int i = 0; i < el.Value.Length; i++)
        {
            battleInfo = new BattleInfoErlang();
            battleClip.battleInfo.Add(battleInfo);
            el2 = el.Value [i] as ErlList;
            //erllist需要倒转顺序
            Array.Reverse(el2.Value);
            for (int j = 0; j < el2.Value.Length; j++)
            {
                skillerlang = new BattleSkillErlang();
                battleInfo.battleSkill.Add(skillerlang);

                msg = new BattleSkillMsg();
                skillerlang.skillMsg = msg;

                //建立条目中的战斗技能
                if (el2.Value [j] is ErlArray)
                {
                    ErlArray arr = el2.Value [j] as ErlArray;
                    //单个战斗回合具体信息
                    // MonoBehaviour.print ("report[" + i + "][" + j + "][" + k + "] is ErlArray length = " + arr.Value.Length);

                    //得到当前战斗回合指令
                    string command = (arr.Value [0] as ErlString).Value;
                    msg.operationType = command;
                    //MonoBehaviour.print ("===command=====" + command);

                    //攻击行为 xxx 使用技能 对 xxx
                    if (command == ABILITY_ATTACK)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createAbiltyAttack(msg, arr2);
                    }
                    //援护 xxx 使用 aaa援护技能 对 xxx2  本次攻击者 xxx3
                    else if (command == INTERVENE)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createIntervene(msg, arr2);
                    }
                    //改变属性 xxx 的 aaa属性 改变 bbb
                    else if (command == ATTR_CHANGE)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createAttrChange(battleData, msg, arr2);
                    }
                    //反击 xxx 使用 aaa 对 xxx2
                    else if (command == REBOUND)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createRebound(msg, arr2);
                    }
                    //急救 xxx 使用 aaa 对 xxx2
                    else if (command == FIRSTAID)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createFirstaid(msg, arr2);
                    }
                    //参与者 合击参与者
                    else if (command == PARTICIPANT)
                    {
                        //erlArray 被攻击者 编号可以是多个
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createParticipant(msg, arr2);
                    }
                    //合击 xxx对xxx合击
                    else if (command == TOGERTHER_ATTACK)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createTogertherAttack(msg, arr2);
                    }
                    //连击 xxx使用技能 aaa 对  xxx
                    else if (command == DOUBLE_ATTACK)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createDoubleAttack(msg, arr2);
                    }
                    //添加buffer xxx使用技能aaa 对xxx
                    else if (command == BUFFER_ADD)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createBufferAdd(msg, arr2);
                    }
                    //移除buffer xxx技能aaa 被移除
                    else if (command == BUFFER_REMOVE)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createBufferRemove(msg, arr2);
                    }
                    //替换buffer xxx的aaa buffer 替换成 bbb buffer
                    else if (command == BUFFER_REPLACE)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createBufferReplace(msg, arr2);
                    }
                    //buffer生效 xxx的aaa buffer 生效
                    else if (command == BUFFER_ABILITY)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        createBufferAbility(msg, arr2);
                    }
                    //剧情NPC登场
                    else if (command == ADD_PLOT_NPC)
                    {
                        createAddNPC(msg);
                    }
                    //剧情NPC退场
                    else if (command == DEL_PLOT_NPC)
                    {
                        createDelNPC(msg);
                    }
                    //对话
                    else if (command == PLOT_TALK)
                    {
                        createTalk(msg, arr.Value [1]);
                    }
                    else if (command == EFFECT_EXIT)
                    {
                        createEffectExit(msg, arr.Value [1]);
                    }
                    else if (command == FIGHTER_INFO)
                    {
                        ErlArray arr2 = arr.Value [1] as ErlArray;
                        addCard(msg, arr2);
                    }
                    else
                    {
                        //MonoBehaviour.print ("======unused ============ command = " + command);
                    }
                }
                else
                {
                    //这里如果信息结构不是ErlArray 可能是结构有所改动
                    //MonoBehaviour.print ("error  report[" + i + "][" + j + "][" + k + "] is not ErlArray  type=" + el2.Value [k]);
                }
            }
        }
    }
Exemple #5
0
    /// <summary>
    /// 初始化战斗信息片段[将战斗数据转换为战斗播放时的显示数据]
    /// </summary>
    /// <param name="info">战斗片段信息数据</param>
    /// <param name="finalInfo">是否为整场战斗的最后一次攻击</param>
    public BattleInfo(BattleInfoErlang info, bool finalInfo)
    {
        int _lastIndex = -1;

        if (SkillList == null)
        {
            SkillList = new List <SkillCtrl> ();
        }
        if (BuffList == null)
        {
            BuffList = new List <BuffCtrl> ();
        }
        //找出最后一个技能
        _lastIndex = findLastSkill(info);
        if (_lastIndex == -1)
        {
            Debug.LogError("no main skill");
            BattleManager.Instance.nextBattle();
            return;
        }
        //处理本次info的所有skill
        for (int i = 0; i < info.battleSkill.Count; i++)
        {
            BattleSkillErlang    each = info.battleSkill [i];
            List <CharacterData> _lst = new List <CharacterData> ();
            CharacterData        _user;
            CharacterData        _trigger;
            //注入使用者

            _user = BattleManager.Instance.getBattleCharacterData(each.skillMsg.userID);
            int res = createBuffCtrlList(each);
            if (res == 0)
            {
                break;
            }
            else if (res == 1)
            {
                continue;
            }
            else
            {
            }
            //以下是技能,buff已经处理干净
            SkillCtrl newSkill = new SkillCtrl();
            //标注最后一个技能
            if (i == _lastIndex)
            {
                newSkill.isOverSkill = true;
            }
            //注入目标
            if (each.skillMsg.targets != null)
            {
                foreach (int eachTarget in each.skillMsg.targets)
                {
                    CharacterData _target = BattleManager.Instance.getBattleCharacterData(eachTarget);
                    _lst.Add(_target);
                }
            }
            if (each.skillMsg.operationType == BattleReportService.INTERVENE)
            {
                //这里开始是援护
                _trigger = BattleManager.Instance.getBattleCharacterData(each.skillMsg.trigger);
                //找到对应要修改的攻击技能
                newSkill.init(each.skillMsg, _lst, _user, _trigger, lastSkill);
            }
            else if (each.skillMsg.operationType == BattleReportService.REBOUND)
            {
                //	反击
                newSkill.init(each.skillMsg, _lst, _user, _user, lastSkill);
            }
            else if (each.skillMsg.operationType == BattleReportService.DOUBLE_ATTACK)
            {
                //	连击
                each.skillMsg.skillID = 0;
                if (each.skillMsg.skillSID == 25118 || each.skillMsg.skillSID == 26118 || each.skillMsg.skillSID == 22118 || each.skillMsg.skillSID == 23118 || each.skillMsg.skillSID == 24118)
                {
                    each.skillMsg.skillSID = SkillSampleManager.SID_COMBO_ATTACKJ;
                }
                else
                {
                    each.skillMsg.skillSID = SkillSampleManager.SID_COMBO_ATTACK;
                }
                newSkill.init(each.skillMsg, _lst, _user, _user, null);
                //每个连击服务器返回统一id,所以前端用instanceID区分;
                newSkill.serverData.id = newSkill.GetHashCode();
            }
            else if (each.skillMsg.operationType == BattleReportService.PARTICIPANT)
            {
                //	参与合击
                each.skillMsg.skillSID = lastSkill.serverData.sample.sid;
                newSkill.init(each.skillMsg, _lst, lastSkill.user, lastSkill.user, lastSkill);
                GroupCombineSkill = newSkill;
            }
            else if (each.skillMsg.operationType == BattleReportService.TOGERTHER_ATTACK)
            {
                //	参与合击,合击技能自创
                each.skillMsg.skillSID = SkillSampleManager.SID_GROUP_ATTACK;
                newSkill.init(each.skillMsg, _lst, _user, GroupCombineSkill.user, null);
            }
            else if (each.skillMsg.operationType == BattleReportService.BUFFER_CHECK)
            {
                //特殊:这个是回合开始前的buff检查skill,用于已有buff的移除,或者激活
                each.skillMsg.skillSID = SkillSampleManager.SID_CHECK_BUFF;
                newSkill.init(each.skillMsg);
            }
            else if (each.skillMsg.operationType == BattleReportService.FIGHTER_INFO)
            {
                //特殊:替补上阵
                //sid = SID_ADD_CARD;
                newSkill.init(each.skillMsg, null, _user);
            }
            else if (each.skillMsg.operationType == BattleReportService.ADD_PLOT_NPC)
            {
                newSkill.init(each.skillMsg, _lst, _user);
            }
            else if (each.skillMsg.operationType == BattleReportService.DEL_PLOT_NPC)
            {
                newSkill.init(each.skillMsg, _lst, _user);
            }
            else
            {
                newSkill.init(each.skillMsg, _lst, _user);
            }
            addSkill(newSkill);
            //记录上次技能,便于下次技能是援护之类的修改目标
            //	if (each.skillMsg .operationType != BattleReportService.ATTR_CHANGE) {
            lastSkill = newSkill;
        }
        if (finalInfo)
        {
            lastSkill.isFinalSkill = true;
        }
    }