Exemplo n.º 1
0
    static bool EntityCanAttack(IEntity entity)
    {
        bool canAttack = true;

        Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart;
        if (skillPart != null)
        {
            int skillerror = 0;
            canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror);
        }
        return(canAttack);
    }
Exemplo n.º 2
0
        /// <summary>
        /// 判断当前目标是否可以攻击
        /// </summary>
        /// <param name="target"></param>
        /// <returns></returns>
        private bool TryGetCurrTarget(out IEntity target)
        {
            target = null;
            if (m_ActiveCtrl == null)
            {
                return(false);
            }

            target = m_ActiveCtrl.GetCurTarget();
            if (target != null)
            {
                if (target.IsDead())
                {
                    return(false);
                }
                if (m_nTargetID != 0 && m_nTargetID != target.GetProp((int)EntityProp.BaseID))
                {
                    return(false);
                }
                int error = 0;
                return(m_skillPart.CheckCanAttackTarget(target, out error));
            }
            return(false);
        }
Exemplo n.º 3
0
 public static bool IsNeedHpSlider(Client.IEntity entity)
 {
     if (entity.GetEntityType() == EntityType.EntityType_NPC)
     {
         INPC npc = entity as INPC;
         //是可以攻击的NPC
         if (npc.IsCanAttackNPC())
         {
             Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart;
             bool canAttack = true;
             if (skillPart != null)
             {
                 int skillerror = 0;
                 canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror);
             }
             if (npc.IsPet())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsSummon())
             {
                 if (npc.IsMainPlayerSlave())
                 {
                     return(true);
                 }
                 else
                 {
                     if (canAttack)
                     {
                         return(true);
                     }
                 }
                 return(false);
             }
             else if (npc.IsMonster())
             {
                 int hp    = entity.GetProp((int)CreatureProp.Hp);
                 int maxhp = entity.GetProp((int)CreatureProp.MaxHp);
                 return(hp < maxhp);
             }
         }
         else
         {
             table.NpcDataBase npcdb = GameTableManager.Instance.GetTableItem <table.NpcDataBase>((uint)entity.GetProp((int)Client.EntityProp.BaseID));
             if (npcdb != null)
             {
                 if (npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_TRANSFER || npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_COLLECT_PLANT ||
                     npcdb.dwType == (int)GameCmd.enumNpcType.NPC_TYPE_FUNCTION)
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Exemplo n.º 4
0
    EntityHpSprite GetSpiteName(IEntity entity)
    {
        EntityHpSprite spriteParams = new EntityHpSprite();

        spriteParams.spriteType = UISprite.Type.Filled;
        bool needHp = RoleStateBarManagerOld.Instance().IsNeedHpSlider(entity);

        Client.ISkillPart skillPart = MainPlayerHelper.GetMainPlayer().GetPart(EntityPart.Skill) as Client.ISkillPart;
        bool canAttack = true;

        if (skillPart != null)
        {
            int skillerror = 0;
            canAttack = skillPart.CheckCanAttackTarget(entity, out skillerror);
        }
        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 = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg);
            if (entity == MainPlayerHelper.GetMainPlayer())
            {
                spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Me);
            }
            else
            {
                if (canAttack)
                {
                    spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Enemy);
                }
                else
                {
                    spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend);
                }
            }
            spriteParams.bShow = true;
        }
        else if (entity.GetEntityType() == EntityType.EntityType_NPC)
        {
            INPC npc = entity as INPC;
            //任意NPC先给一个默认的血条
            spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.NoneBg);
            spriteParams.spriteName   = RoleStateBarManager.GetHpSpriteName(HpSpriteType.None);
            spriteParams.bShow        = needHp;
            //是可以攻击的NPC
            if (npc.IsCanAttackNPC())
            {
                //是不是佣兵
                if (npc.IsMercenary())
                {
                    spriteParams.spriteName   = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend);
                    spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg);
                    spriteParams.bShow        = true;
                }
                else
                {
                    if (npc.IsPet())
                    {
                        spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PetBg);
                        if (npc.IsMainPlayerSlave())
                        {
                            spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MyPet);
                        }
                        else
                        {
                            if (canAttack)
                            {
                                spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.EnemyPet);
                            }
                        }
                    }
                    else if (npc.IsSummon())
                    {
                        spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.SummonBg);
                        if (npc.IsMainPlayerSlave())
                        {
                            spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MySummon);
                        }
                        else
                        {
                            if (canAttack)
                            {
                                spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.EnemySummon);
                            }
                        }
                    }
                    else if (npc.IsMonster())
                    {
                        spriteParams.bgSpriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.MonsterBg);
                        spriteParams.spriteName   = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Monster);
                        spriteParams.spriteType   = UISprite.Type.Simple;
                    }
                }
            }
        }
        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 = RoleStateBarManager.GetHpSpriteName(HpSpriteType.PlayerBg);
            if (entity == MainPlayerHelper.GetMainPlayer())
            {
                spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Me);
            }
            else
            {
                if (canAttack)
                {
                    spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Enemy);
                }
                else
                {
                    spriteParams.spriteName = RoleStateBarManager.GetHpSpriteName(HpSpriteType.Friend);
                }
            }
            spriteParams.bShow = true;
        }


        return(spriteParams);
    }