void InClassProj::DrawParticles() { XMVECTOR eyePos = m2DCam->GetPos(); XMMATRIX proj = XMLoadFloat4x4(&mProj); XMMATRIX view = m2DCam->GetView(); XMMATRIX vp = view * proj; mParticleEffect->SetPerFrameParams(eyePos); mParticleEffect->SetPerObjectParams(vp, mParticleTexture); md3dImmediateContext->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_POINTLIST); md3dImmediateContext->IASetInputLayout(Vertex::GetParticleVertLayout()); UINT stride = sizeof(Vertex::ParticleVertex); UINT offset = 0; md3dImmediateContext->IASetVertexBuffers(0, 1, &mParticleVB, &stride, &offset); md3dImmediateContext->OMSetDepthStencilState(mNoDepthDS, 0); float blendFactor[4] = { 0.0f, 0.0f, 0.0f, 0.0f }; md3dImmediateContext->OMSetBlendState(mAdditiveBS, blendFactor, 0xffffffff); D3DX11_TECHNIQUE_DESC techDesc; mParticleEffect->GetTech()->GetDesc(&techDesc); for (UINT p = 0; p < techDesc.Passes; ++p) { mParticleEffect->GetTech()->GetPassByIndex(p)->Apply(0, md3dImmediateContext); md3dImmediateContext->Draw(mParticles.size(), 0); } md3dImmediateContext->OMSetBlendState(0, blendFactor, 0xffffffff); md3dImmediateContext->OMSetDepthStencilState(NULL, 0); }
void Explosion::Set(const Vector3 position, const Color color, const float size) { Effect::Set(position); rootNode_->SetScale(size); initialMass_ = 3.0f * size; rigidBody_->SetMass(initialMass_); light_->SetColor(color); light_->SetBrightness(initialBrightness_); ParticleEffect* particleEffect = particleEmitter_->GetEffect(); Vector<ColorFrame> colorFrames; colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f)); Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_); colorFrames.Push(ColorFrame(mixColor, 0.1f)); colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f)); colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f)); particleEffect->SetColorFrames(colorFrames); sampleSource_->SetGain(Min(0.5f*size, 1.0f)); sampleSource_->Play(sample_); masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_)); SubscribeToEvent(E_POSTUPDATE, URHO3D_HANDLER(Explosion, UpdateExplosion)); }
ParticleEffect* ParticleManager::_AddEffect(const ParticleEffectDef *def, float x, float y) { if (!def) { IF_PRINT_WARNING(VIDEO_DEBUG) << "AddEffect() failed because def was NULL!" << std::endl; return 0; } if (def->_systems.empty()) { IF_PRINT_WARNING(VIDEO_DEBUG) << "AddEffect() failed because def->_systems was empty!" << std::endl; return 0; } ParticleEffect *effect = _CreateEffect(def); if (!effect) { IF_PRINT_WARNING(VIDEO_DEBUG) << "Could not create particle effect!" << std::endl; return 0; } effect->Move(x, y); _all_effects.push_back(effect); _active_effects.push_back(effect); return effect; };
bool EnergyReceiver::AcceptMessage(const Message &message) { if(message.is("DestroyFinished")) { if(message.getData() == _uid) { if(_state == ER_ACTIVATED_BREAK) { _state = ER_ACTIVATED_BREAK_FINISHFLY; } else { Assert(false); } return true; }else{ //На остальных приемниках запускаем акцентирующий эффект реакции на прилет другого приемника в лут if(!IsOrdered() && !IsActivatedByEnergy()) { ParticleEffect *eff = 0; eff = _effContUp.AddEffect("RecOnLoot"); eff->SetPos(FPoint(0.0f, 0.0f)); eff->Reset(); } return false; } } else if(message.is("JumpFinished", _uid)) { ReleaseSquares(); Match3::RunFallColumn(GetIndex().x); } else if(message.is("Start")) { if(_order) { _order->InitAppear(100.f, 100.f); } ReleaseEffects(); if(message.getData() == "from_tutorial") { _localTime = -GameSettings::gamefield[_index]->_flySquarePauseStore; }else{ _localTime = -gameInfo.getConstFloat("CRISTAL_DELAY_APPEAR_ON_RECIVER", 0.f); } ParticleEffect *eff1 = _effContDown.AddEffect("RDown"); eff1->SetPos(FPoint(0.0f, 0.0f)); _partUp = _effContUpStatic.AddEffect("RUp"); _partUp->SetPos(FPoint(0.0f, 0.0f)); _partUp->Reset(); _firstShowed = false; _lockLiveEffectShowed = false; _timeAppear = -0.2f; _timerForAppearOrder = -1.f; _state = ER_APPEAR; _hideByThief = false; } return false; }
void ParticleManager::clearParticleBank() { for (ParticleBank::iterator i = particleBank.begin(); i != particleBank.end(); i++) { ParticleEffect *e = (*i).second; if (e) { e->destroy(); delete e; } } particleBank.clear(); }
void ParticleSystem::Render(Effect * effect) { ParticleEffect *pParticleEffect = static_cast<ParticleEffect*>(effect); if(!m_finalized) { Finalize(); m_finalized = true; } pParticleEffect->SetTime(m_time); DrawParticle(indexObject, vertexObject, pixelObject, *pParticleEffect); }
void loadParticleCallback(const std::string &filename, intptr_t param) { ParticleEffect *e = new ParticleEffect(); std::string ident; int first = filename.find_last_of('/')+1; ident = filename.substr(first, filename.find_last_of('.')-first); stringToLower(ident); e->bankLoad(ident, ParticleManager::particleBankPath); particleBank[ident] = e; }
void ParticleManager::loadParticleEffectFromBank(const std::string &name, ParticleEffect *load) { std::string realName = name; stringToLower(realName); ParticleEffect *fx = particleBank[realName]; if (fx) fx->transfer(load); else { std::ostringstream os; os << "Did not find PE [" << name << "] in particle bank"; debugLog(os.str()); } }
void Draw ( ESContext *esContext ) { GLuint offset = 0; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); mySprite.Draw(); myFireEffect.Draw(); Vector4 worldPos = posLight*myCamera.calculateWorldMatrix(); glUseProgram(myShadersLighted.program); //glUniform3f(mySpriteLighted.m_shaderInfo.u_LightDirection, worldPos.x, worldPos.y, worldPos.z); glUniform3f(mySpriteLighted.m_shaderInfo.u_LightDirection, 10.0f, 10.0f, 10.0f); glUniformMatrix4fv(mySpriteLighted.m_shaderInfo.u_World, 1, false, myCamera.calculateWorldMatrix().getDataMembers()); mySpriteLighted.Draw(); eglSwapBuffers ( esContext->eglDisplay, esContext->eglSurface ); }
bool ParticleManager::AddParticleEffect(const std::string &effect_filename, float x, float y) { ParticleEffect *effect = new ParticleEffect(effect_filename); if(!effect->IsLoaded()) { PRINT_WARNING << "Failed to add effect to particle manager" << " for file: " << effect_filename << std::endl; delete effect; return false; } effect->Move(x, y); _all_effects.push_back(effect); _active_effects.push_back(effect); return true; }
void Update ( ESContext *esContext, float deltaTime ) { globalAngle += (deltaTime/2); myCamera.Update(deltaTime); mySprite.Update(deltaTime); mySpriteLighted.Update(deltaTime); myFireEffect.Update(deltaTime); }
void LockBarrierBase::InitCell() { Game::Square *cell = Game::GetValidSquare(_pos.x, _pos.y); cell->Reset(); cell->SetStone(false); cell->ice = false; cell->SetFake(true); cell->SetWall(1); cell->GetChip().Reset(true); cell->barrierIndex = 1; _effectCont.KillAllEffects(); ParticleEffect* eff = _effectCont.AddEffect("LockLive"); eff->SetPos(FPoint(0.f, LockBarrierBase::YOffset_LOCK)); eff->Reset(); eff->Update(100.f); _effectCont.Update(0.f); }
Explosion::Explosion(Context *context, MasterControl *masterControl, Vector3 position, Color color, double size): Effect(context, masterControl, position), initialMass_{static_cast<float>(3.0f*size)}, initialBrightness_{8.0f} { rootNode_->SetName("Explosion"); rootNode_->SetPosition(position); rootNode_->SetScale(size); rigidBody_ = rootNode_->CreateComponent<RigidBody>(); rigidBody_->SetMass(initialMass_); rigidBody_->SetLinearFactor(Vector3::ONE - Vector3::UP); light_ = rootNode_->CreateComponent<Light>(); light_->SetRange(13.0f); light_->SetColor(color); light_->SetBrightness(initialBrightness_); particleEmitter_ = rootNode_->CreateComponent<ParticleEmitter>(); ParticleEffect* particleEffect = masterControl_->cache_->GetResource<ParticleEffect>("Resources/Particles/Explosion.xml"); Vector<ColorFrame> colorFrames; colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f)); Color mixColor = 0.5f * (color + particleEffect->GetColorFrame(1)->color_); colorFrames.Push(ColorFrame(mixColor, 0.1f)); colorFrames.Push(ColorFrame(mixColor*0.1f, 0.35f)); colorFrames.Push(ColorFrame(Color(0.0f, 0.0f, 0.0f, 0.0f), 0.0f)); particleEffect->SetColorFrames(colorFrames); particleEmitter_->SetEffect(particleEffect); sample_ = masterControl_->cache_->GetResource<Sound>("Resources/Samples/Explode.ogg"); sample_->SetLooped(false); sampleSource_ = rootNode_->CreateComponent<SoundSource>(); sampleSource_->SetGain(Min(0.5f*size, 1.0f)); sampleSource_->SetSoundType(SOUND_EFFECT); sampleSource_->Play(sample_); masterControl_->tileMaster_->AddToAffectors(WeakPtr<Node>(rootNode_), WeakPtr<RigidBody>(rigidBody_)); SubscribeToEvent(E_POSTUPDATE, HANDLER(Explosion, UpdateExplosion)); }
void LevelEndEffect::Update(float dt) { local_time += time_scale * dt; float t = math::clamp(0.0f, 1.0f, local_time); //FPoint pos = _path.getGlobalFrame(t); float x = _pathX.getGlobalFrame(t); float y = _pathY.getGlobalFrame(t); _effect->SetPos(x, y); if( local_time > 1.0f ) { _effect->Finish(); _effect.reset(); ParticleEffect *fallEff = gameField->_effContUp.AddEffect("EndLevel_Fall"); fallEff->SetPos(320.0f, 900.0f); fallEff->Reset(); ParticleEffect *expEff = gameField->_effContUp.AddEffect("EndLevel_Explode"); expEff->SetPos(320.0f, 700.0f); expEff->Reset(); gameField->TriggerBonusesFromMoves(); } }
int Init ( ESContext *esContext ) { glClearColor ( 0.7f, 0.7f, 0.7f, 1.0f ); int result = myShaders.Init("../Resources/Shaders/TriangleShaderVS.vs", "../Resources/Shaders/TriangleShaderFS.fs"); int resultFire = myFireShader.Init("../Resources/Shaders/FireSample.vs", "../Resources/Shaders/FireSample.fs"); int resultLighted = myShadersLighted.Init("../Resources/Shaders/ModelsLighted.vs", "../Resources/Shaders/ModelsLighted.fs"); mySprite.Init("../../NewResourcesPacket/Models/Croco.nfg", myShaders.GetShaderInfo()); mySpriteLighted.Init("../../NewResourcesPacket/Models/Croco.nfg", myShadersLighted.GetShaderInfo()); //mySprite.Init("../../NewResourcesPacket/Models/Marine.nfg", myShaders.GetShaderInfo()); //mySprite.Init("../../NewResourcesPacket/Models/Woman1.nfg", myShaders.GetShaderInfo()); myFireEffect.Init("../../NewResourcesPacket/Models/fire.nfg", myFireShader.GetShaderInfo()); mySprite.SetPosition(Vector3(300, 0, 0)); mySpriteLighted.SetPosition(Vector3(-300, 0, 0)); return result&&resultFire&&resultLighted; }
bool InClassProj::Init() { if(!D3DApp::Init()) return false; //FMOD sounds result = FMOD::System_Create(&sys); result = sys->getVersion(&version); if (version < FMOD_VERSION) { OutputDebugString(L"FMOD lib version doesn't match header version"); } result = sys->init(32, FMOD_INIT_NORMAL, extradriverdata); result = sys->createSound("Sounds/choo.ogg", FMOD_DEFAULT, 0, &sound1); //fire arrow sfx (placeholder?) result = sound1->setMode(FMOD_LOOP_OFF); mLitTexEffect = new LitTexEffect(); mLitTexEffect->LoadEffect(L"FX/lighting.fx", md3dDevice); mParticleEffect = new ParticleEffect(); mParticleEffect->LoadEffect(L"FX/ParticleEffect.fx", md3dDevice); Vertex::InitLitTexLayout(md3dDevice, mLitTexEffect->GetTech()); //camera m2DCam = new BaseCamera(XMVectorSet(0.0f, 0.0f, -0.5f, 0.0f), XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f), XMVectorSet(0.0f, 1.0f, 0.0f, 0.0f)); m2DCam->Update(); BuildSceneLights(); Vertex::InitParticleVertLayout(md3dDevice, mParticleEffect->GetTech()); BuildParticleVB(); D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/TestAdditive.png", 0, 0, &mParticleTexture, 0); BuildBlendStates(); BuildDSStates(); //font ID3D11ShaderResourceView* font; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/font.png", 0, 0, &font, 0); mFont = new FontRasterizer(m2DCam, XMLoadFloat4x4(&m2DProj), mLitTexEffect, 10, 10, font, md3dDevice); //projectile image ID3D11ShaderResourceView* projImage; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/arrow.png", 0, 0, &projImage, 0); //projectile frame projectileFrame->imageWidth = 22; projectileFrame->imageHeight = 9; projectileFrame->x = 0; projectileFrame->y = 0; projectileFrame->image = projImage; projFrame.push_back(projectileFrame); //bg image Sprite::Frame* BGFrame = new Sprite::Frame(); ID3D11ShaderResourceView* BGimage; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/TFAbgTiled.png", 0, 0, &BGimage, 0); //bg frame BGFrame->imageWidth = 1024; BGFrame->imageHeight = 768; BGFrame->x = 0; BGFrame->y = 0; BGFrame->image = BGimage; std::vector<Sprite::Frame*> bgFrame; bgFrame.push_back(BGFrame); //Player spritesheet image Sprite::Frame* newFrame = new Sprite::Frame(); ID3D11ShaderResourceView* image; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/player.png", 0, 0, &image, 0); //player frame1 newFrame->imageWidth = 96; newFrame->imageHeight = 96; newFrame->x = 0; newFrame->y = 0; newFrame->image = image; std::vector<Sprite::Frame*> frames; frames.push_back(newFrame); //player frame2 newFrame = new Sprite::Frame(); newFrame->imageWidth = 96; newFrame->imageHeight = 96; newFrame->x = 32; newFrame->y = 0; newFrame->image = image; frames.push_back(newFrame); //player frame3 newFrame = new Sprite::Frame(); newFrame->imageWidth = 96; newFrame->imageHeight = 96; newFrame->x = 64; newFrame->y = 0; newFrame->image = image; frames.push_back(newFrame); //Enemy1 spritesheet image Sprite::Frame* enemyFrame1 = new Sprite::Frame(); ID3D11ShaderResourceView* enemyImage1; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/enemyStrip1.png", 0, 0, &enemyImage1, 0); //Enemy1 frame1 enemyFrame1->imageWidth = 96; enemyFrame1->imageHeight = 32; enemyFrame1->x = 0; enemyFrame1->y = 0; enemyFrame1->image = enemyImage1; std::vector<Sprite::Frame*> enemyFrames1; enemyFrames1.push_back(enemyFrame1); //Enemy1 frame2 enemyFrame1 = new Sprite::Frame(); enemyFrame1->imageWidth = 96; enemyFrame1->imageHeight = 32; enemyFrame1->x = 32; enemyFrame1->y = 0; enemyFrame1->image = enemyImage1; enemyFrames1.push_back(enemyFrame1); //Enemy1 frame3 enemyFrame1 = new Sprite::Frame(); enemyFrame1->imageWidth = 96; enemyFrame1->imageHeight = 32; enemyFrame1->x = 64; enemyFrame1->y = 0; enemyFrame1->image = enemyImage1; enemyFrames1.push_back(enemyFrame1); //Enemy2 spritesheet image Sprite::Frame* enemyFrame2 = new Sprite::Frame(); ID3D11ShaderResourceView* enemyImage2; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/enemyStrip2.png", 0, 0, &enemyImage2, 0); //Enemy2 frame1 enemyFrame2->imageWidth = 96; enemyFrame2->imageHeight = 32; enemyFrame2->x = 0; enemyFrame2->y = 0; enemyFrame2->image = enemyImage2; std::vector<Sprite::Frame*> enemyFrames2; enemyFrames2.push_back(enemyFrame2); //Enemy2 frame2 enemyFrame2 = new Sprite::Frame(); enemyFrame2->imageWidth = 96; enemyFrame2->imageHeight = 32; enemyFrame2->x = 32; enemyFrame2->y = 0; enemyFrame2->image = enemyImage2; enemyFrames2.push_back(enemyFrame2); //Enemy2 frame3 enemyFrame2 = new Sprite::Frame(); enemyFrame2->imageWidth = 96; enemyFrame2->imageHeight = 32; enemyFrame2->x = 64; enemyFrame2->y = 0; enemyFrame2->image = enemyImage2; enemyFrames2.push_back(enemyFrame2); //Enemy3 spritesheet image Sprite::Frame* enemyFrame3 = new Sprite::Frame(); ID3D11ShaderResourceView* enemyImage3; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/enemyStrip3.png", 0, 0, &enemyImage3, 0); //Enemy3 frame1 enemyFrame3->imageWidth = 96; enemyFrame3->imageHeight = 32; enemyFrame3->x = 0; enemyFrame3->y = 0; enemyFrame3->image = enemyImage3; std::vector<Sprite::Frame*> enemyFrames3; enemyFrames3.push_back(enemyFrame3); //Enemy3 frame2 enemyFrame3 = new Sprite::Frame(); enemyFrame3->imageWidth = 96; enemyFrame3->imageHeight = 32; enemyFrame3->x = 32; enemyFrame3->y = 0; enemyFrame3->image = enemyImage3; enemyFrames3.push_back(enemyFrame3); //Enemy3 frame3 enemyFrame3 = new Sprite::Frame(); enemyFrame3->imageWidth = 96; enemyFrame3->imageHeight = 32; enemyFrame3->x = 64; enemyFrame3->y = 0; enemyFrame3->image = enemyImage3; enemyFrames3.push_back(enemyFrame3); //enemy green health bar image Sprite::Frame* greenHBFrame = new Sprite::Frame(); ID3D11ShaderResourceView* greenHBimage; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/greenHealth.png", 0, 0, &greenHBimage, 0); greenHBFrame->imageWidth = 32; greenHBFrame->imageHeight = 8; greenHBFrame->x = 0; greenHBFrame->y = 0; greenHBFrame->image = greenHBimage; hbFrameG.push_back(greenHBFrame); //enemy red health bar image Sprite::Frame* redHBFrame = new Sprite::Frame(); ID3D11ShaderResourceView* redHBimage; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/redHealth.png", 0, 0, &redHBimage, 0); redHBFrame->imageWidth = 32; redHBFrame->imageHeight = 8; redHBFrame->x = 0; redHBFrame->y = 0; redHBFrame->image = redHBimage; hbFrameR.push_back(redHBFrame); //end of level object image Sprite::Frame* EOLobjFrame = new Sprite::Frame(); ID3D11ShaderResourceView* EOLobjImg; D3DX11CreateShaderResourceViewFromFile(md3dDevice, L"Textures/EOLobj.png", 0, 0, &EOLobjImg, 0); //EOLobj frame1 EOLobjFrame->imageWidth = 192; EOLobjFrame->imageHeight = 64; EOLobjFrame->x = 0; EOLobjFrame->y = 0; EOLobjFrame->image = EOLobjImg; EOLobjFrames.push_back(EOLobjFrame); //EOLobj frame2 EOLobjFrame = new Sprite::Frame(); EOLobjFrame->imageWidth = 192; EOLobjFrame->imageHeight = 64; EOLobjFrame->x = 64; EOLobjFrame->y = 0; EOLobjFrame->image = EOLobjImg; EOLobjFrames.push_back(EOLobjFrame); //EOLobj frame3 EOLobjFrame = new Sprite::Frame(); EOLobjFrame->imageWidth = 192; EOLobjFrame->imageHeight = 64; EOLobjFrame->x = 128; EOLobjFrame->y = 0; EOLobjFrame->image = EOLobjImg; EOLobjFrames.push_back(EOLobjFrame); //background mBG = new Sprite(XMVectorSet(mClientWidth / 2.0f, mClientHeight / 2.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 1024.0f, 768.0f, 1.0f, bgFrame, 0.25f, md3dDevice, 0.0f); //player mPlayer = new Player(XMVectorSet(mClientWidth / 2.0f, mClientHeight / 2.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32, 32, 0.1f, frames, 0.25f, md3dDevice, 5.0f); //enemy1 mEnemy1 = new Enemy(XMVectorSet(800.0f, 500.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32.0f, 32.0f, 0.1f, enemyFrames1, 0.25f, md3dDevice, 1.0f); enemies.push_back(mEnemy1); //enemy2 mEnemy2 = new Enemy(XMVectorSet(600.0f, 700.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32.0f, 32.0f, 0.1f, enemyFrames2, 0.25f, md3dDevice, 1.0f); enemies.push_back(mEnemy2); //enemy3 mEnemy3 = new Enemy(XMVectorSet(800, 200.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32.0f, 32.0f, 0.1f, enemyFrames3, 0.25f, md3dDevice, 1.0f); enemies.push_back(mEnemy3); //enemy health bars for (int i = 0; i < enemies.size(); ++i) { mGreenHBar = new Sprite(XMVectorSet(enemies[i]->GetPos().m128_f32[0], enemies[i]->GetPos().m128_f32[1] + 32, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32.0f, 8.0f, 1.0f, hbFrameG, 0.25f, md3dDevice, 0.0f); greenBarVec.push_back(mGreenHBar); mRedHBar = new Sprite(XMVectorSet(redXPos, enemies[i]->GetPos().m128_f32[1] + 32, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 32.0f, 8.0f, 1.0f, hbFrameR, 0.25f, md3dDevice, 0.0f); redBarVec.push_back(mRedHBar); } //end of level object EOLobj = new Sprite(XMVectorSet(mClientWidth / 2.0f, mClientHeight - 64.0f, 0.0f, 0.0f), XMVectorSet(1.0f, 1.0f, 1.0f, 0.0f), 64.0f, 64.0f, 1.0f, EOLobjFrames, 0.25f, md3dDevice, 0.0f); mPlayer->Play(true); for (int i = 0; i < enemies.size(); ++i) { enemies[i]->Play(true); } //result = sys->playSound(sound1, 0, false, &channel); InitBoundingBoxes(); return true; }
void EnergyReceiver::Update(float dt) { if( _state == ER_INIT || !GameSettings::gamefield[_index]->IsFlyType(Game::Square::FLY_STAY)) { return; } _localTime += dt; if(_localTime < 0) { return; } _fly_offset_y = 6.0f * math::sin(_localTime * 1.2f); float t = math::clamp(0.f, 1.f, _timeAppear); float ampl = math::clamp(0.f, 1.f, (1.f - _timeAppear/4.f)); ampl = 60.0f * ampl * ampl; //Очень быстрое затухание _fly_offset_y += -40.f * (1.0f - t) + ampl * math::sin(_timeAppear*math::PI - math::PI*0.5f); _fly_offset_y *= GameSettings::SQUARE_SCALE; if(_hideByThief) { if(_hideByThiefTime < 0) { _hideByThiefTime += dt; } else if(_hideByThiefTime < 1) { _hideByThiefTime += dt*1.5f; if(_hideByThiefTime >= 1) { _hideByThiefTime = 1.F; } } } if(_firstShowed) { if(_timeAppear < 0) { _timeAppear += dt; } else { _timeAppear += dt*1.5f; } if(_timeAppear >= 1.f && _state == ER_APPEAR) { //_timeAppear = 1.f; _state = ER_STAND; } } if(!_firstShowed && Game::activeRect.Inflated(1).Contains(GetIndex())) { _firstShowed = true; //Акцентирующий эффект при первом появлении на экране ParticleEffect *eff2 = 0; if(IsOrdered()) { eff2 = _effectCellCont.AddEffect("RecStartAccentLock"); } else { eff2 = _effectCellCont.AddEffect("RecStartAccent"); } eff2->SetPos(FPoint(0.0f, 0.0f)); eff2->Reset(); MM::manager.PlaySample("ReceiverShow"); _timerForAppearOrder = gameInfo.getConstFloat("ShowOrderOnRecDelay", 3.f); } if(!IsOrdered()) { _timerForAppearOrder = 0.f; } else if(_timerForAppearOrder > -1) { if(_timerForAppearOrder > 0) { _timerForAppearOrder -= dt; }else{ _timerForAppearOrder -= dt*7.f; } if(_timerForAppearOrder <= 0.5f) { if(IsOrdered() && !_lockLiveEffectShowed) { ParticleEffect* eff = _effectCellCont.AddEffect("LockLive"); eff->SetPos(FPoint(0.f, LockBarrierBase::YOffset_LOCK)); eff->Reset(); _effectCellCont.Update(0.f); _order->InitAppear(0.8f, 0.7f); _lockLiveEffectShowed = true; MM::manager.PlaySample("ReceiverOrderAppear"); } } if(_timerForAppearOrder < -1) { _timerForAppearOrder = -1; } } if(_order) { _order->Update(dt); if(!IsOrdered()) //Все больше не залочены { SetOrder(Game::Order::HardPtr()); Energy::field.UpdateSquare(Game::FieldAddress(GetIndex())); _effectCellCont.KillAllEffects(); Game::AddController(new FlashAnimationPlayer(Game::ANIM_RESOURCES["LockBreak"], FPoint(GetIndex())*GameSettings::SQUARE_SIDEF + FPoint(0.f, LockBarrierBase::YOffset_LOCK), FlashAnimationPlayer::DRAW_UP)); MM::manager.PlaySample("ReceiverOrderComplete"); } } _effectCellCont.Update(dt); _effContUpStatic.Update(dt); _effContUp.Update(dt); _effContDown.Update(dt); if(_crystalAnim.get()) { if(_state == ER_STAND) { _crystalAnim->Update(dt*_crystalTimeScale); }else if(_state == ER_ACTIVATED_BREAK){ Receiver::ReceiverEffect::keep_camera = true; //_crystalTime += dt*_crystalTimeScale; //if(_crystalTime >= 1) //{ // _crystalTime = 1.f; // _crystalAnim.reset(); // Game::AddController(new Receiver::ReceiverEffect(FPoint(GetIndex())*GameSettings::SQUARE_SIDEF + FPoint(0.f, _fly_offset_y * GameSettings::SQUARE_SCALE), _uid)); // ParticleEffectPtr eff = Game::AddEffect(GameField::Get()->_effCont, "RecBreak"); // eff->SetPos(GetCenterPos()); // eff->Reset(); // ParticleEffectPtr eff2 = Game::AddEffect(GameField::Get()->_effTopCont, "RecBreak_2"); // eff2->SetPos(GetCenterPos()); // eff2->Reset(); //}else{ // int frames_count = _crystalAnim->GetLastPlayedFrame() - _crystalAnim->GetFirstPlayedFrame(); // float t = math::ease(_crystalTime, 0.f, 1.f); // int frame = _crystalAnim->GetFirstPlayedFrame() + (math::lerp(_frame1, _frame2, t) % frames_count); // _crystalAnim->SetCurrentFrame(frame); //} } } //if(!HasOrder() && _state <= ER_ACTIVATED_BREAK) //{ // if(_timerLight > 0) // { // _timerLight -= dt; // if(_timerLight < 0) // { // ParticleEffect *eff = _effContUp.AddEffect("RecLight"); // eff->SetPos(FPoint(0.0f, 0.0f)); // eff->Reset(); // _timerLight = math::random(10.f, 30.f); // } // } //} if(_timerForRunChipFall >= 0) { _timerForRunChipFall -= dt; if(_timerForRunChipFall <= 0) { Gadgets::receivers.AcceptMessage(Message("JumpFinished", _uid)); _timerForRunChipFall = -1.f; } } }
void CParticleManager::SetMaxParticles(int effect_id, u32 max_particles) { ParticleEffect *pe = GetEffectPtr(effect_id); pe->Resize (max_particles); }
// effect void CParticleManager::RemoveParticle(int effect_id, u32 p_id) { ParticleEffect *pe = GetEffectPtr(effect_id); pe->Remove (p_id); }
void Intro2::applyState() { StateObject::applyState(); ActionMapper::clearActions(); //addAction(MakeFunctionEvent(Intro2, skipIntro), KEY_ESCAPE, 0); dsq->subtitlePlayer.show(0.5f); core->resetCamera(); dsq->jiggleCursor(); dsq->setCutscene(1,1); core->main(1); dsq->overlay->alpha.interpolateTo(0, 40); dsq->toggleCursor(0); // OLD WAY of skipping //dsq->user.control.actionSet.importAction(this, "Escape", ACTION_ESC); Quad *frame4 = new Quad; { frame4->setTexture("gameover-0004"); frame4->position = Vector(400,310); frame4->setWidthHeight(600, 600); frame4->setSegs(2, 32, 0.1, 0.1, 0.002, 0.003, 2.0, 1); } addRenderObject(frame4, LR_BACKGROUND); ParticleEffect *emitter = new ParticleEffect; emitter->load("NaijaIntro_Idle"); emitter->position = Vector(400,300); addRenderObject(emitter, LR_PARTICLES); emitter->start(); ParticleEffect *emitter3 = new ParticleEffect; emitter3->load("VerseEnergy2"); emitter3->position = Vector(400,300); addRenderObject(emitter3, LR_PARTICLES); emitter3->start(); ParticleEffect *emitter2 = new ParticleEffect; emitter2->load("NaijaIntro_Transition"); emitter2->position = Vector(400,300); addRenderObject(emitter2, LR_PARTICLES); dsq->voice("Naija_Intro-music"); while (dsq->sound->isPlayingVoice()) dsq->main(FRAME_TIME); /* while (dsq->sound->isPlayingVoice()) { if (isActing(ACTION_ESC)) { while (isActing(ACTION_ESC) && dsq->sound->isPlayingVoice()) { core->main(FRAME_TIME); } dsq->overlay->alpha.interpolateTo(1, 1); dsq->stopVoice(); dsq->main(1); dsq->newGame(); return; } core->main(FRAME_TIME); } */ /* Quad *frame3 = new Quad; { frame3->setTexture("gameover-0002"); frame3->position = Vector(400,300); frame3->width = 600; frame3->height = 600; } addRenderObject(frame3, LR_BACKGROUND); Quad *frame2 = new Quad; { frame2->setTexture("gameover-0003"); frame2->position = Vector(400,300); frame2->width = 600; frame2->height = 600; } addRenderObject(frame2, LR_BACKGROUND); Quad *frame1 = new Quad; { frame1->setTexture("gameover-0004"); frame1->position = Vector(400,300); frame1->width = 600; frame1->height = 600; } addRenderObject(frame1, LR_BACKGROUND); */ /* dsq->voice("Naija_Intro1"); while (dsq->isStreamingVoice()) core->main(1); */ /* frame1->alpha.interpolateTo(0, 1); core->main(1); */ /* dsq->voice("Naija_Intro2"); while (dsq->isStreamingVoice()) core->main(1); */ //frame2->alpha.interpolateTo(0, 1); /* dsq->voice("Naija_Intro3"); while (dsq->isStreamingVoice()) core->main(1); */ /* frame3->alpha.interpolateTo(0, 1); core->main(1); */ /* dsq->voice("Naija_Intro3"); while (dsq->isStreamingVoice()) core->main(1); */ //frame4->alpha.interpolateTo(0, 1); /* dsq->voice("Naija_Intro4"); while (dsq->isStreamingVoice()) core->main(1); */ emitter->stop(); emitter2->start(); core->main(0.5); core->sound->playSfx("NormalForm"); dsq->overlay->color = Vector(1,1,1); dsq->overlay->alpha = 0; dsq->fade(1, 1); core->main(1); frame4->alpha = 0; dsq->overlay->color.interpolateTo(0, 1); core->main(1); dsq->overlay->color = 0; dsq->overlay->alpha = 1; dsq->setCutscene(0); dsq->newGame(); }