void SkillNormalBombStep::update(float dt) { if (!_start || !_stepData || _targetRoles.size()==0) return; if (_step == 0) { for(int i=0; i<_targetRoles.size(); i++) { auto role = _targetRoles.at(i); auto player = AnimiPlayer::create(_frames, _stepData->frameDt); player->setTag(1000+i); player->start(1); player->setUserObject(role); player->setStopEvent([&](AnimiPlayer* player) { auto effect = DamageEffect::create(_stepData->_hurtHP); effect->setPosition(Point(CCRANDOM_MINUS1_1()*10, CCRANDOM_MINUS1_1()*10+60)); auto role = static_cast<BattleRole*>(player->getUserObject()); role->getNode()->addChild(effect, 10); int hp = role->getHP() + _stepData->_hurtHP; role->setHP(hp); player->removeFromParent(); }); player->setPosition(GRID_CONVER_TO_PIXEL(role->getGridIndex().x, role->getGridIndex().y)); BattleController::getInstance()->addChild(player, ZORDER_BATTLE_EFFECT); } _step ++; } else if (_step == 1) { bool over = true; for(int i=0; i<_targetRoles.size(); i++) { auto node = BattleController::getInstance()->getChildByTag(1000+i); if (node) { over = false; } } if (over) { setOver(over); _step++; } } }
Indicator(const ObjectPtr &object, SceneManipulator *sceneManipulator) : mProxy(NULL) { assert(sceneManipulator); mUserAny = Ogre::Any(); mProxy = new ObjectProxy(object); // 根据光源位置来定节点位置 Ogre::Vector3 pos = VariantCast<Ogre::Vector3>(object->getProperty("position")); mIndicatorSceneNode = sceneManipulator->getIndicatorRootSceneNode()->createChildSceneNode(pos); Real radius = 5; int rings = 16; int segments = 16; Ogre::MeshPtr sphereMesh = createCommonSphere(radius, rings, segments); Ogre::MaterialPtr material = createPureColourMaterial( Ogre::ColourValue(1, 0, 0, 0.75) ); mIndicatorEntity = sceneManipulator->getSceneManager()->createEntity(mIndicatorSceneNode->getName(), sphereMesh->getName()); //david-<< //mIndicatorEntity->setNormaliseNormals(true); //david->> mIndicatorEntity->setMaterialName(material->getName()); setUserObject(mProxy); mIndicatorSceneNode->attachObject(mIndicatorEntity); // 选择时不考虑粒子系统的包围盒,用的是指示器的包围盒 ParticleSystemObject *particleSystemObject = static_cast<ParticleSystemObject *> (object.get()); Ogre::ParticleSystem *system = particleSystemObject->getParticleSystem(); if (system) system->setQueryFlags(0); // 根据光源类型来挂接模型 showIndicator(false); }
void bimWorld::MaterialCallback::update(osg::Node* node) { if (!m_host->_MaterialSetting()->isModified()) { return; } auto state = getTopStateSet(node); if (state) { std::mutex _mutex; _mutex.lock(); //node->getOrCreateUserDataContainer()->setUserObject(NODE_CURRENT_STATESET, node->getStateSet()); node->getOrCreateUserDataContainer()->setUserObject(NODE_TEMP_STATESET, state); //node->setUserValue("now_material", state); node->setStateSet(state); _mutex.unlock(); } else { auto container = node->getOrCreateUserDataContainer(); if (container->getNumUserObjects() <= 0) { return; } auto state = static_cast<osg::StateSet*>(container->getUserObject(NODE_CURRENT_STATESET)); std::mutex _mutex; _mutex.lock(); container->setUserObject(NODE_TEMP_STATESET, NULL); node->setStateSet(NULL); node->setStateSet(state); _mutex.unlock(); } }
Indicator(const ObjectPtr &object, Ogre::SceneManager *sceneMgr, Fairy::SceneManipulator *sceneManipulator) : mProxy(NULL), mOldPos(Ogre::Vector3::ZERO) { assert(sceneMgr && sceneManipulator); mUserAny = Ogre::Any(); mProxy = new ObjectProxy(object); mSceneManipulator = sceneManipulator; mCurrentLightEntity = NULL; // 根据光源位置来定节点位置 Ogre::Vector3 pos = VariantCast<Ogre::Vector3>(object->getProperty("position")); mIndicatorSceneNode = sceneManipulator->getIndicatorRootSceneNode()->createChildSceneNode(pos); // mIndicatorSceneNode->scale(2.0,15.0,2.0); // 创建三个entity分别来代表三种光源的模型 mPointLightEntity = sceneMgr->createEntity(mIndicatorSceneNode->getName()+"point","pointLight.mesh"); mDirectionalLightEntity = sceneMgr->createEntity(mIndicatorSceneNode->getName()+"directional","directionalLight.mesh"); mDirectionalLightEntity->setQueryFlags(0); mSpotLightEntity = sceneMgr->createEntity(mIndicatorSceneNode->getName()+"spotlight","spotLight.mesh"); setUserObject(mProxy); // 根据光源类型来挂接模型 setIndicatorModel(mProxy->getObject()->getPropertyAsString("type")); // 根据光源方向来决定scenenode方向 Ogre::Vector3 &dir = VariantCast<Ogre::Vector3>(object->getProperty("direction")); setDirection(dir); showIndicator(false); }