/********************************************************************* ** 功能: 能量球运动后追逐角色 ** 输入参数: 无 ** 返回值: 无 ** 修改记录: *********************************************************************/ void EnergyBall::energyBallSearchObject() { auto roles = UserData::getInstance()->getRoles(); auto itr = roles.begin(); while (itr != roles.end()) { auto role = (Role *)(*itr); auto info = role->getRoleInfo(); if ((RoleStatus_Death == info.status) || (m_iSceneID != role->getSceneID()))/* 已阵亡或不同区域 */ { itr = roles.erase(itr); } else { itr ++; } } auto size = roles.size(); if (0 < size) { m_Role = (Role *)roles.at(ToolFunc::calcRandom(0, size - 1)); m_bCollision = true; } else /* 预览模式,销毁 */ { this->removeFromParentAndCleanup(true); } }
int AGIPRoleListRes::showInfo() { int nRetCode = E_ERROR; int32_t nResultCode = 0; int32_t nRoleCount = 0; uint32_t unRoleID = 0; char strRoleName[AGIP_ROLE_NAME_LEN + 1]; SysProtocol::showInfo(); nRetCode = getResultCode(&nResultCode); nRetCode = getRoleCount(&nRoleCount); printf("--------------------------------------------------------AGIPRoleListRes\n"); printf("Result_Code:\t%d\n", nResultCode); printf("Role_Count:\t%d\n", nRoleCount); for (int i = 0; i < nRoleCount; i++) { nRetCode = getRoleInfo(i, &unRoleID, strRoleName); strRoleName[AGIP_ROLE_NAME_LEN] = '\0'; printf("[%d]Role_ID:\t%u,\t%s\n", i, unRoleID, strRoleName); } printf("--------------------------------------------------------AGIPRoleListRes\n"); return S_SUCCESS; }
/********************************************************************* ** 功能: 碰撞检测 ** 输入参数: float dt: 延时销毁的时间 ** 返回值: 无 ** 修改记录: *********************************************************************/ void FlightProp::PropCollisionDetective(float dt) { if (NULL == _owner) /* 无施放者死亡或未设置施放者 */ { releaseCallBack(); return; } auto roles = UserData::getInstance()->getRoles(); auto rcA = this->getBoundingBox(); auto ownerInfo = _owner->getRoleInfo(); if (RoleStatus_Death == ownerInfo.status) /* 施放者死亡 */ { releaseCallBack(); return; } bool bHit = false; auto ptLoc = Point(this->getPositionX(), this->getPositionY() - m_fHeight);/* 实际坐标需扣除高度 */ this->setLocalZOrder(_owner->getLocalZOrder()); for(unsigned int index = 0;index < roles.size();index ++) /* 敌人角色遍历获取 */ { auto role = (Role *)roles[index]; auto info = role->getRoleInfo(); if ((RoleStatus_Invincible == info.status) || (RoleStatus_Death == info.status) || (ownerInfo.camp == info.camp) || (_owner->getSceneID() != role->getSceneID())) { continue; /* 无敌、同阵营、死亡或是自身不处理 */ } auto rcB = Rect(role->getPositionX() - 10, role->getPositionY() + 20, 20, 40); /* 有效区域 */ if (true == rcB.intersectsRect(rcA)) /* 碰撞 */ { auto ptOffset = role->getPosition() - ptLoc; if (m_stPropInfo.skillInfo.yAtkDis >= abs(ptOffset.y)) /* 动作有效范围判断 */ { bHit = true; role->roleHurt(_owner, m_stPropInfo.skillInfo, m_bDown); } } } if (true == bHit) { releaseWithDelay(dt); } }
unsigned TRoleManager::getModelID( unsigned roleID ) { return TResManager::getInstance().getActorModelID( getRoleInfo( roleID )->modelName.c_str() ); }