예제 #1
0
        public override void Update()
        {
            //全部被攻击者动画播放完以后可以可以进行一下次攻击
            bool can_next = false;

            if (m_CurAttackCard != null)
            {
                Dictionary <BattleCard, BeHitBag> .KeyCollection key_col = m_CurActionBag.behitMap.Keys;
                bool end = true;
                foreach (BattleCard card in key_col)
                {
                    if (card.InBehitAction == true)
                    {
                        end = false;
                        break;
                    }
                }
                if (end)
                {
                    m_CurAttackCard = null;
                    m_CurActionBag  = null;
                    can_next        = true;
                }
            }
            else
            {
                can_next = true;
            }

            if (can_next)
            {
                ExecuteOneAttack();
            }
        }
예제 #2
0
        private bool CanExcuteNext()
        {
            if (m_CurAttackCard == null || m_CurAttackCard.InAttackAction)
            {
                return(false);
            }

            if (!m_BattleActionBagList.ContainsKey(m_TurnCounter))
            {
                return(false);
            }

            if (m_StepCounter < m_BattleActionBagList[m_TurnCounter].Count)
            {
                ActionBag action_bag = m_BattleActionBagList[m_TurnCounter][m_StepCounter];
                if (action_bag.attackCard.InBehitAction)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                m_StepCounter = 0;
                m_TurnCounter++;
                return(CanExcuteNext());
            }
        }
예제 #3
0
        public override void OnEnter()
        {
            m_TurnCounter     = 0;
            m_StepCounter     = 0;
            m_BattleRoundData = m_Manager.GetBattlePlayer().GetBattleRoundData();
            //m_BattleActionBagList = m_Manager.GetBattlePlayer().BattleReportReader(m_BattleRoundData);
            m_CurAttackCard = null;
            m_CurActionBag  = null;
            Obj_MyselfPlayer.GetMe().reviveCount = 0;

            BattleCardManager.Instance.MakeCardInBattling();
        }
예제 #4
0
 private void ExcuteOnCommand()
 {
     if (m_BattleActionBagList.ContainsKey(m_TurnCounter))
     {
         if (m_StepCounter < m_BattleActionBagList[m_TurnCounter].Count)
         {
             ActionBag action_bag = m_BattleActionBagList[m_TurnCounter][m_StepCounter];
             m_CurAttackCard = action_bag.attackCard;
             m_CurActionBag  = action_bag;
             action_bag.attackCard.DoAttack(action_bag);
             m_StepCounter++;
         }
         else
         {
             m_StepCounter = 0;
             m_TurnCounter++;
             ExcuteOnCommand();
         }
     }
     else
     {
         m_Manager.ChangProcedure(BattleProcedureType.E_BATTLE_PROCEDURE_SHOW_TROPHY);
     }
 }
예제 #5
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);
            }
        }
예제 #6
0
        //攻击--
        public void DoAttack(ActionBag bag)
        {
            Debug.LogWarning("DoAttack(), SlotIndex: " + m_BattleSlot.SlotIndex + ", skillID = " + bag.attackBag.skillID);
            m_CurrentHp = bag.attackBag.curHp;

            //在攻击前看受击对象里面有没有反伤BUFF,如果有,把BUFF的值加上,在受击对象受击时再减去--
            foreach (KeyValuePair <BattleCard, BeHitBag> kvp in bag.behitMap)
            {
                foreach (BuffInfo buff_info in kvp.Value.behitBuffs)
                {
                    if (buff_info.buf_id == (int)BattleBuffType.E_BATTLE_BUFF_TYPE_FAN_SHANG)
                    {
                        m_CurrentHp += buff_info.buf_value;
                    }
                }
            }

            SkillBase temp_skill = null;

            if (m_SkillComm != null && bag.attackBag.skillID == m_SkillComm.SkillId)
            {
                temp_skill = m_SkillComm;
            }
            else if (m_SkillVol != null && bag.attackBag.skillID == m_SkillVol.SkillId)
            {
                temp_skill = m_SkillVol;
            }
            else if (SkillComb != null && bag.attackBag.skillID == SkillComb.SkillId)
            {
                temp_skill = SkillComb;
                Debug.Log("loverIdx = " + bag.attackBag.loverIdx);
                BattleCard lover = BattleCardManager.Instance.FindCardBySlotIndex(bag.attackBag.loverIdx);
                if (lover != null)
                {
                    ((SkillCombine)SkillComb).LoverTempID = lover.Card_Data.CardTempId;
                }
                else
                {
                    Debug.LogError("Cant find lover, lover_index = " + bag.attackBag.loverIdx + ", heti skillid = " + bag.attackBag.skillID);
                }
            }
            else
            {
                Debug.LogError("DoAttack(), card has no such skill, cardid = " + m_CardData.CardTempId + ", slot_index = " + m_BattleSlot.SlotIndex + ", skillid = " + bag.attackBag.skillID);
            }

            if (temp_skill == null)
            {
                Debug.LogError("card has no such skill, can not play !");
                return;
            }

            //先显示Buff
            UpdateBuff(bag.attackBag.attackBuffs);
            ShowBuffValue(true);

            //如果技能没有目标,返回
            if (!temp_skill.SetTarget(bag.behitMap))
            {
                Debug.Log("temp_skill.SetTarget(), return false! no target card!");
                //流血buff在攻击动作结束后结算--
                ShowBuffValue(false);

                //在出手时可能会有中毒Buff杀掉自己d--
                if (m_CurrentHp <= 0)
                {
                    OnDead();
                }

                return;
            }

            Dictionary <BattleCard, BeHitBag> .KeyCollection keyCol = bag.behitMap.Keys;
            foreach (BattleCard card in keyCol)
            {
                card.InBehitAction = true;
            }

            m_CurActionBag = bag;
            m_CurSkill     = temp_skill;
            ChangeState(CardStateType.E_CARD_STATE_ATTACK);
        }
        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);
        }