示例#1
0
    /// <summary>
    /// 是否实体顶部栏可用
    /// </summary>
    /// <param name="entity"></param>
    /// <param name="statusType"></param>
    /// <returns></returns>
    public static bool IsEntityHeadStatusTypeEnable(IEntity entity, HeadStatusType statusType)
    {
        bool enable = false;

        if (null != entity)
        {
            switch (statusType)
            {
            case HeadStatusType.Hp:
            {
                EntityHpSprite hpSp = RoleStateBarManager.GetEntityHpSpData(entity);
                if (hpSp != null)
                {
                    enable = hpSp.bShow;
                }
            }
            break;

            case HeadStatusType.Name:
            {
                enable = PlayerNameEnable;
                if (entity.GetEntityType() == EntityType.EntityType_NPC)
                {
                    INPC npc = entity as INPC;
                    enable = npc.WhetherShowHeadTips();
                }
            }
            break;

            case HeadStatusType.Clan:
            {
                uint clanIdLow  = (uint)entity.GetProp((int)CreatureProp.ClanIdLow);
                uint clanIdHigh = (uint)entity.GetProp((int)CreatureProp.ClanIdHigh);
                uint clanid     = (clanIdHigh << 16) | clanIdLow;
                enable = ClanNameEnable && (clanid != 0);

                //enable = ClanNameEnable && ((uint)entity.GetProp((int)CreatureProp.ClanId) != 0);
            }
            break;

            case HeadStatusType.Title:
            {
                enable = PlayerTitleEnable && (entity.GetEntityType() == EntityType.EntityType_Player &&
                                               (uint)entity.GetProp((int)PlayerProp.TitleId) != 0);
            }
            break;

            case HeadStatusType.Collect:
            {
            }
            break;

            case HeadStatusType.HeadMaskIcon:
            {
                enable = IsEntityHaveHeadIconMask(entity);
            }
            break;

            case HeadStatusType.TaskStatus:
            {
                if (entity.GetEntityType() == EntityType.EntityType_NPC)
                {
                    QuestTraceInfo info = null;
                    if (TryGetNPCTraceInfo(entity, out info))
                    {
                        enable = true;
                    }
                }
            }
            break;

            case HeadStatusType.CampMask:
            {
                int camp = entity.GetProp((int)Client.CreatureProp.Camp);
                if (camp == (int)GameCmd.eCamp.CF_Green || camp == (int)GameCmd.eCamp.CF_Red)
                {
                    enable = true;
                }
            }
            break;

            case HeadStatusType.BossSay:
            {
                int baseID = entity.GetProp((int)EntityProp.BaseID);
                if (baseID == DataManager.Manager <RoleStateBarManager>().GetTalkingBossID())
                {
                    enable = DataManager.Manager <RoleStateBarManager>().GetBossTalkVisible();
                }
                else
                {
                    enable = false;
                }
            }
            break;
            }
        }
        return(enable);
    }
示例#2
0
    /// <summary>
    /// 获取实体血条
    /// </summary>
    /// <param name="entity"></param>
    /// <returns></returns>
    public static EntityHpSprite GetEntityHpSpData(IEntity entity)
    {
        EntityHpSprite spriteParams = new EntityHpSprite();

        spriteParams.spriteType = UISprite.Type.Filled;
        if (entity.GetEntityType() == EntityType.EntityType_Player)
        {
            GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp);
            GameCmd.eCamp camp   = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp);
            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg);
            if (entity == MainPlayerHelper.GetMainPlayer())
            {
                spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Me);
            }
            else
            {
                if (EntityCanAttack(entity))
                {
                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Enemy);
                }
                else
                {
                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Friend);
                }
            }
            spriteParams.bShow = true;
        }
        else if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            INPC npc = entity as INPC;
            //任意NPC先给一个默认的血条
            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.NoneBg);
            spriteParams.spriteName   = GetHpSpriteName(HpSpriteType.None);
            spriteParams.bShow        = IsNeedHpSlider(entity);
            if (npc.WhetherShowHeadTips())
            {
                //是可以攻击的NPC
                if (npc.IsCanAttackNPC())
                {
                    //是不是佣兵
                    if (npc.IsMercenary())
                    {
                        spriteParams.spriteName   = GetHpSpriteName(HpSpriteType.Friend);
                        spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg);
                        spriteParams.bShow        = true;
                    }
                    else
                    {
                        if (npc.IsPet())
                        {
                            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PetBg);
                            if (npc.IsMainPlayerSlave())
                            {
                                spriteParams.spriteName = GetHpSpriteName(HpSpriteType.MyPet);
                            }
                            else
                            {
                                if (EntityCanAttack(entity))
                                {
                                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.EnemyPet);
                                }
                            }
                        }
                        else if (npc.IsSummon())
                        {
                            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.SummonBg);
                            if (npc.IsMainPlayerSlave())
                            {
                                spriteParams.spriteName = GetHpSpriteName(HpSpriteType.MySummon);
                            }
                            else
                            {
                                if (EntityCanAttack(entity))
                                {
                                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.EnemySummon);
                                }
                            }
                        }
                        else if (npc.IsMonster())
                        {
                            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.MonsterBg);
                            spriteParams.spriteName   = GetHpSpriteName(HpSpriteType.Monster);
                            spriteParams.spriteType   = UISprite.Type.Simple;
                        }
                    }
                }
            }
            else
            {
                spriteParams.bShow = false;
            }
        }
        else if (entity.GetEntityType() == EntityType.EntityTYpe_Robot)
        {
            GameCmd.eCamp mycamp = (GameCmd.eCamp)MainPlayerHelper.GetMainPlayer().GetProp((int)CreatureProp.Camp);
            GameCmd.eCamp camp   = (GameCmd.eCamp)entity.GetProp((int)CreatureProp.Camp);
            spriteParams.bgSpriteName = GetHpSpriteName(HpSpriteType.PlayerBg);
            if (entity == MainPlayerHelper.GetMainPlayer())
            {
                spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Me);
            }
            else
            {
                if (EntityCanAttack(entity))
                {
                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Enemy);
                }
                else
                {
                    spriteParams.spriteName = GetHpSpriteName(HpSpriteType.Friend);
                }
            }
            spriteParams.bShow = true;
        }

        return(spriteParams);
    }