KBOOL Kylin::BaseAI::Tick_Radar( KFLOAT fElapsed ) { m_fScanTime += fElapsed; if (m_fScanTime > g_radar_time) { m_fScanTime = .0f; //----------------------------------------------------------- // radar // KPoint3 kPos = m_pHostChar->GetTranslate(); // kPos.y += m_pHostChar->GetEntityPtr()->getBoundingRadius(); // KPoint3 kDes = m_kDestination; // kDes.y = kPos.y; // Ogre::Ray kRay(kPos,kDes); // Ogre::Entity* pEnt = NULL; // m_bToBlock = OgreUtils::PickEntityBoundBox(kRay,&pEnt,kPos,KylinRoot::KR_SCENE_OBJ,VISIBLE_DISTANCE); // | KylinRoot::KR_NPC_MASK // if (m_bToBlock) // { // Kylin::PhyX::PhysicalSystem::GetSingletonPtr()->GetMotionSimulator()->Commit(m_pHostChar,KPoint3(m_fSpeed, 0, 0)); // // random move dir ( left or right ) // // radar // } // else { Action* pAction = m_pHostChar->GetActionDispatcher()->GetFirstActionPtr(); if (pAction) { // 若该NPC存在技能 KFLOAT fRange = m_pHostChar->GetEntityPtr()->getBoundingRadius() + pAction->GetRange(); KVEC<Ogre::Entity*> kEntities; Kylin::OgreUtils::SphereQuery(m_pHostChar->GetTranslate(),fRange,kEntities,Kylin::KylinRoot::KR_NPC_MASK); for (KUINT i = 0; i < kEntities.size(); i++) { if (!kEntities[i]->getUserAny().isEmpty()) { KUINT uID = Ogre::any_cast<KUINT>(kEntities[i]->getUserAny()); Character* pTar = BtDynamicCast(Character,KylinRoot::GetSingletonPtr()->GetEntity(uID)); if ( pTar && KylinRoot::GetSingletonPtr()->CheckRelation(pTar,m_pHostChar) == KylinRoot::RELATION_ENEMY ) { //--------------------------------------- KPoint3 kDir = pTar->GetTranslate() - m_pHostChar->GetTranslate(); kDir.y = 0; Enter_UseSkill(pAction->GetGID(),uID,pTar->GetTranslate(),kDir); return true; } } } } } } return false; }