/********************************************************************* ** 功能: 能量球运动后追逐角色 ** 输入参数: 无 ** 返回值: 无 ** 修改记录: *********************************************************************/ 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); } }
bool Scene::removeEntity(EntityID eid) { auto entity = getEntity(eid); if (!entity) { LOGE(""); return false; } if(_move->isValidAgent(entity->_control.agentNo)) { _move->delAgent(entity->_control.agentNo); entity->_control.agentNo = RVO::RVO_ERROR; } if (entity->_state.etype == ENTITY_PLAYER) { _players.erase(entity->_state.avatarID); SceneMgr::getRef().sendToWorld(SceneServerGroupStateFeedback(getSceneID(), entity->_state.groupID, SCENE_NONE)); } _entitys.erase(eid); RemoveEntityNotice notice; notice.eids.push_back(eid); broadcast(notice); onRemoveEntity(entity); return true; }
void SceneManager::pushSceneWithID( const int sceneID,const bool isFade /*=true*/ ) { if (isFade) { cocos2d::Director::getInstance()->replaceScene(cocos2d::TransitionFade::create(1.0,SceneManager::getSceneID(sceneID))); }else { cocos2d::Director::getInstance()->replaceScene(getSceneID(sceneID)); } }
bool Scene::cleanScene() { _lastEID = ServerConfig::getRef().getSceneConfig()._sceneID * 1000 + 1000; _entitys.clear(); _players.clear(); _sceneType = SCENE_TYPE_NONE; _sceneStatus = SCENE_STATUS_NONE; _lastStatusChangeTime = getFloatNowTime(); SceneMgr::getRef().refreshSceneStatusToWorld(getSceneID()); return true; }
/********************************************************************* ** 功能: 碰撞检测 ** 输入参数: 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); } }
bool Scene::loadScene(SCENE_TYPE sceneType) { if (_sceneStatus != SCENE_STATUS_NONE) { LOGE("Scene::loadScene scene status error"); return false; } _sceneType = sceneType; _sceneStatus = SCENE_STATUS_WAIT; _lastStatusChangeTime = getFloatNowTime(); _startTime = getFloatNowTime(); _endTime = getFloatNowTime() + 3600; //load map //load entitys SceneMgr::getRef().refreshSceneStatusToWorld(getSceneID()); return true; }