void Monster::harmCheck(float timeSinceLastFrame) { /// 先检查地形,更新怪物信息 checkCellType(); checkMonsterIsChange(); mCheckMethod->bulletHarmCheck(mMonsterState->getBulletState(), mBulletHarmValue, mBulletHarmTime, mBlood, mSpeedPre, mSpeedCurrent, mSpeedTemp, timeSinceLastFrame); mCheckMethod->terrainHarmCheck(mMonsterState->getTerrainState(), mTerrainHarmvalue, mBlood, mSpeedPre, mSpeedCurrent, mSpeedTemp, timeSinceLastFrame); /// 状态恢复 stateRecover(); /// 判断是否死亡 //mIsDead = mCheckMethod->checkIsDead(mBlood); if (!mIsDead && mCheckMethod->checkIsDead(mBlood)) { mIsDead = true; Stage::playSound("../Media/Sound/dead.wav", false); } /// 根据地形改地图 changeMazeByTerrain(mMonsterState->getTerrainState()); /// 改变头顶血量显示 Billboard* health = mHealthHUD->getBillboard(0); float healthPer = mBlood / mMaxBlood; float healthLength = healthPer * mHealthHUD->getDefaultWidth(); health->setDimensions(healthLength, mHealthHUD->getDefaultHeight()); ColourValue maxHealthCol = ColourValue(0, 0.8f, 0); ColourValue minHealthCol = ColourValue(1, 0, 0); ColourValue currHealthCol = maxHealthCol * healthPer + minHealthCol * (1 - healthPer); health->setColour(currHealthCol); // 设置是否显示着火和冰冻 if (!mFrozenPs) mFrozenPs = (ParticleSystem*)mNode->getAttachedObject(mNode->getName() + "frozen"); if (!mBurnPs) mBurnPs = (ParticleSystem*)mNode->getAttachedObject(mNode->getName() + "burn"); if (mMonsterState->getBulletState() == "ice") { mBurnPs->setVisible(false); mFrozenPs->setVisible(true); } else if (mMonsterState->getBulletState() == "fire") { mBurnPs->setVisible(true); mFrozenPs->setVisible(false); } else { mBurnPs->setVisible(false); mFrozenPs->setVisible(false); } }
void BillboardSetComponent::createBillboard(const PonykartParsers::BillboardBlock* const block) { Billboard* bb = billboardSet->createBillboard(block->getVectorProperty("Position")); // make our billboard // set its color if it has one, and a rotation auto quatIt=block->getQuatTokens().find("colour"); if (quatIt != block->getQuatTokens().end()) bb->setColour(toColourValue(quatIt->second)); bb->setRotation(Degree(block->getFloatProperty("Rotation", 0))); auto rectQIt = block->getQuatTokens().find("texturecoords"); if (rectQIt != block->getQuatTokens().end()) bb->setTexcoordRect(rectQIt->second.x, rectQIt->second.y, rectQIt->second.z, rectQIt->second.w); // It's best to not do this unless we really need to since it makes it less efficient auto fTokens = block->getFloatTokens(); auto heightIt=fTokens.find("height"), widthIt=fTokens.find("width"); if (heightIt!=fTokens.end() && widthIt!=fTokens.end()) bb->setDimensions(widthIt->second, heightIt->second); }
void EntityEx::Create( const String& entityName, const String& meshName, const String& mtlName ) { mpSceneMgr = GetEditor()->GetSceneManager(); // create main model msEntityName = entityName; mpSceneNode = mpSceneMgr->getRootSceneNode()->createChildSceneNode(); mpEntity = mpSceneMgr->createEntity( msEntityName, meshName ); mpEntity->setUserAny( Ogre::Any(this) ); mbVisible = false; mpTipNode = static_cast<SceneNode*>(mpSceneNode->createChild()); msBillboardName = entityName + "bbinfo"; mpTipBoard = mpSceneMgr->createBillboardSet(msBillboardName); Billboard* pTip = mpTipBoard->createBillboard(Vector3(0, 50, 0)); pTip->setDimensions( 20.0f, 20.0f ); if ( mtlName != "NULL" ) { mpEntity->setMaterialName(mtlName); mpTipBoard->setMaterialName(mtlName); } }
void Projectile::onTimeStep() { Object::onTimeStep(); Billboard* billboard = billboards_->getBillboard(0); billboard->setRotation(billboard->getRotation() + Radian(0.2f)); time_ += 0.1f; float width = billboard->getOwnWidth(); float height = billboard->getOwnWidth(); if (hit_) { if (target_) node_->setPosition(target_->getPosition()); width = min(2.0f, width + 0.2f); // Grow the projectile height = min(2.0f, height + 0.2f); } else { width = 0.2f * sinf(time_) + 1.0f; // Make the projectile oscillate in size height = 0.2f * sinf(time_) + 1.0f; } billboard->setDimensions(width, height); }