void OpBubble::OnTimeOut(OpTimer* timer) { if (timer == &m_timer) { double duration = GetAnimationDuration(GetAnimation()); double now = g_op_time_info->GetWallClockMS(); double progress = (now - m_timer_start_time) / duration; if (progress < 1) m_timer.Start(BUBBLE_ANIM_TIMER_RES); else progress = 1; if (GetAnimation() == ANIMATION_BOUNCE) { m_extra_distance = (int)((op_fabs(op_cos(progress * M_PI * BUBBLE_ANIM_BOUNCE_COUNT) * (1 - progress * progress))) * BUBBLE_ANIM_BOUNCE_DROP_DISTANCE); Show(); // Fade should be twice as fast as the bounce progress *= 2; progress = MIN(progress, 1); } else if (GetAnimation() == ANIMATION_SHAKE) { m_extra_shift = (int)(op_sin(progress * M_PI * BUBBLE_ANIM_SHAKE_COUNT) * BUBBLE_ANIM_SHAKE_DISTANCE * (1 - progress * progress)); Show(); // Fade should be four times as fast as the shake progress *= 4; progress = MIN(progress, 1); } GetWindow()->SetTransparency((INT32)(progress * 255)); } }
void CGUIControl::QueueAnimation(ANIMATION_TYPE animType) { MarkDirtyRegion(); if (!CheckAnimation(animType)) return; CAnimation *reverseAnim = GetAnimation((ANIMATION_TYPE)-animType, false); CAnimation *forwardAnim = GetAnimation(animType); // we first check whether the reverse animation is in progress (and reverse it) // then we check for the normal animation, and queue it if (reverseAnim && reverseAnim->IsReversible() && (reverseAnim->GetState() == ANIM_STATE_IN_PROCESS || reverseAnim->GetState() == ANIM_STATE_DELAYED)) { reverseAnim->QueueAnimation(ANIM_PROCESS_REVERSE); if (forwardAnim) forwardAnim->ResetAnimation(); } else if (forwardAnim) { forwardAnim->QueueAnimation(ANIM_PROCESS_NORMAL); if (reverseAnim) reverseAnim->ResetAnimation(); } else { // hidden and visible animations delay the change of state. If there is no animations // to perform, then we should just change the state straightaway if (reverseAnim) reverseAnim->ResetAnimation(); UpdateStates(animType, ANIM_PROCESS_NORMAL, ANIM_STATE_APPLIED); } }
//////////////////////////////////////////////////////// // Function: "~CBase" // // Paramaters: void // // Returns: void //////////////////////////////////////////////////////// CBase::~CBase(void) { if(GetAnimation() != NULL) CAnimationManager::GetInstance()->UnloadAnimation(GetAnimation()); CEventSystem::GetInstance()->UnregisterClient("Change_Position", this); CEventSystem::GetInstance()->UnregisterClient("Spawn_Jeep", this); CEventSystem::GetInstance()->UnregisterClient("Spawn_Tank", this); CEventSystem::GetInstance()->UnregisterClient("need.cover", this); }
void Unit::ReloadWeapon() { if (!IsAlive()) return; if ( gCurrentWeapon ) { if (gCurrentWeapon->Reload()) { float reloadTime = gCurrentWeapon->GetReloadTime(); string animation; string animationAfter; switch (gWeaponState) { case Hold: animation = GetAnimation("DrawReloadPutAway"); switch (gMoveState) { case Stand: case Crouch: animationAfter = GetAnimation("UpperStand"); break; case Walk: animationAfter = GetAnimation("UpperWalk"); case Run: animationAfter = GetAnimation("UpperRun"); } if (PlayingAnimation(GetAnimation("PutAway"))) PlayAnimationAfter(GetAnimation("PutAway"), animation); else PlayAnimation(animation); LoopAnimationAfter(animation, animationAfter); SetAnimationSpeed(animation, GetAnimationTime(animation) / reloadTime); break; case Aim: animation = GetAnimation("Reload"); animationAfter = GetAnimation("Aim"); if (PlayingAnimation(GetAnimation("Draw"))) PlayAnimationAfter(GetAnimation("Draw"), animation); else PlayAnimation(animation); PlayAnimationAfter(animation, animationAfter); SetAnimationSpeed(animation, GetAnimationTime(animation) / reloadTime); break; } } } }
void SpriteObject::ExposeResources(gd::ArbitraryResourceWorker & worker) { for ( unsigned int j = 0; j < GetAnimationsCount();j++ ) { for ( unsigned int k = 0;k < GetAnimation( j ).GetDirectionsCount();k++ ) { for ( unsigned int l = 0;l < GetAnimation( j ).GetDirection(k).GetSpritesCount();l++ ) worker.ExposeImage(GetAnimation( j ).GetDirection(k).GetSprite(l).GetImageName()); } } }
void UActiveSkill::Execute(ABaseCharacter* Executor) { if (Executor) { if (GetAnimation()) { UFrameworkAnimInstance* AnimInstance = Cast<UFrameworkAnimInstance>(Executor->GetMesh()->GetAnimInstance()); if (AnimInstance) { AnimInstance->CurrentMontage = GetAnimation(); AnimInstance->Montage_Play(GetAnimation()); } } } ExecuteEvent->Event.Broadcast(Executor, this); }
Animation* AnimationFactory::GetAnimation(AnimationList anim, Entity* target) { //start the Animation at the position of the given Entity sf::FloatRect t = target->GetNode()->getTransform().transformRect(target->GetBattleSprite()->getLocalBounds()); Animation* ret = GetAnimation(anim, t); if(ret == nullptr) { //anim is not for target of a position std::vector<Entity*> entities; entities.push_back(target); ret = GetAnimation(anim, &entities); } return ret; }
void SpeedDialThumbnail::OnMouseUp(const OpPoint& point, MouseButton button, UINT8 nclicks) { m_mouse_down_active = false; if (IsDragging()) { StopDragging(); return; } if (!GetAnimation() || !GetAnimation()->IsAnimating()) SetFloating(false); GenericThumbnail::OnMouseUp(point, button, nclicks); }
float FFaceFXTrackKey::GetAnimationDuration(const AActor* Actor) const { if(!bIsAnimationDurationLoaded) { #if FACEFX_USEANIMATIONLINKAGE //try to resolve the animation duration if(AnimationId.IsValid() && Actor) { //resolve by animtion id float AnimStart, AnimEnd; if(UFaceFXCharacter::GetAnimationBoundsById(Actor, AnimationId, AnimStart, AnimEnd)) { AnimationDuration = AnimEnd - AnimStart; } } else #endif //FACEFX_USEANIMATIONLINKAGE if(UFaceFXAnim* TargetAnimation = GetAnimation(*this, nullptr)) { //resolve by animation asset float AnimStart, AnimEnd; if(UFaceFXCharacter::GetAnimationBounds(TargetAnimation, AnimStart, AnimEnd)) { AnimationDuration = AnimEnd - AnimStart; } } bIsAnimationDurationLoaded = true; } return AnimationDuration; }
void CGUIControl::SetVisible(bool bVisible, bool setVisState) { if (bVisible && setVisState) { // TODO: currently we only update m_visible from GUI_MSG_VISIBLE (SET_CONTROL_VISIBLE) // otherwise we just set m_forceHidden GUIVISIBLE visible; if (m_visibleCondition) visible = m_visibleCondition->Get() ? VISIBLE : HIDDEN; else visible = VISIBLE; if (visible != m_visible) { m_visible = visible; SetInvalid(); } } if (m_forceHidden == bVisible) { m_forceHidden = !bVisible; SetInvalid(); if (m_forceHidden) MarkDirtyRegion(); } if (m_forceHidden) { // reset any visible animations that are in process if (IsAnimating(ANIM_TYPE_VISIBLE)) { // CLog::Log(LOGDEBUG, "Resetting visible animation on control %i (we are %s)", m_controlID, m_visible ? "visible" : "hidden"); CAnimation *visibleAnim = GetAnimation(ANIM_TYPE_VISIBLE); if (visibleAnim) visibleAnim->ResetAnimation(); } } }
void PlayerGraphicsComponent::Render(GraphicsManager& graphics, int xPosition, int yPosition, bool newIsMoving, MoveDirection::MoveDirectionEnum direction) { // Reset the animation time if the moving state has changed. if (newIsMoving != isMoving_) { animationTime_ = 0; isMoving_ = newIsMoving; } else { // Advance one step in the animation. // animationTime is between 0 and the produce of the animation length and the animation speed. animationTime_ = (animationTime_ + 1) % (GetAnimation(isMoving_, direction)->GetAnimationLength() * animationSpeed_); } graphics.DrawGameObject(GetAnimation(isMoving_, direction)->GetSprite(animationTime_ / animationSpeed_), xPosition, yPosition - 39); }
const Sprite * SpriteObject::GetInitialInstanceSprite(gd::InitialInstance & instance, gd::Project & project, gd::Layout & layout, bool * shouldNotRotate) const { if ( HasNoAnimations() ) return NULL; //Search the first sprite of the current animation/direction. std::size_t animationId = instance.floatInfos.find("animation") != instance.floatInfos.end() ? instance.floatInfos.find("animation")->second : 0; if ( animationId >= GetAnimationsCount() ) animationId = 0; const Animation & animation = GetAnimation(animationId); if ( animation.HasNoDirections() ) return NULL; std::size_t directionId = 0; if ( animation.useMultipleDirections ) { float normalizedAngle = static_cast<int>(instance.GetAngle())%360; if ( normalizedAngle < 0 ) normalizedAngle += 360; directionId = static_cast<int>(gd::Round(normalizedAngle/45.f))%8; } if ( directionId >= animation.GetDirectionsCount() ) directionId = 0; const Direction & direction = animation.GetDirection(directionId); if ( shouldNotRotate ) *shouldNotRotate = animation.useMultipleDirections; return direction.HasNoSprites() ? NULL : &direction.GetSprite(0); }
bool CAnimationManager::IsAnimationPlaying(int nAnimID) const { CAnimation* anim = GetAnimation(nAnimID); if(anim) return anim->IsPlaying(); else return false; }
void SpriteObject::DoSerializeTo(gd::SerializerElement & element) const { //Animations gd::SerializerElement & animationsElement = element.AddChild("animations"); animationsElement.ConsiderAsArrayOf("animation"); for ( std::size_t k = 0;k < GetAnimationsCount();k++ ) { gd::SerializerElement & animationElement = animationsElement.AddChild("animation"); animationElement.SetAttribute( "useMultipleDirections", GetAnimation(k).useMultipleDirections); gd::SerializerElement & directionsElement = animationElement.AddChild("directions"); directionsElement.ConsiderAsArrayOf("direction"); for ( std::size_t l = 0;l < GetAnimation(k).GetDirectionsCount();l++ ) { GetAnimation(k).GetDirection(l).SerializeTo(directionsElement.AddChild("direction")); } } }
bool CAnimationManager::SetAnimTexture(const int nAnimID, const int nImageID) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->SetImageID(nImageID); return true; } return false; }
bool CAnimationManager::ResumeAnimation(int nAnimID) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->Resume(); return true; } return false; }
bool CAnimationManager::StopAnimation(int nAnimID) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->Stop(); return true; } return false; }
bool CAnimationManager::StopAnimationAtFrame(int nAnimIndex, int nFrameIndex) { CAnimation* anim = GetAnimation(nAnimIndex); if(anim) { anim->StopAtFrame(nFrameIndex); return true; } return false; }
bool CAnimationManager::UpdateAnimation(float fDelta, int nAnimID) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->Update(fDelta); return true; } return false; }
bool CAnimationManager::PlayAnimation(int nAnimID) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->Play(); return true; } return false; }
void cAnimationManager::DrawAnimation(uint animationId, int x, int y, float scale, float rotation){ cAnimation *tmpA = GetAnimation(animationId); if(tmpA == NULL) return; if(tmpA->IsUseTextures()){ tManager->DrawTexture(tmpA->GetCurTexture(), x, y, scale, rotation); }else{ tManager->DrawSection(tmpA->GetCurTexture(), x, y, scale, rotation); } }
int32 nuiSpriteDef::GetAnimation(const nglString& rName) const { CheckValid(); for (int32 i = 0; i < GetAnimationCount(); i++) { const nuiSpriteAnimation* pAnim = GetAnimation(i); if (pAnim->GetName() == rName) return i; } return 0; }
bool Unit::FireWeapon(GameObject* Target) { if (!IsAlive()) return false; if ( gCurrentWeapon ) { if (gWeaponState == Aim && !PlayingAnimation(GetAnimation("Draw"))) { if (gCurrentWeapon->Fire( this, Target, gMultipliers[1] )) { PlayAnimation(GetAnimation("Shoot")); PlayAnimationAfter(GetAnimation("Shoot"), GetAnimation("Aim")); return true; } } } return false; }
void DiMotion::ApplySkeletonAnimation( DiSkeletonInstance* skel, DiClipControllerSet* clipset ) { if (!GetNumAnimations()) { return; } skel->Reset(); float weightFactor = 1.0f; if (skel->GetBlendMode() == ANIMBLEND_AVERAGE) { float totalWeights = 0.0f; ConstEnabledClipsIt stateIt = clipset->GetEnabledClipsIterator(); while (stateIt.HasMoreElements()) { const DiClipController* animState = stateIt.GetNext(); totalWeights += animState->GetWeight(); } if (totalWeights > 1.0f) { weightFactor = 1.0f / totalWeights; } } ConstEnabledClipsIt stateIt = clipset->GetEnabledClipsIterator(); while (stateIt.HasMoreElements()) { const DiClipController* animState = stateIt.GetNext(); DiAnimation* anima = GetAnimation(animState->GetAnimationName()); if( anima ) { DiTimeIndex timeIndex = anima->GetTimeIndex(animState->GetTimePosition()); if(animState->HasBoneBlendMask()) { anima->ApplySkeleton(skel, timeIndex, animState->GetWeight() * weightFactor, animState->GetBoneBlendMask(), 1.0f); } else { anima->ApplySkeleton(skel, timeIndex, animState->GetWeight() * weightFactor, 1.0f); } } } }
bool CAnimationManager::Draw(int nAnimID,int nPosX, int nPosY, float fScaleX, float fScaleY, float fRotCenterX, float fRotCenterY, float fRotation, DWORD dwColor) { CAnimation* anim = GetAnimation(nAnimID); if(anim) { anim->Draw(nPosX, nPosY, fScaleX, fScaleY, fRotCenterX, fRotCenterY, fRotation, dwColor); return true; } return false; }
bool SpriteObject::GenerateThumbnail(const gd::Project & project, wxBitmap & thumbnail) const { #if !defined(GD_NO_WX_GUI) //Generate a thumbnail from the first animation if ( !HasNoAnimations() && !GetAnimation(0).HasNoDirections() && !GetAnimation(0).GetDirection(0).HasNoSprites() ) { gd::String imageName = GetAnimation(0).GetDirection(0).GetSprite(0).GetImageName(); if ( project.GetResourcesManager().HasResource(imageName) && wxFileExists(project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project)) ) { thumbnail = wxBitmap( project.GetResourcesManager().GetResource(imageName).GetAbsoluteFile(project), wxBITMAP_TYPE_ANY); wxImage thumbImage = thumbnail.ConvertToImage(); thumbnail = wxBitmap(thumbImage.Scale(24, 24)); return true; } } #endif return false; }
wxObject *wxAnimationCtrlXmlHandler::DoCreateResource() { XRC_MAKE_INSTANCE(ctrl, wxAnimationCtrl) ctrl->Create(m_parentAsWindow, GetID(), GetAnimation(wxT("animation")), GetPosition(), GetSize(), GetStyle(_T("style"), wxAC_DEFAULT_STYLE), GetName()); // if no inactive-bitmap has been provided, GetBitmap() will return wxNullBitmap // which just tells wxAnimationCtrl to use the default for inactive status ctrl->SetInactiveBitmap(GetBitmap(wxT("inactive-bitmap"))); SetupWindow(ctrl); return ctrl; }
void ShapeRenderer::Render(EDRendererD3D::RenderContext *contextPtr) { if( renderShapePtr != 0 ) { const EDMath::Float4x4& worldMat = GetGameObject()->GetTransform()->GetWorldMatrix(); EDGameCore::Animation* animation = GetAnimation(); if( animation != 0 ) { EDRendererD3D::RenderShapeSkinned *skinShape = (EDRendererD3D::RenderShapeSkinned *)renderShapePtr; skinShape->SetBoneMatrices( animation->GetFlatMats() ); } else renderShapePtr->SetWorldMatrix( (DirectX::XMFLOAT4X4*)&worldMat ); renderShapePtr->AddToContextSet(contextPtr); } }
void CBase::SetCurrAnimation(const char* szAnimationName) { if( strcmp(this->m_pAnimation->currAnimation->szName,szAnimationName) == 0 ) { return; } GetAnimation()->currAnimation->Stop(); GetAnimation()->currAnimation->Reset(); for( unsigned int count = 0; count < GetAnimation()->currSheet->m_vAnimations.size(); count++ ) { if( strcmp(GetAnimation()->currSheet->m_vAnimations[count]->szName, szAnimationName) == 0 ) { GetAnimation()->currAnimation = GetAnimation()->currSheet->m_vAnimations[count]; break; } } GetAnimation()->currAnimation->Reset(); GetAnimation()->currAnimation->Play(); }
CHeavyInfantry::CHeavyInfantry(void) : CEnemy(WEP_PISTOL) { SetEnemyID(ENEMY_HEAVY); SetMaxHealth(200); SetHealth(GetMaxHealth()); // SetImageID(CSGD_TextureManager::GetInstance()->LoadTexture("Resource\\Graphics\\HeavyInfantry_editor.png")); SetAnimation(CAnimationManager::GetInstance()->LoadAnimation("Resource\\Data\\Animations\\JeG_HeavyInfantry.bin")); GetAnimation()->currAnimation->Play(); SetMoneyReward(25); SetRepReward(10); SetWidth(32); SetHeight(32); SetArmor(25); SetSpeed(25.0f); CEventSystem::GetInstance()->RegisterClient("big.bang",this); CEventSystem::GetInstance()->RegisterClient("form.up",this); CEventSystem::GetInstance()->RegisterClient("engage.player",this); CEventSystem::GetInstance()->RegisterClient("over.here",this); CEventSystem::GetInstance()->RegisterClient("player.detected",this); CEventSystem::GetInstance()->RegisterClient("fire.bullet",this); }