コード例 #1
0
        a3_BagItemData SetDataFromVariant(a3_BagItemData itemData, Variant item)
        {
            itemData.summondata.id         = item["id"];
            itemData.summondata.tpid       = item["tpid"];
            itemData.summondata.level      = item["level"];
            itemData.summondata.currentexp = item["exp"];
            if (item.ContainsKey("hp"))
            {
                itemData.summondata.currenthp = item["hp"];
            }
            itemData.summondata.lifespan = item["life"];
            itemData.summondata.power    = item["combpt"];
            //itemData.summondata.grade = item["quality"];
            //itemData.summondata.isSpecial = item["type"]==2;
            //itemData.summondata.naturaltype = item["speciality"];
            //itemData.summondata.blood = item["bloodline"];
            itemData.summondata.luck = item["luckly"];
            //itemData.summondata.talent_type = item["talent_type"];
            //itemData.summondata.skillNum = item["skill_num"];
            itemData.summondata.attNatural = item["att"];
            itemData.summondata.defNatural = item["def"];
            itemData.summondata.agiNatural = item["agi"];
            itemData.summondata.conNatural = item["con"];
            itemData.summondata.star       = item["talent"];
            if (item.ContainsKey("status"))
            {
                itemData.summondata.status = item["status"];
            }
            if (itemData.summondata.status > 0)
            {
                nowShowAttackID = (uint)itemData.summondata.id;
            }
            Variant atts = item["battleAttrs"];

            itemData.summondata.maxhp              = atts["max_hp"];
            itemData.summondata.max_attack         = atts["max_attack"];
            itemData.summondata.min_attack         = atts["min_attack"];
            itemData.summondata.physics_def        = atts["physics_def"];
            itemData.summondata.magic_def          = atts["magic_def"];
            itemData.summondata.physics_dmg_red    = atts["physics_dmg_red"];
            itemData.summondata.magic_dmg_red      = atts["magic_dmg_red"];
            itemData.summondata.double_damage_rate = atts["fatal_att"];
            itemData.summondata.reflect_crit_rate  = atts["fatal_dodge"];
            itemData.summondata.fatal_damage       = atts["fatal_damage"];
            itemData.summondata.hit   = atts["hit"];
            itemData.summondata.dodge = atts["dodge"];

            if (item.ContainsKey("skills"))
            {
                Variant sks = item["skills"];
                if (itemData.summondata.skills == null)
                {
                    itemData.summondata.skills = new Dictionary <int, summonskill>();
                }
                for (int i = 0; i < sks.Count; i++)
                {
                    //itemData.summondata.skills[sks[i]["index"]] = sks[i]["skill_id"];
                    summonskill skill = new summonskill();
                    skill.skillid = sks[i]["skill_id"];
                    skill.skilllv = sks[i]["skill_lvl"];
                    itemData.summondata.skills[sks[i]["skill_id"]] = skill;
                }
            }


            if (item.ContainsKey("link_ply"))
            {
                Variant link = item["link_ply"];
                if (itemData.summondata.linkdata == null)
                {
                    itemData.summondata.linkdata = new Dictionary <int, link_data>();
                }
                float Combpt = 0;
                for (int i = 0; i < link.Count; i++)
                {
                    link_data li = new link_data();
                    li.type       = link[i]["att_type"];
                    li.per        = link[i]["att_per"];
                    li.lock_state = link[i]["lock_state"];
                    itemData.summondata.linkdata[i] = li;

                    SXML x = XMLMgr.instance.GetSXML("calculate.combpt", "att_id==" + li.type);
                    if (x != null)
                    {
                        float attvalue = (int)Math.Ceiling((A3_SummonModel.getInstance().getAttValue(itemData.summondata, li.type) * ((float)li.per / 100.00f)));
                        Combpt += (attvalue * x.getFloat("sm_per")) / 10000;
                    }
                }
                itemData.summondata.linkCombpt = (int)Combpt;
            }
            if (item.ContainsKey("att_soul"))
            {
                Variant soul = item["att_soul"];
                if (itemData.summondata.shouhun == null)
                {
                    itemData.summondata.shouhun = new Dictionary <int, summonshouhun>();
                }


                for (int i = 0; i < soul.Count; i++)
                {
                    summonshouhun sh = new summonshouhun();
                    sh.soul_type = soul[i]["soul_type"];
                    sh.lvl       = soul[i]["soul_lvl"];
                    sh.exp       = soul[i]["soul_exp"];
                    itemData.summondata.shouhun[soul[i]["soul_type"]] = sh;
                }
            }

            if (item.ContainsKey("reset_talent") && item["reset_talent"].Count > 0)
            {
                Variant reset_talent = item["reset_talent"];
                itemData.summondata.haveReset = true;
                itemData.summondata.resetluck = reset_talent["luckly"];
                itemData.summondata.resetatt  = reset_talent["att"];
                itemData.summondata.resetdef  = reset_talent["def"];
                itemData.summondata.resetagi  = reset_talent["agi"];
                itemData.summondata.resetcon  = reset_talent["con"];
            }
            else
            {
                itemData.summondata.haveReset = false;
            }

            return(itemData);
        }
コード例 #2
0
        private void SummonOP_new(Variant data)
        {
            Debug.LogError("召唤兽信息" + data.dump());
            int tp = -1;

            if (data.ContainsKey("res"))
            {
                tp = data["res"];
                if (tp < 0)
                {
                    Globle.err_output(tp);
                    return;
                }
            }
            uint    summon_id = 0;
            Variant info      = new Variant();

            switch (tp)
            {
            case 0:     //读取召唤兽列表
                info = data["summons"];
                if (info != null)
                {
                    foreach (Variant item in info._arr)
                    {
                        A3_SummonModel.getInstance().AddSummon(item);
                    }
                }
                if (data.ContainsKey("summon_on"))
                {
                    Variant so = data["summon_on"];
                    A3_SummonModel.getInstance().nowShowAttackID    = so["id"];
                    A3_SummonModel.getInstance().nowShowAttackModel = so["att_type"];
                    A3_SummonModel.getInstance().lastSummonID       = so["id"];
                }
                if (data.ContainsKey("link_list"))
                {
                    A3_SummonModel.getInstance().link_list.Clear();
                    foreach (Variant item in data["link_list"]._arr)
                    {
                        A3_SummonModel.getInstance().link_list.Add(item);
                    }
                }

                break;

            case 1:     // 获得新的召唤兽
                getNewSum = true;
                dispatchEvent(GameEvent.Create(EVENT_SHOWIDENTIFYANSWER, this, data));
                break;

            case 2:     // 资质洗练
                if (data.ContainsKey("reset_info"))
                {
                    Variant reset_info = data["reset_info"];
                    if (data.ContainsKey("summon_id"))
                    {
                        summon_id = data["summon_id"];
                        if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id))
                        {
                            var sm = A3_SummonModel.getInstance().GetSummons()[summon_id];
                            sm.summondata.haveReset = true;
                            sm.summondata.resetluck = reset_info["luckly"];
                            sm.summondata.resetatt  = reset_info["att"];
                            sm.summondata.resetdef  = reset_info["def"];
                            sm.summondata.resetagi  = reset_info["agi"];
                            sm.summondata.resetcon  = reset_info["con"];
                            A3_SummonModel.getInstance().GetSummons().Remove(summon_id);
                            A3_SummonModel.getInstance().GetSummons()[summon_id] = sm;
                        }
                    }
                    dispatchEvent(GameEvent.Create(EVENT_XILIAN, this, data));
                }

                break;

            case 3:     // 资质替换
                if (data.ContainsKey("summon"))
                {
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                    dispatchEvent(GameEvent.Create(EVENT_SAVE, this, data));
                }
                break;

            case 4:     // 兽魂强化
                if (data.ContainsKey("summon_id"))
                {
                    summon_id = data["summon_id"];
                    if (data.ContainsKey("soul_info"))
                    {
                        int type = data["soul_info"]["soul_type"];
                        int lvl  = data["soul_info"]["soul_lvl"];
                        int exp  = data["soul_info"]["soul_exp"];
                        if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id))
                        {
                            var sm = A3_SummonModel.getInstance().GetSummons()[summon_id];
                            if (sm.summondata.shouhun.ContainsKey(type))
                            {
                                summonshouhun sh = new summonshouhun();
                                sh.soul_type = type;
                                sh.lvl       = lvl;
                                sh.exp       = exp;
                                sm.summondata.shouhun[type] = sh;
                            }
                        }
                    }
                }
                else if (data.ContainsKey("summon"))
                {
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                }
                dispatchEvent(GameEvent.Create(EVENT_SHOUHUN, this, data));
                break;

            case 5:     // 喂食经验
                if (data.ContainsKey("summon_id"))
                {
                    summon_id = data["summon_id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id))
                    {
                        if (data.ContainsKey("add_exp"))
                        {
                            int addexp = data["add_exp"];
                            var sm     = A3_SummonModel.getInstance().GetSummons()[summon_id];
                            sm.summondata.currentexp = addexp;
                            A3_SummonModel.getInstance().GetSummons().Remove(summon_id);
                            A3_SummonModel.getInstance().GetSummons()[summon_id] = sm;
                        }
                    }
                }
                else if (data.ContainsKey("summon"))
                {
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                }
                dispatchEvent(GameEvent.Create(EVENT_FEEDEXP, this, data));
                break;

            case 6:     // 喂食寿命
                if (data.ContainsKey("summon_id"))
                {
                    summon_id = data["summon_id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id))
                    {
                        if (data.ContainsKey("summon_life"))
                        {
                            int lifespan = data["summon_life"];
                            var sm       = A3_SummonModel.getInstance().GetSummons()[summon_id];
                            sm.summondata.lifespan = lifespan;
                            A3_SummonModel.getInstance().GetSummons().Remove(summon_id);
                            A3_SummonModel.getInstance().GetSummons()[summon_id] = sm;
                        }
                    }
                    dispatchEvent(GameEvent.Create(EVENT_FEEDSM, this, data));
                    if (data["summon_id"] == A3_SummonModel.getInstance().nowShowAttackID || data["summon_id"] == A3_SummonModel.getInstance().lastatkID)
                    {
                        if (a3_herohead.instance)
                        {
                            a3_herohead.instance.refresh_sumbar();
                        }
                    }
                }
                break;

            case 7:     // 转移到召唤兽列表
                info = data["summon"];
                A3_SummonModel.getInstance().AddSummon(info);
                flytxt.instance.fly(ContMgr.getCont("a3_summon_chenggongzh"));
                dispatchEvent(GameEvent.Create(EVENT_INSUMMON, this, data));
                break;

            case 8:     // 查询召唤兽信息
                dispatchEvent(GameEvent.Create(EVENT_SUMINFO, this, data));
                break;

            case 9:     // 出战召唤兽
                summon_id = data["summon_id"];
                A3_SummonModel.getInstance().lastSummonID    = summon_id;
                A3_SummonModel.getInstance().nowShowAttackID = summon_id;
                if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id))
                {
                    var sd = A3_SummonModel.getInstance().GetSummons()[summon_id];
                    sd.summondata.status = 1;
                }
                flytxt.instance.fly(ContMgr.getCont("A3_SummonProxy_togo"));
                if (a3_herohead.instance)
                {
                    a3_herohead.instance.refresh_sumbar();
                }
                dispatchEvent(GameEvent.Create(EVENT_CHUZHAN, this, data));
                break;

            case 10:     // 召回召唤兽

                //休息
                uint summon_id_10 = data["summon_id"];
                A3_SummonModel.getInstance().nowShowAttackID = 0;
                if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id_10))
                {
                    var sd = A3_SummonModel.getInstance().GetSummons()[summon_id_10];
                    sd.summondata.status = 0;
                }
                if (data.ContainsKey("summon_life"))
                {
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(summon_id_10))
                    {
                        var sm    = A3_SummonModel.getInstance().GetSummons()[summon_id_10];
                        int oldsm = sm.summondata.lifespan;
                        sm.summondata.lifespan = data["summon_life"];
                        A3_SummonModel.getInstance().GetSummons().Remove(summon_id_10);
                        A3_SummonModel.getInstance().GetSummons()[summon_id_10] = sm;
                        //A3_SummonModel.getInstance().SortSummon();
                        if (oldsm > data["summon_life"] && data.ContainsKey("die_timelist"))
                        {
                            //召唤兽死亡
                            A3_SummonModel.getInstance().addSumCD((int)summon_id_10, data["die_timelist"][0]._int64 - muNetCleint.instance.CurServerTimeStamp);
                            debug.Log("time" + (data["die_timelist"][0]._int - muNetCleint.instance.CurServerTimeStamp));
                            if (a3_herohead.instance)
                            {
                                A3_SummonModel.getInstance().lastatkID = summon_id_10;
                                a3_herohead.instance.refresh_sumbar();
                                a3_herohead.instance.refresh_sumHp(0, 1);    //召唤兽出视野同步不到血量,这里强行降血条设为0
                            }
                        }
                    }
                }
                else
                {
                    //召回
                    if (a3_herohead.instance)
                    {
                        A3_SummonModel.getInstance().lastatkID = 0;  //清除出战召唤兽id缓存
                        a3_herohead.instance.refresh_sumbar();
                        a3_herohead.instance.refresh_sumHp(0, 1);    //召唤兽出视野同步不到血量,这里强行降血条设为0
                    }
                }
                if (!data.ContainsKey("summon_life") || data["summon_life"] > 0)
                {
                    flytxt.instance.fly(ContMgr.getCont("A3_SummonProxy_torest"));
                }
                dispatchEvent(GameEvent.Create(EVENT_XIUXI, this, data));
                break;

            case 11:     //设置召唤兽三种攻击模式
                break;

            case 12:     //查询分解信息

                dispatchEvent(GameEvent.Create(EVENT_FENJIEINFO, this, data));
                break;

            case 13:    //分解结果
                if (data.ContainsKey("rmv_id"))
                {
                    uint rmvid = data["rmv_id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(rmvid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(rmvid);
                    }
                }

                dispatchEvent(GameEvent.Create(EVENT_FENJIERES, this, data));
                break;

            case 14:
                if (data.ContainsKey("rmv_id"))
                {
                    uint rmvid = data["rmv_id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(rmvid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(rmvid);
                    }
                }
                if (data.ContainsKey("summon"))
                {
                    flytxt.instance.fly(ContMgr.getCont("TunshiChengGong"));
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                }
                else
                {
                    flytxt.instance.fly(ContMgr.getCont("TunshiShiBai"));
                }
                dispatchEvent(GameEvent.Create(EVENT_TUNSHI, this, data));
                break;

            case 15:    //融合
                if (data.ContainsKey("rmv_id"))
                {
                    uint rmvid = data["rmv_id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(rmvid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(rmvid);
                    }
                }
                if (data.ContainsKey("summon"))
                {
                    flytxt.instance.fly(ContMgr.getCont("RongheChengGong"));
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                }
                else
                {
                    flytxt.instance.fly(ContMgr.getCont("RongheShiBai"));
                }
                dispatchEvent(GameEvent.Create(EVENT_RONGHE, this, data));
                break;

            case 16:    //技能升级
                if (data.ContainsKey("summon"))
                {
                    info = data["summon"];
                    uint uid = info["id"];
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(uid))
                    {
                        A3_SummonModel.getInstance().GetSummons().Remove(uid);
                    }
                    A3_SummonModel.getInstance().AddSummon(info);
                    dispatchEvent(GameEvent.Create(EVENT_SKILLUP, this, data));
                }
                break;

            case 18:
                if (data.ContainsKey("summon_id"))
                {
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(data["summon_id"]))
                    {
                        var sd = A3_SummonModel.getInstance().GetSummons()[data["summon_id"]];
                        if (data.ContainsKey("link_ply"))
                        {
                            if (sd.summondata.linkdata == null)
                            {
                                sd.summondata.linkdata = new Dictionary <int, link_data>();
                            }
                            sd.summondata.linkdata.Clear();
                            Variant link = data["link_ply"];
                            for (int i = 0; i < link.Count; i++)
                            {
                                link_data li = new link_data();
                                li.type                   = link[i]["att_type"];
                                li.per                    = link[i]["att_per"];
                                li.lock_state             = link[i]["lock_state"];
                                sd.summondata.linkdata[i] = li;
                            }
                        }
                        dispatchEvent(GameEvent.Create(EVENT_REFLIANXIE, this, data));
                    }
                }
                break;

            case 17:
                if (data.ContainsKey("summon_id"))
                {
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(data["summon_id"]))
                    {
                        var sd = A3_SummonModel.getInstance().GetSummons()[data["summon_id"]];
                        if (data.ContainsKey("link_ply"))
                        {
                            if (sd.summondata.linkdata == null)
                            {
                                sd.summondata.linkdata = new Dictionary <int, link_data>();
                            }
                            sd.summondata.linkdata.Clear();
                            Variant link = data["link_ply"];
                            for (int i = 0; i < link.Count; i++)
                            {
                                link_data li = new link_data();
                                li.type                   = link[i]["att_type"];
                                li.per                    = link[i]["att_per"];
                                li.lock_state             = link[i]["lock_state"];
                                sd.summondata.linkdata[i] = li;
                            }
                        }
                        dispatchEvent(GameEvent.Create(EVENT_REFLIANXIE, this, data));
                    }
                }
                break;

            case 19:
                if (data.ContainsKey("summon_id"))
                {
                    if (A3_SummonModel.getInstance().GetSummons().ContainsKey(data["summon_id"]))
                    {
                        var sd = A3_SummonModel.getInstance().GetSummons()[data["summon_id"]];
                        if (data.ContainsKey("link_ply"))
                        {
                            float Combpt = 0;
                            if (sd.summondata.linkdata == null)
                            {
                                sd.summondata.linkdata = new Dictionary <int, link_data>();
                            }
                            sd.summondata.linkdata.Clear();
                            Variant link = data["link_ply"];
                            for (int i = 0; i < link.Count; i++)
                            {
                                link_data li = new link_data();
                                li.type                   = link[i]["att_type"];
                                li.per                    = link[i]["att_per"];
                                li.lock_state             = link[i]["lock_state"];
                                sd.summondata.linkdata[i] = li;
                                SXML x = XMLMgr.instance.GetSXML("calculate.combpt", "att_id==" + li.type);
                                if (x != null)
                                {
                                    float attvalue = (int)Math.Ceiling((A3_SummonModel.getInstance().getAttValue(sd.summondata, li.type) * ((float)li.per / 100.00f)));
                                    Combpt += (attvalue * x.getFloat("sm_per")) / 10000;
                                }
                            }
                            sd.summondata.linkCombpt = (int)Combpt;
                        }
                        dispatchEvent(GameEvent.Create(EVENT_REFLIANXIE, this, data));
                    }
                }
                break;

            case 20:
                if (data.ContainsKey("link_list"))
                {
                    A3_SummonModel.getInstance().link_list.Clear();
                    foreach (Variant item in data["link_list"]._arr)
                    {
                        A3_SummonModel.getInstance().link_list.Add(item);
                    }
                    dispatchEvent(GameEvent.Create(EVENT_LINK, this, data));
                }
                break;
            }

            List <uint> removeid = new List <uint>();

            foreach (uint id in A3_SummonModel.getInstance().link_list)
            {
                if (!A3_SummonModel.getInstance().GetSummons().ContainsKey(id))
                {
                    removeid.Add(id);
                }
            }

            foreach (uint remove in removeid)
            {
                if (A3_SummonModel.getInstance().link_list.Contains(remove))
                {
                    A3_SummonModel.getInstance().link_list.Remove(remove);
                }
            }
        }