Example #1
0
    private void LoadJsonData(string text, JsonDllType dllType)
    {
        if (string.IsNullOrEmpty(text))
        {
            return;
        }
        Profiler.BeginSample("BattleJsonTest");
        try {
            try {
                switch (dllType)
                {
                case JsonDllType.LitJson:
                    m_RoundData = LitJson.JsonMapper.ToObject <BattleRoundData>(text);
                    break;

                case JsonDllType.NewtonJson:
                    m_RoundData = Newtonsoft.Json.JsonConvert.DeserializeObject <BattleRoundData>(text);
                    break;

                case JsonDllType.fastJson:
                    m_RoundData = fastJSON.JSON.ToObject <BattleRoundData>(text);
                    break;
                }
            } catch (Exception e) {
                Debug.LogError(e.ToString());
            }
        } finally {
            Profiler.EndSample();
        }
    }
Example #2
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();
        }
        private void SetBatttleData(BattleRoundData round_data, List <LogicObject.DropBag> drop_bags)
        {
            m_BattleRoundData = round_data;

            if (m_BattleRoundData.isLastBattle)
            {
                m_RoundCounter = m_BattleRoundData.roundCount;
                int      main_id   = TableManager.GetCopydetailByID(m_BattleRoundData.missionID).Copyfather;
                MainCopy main_copy = new MainCopy(main_id);
                SubCopy  sub_copy  = new SubCopy(m_BattleRoundData.missionID);
                Obj_MyselfPlayer.GetMe().curMainCopy = main_copy;
                Obj_MyselfPlayer.GetMe().curSubcopy  = sub_copy;

                string log = "setBattleData(), isLastBattle = true, roundCount = " + m_RoundCounter;
                log += ", main_copy = " + main_id;
                log += ", sub_copy = " + m_BattleRoundData.missionID;
                Debug.Log(log);

                InitCopys();
                Obj_MyselfPlayer.GetMe().UpdateCopyList(CopyType.NORMAL);
                //记录当前小副本的大副本是否已经开启 by 王明磊
                foreach (MainCopy main in Obj_MyselfPlayer.GetMe().normalMainCopys)
                {
                    if (main.copyId == sub_copy.tblCopyDetail.Copyfather && main.copyState == CopyState.PASSED)
                    {
                        Debug.Log("Next Main Copy Already Opened");
                        Obj_MyselfPlayer.GetMe().isNextMainOpened = true;
                        break;
                    }
                }

                foreach (DropBag drop_bag in drop_bags)
                {
                    if (drop_bag.type == DropType.CARD)
                    {
                        m_BattleTopUI.GetComponent <BattleTopUI>().AddCard(1);
                        Debug.Log("Add card");
                    }
                    else if (drop_bag.type == DropType.TIEM)
                    {
                        m_BattleTopUI.GetComponent <BattleTopUI>().AddItem(1);
                        Debug.Log("Add AddItem");
                    }
                    else if (drop_bag.type == DropType.MONEY)
                    {
                        m_BattleTopUI.GetComponent <BattleTopUI>().AddMoney(drop_bag.val);
                        Debug.Log("Add AddMoney");
                    }
                }
            }
        }
 public void OnAskContinuePataBattleRet(bool isSucceed)
 {
     if (isSucceed)
     {
         Debug.Log("OnAskContinuePataBattleRet(), isSucceed = true");
         if (m_ProcedureManager.GetActiveProcedure().GetProcedureType() == BattleProcedureType.E_BATTLE_PROCEDURE_WAITING)
         {
             m_BattleRoundData = Obj_MyselfPlayer.GetMe().battleData;
             BattleCardManager.Instance.ResetCard(BattleCardType.E_BATTLE_CARD_TYPE_SELF);
             m_ProcedureManager.ChangProcedure(BattleProcedureType.E_BATTLE_PROCEDURE_CARD_FORWARD);
         }
     }
     else
     {
         Debug.LogError("OnAskContinueBattleRet(), isSucceed = false");
     }
 }
        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);
        }