示例#1
0
        //播放 废弃--
        public void ExecuteOneAttack()
        {
            if (m_BattleRoundData == null)
            {
                Debug.Log("Execute(), m_BattleRoundData == null");
                return;
            }

            Debug.Log("DoPlayOneStep(), turnCount = " + m_TurnCounter + ", stepCount = " + m_StepCounter);

            if (m_TurnCounter < m_BattleRoundData.battleRound.battleTurns.Count)
            {
                if (m_StepCounter < m_BattleRoundData.battleRound.battleTurns[m_TurnCounter].battleSteps.Count)
                {
                    BattleStep tStep = m_BattleRoundData.battleRound.battleTurns[m_TurnCounter].battleSteps[m_StepCounter];

                    BattleCard tAttackcard = null;
                    AttackBag  attack_bag  = new AttackBag();
                    if (tStep.attacks.Count > 0)
                    {
                        StepAction tAttack = tStep.attacks[0];
                        tAttackcard = BattleCardManager.Instance.FindCardBySlotIndex(tAttack.slotIndex);
                        if (tAttackcard != null)
                        {
                            Debug.Log("Attack, slotindex: " + tAttack.slotIndex + ", CardID: " + tAttackcard.Card_Data.CardTempId + ", SkillID: " + tAttack.skillID);
                            attack_bag.skillID  = tAttack.skillID;
                            attack_bag.curHp    = tAttack.curHp;
                            attack_bag.loverIdx = tAttack.hetiIndex;
                            if (tAttack.buff != null && tAttack.buff.Count != 0)
                            {
                                foreach (BuffInfo info in tAttack.buff)
                                {
                                    attack_bag.attackBuffs.Add(info);
                                }
                            }
                        }
                        else
                        {
                            Debug.LogError("DoPlayOneStep(), can not find attack card! " + tAttack.slotIndex);
                            m_StepCounter++;
                            return;
                        }
                    }
                    else
                    {
                        Debug.LogError("DoPlayOneStep(), no attack card !");
                        m_StepCounter++;
                        return;
                    }

                    if (tStep.attacks.Count > 1)
                    {
                        Debug.LogError("DoPlayOneStep(), attack card more then one ! " + tStep.attacks.Count);
                    }

                    Dictionary <BattleCard, BeHitBag> behit_map = new Dictionary <BattleCard, BeHitBag>();
                    foreach (StepAction tBeAtt in tStep.behits)
                    {
                        BeHitBag   behit_bag    = new BeHitBag();
                        BattleCard tDefenceCard = BattleCardManager.Instance.FindCardBySlotIndex(tBeAtt.slotIndex);
                        if (tDefenceCard != null)
                        {
                            Debug.Log("Behit, slotindex: " + tBeAtt.slotIndex + ", CardID: " + tDefenceCard.Card_Data.CardTempId + ", attackHp: " + tBeAtt.attackHp);
                            behit_bag.behitValue = tBeAtt.attackHp;
                            behit_bag.curHp      = tBeAtt.curHp;
                            behit_bag.isCrit     = tBeAtt.isStorm;
                            if (tBeAtt.buff != null && tBeAtt.buff.Count != 0)
                            {
                                foreach (BuffInfo info in tBeAtt.buff)
                                {
                                    behit_bag.behitBuffs.Add(info);
                                }
                            }
                            behit_map.Add(tDefenceCard, behit_bag);
                        }
                    }

                    //send bag
                    ActionBag action_bag = new ActionBag();
                    action_bag.attackBag = attack_bag;
                    action_bag.behitMap  = behit_map;
                    m_CurAttackCard      = tAttackcard;
                    m_CurActionBag       = action_bag;
                    tAttackcard.DoAttack(action_bag);

                    m_StepCounter++;
                }
                else
                {
                    m_StepCounter = 0;
                    m_TurnCounter++;
                    ExecuteOneAttack();
                }
            }
            else
            {
                m_Manager.ChangProcedure(BattleProcedureType.E_BATTLE_PROCEDURE_SHOW_TROPHY);
            }
        }
        public Dictionary <int, List <ActionBag> > BattleReportReader(BattleRoundData round_data)
        {
            if (round_data == null)
            {
                Debug.LogError("BattleReportReader(), m_BattleRoundData == null");
                return(null);
            }
            int turn_counter = 0;

            Dictionary <int, List <ActionBag> > battle_action_dic = new Dictionary <int, List <ActionBag> >();

            foreach (BattleTurn turn in round_data.battleRound.battleTurns)
            {
                List <ActionBag> action_list = new List <ActionBag>();
                foreach (BattleStep step in turn.battleSteps)
                {
                    if (step.attacks.Count == 0)
                    {
                        Debug.LogError("BattleReportReader(), step.attacks.Count == 0");
                        continue;
                    }

                    BattleCard attack_card = BattleCardManager.Instance.FindCardBySlotIndex(step.attacks[0].slotIndex);
                    if (attack_card == null)
                    {
                        Debug.LogError("BattleReportReader(), attack_card == null");
                        continue;
                    }

                    AttackBag attack_bag = new AttackBag();
                    attack_bag.skillID     = step.attacks[0].skillID;
                    attack_bag.curHp       = step.attacks[0].curHp;
                    attack_bag.loverIdx    = step.attacks[0].hetiIndex;
                    attack_bag.attackBuffs = step.attacks[0].buff;

                    Dictionary <BattleCard, BeHitBag> behit_map = new Dictionary <BattleCard, BeHitBag>();
                    foreach (StepAction action in step.behits)
                    {
                        BattleCard behit_card = BattleCardManager.Instance.FindCardBySlotIndex(action.slotIndex);
                        if (behit_card == null)
                        {
                            Debug.LogError("BattleReportReader(), behit_card == null");
                            continue;
                        }

                        BeHitBag behit_bag = new BeHitBag();
                        behit_bag.behitValue = action.attackHp;
                        behit_bag.curHp      = action.curHp;
                        behit_bag.isCrit     = action.isStorm;
                        behit_bag.behitBuffs = action.buff;

                        behit_map.Add(behit_card, behit_bag);
                    }

                    if (behit_map.Count == 0)
                    {
                        Debug.LogError("BattleReportReader(), behit_map.Count == 0");
                        continue;
                    }

                    ActionBag action_bag = new ActionBag();
                    action_bag.attackCard = attack_card;
                    action_bag.attackBag  = attack_bag;
                    action_bag.behitMap   = behit_map;
                    action_list.Add(action_bag);
                }
                battle_action_dic.Add(turn_counter, action_list);
            }

            return(battle_action_dic);
        }