コード例 #1
0
ファイル: Role_Protocol.cs プロジェクト: zuojiashun/src
    public void SetRoleHP(stHPChangeDataUserCmd_S cmd)
    {//
        stBuffDamage st = new stBuffDamage();

        st.changeValue = cmd.value;
        st.damagetype  = cmd.ctype;
        st.curHp       = cmd.cur_hp;
        if (cmd.obj_type == (int)GameCmd.SceneEntryType.SceneEntry_Player)
        {
            IEntity player = EntitySystem.EntityHelper.GetEntity(SceneEntryType.SceneEntry_Player, cmd.obj_id);
            if (player != null)
            {
                st.uid        = player.GetUID();
                st.entityType = (int)EntityType.EntityType_Player;

                if (cmd.max_hp != 0)
                {
                    player.SetProp((int)CreatureProp.MaxHp, (int)cmd.max_hp);
                }
                if (cmd.cur_hp != 0)
                {
                    player.SetProp((int)CreatureProp.Hp, (int)cmd.cur_hp);
                }
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.SKILLSYSTEM_SHOWBUFFDAMAGE, (object)st);
            }
        }
        else if (cmd.obj_type == (int)GameCmd.SceneEntryType.SceneEntry_NPC)
        {
            IEntity player = EntitySystem.EntityHelper.GetEntity(SceneEntryType.SceneEntry_NPC, cmd.obj_id);
            if (player != null)
            {
                st.uid        = player.GetUID();
                st.entityType = (int)EntityType.EntityType_NPC;
                if (cmd.max_hp != 0)
                {
                    player.SetProp((int)CreatureProp.MaxHp, (int)cmd.max_hp);
                }
                if (cmd.cur_hp != 0)
                {
                    player.SetProp((int)CreatureProp.Hp, (int)cmd.cur_hp);
                }
                Engine.Utility.EventEngine.Instance().DispatchEvent((int)GameEventID.SKILLSYSTEM_SHOWBUFFDAMAGE, (object)st);
            }
        }
    }
コード例 #2
0
ファイル: FlyFontDataManager.cs プロジェクト: zuojiashun/src
    public void ShowBuffDamage(stBuffDamage damage)
    {
        Client.IEntity entity = GetEntity(damage.uid);
        if (entity == null)
        {
            Engine.Utility.Log.Error("找不到实体roleid:{0}", damage.uid);
            return;
        }

        SetEntityCurHP(entity, damage.curHp);

        if (damage.uid != MainPlayerHelper.GetPlayerUID())
        {
            return;
        }

        EntityType entype = damage.entityType == (int)EntityType.EntityType_Player ? EntityType.EntityType_Player : EntityType.EntityType_NPC;

        DamageType dt = DamageType.Normal;

        if (damage.changeValue > 0)
        {
            dt = DamageType.AddHp;
        }
        if (testType != DamageType.None)
        {
            dt = testType;
        }
        if (entity != null)
        {
            if (damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Buff || damage.damagetype == (int)GameCmd.HPChangeType.HPChangeType_Imme)
            {
                FlyFont font = GetFlyFont(dt);
                if (font == null)
                {
                    return;
                }
                font.InitDamageType(dt);
                AddFlyFont(entity, entype, dt, font, damage.changeValue);
            }
        }
    }
コード例 #3
0
ファイル: FlyFontDataManager.cs プロジェクト: zuojiashun/src
    void OnEvent(int eventID, object param)
    {
        if (eventID == (int)Client.GameEventID.SKILLSYSTEM_SHOWDAMAGE)
        {
            stShowDemage st      = (stShowDemage)param;
            bool         IsMyNpc = false;//是否是其他人的宠物或者召唤物
            if ((GameCmd.SceneEntryType)st.attacktype != GameCmd.SceneEntryType.SceneEntry_Player)
            {
                IEntity attacker = EntitySystem.EntityHelper.GetEntity((GameCmd.SceneEntryType)st.attacktype, st.attackID);
                if (attacker != null)
                {
                    INPC npc = attacker as INPC;
                    if (npc != null)
                    {
                        if (npc.IsMainPlayerSlave())
                        {
                            IsMyNpc = true;
                        }
                    }
                }
            }

            uint skillid = st.skillid;
            List <GameCmd.stMultiAttackDownMagicUserCmd_S.stDefender> defenerList = st.defenerList;
            if (IsMyNpc || st.attackID == MainPlayerHelper.GetPlayerID())
            {
                //如果攻击者是自己或者自己的宠物 飘血

                for (int i = 0; i < defenerList.Count; i++)
                {
                    var        info = defenerList[i];
                    EntityType type = EntitySystem.EntityHelper.GetEntityEtype(info.byDefencerType);
                    if (info.dwDamage == 0 && info.byDamType == (uint)GameCmd.AttackType.ATTACK_TYPE_FO)
                    {
                        continue;
                    }
                    ShowDamage(info.dwDamage, info.byDamType, info.dwDefencerID, type, info.dwDefencerHP, skillid, st.attackID);
                }
            }
            else
            {
                for (int i = 0; i < defenerList.Count; i++)
                {
                    var info = defenerList[i];
                    //如果受击者是自己或者自己的宠物 飘血
                    if (info.dwDamage == 0 && info.byDamType == (uint)GameCmd.AttackType.ATTACK_TYPE_FO)
                    {
                        continue;
                    }
                    if (info.dwDefencerID != MainPlayerHelper.GetPlayerID())
                    {
                        IEntity en = EntitySystem.EntityHelper.GetEntity(info.byDefencerType, info.dwDefencerID);
                        if (en != null)
                        {
                            INPC npc = en as INPC;
                            if (npc != null)
                            {
                                if (npc.IsTrap())
                                {
                                    return;
                                }
                                if (npc.IsMainPlayerSlave())
                                {//防御者是自己的宠物
                                    EntityType type = EntitySystem.EntityHelper.GetEntityEtype(info.byDefencerType);
                                    ShowDamage(info.dwDamage, info.byDamType, info.dwDefencerID, type, info.dwDefencerHP, skillid, st.attackID);
                                }
                            }
                            else
                            {
                                //怪打人 血量同步 先不同步
                                //IPlayer otherPlayer = en as IPlayer;
                                //if(otherPlayer != null)
                                //{
                                //    SetEntityCurHP(en, info.dwDefencerHP);
                                //}
                            }
                        }
                    }
                    else
                    {//防御者是自己
                        EntityType type = EntitySystem.EntityHelper.GetEntityEtype(info.byDefencerType);
                        ShowDamage(info.dwDamage, info.byDamType, info.dwDefencerID, type, info.dwDefencerHP, skillid, st.attackID);
                    }
                }
            }
        }
        else if (eventID == (int)Client.GameEventID.SKILLSYSTEM_SHOWBUFFDAMAGE)
        {
            stBuffDamage st = (stBuffDamage)param;

            ShowBuffDamage(st);
        }
        else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_PROPUPDATE)
        {
            stPropUpdate prop = (stPropUpdate)param;
            if (MainPlayerHelper.GetPlayerUID() != prop.uid)
            {
                return;
            }
            if (prop.nPropIndex == (int)PlayerProp.Exp)
            {
                int exp = prop.newValue - prop.oldValue;
                if (exp < 0)
                {
                    return;
                }

                ShowExp(exp);
            }
        }
        else if (eventID == (int)Client.GameEventID.ENTITYSYSTEM_LEAVEMAP)
        {
            OnLowMemoryWarning();
        }
        else if (eventID == (int)GameEventID.APPLICATION_LOWMEMORY)
        {
            OnLowMemoryWarning();
        }
    }