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


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

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


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

示例1: Run

    int SkillTracer::Run(BaseAI *ai)
    {
        if(timeGetTime() >= m_EndTime)
        {
            return TIMEOUT;
        }
        CMoveShape *self = ai->GetOwner();
        CServerRegion *rgn = dynamic_cast<CServerRegion*>(self->GetFather());
        CMoveShape *target = AIUtils::FindShape(rgn, m_TargetID);
        if(target == NULL)
        {
            return FAILED;
        }
#ifdef MONSTER_DIS_FLOAT
        float dis = self->RealDistanceF(target);
#else
        long dis = self->Distance(target);
#endif
        long dx = target->GetTileX();
        long dy = target->GetTileY();
        if(dis > m_SkillMaxDis)
        {
            ai->Move(dx, dy);
        }
        else if(dis < m_SkillMinDis)
        {
            long dir = GetLineDir(dx, dy, self->GetTileX(), self->GetTileY());
            ai->Move(dir);
        }
        else
        {
            return Okay;
        }
        return RUNNING;
    }
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:35,代码来源:ScriptStateImpl.cpp

示例2: Execute

	void EscapeStateNormal::Execute(BaseType::EntityType *entity)
	{
		if (entity == NULL)
		{
			LogError(AI_MODULE, "entity is null.");
			return;
		}
		MonsterAI *monsterAI = static_cast<MonsterAI*>(entity);

		// check cycle action
		AIState *cycle_action = entity->GetState(ST_CYCLE);
		CycleStateExecutor cycleExecutor;
		if(cycleExecutor.Execute(cycle_action, entity))
		{
			return ;
		}

		// check return peace
		if(monsterAI->GetFightObj().CheckReturnPeace())
		{
			return ;
		}

		CMoveShape *target = entity->GetTarget();
		if(target == NULL)
		{
			LogError(AI_MODULE, "target is null.");
			monsterAI->GetFightObj().LoseTarget();
			entity->Resume(OPER_FAILED_TIME);
		}
		else
		{
			CMoveShape *owner = entity->GetOwner();
			long dir = GetLineDir(target->GetTileX(), target->GetTileY(),
				owner->GetTileX(), owner->GetTileY());
			entity->Move(dir);
		}
	}
开发者ID:Caoxuyang,项目名称:klcommon,代码行数:38,代码来源:EscapeStateImpl.cpp

示例3: Execute

//执行
void COpDirec::Execute(CMoveShape* pShape)
{
    if (pShape == m_pParam->pUser && m_eDir!=eDir_Mouse)
    {
        return;
    }
    CMoveShape *pMoveShape = GetOpShape(pShape);
    long lX = 0,lY = 0;

    if(pMoveShape == NULL)
    {
        lX = m_pParam->nMouseX;
        lY = m_pParam->nMouseY;
        float fDir =GetRadianDir((float)m_pParam->pUser->GetTileX(),(float)m_pParam->pUser->GetTileY(),(float)lX,(float)lY);
        m_pParam->pUser->SetDir((long)fDir);
        //SendChangeDir(m_pParam->pUser);
        return;
    }

    if(m_eDir == eDir_Mouse)
    {
        lX = m_pParam->nMouseX;
        lY = m_pParam->nMouseY;
    }
    else if(m_eDir == eDir_Self)
    {
        lX = m_pParam->pUser->GetTileX();
        lY = m_pParam->pUser->GetTileY();
    }
    else if(m_eDir == eDir_Dest && pShape )//&&
    {
        lX = pShape->GetTileX();
        lY = pShape->GetTileY();
        if (m_pParam->pMouseShape)
        {
            lX = m_pParam->pMouseShape->GetTileX();
            lY = m_pParam->pMouseShape->GetTileY();
        }
    }
    if((lX !=0 || lY !=0) && pMoveShape)
    {
        float fDir =GetRadianDir((float)pMoveShape->GetTileX(),(float)pMoveShape->GetTileY(),(float)lX,(float)lY);
        pMoveShape->SetDirEx(fDir);
        //SendChangeDir(pMoveShape);
    }

}
开发者ID:,项目名称:,代码行数:48,代码来源:

示例4: AI

void CFighterPet::AI()
{
	if( m_pMaster && m_pRegion )
	{
		CMoveShape* pAimShape = m_pMaster;
		long lX = GetTileX();
		long lY = GetTileY();
		long lAimX = pAimShape->GetTileX();
		long lAimY = pAimShape->GetTileY();

		//	¸úËæÖ÷ÈËÒƶ¯
		if( abs(lX-lAimX) > 3 || abs(lY-lAimY) > 3 )
		{
			if( IsActive())
				AutoMoveAI(lAimX,lAimY);
		}
	}
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:18,代码来源:CFighterPet.cpp

示例5: AI

void CSummonPet::AI()
{
	if( m_pMaster && m_pRegion )
	{
		CMoveShape* pAimShape = m_pMaster;
		long lFightMode = PetFightAI();
		long lX = GetTileX();
		long lY = GetTileY();
		long lAimX = pAimShape->GetTileX();
		long lAimY = pAimShape->GetTileY();
		int nRet = -1;
		switch(lFightMode)
		{
		case FMR_Trace_Far:
			if( IsActive() )
			{
				long x = m_pCurAtkShape->GetPosX();
				long y = m_pCurAtkShape->GetPosY();
				nRet = AutoMoveAI(x,y);
			}
			break;
		case FMR_Trace_Near:
		case FMR_Attack:
			{
				UsePetSkill(m_lCurUseSkillPos);
			}
			break;
		case FMR_No_TARGET:
			{
				//	¸úËæÖ÷ÈËÒƶ¯
				if( abs(lX-lAimX) > 3 || abs(lY-lAimY) > 3 )
				{
					if( IsActive())
						AutoMoveAI(lAimX,lAimY);
				}
			}
			break;
		default: break;
		}
	}
}
开发者ID:xiongshaogang,项目名称:mmo-resourse,代码行数:41,代码来源:CSummonPet.cpp

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