当前位置: 首页>>代码示例>>C++>>正文


C++ CMoveShape::IsAttackAble方法代码示例

本文整理汇总了C++中CMoveShape::IsAttackAble方法的典型用法代码示例。如果您正苦于以下问题:C++ CMoveShape::IsAttackAble方法的具体用法?C++ CMoveShape::IsAttackAble怎么用?C++ CMoveShape::IsAttackAble使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CMoveShape的用法示例。


在下文中一共展示了CMoveShape::IsAttackAble方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CheckReturnPeace

bool FightObj::CheckReturnPeace()
{
    if (m_Owner->GetIsFlyToPeace() == 0)
        return false;

    long dis = Distance(m_EnterFightPos.x, m_EnterFightPos.y, m_Owner->GetTileX(),
                        m_Owner->GetTileY());

    unsigned long thisTime = timeGetTime();
    if(m_AI->HasTarget())
    {
        CMoveShape *target = m_AI->GetTarget();

        if (target == NULL || PHASEMAN.PhasePlayerFilter(target,m_Owner))
        {
            ReturnPeace();
            return true;
        }

        if(target->IsDied() ||
                !target->IsAttackAble(m_Owner) ||
                !target->IsVisible(m_Owner))
        {
            ReturnPeace();
            return true;
        }

        if(dis > m_Owner->GetBaseChaseRange())
        {
            ReturnPeace();
            return true;
        }

        if(dis > m_Owner->GetReturnRange() && thisTime > m_HurtTime)
        {
            ReturnPeace();
            return true;
        }
    }
    else if(thisTime > m_GuardTime)
    {
        ReturnPeace();
        return true;
    }

    return false;
}
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:47,代码来源:FightObj.cpp

示例2: SearchEnemy

    bool PetAI::SearchEnemy()
    {
        CPet *owner = (CPet*) m_Owner;
        CMoveShape *host = owner->GetHost();
        if(NULL == host)
        {
			LogError(AI_MODULE, "m_Owner->GetHost() error.");
            return false;
        }
        CMoveShape *target = GetTarget();

        // 当前有追踪目标
        if(target != NULL)
        {
            long dis = owner->Distance(target);
            long tracDis = owner->GetTrackRange();
            if(!target->IsDied() &&
                tracDis > dis &&
                !target->IsGod())
            {
                return true;
            }
        }

        // 寻找所在场景
        CServerRegion *region = dynamic_cast<CServerRegion*>(host->GetFather());
        if(NULL == region)
        {
            return false;
        }

        vector<CShape*> vOut;
        region->FindAroundObject(owner, TYPE_PLAYER, vOut);
        region->FindAroundObject(owner, TYPE_MONSTER, vOut);
        region->FindAroundObject(owner, TYPE_PET, vOut);

        bool ret = false;
        map<long, CMoveShape*> AroundObjs;
        long distance = 0;
        for(size_t i=0; i < vOut.size(); ++i)
        {
            target = (CMoveShape*)vOut[i];
            if(target != NULL &&
                target->IsDied() &&
                !target->IsGod() &&
                target->IsAttackAble(owner))
            {
                distance = m_Owner->Distance(target->GetTileX(), target->GetTileY());
                AroundObjs[distance] = target;
                ret = true;
            }
        }

        if(ret)		// 满足条件设置对象
        {
            map<long, CMoveShape*>::iterator itr = AroundObjs.begin();
            target = itr->second;
            SetTarget(target->GetExID(), target->GetType());
            //if(PET_TYPE_TRAP == owner->GetPetType())
            //{
            //    owner->SetActTime(0, 0);		// 避免寻敌后无法攻击
            //    owner->OnTrapSpring();
            //}
        }

        return true;
    }
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:67,代码来源:PetAI.cpp


注:本文中的CMoveShape::IsAttackAble方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。