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 AmTrackDataView::DrawShadowEvents(BRect clip, BView* view, const AmSong* song) { /* Shadow events can draw themselves as translucent if they * wish. So set that up. */ drawing_mode mode = view->DrawingMode(); if (mShadowSaturation > 0 && mShadowSaturation < 1 ) { view->SetDrawingMode(B_OP_ALPHA); view->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE); view->SetLowColor(mSecondaryBase); } const AmTrack* track; for (uint32 k=0; (track = song->Track(k)) != 0; k++) { if (!IsOrdered(track->Id() )) DrawTrack(track, clip, view, ARPEVENT_SHADOW); } view->SetDrawingMode(mode); }
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 EnergyReceiver::DrawUp() { if(!IsCellDraw()) { return; } Render::device.PushMatrix(); Render::device.MatrixTranslate(GetIndex()*GameSettings::SQUARE_SIDE); Game::MatrixSquareScale(); if(_crystalAnim.get()) { if(_timeAppear < 1) { Render::device.BeginClipping(IRect(-10, 4, 20, 20), ClippingMode::BOTTOM); } ////Хитрости для постепенного появления кристала из отверстия //FRect frect_crystal = FRect(0.f, 1.f, 0.f, 1.f); //FRect rect_crystal = FRect(0.f, _crystalAnim->GetOrigWidth(), 0.f, _crystalAnim->GetOrigHeight()); //rect_crystal.MoveBy(FPoint(17.f, 17.f + _fly_offset_y)); //FRect cut_rect = rect_crystal.CutBy(FRect(0.f, GameSettings::SQUARE_SIDEF, 5.5f, 200.f)); //frect_crystal.yStart = 1.f - cut_rect.Height() / rect_crystal.Height(); //rect_crystal = cut_rect; float alpha_cristall = math::clamp(0.f, 1.f, 1 + _timerForAppearOrder); if(_hideByThief) { //rect_crystal.yEnd = math::lerp(rect_crystal.yEnd, rect_crystal.yStart, _hideByThiefTime); //frect_crystal.yEnd = math::lerp(frect_crystal.yEnd, frect_crystal.yStart, _hideByThiefTime); alpha_cristall *= math::clamp(0.f, 1.f, 1 - (_hideByThiefTime - 0.5f)/0.2f); } Render::BeginAlphaMul(alpha_cristall); { if( IsWalking() ) { Render::BeginColor( Color(100, 255, 100) ); } Render::device.PushMatrix(); Render::device.MatrixTranslate(CRYSTAL_POS_ANIM_ON_SQUARE + FPoint(0.f, _fly_offset_y)); _crystalAnim->Draw(); Render::device.PopMatrix(); //_crystalAnim->Bind(); //Render::DrawRect(rect_crystal.MovedBy(CRYSTAL_POS_ANIM_ON_SQUARE), frect_crystal); if( IsWalking() ) { Render::EndColor(); } } Render::EndAlphaMul(); if(_timeAppear < 1) { Render::device.EndClipping(); } } Render::BeginAlphaMul(math::clamp(0.f, 1.f, 1 + _timerForAppearOrder)); Render::device.PushMatrix(); _effContUpStatic.Draw(); Render::device.MatrixTranslate(math::Vector3(0.f, _fly_offset_y , 0.f)); _effContUp.Draw(); Render::device.PopMatrix(); Render::EndAlphaMul(); FPoint offset(0.f, 0.f); if(_order && _order->IsReadyToBreak()) { offset.x += math::sin(_localTime*30.f); } if(_state != ER_INIT) { _effectCellCont.Draw(); if(IsOrdered()) { _order->Draw(offset.Rounded()); } } Render::device.PopMatrix(); }
// handle underfull leaf nodes int GiST::CondenseTree(GiSTnode *node) { GiSTlist<GiSTentry*> Q; int deleted=0; // Must be condensing a leaf assert(node->IsLeaf()); while(!node->Path().IsRoot()) { GiSTpath parent_path=node->Path(); parent_path.MakeParent(); GiSTnode *P=ReadNode(parent_path); GiSTentry *En=P->SearchPtr(node->Path().Page()); assert(En!=NULL); // Handle under-full node if(node->IsUnderFull(*store)) { if(!IsOrdered()) { TruePredicate truePredicate; GiSTlist<GiSTentry*> list=node->Search(truePredicate); while(!list.IsEmpty()) { GiSTentry *e=list.RemoveFront(); Q.Append(e); } P->DeleteEntry(En->Position()); WriteNode(P); deleted=1; AdjustKeys(P, NULL); } else { // Try to borrow entries, else coalesce with a neighbor // Have to look at left sibling??? GiSTpage neighbor_page=P->SearchNeighbors(node->Path().Page()); GiSTpath neighbor_path=node->Path(); neighbor_path.MakeSibling(neighbor_page); if(neighbor_page!=0) { GiSTnode *neighbor; // If neighbor is RIGHT sibling... if(node->Sibling()==neighbor_page) neighbor=ReadNode(neighbor_path); else { neighbor=node; node=ReadNode(neighbor_path); } GiSTentry *e=P->SearchPtr(node->Path().Page()); node->Coalesce(*neighbor, *e); delete e; // If not overfull, coalesce, kill right node if(!node->IsOverFull(*store)) { node->SetSibling(neighbor->Sibling()); WriteNode(node); // Delete the neighbor from parent GiSTentry *e=P->SearchPtr(neighbor->Path().Page()); P->DeleteEntry(e->Position()); WriteNode(P); delete e; store->Deallocate(neighbor->Path().Page()); deleted=1; } // If overfull, split (same as borrowing) else { GiSTnode *node2=node->PickSplit(); node2->Path()=neighbor->Path(); node2->SetSibling(neighbor->Sibling()); WriteNode(node); WriteNode(node2); AdjustKeys(node2, &P); delete node2; deleted=1; } delete neighbor; } } } // Adjust covering predicate if(!deleted) AdjustKeys(node, &P); parent_path=node->Path(); parent_path.MakeParent(); delete node; // Propagate deletes if(!deleted) break; node=P; } // Re-insert orphaned entries while(!Q.IsEmpty()) { GiSTentry *e=Q.RemoveFront(); InsertHelper(*e, e->Level()); delete e; } return(deleted); }