Exemplo n.º 1
0
        void on_single_damage(Variant msg)
        {
            if (GRMap.grmap_loading)
            {
                battleProxy_damage.Add(msg);
                return;
            }


            //RoleMgr._instance.onHurt(msgData);
            if (msg.ContainsKey("damages"))
            {
                List <Variant> l = msg["damages"]._arr;
                foreach (Variant v in l)
                {
                    //被攻击时记录一个时间,表里面有个时间间隔,两次攻击的时间差>=这个间隔,算脱离战斗状态(分线功能(可分线))
                    if (v["frm_iid"] == PlayerModel.getInstance().iid || v["to_iid"] == PlayerModel.getInstance().iid)
                    {
                        hurt_old_time = NetClient.instance.CurServerTimeStamp;
                    }
                    doHurt(v);
                }
            }
            if (msg.ContainsKey("link_damage"))
            {
                bool hasKilledMon = false;
                int  tuneid       = msg["rune_id"];

                List <Variant> l = msg["link_damage"]._arr;
                foreach (Variant v in l)
                {
                    uint to_iid  = v["to_iid"]._uint;
                    int  damage  = v["dmg"]._int;
                    bool isdie   = v["isdie"]._bool;//<v name="isdie" type="bool" />
                    int  hprest  = v["hprest"]._int;
                    uint frm_iid = v["frm_iid"]._uint;
                    bool stagger = false;
                    hasKilledMon |= frm_iid == PlayerModel.getInstance().iid;
                    if (v.ContainsKey("stagger"))
                    {
                        stagger = v["stagger"];
                    }
                    BaseRole toRole = RoleMgr._instance.getRole(to_iid);
                    if (toRole == null)
                    {
                        return;
                    }
                    BaseRole frm = RoleMgr._instance.getRole(frm_iid);
                    debug.Log("名字" + toRole.roleName);
                    doHurt(toRole, frm, damage, isdie, hprest, tuneid, false, stagger);

                    GameObject eff = EffMgr.getRuneEff(tuneid);
                    if (eff != null)
                    {
                        //GameObject fx_inst = GameObject.Instantiate(eff) as GameObject;
                        //GameObject.Destroy(fx_inst, 1.2f);
                        //fx_inst.transform.SetParent(toRole.m_curModel, false);

                        EffMgr.instance.addEff(frm, toRole, GameObject.Instantiate(eff) as GameObject, 0.4f);

                        GameObject fx_inst = GameObject.Instantiate(SceneTFX.m_HFX_Prefabs[1], toRole.m_curModel.position, toRole.m_curModel.rotation) as GameObject;
                        fx_inst.transform.SetParent(U3DAPI.FX_POOL_TF, false);
                        GameObject.Destroy(fx_inst, 2f);
                    }
                }
                if (hasKilledMon)
                {
                    dispatchEvent(GameEvent.Create(EVENT_SELF_KILL_MON, this, null));
                }
            }
            //if (msg.ContainsKey("holy_shield"))
            //{
            //    //剩余pvp盾值
            //    hudunModel.NowCount = msg["holy_shield"];
            //}

            if (msg.ContainsKey("random_damage"))
            {
                int tuneid = msg["rune_id"];


                List <Variant> l = msg["random_damage"]._arr;
                foreach (Variant v in l)
                {
                    uint to_iid  = v["to_iid"]._uint;
                    int  damage  = v["dmg"]._int;
                    bool isdie   = v["isdie"]._bool;//<v name="isdie" type="bool" />
                    int  hprest  = v["hprest"]._int;
                    uint frm_iid = v["frm_iid"]._uint;
                    bool stagger = false;
                    if (v.ContainsKey("stagger"))
                    {
                        stagger = v["stagger"];
                    }
                    BaseRole toRole = RoleMgr._instance.getRole(to_iid);
                    if (toRole == null)
                    {
                        return;
                    }
                    BaseRole frm = RoleMgr._instance.getRole(frm_iid);

                    doHurt(toRole, frm, damage, isdie, hprest, -1, false, stagger);
                    GameObject eff = EffMgr.getRuneEff(tuneid);
                    if (eff != null)
                    {
                        GameObject fx_inst = GameObject.Instantiate(eff) as GameObject;
                        GameObject.Destroy(fx_inst, 2f);
                        fx_inst.transform.SetParent(toRole.m_curModel, false);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void onAttchange(Variant msgData)
        {
            debug.Log("onAttchange::" + msgData.dump());
            BaseRole role = getRole(msgData["iid"]);

            if (role == null)
            {
                return;
            }

            //if (msgData.ContainsKey("hpadd") && msgData["hpadd"].ContainsKey("die") && msgData["hpadd"]["die"]._bool)
            //    role.Die(msgData);

            bool isUser = role.m_isMain;

            if (msgData.ContainsKey("speed") && role is ProfessionRole)
            {
                var pro = (role as ProfessionRole);

                pro.speed = msgData["speed"]._int;

                if (isUser)
                {
                    PlayerModel.getInstance().speed = pro.speed;
                }
            }

            uint             frm_iid = 0;
            LGAvatarGameInst frm_lc  = null;

            if (msgData.ContainsKey("hpchange"))
            {
                Variant hpchanged = msgData["hpchange"];
                int     hpchange  = hpchanged["hpchange"];
                int     curhp     = hpchanged["hp_left"];
                Variant d         = new Variant();
                if (isUser)
                {
                    PlayerModel.getInstance().modHp(curhp);
                }
                if (hpchange > 0)
                {
                    role.modHp(curhp);
                    if (isUser)
                    {
                        FightText.play(FightText.HEAL_TEXT, role.getHeadPos(), hpchange);
                    }
                    if (healEff == null)
                    {
                        healEff = GAMEAPI.ABFight_LoadPrefab("FX_comFX_fuwenFX_FX_fuwen_chuyong");
                    }
                    if (healEff != null && role is ProfessionRole)
                    {
                        GameObject fx_inst = GameObject.Instantiate(healEff) as GameObject;
                        GameObject.Destroy(fx_inst, 1f);
                        fx_inst.transform.SetParent(role.m_curModel, false);
                    }
                    if (msgData.ContainsKey("rune_ids"))
                    {
                        List <Variant> l = msgData["rune_ids"]._arr;
                        foreach (Variant rune_id in l)
                        {
                            FightText.play(FightText.ADD_IMG_TEXT, role.getHeadPos(), hpchange, false, rune_id);
                        }
                    }
                }
                else if (hpchange < 0)
                {
                    frm_iid = hpchanged["frm_iid"];
                    BaseRole frm = RoleMgr._instance.getRole(frm_iid);

                    if (msgData.ContainsKey("rune_ids"))
                    {
                        Variant rune = msgData["rune_ids"];
                        if (rune.Count > 0)
                        {
                            int            id_rune = rune[0];
                            List <Variant> l       = msgData["rune_ids"]._arr;
                            foreach (Variant rune_id in l)
                            {
                                role.onServerHurt(-hpchange, curhp, hpchanged["die"], frm, id_rune);
                            }
                        }
                    }
                }
            }

            if (msgData.ContainsKey("mpchange"))
            {
                Variant mpchanged = msgData["mpchange"];
                int     mpchange  = mpchanged["mpchange"];
                int     curmp     = mpchanged["mp_left"];
                if (isUser)
                {
                    PlayerModel.getInstance().modMp(curmp);
                }
            }
            if (msgData.ContainsKey("pk_state"))
            {
                int pkstate = msgData["pk_state"];
                switch (pkstate)
                {
                case 0:
                    role.m_ePK_Type = PK_TYPE.PK_PEACE;
                    break;

                case 1:
                    role.m_ePK_Type = PK_TYPE.PK_PKALL;
                    break;

                case 2:
                    role.m_ePK_Type = PK_TYPE.PK_TEAM;
                    break;

                case 3:
                    role.m_ePK_Type = PK_TYPE.PK_LEGION;
                    break;

                case 4:
                    role.m_ePK_Type = PK_TYPE.PK_HERO;
                    break;

                case 5:
                    role.m_ePK_Type = PK_TYPE.Pk_SPOET;
                    break;
                }
                ;
            }
            if (msgData.ContainsKey("clanid"))
            {
                role.m_unLegionID = msgData["clanid"];
            }
            if (msgData.ContainsKey("teamid"))
            {
                role.m_unTeamID = msgData["teamid"];

                if (isUser)
                {
                    PlayerModel.getInstance().teamid = role.m_unTeamID;

                    PlayerNameUIMgr.getInstance().refeshHpColor();
                }
                else
                {
                    PlayerNameUIMgr.getInstance().refeshHpColor(role);
                }
            }

            if (msgData.ContainsKey("rune_ids"))
            {
                List <Variant> l = msgData["rune_ids"]._arr;
                foreach (Variant rune_id in l)
                {
                    GameObject eff = EffMgr.getRuneEff(rune_id._int);
                    if (eff != null)
                    {
                        GameObject fx_inst = GameObject.Instantiate(eff) as GameObject;
                        GameObject.Destroy(fx_inst, 2f);
                        fx_inst.transform.SetParent(role.m_curModel, false);
                    }
                }
                //if (!msgData.ContainsKey("hpchange"))
                //{
                //    foreach (Variant rune_id in l)
                //    {
                //        FightText.play(FightText.IMG_TEXT, role.getHeadPos(), 0, false, rune_id);
                //    }
                //}
            }

            if (msgData.ContainsKey("sprite_flag"))
            {
                uint call = msgData["sprite_flag"];
                uint iid  = msgData["iid"];
                var  vv   = MonsterMgr._inst.getMonster(iid);
                if (vv != null)
                {
                    SkinnedMeshRenderer render = vv.m_curModel.FindChild("body").GetComponent <SkinnedMeshRenderer>();
                    switch (call)
                    {
                    case 0:
                        foreach (var v in render.sharedMaterials)
                        {
                            v.shader = Shader.Find("A3/A3_Char_Streamer_H");
                            v.SetColor("_RimColor", new Color(0, 0, 0, 0));
                            v.SetFloat("_RimWidth", 0f);
                        }
                        break;

                    case 1:
                        render.sharedMaterial = U3DAPI.U3DResLoad <Material>("default/monster_1021_heite_gold");
                        break;
                    }
                }
            }

            if (isUser == false)
            {
                if (msgData.ContainsKey("dress"))
                {
                    var _role = role as ProfessionRole;

                    _role.rideId = msgData.getValue("dress")._int;

                    if (msgData.getValue("mount")._uint == (uint)RIDESTATE.UP && _role != null)
                    {
                        _role.ridestate = RIDESTATE.UP;

                        if (_role.invisible == false && _role.dianjiTime == -1 && _role.isUp == false)
                        {
                            _role.ChangeRideState(true);
                        }

                        //_role.set_Ride( msgData.getValue( "dress" )._int);
                    }

                    else if (msgData.getValue("mount")._uint == ( uint )RIDESTATE.Down && _role != null)
                    {
                        _role.ridestate = RIDESTATE.Down;

                        _role.Remove_Ride();
                    }
                }
            } //其他玩家坐骑切换

            //if (msgData.ContainsKey("speed"))
            //    role.modSpeed(msgData["speed"]._int);

            //if (msgData.ContainsKey("maxhp"))
            //{
            //    int maxhp = msgData["maxhp"];
            //    role.modMaxHp(maxhp);
            //    if (isUser)
            //    {
            //        PlayerModel.getInstance().max_hp = maxhp;
            //    }
            //}

            //if (msgData.ContainsKey("maxdp"))
            //    role.modMaxDp(msgData["maxdp"]._int);

            //if (msgData.ContainsKey("in_pczone"))
            //{
            //    if (role.isMainPlayer())
            //    {
            //        if (msgData["in_pczone"]._bool)
            //        {
            //           // lgGeneral.PKStateChange(0);需要切换pk模式 lucisa
            //        }
            //        lguiMain.PczoneChange(msgData["in_pczone"]._bool);
            //    }
            //    this.in_pczone = msgData["in_pczone"]._bool;

            //}
            //if (msgData.ContainsKey("follow"))
            //{
            //    this.follow = msgData["follow"]._bool;
            //}
            //if (msgData.ContainsKey("ghost"))
            //{
            //    this.ghost = msgData["ghost"]._bool;
            //}
            //if (msgData.ContainsKey("ride_mon_id"))
            //{
            //    this.ride_mon = msgData["ride_mon_id"];//坐骑 lucisa
            //}
        }
Exemplo n.º 3
0
        public void onAttchange(Variant msgData)
        {
            debug.Log("onAttchange::" + msgData.dump());
            BaseRole role = this.getRole(msgData["iid"]);
            bool     flag = role == null;

            if (!flag)
            {
                bool isMain = role.m_isMain;
                bool flag2  = msgData.ContainsKey("hpchange");
                if (flag2)
                {
                    Variant variant  = msgData["hpchange"];
                    int     num      = variant["hpchange"];
                    int     num2     = variant["hp_left"];
                    Variant variant2 = new Variant();
                    bool    flag3    = isMain;
                    if (flag3)
                    {
                        ModelBase <PlayerModel> .getInstance().modHp(num2);
                    }
                    bool flag4 = num > 0;
                    if (flag4)
                    {
                        role.modHp(num2);
                        bool flag5 = isMain;
                        if (flag5)
                        {
                            FightText.play(FightText.HEAL_TEXT, role.getHeadPos(), num, false, -1);
                        }
                        bool flag6 = this.healEff == null;
                        if (flag6)
                        {
                            this.healEff = Resources.Load <GameObject>("FX/comFX/fuwenFX/FX_fuwen_chuyong");
                        }
                        bool flag7 = this.healEff != null && role is ProfessionRole;
                        if (flag7)
                        {
                            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.healEff);
                            UnityEngine.Object.Destroy(gameObject, 1f);
                            gameObject.transform.SetParent(role.m_curModel, false);
                        }
                        bool flag8 = msgData.ContainsKey("rune_ids");
                        if (flag8)
                        {
                            List <Variant> arr = msgData["rune_ids"]._arr;
                            foreach (Variant current in arr)
                            {
                                FightText.play(FightText.ADD_IMG_TEXT, role.getHeadPos(), num, false, current);
                            }
                        }
                    }
                    else
                    {
                        bool flag9 = num < 0;
                        if (flag9)
                        {
                            uint     iid      = variant["frm_iid"];
                            BaseRole role2    = RoleMgr._instance.getRole(iid);
                            Variant  variant3 = msgData["rune_ids"];
                            int      isCrit   = variant3[0];
                            bool     flag10   = msgData.ContainsKey("rune_ids");
                            if (flag10)
                            {
                                List <Variant> arr2 = msgData["rune_ids"]._arr;
                                foreach (Variant current2 in arr2)
                                {
                                    role.onServerHurt(-num, num2, variant["die"], role2, isCrit, false, false);
                                }
                            }
                        }
                    }
                }
                bool flag11 = msgData.ContainsKey("mpchange");
                if (flag11)
                {
                    Variant variant4 = msgData["mpchange"];
                    int     num3     = variant4["mpchange"];
                    int     mprest   = variant4["mp_left"];
                    bool    flag12   = isMain;
                    if (flag12)
                    {
                        ModelBase <PlayerModel> .getInstance().modMp(mprest);
                    }
                }
                bool flag13 = msgData.ContainsKey("pk_state");
                if (flag13)
                {
                    switch (msgData["pk_state"])
                    {
                    case 0:
                        role.m_ePK_Type = PK_TYPE.PK_PEACE;
                        break;

                    case 1:
                        role.m_ePK_Type = PK_TYPE.PK_PKALL;
                        break;

                    case 2:
                        role.m_ePK_Type = PK_TYPE.PK_TEAM;
                        break;

                    case 3:
                        role.m_ePK_Type = PK_TYPE.PK_LEGION;
                        break;

                    case 4:
                        role.m_ePK_Type = PK_TYPE.PK_HERO;
                        break;
                    }
                }
                bool flag14 = msgData.ContainsKey("clanid");
                if (flag14)
                {
                    role.m_unLegionID = msgData["clanid"];
                }
                bool flag15 = msgData.ContainsKey("teamid");
                if (flag15)
                {
                    role.m_unTeamID = msgData["teamid"];
                }
                bool flag16 = msgData.ContainsKey("rune_ids");
                if (flag16)
                {
                    List <Variant> arr3 = msgData["rune_ids"]._arr;
                    foreach (Variant current3 in arr3)
                    {
                        GameObject runeEff = EffMgr.getRuneEff(current3._int);
                        bool       flag17  = runeEff != null;
                        if (flag17)
                        {
                            GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(runeEff);
                            UnityEngine.Object.Destroy(gameObject2, 2f);
                            gameObject2.transform.SetParent(role.m_curModel, false);
                        }
                    }
                }
                bool flag18 = msgData.ContainsKey("sprite_flag");
                if (flag18)
                {
                    uint        num4    = msgData["sprite_flag"];
                    uint        iid2    = msgData["iid"];
                    MonsterRole monster = MonsterMgr._inst.getMonster(iid2);
                    bool        flag19  = monster != null;
                    if (flag19)
                    {
                        SkinnedMeshRenderer component = monster.m_curModel.FindChild("body").GetComponent <SkinnedMeshRenderer>();
                        uint num5 = num4;
                        if (num5 != 0u)
                        {
                            if (num5 == 1u)
                            {
                                component.sharedMaterial = Resources.Load <Material>("default/monster_1021_heite_gold");
                            }
                        }
                        else
                        {
                            Material[] sharedMaterials = component.sharedMaterials;
                            for (int i = 0; i < sharedMaterials.Length; i++)
                            {
                                Material material = sharedMaterials[i];
                                material.shader = Shader.Find("A3/A3_Char_Streamer_H");
                                material.SetColor("_RimColor", new Color(0f, 0f, 0f, 0f));
                                material.SetFloat("_RimWidth", 0f);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
        private void on_single_damage(Variant msg)
        {
            bool flag = msg.ContainsKey("damages");

            if (flag)
            {
                List <Variant> arr = msg["damages"]._arr;
                foreach (Variant current in arr)
                {
                    this.doHurt(current);
                }
            }
            bool flag2 = msg.ContainsKey("link_damage");

            if (flag2)
            {
                bool           flag3 = false;
                int            num   = msg["rune_id"];
                List <Variant> arr2  = msg["link_damage"]._arr;
                foreach (Variant current2 in arr2)
                {
                    uint @uint   = current2["to_iid"]._uint;
                    int  @int    = current2["dmg"]._int;
                    bool @bool   = current2["isdie"]._bool;
                    int  int2    = current2["hprest"]._int;
                    uint uint2   = current2["frm_iid"]._uint;
                    bool stagger = false;
                    flag3 |= (uint2 == ModelBase <PlayerModel> .getInstance().iid);
                    bool flag4 = current2.ContainsKey("stagger");
                    if (flag4)
                    {
                        stagger = current2["stagger"];
                    }
                    BaseRole role  = RoleMgr._instance.getRole(@uint);
                    bool     flag5 = role == null;
                    if (flag5)
                    {
                        return;
                    }
                    BaseRole role2 = RoleMgr._instance.getRole(uint2);
                    this.doHurt(role, role2, @int, @bool, int2, num, false, stagger, 0u);
                    GameObject runeEff = EffMgr.getRuneEff(num);
                    bool       flag6   = runeEff != null;
                    if (flag6)
                    {
                        EffMgr.instance.addEff(role2, role, UnityEngine.Object.Instantiate <GameObject>(runeEff), 0.4f);
                        GameObject gameObject = UnityEngine.Object.Instantiate(SceneTFX.m_HFX_Prefabs[1], role.m_curModel.position, role.m_curModel.rotation) as GameObject;
                        gameObject.transform.SetParent(U3DAPI.FX_POOL_TF, false);
                        UnityEngine.Object.Destroy(gameObject, 2f);
                    }
                }
                bool flag7 = flag3;
                if (flag7)
                {
                    base.dispatchEvent(GameEvent.Create(BattleProxy.EVENT_SELF_KILL_MON, this, null, false));
                }
            }
            bool flag8 = msg.ContainsKey("random_damage");

            if (flag8)
            {
                int            tuneid = msg["rune_id"];
                List <Variant> arr3   = msg["random_damage"]._arr;
                foreach (Variant current3 in arr3)
                {
                    uint uint3    = current3["to_iid"]._uint;
                    int  int3     = current3["dmg"]._int;
                    bool bool2    = current3["isdie"]._bool;
                    int  int4     = current3["hprest"]._int;
                    uint uint4    = current3["frm_iid"]._uint;
                    bool stagger2 = false;
                    bool flag9    = current3.ContainsKey("stagger");
                    if (flag9)
                    {
                        stagger2 = current3["stagger"];
                    }
                    BaseRole role3  = RoleMgr._instance.getRole(uint3);
                    bool     flag10 = role3 == null;
                    if (flag10)
                    {
                        break;
                    }
                    BaseRole role4 = RoleMgr._instance.getRole(uint4);
                    this.doHurt(role3, role4, int3, bool2, int4, -1, false, stagger2, 0u);
                    GameObject runeEff2 = EffMgr.getRuneEff(tuneid);
                    bool       flag11   = runeEff2 != null;
                    if (flag11)
                    {
                        GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(runeEff2);
                        UnityEngine.Object.Destroy(gameObject2, 2f);
                        gameObject2.transform.SetParent(role3.m_curModel, false);
                    }
                }
            }
        }