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 CSmashBot::Update(float fDelta) { if(m_fIsFading > 0.0f) { m_fIsFading -= fDelta; D3DXMATRIX tempCurr = GetMatrix(); tempCurr[13] -= m_fIsFading * 0.05f; SetMatrix(tempCurr); if(m_fIsFading <= 0.0f) CGame::GetInstance()->GetOF()->Destroy(this); return; } if(m_fDying) { m_fDying += fDelta; if( m_fDying > m_fDieTime ) { m_fIsFading = 2.0f; return; } float animTime = GetAnimationTime(); animTime += fDelta; if(animTime > m_fDieTime) animTime = m_fDieTime; CAnimationProcessor::UpdateTime(GetCurrentAnimation(), animTime); CAnimationProcessor::Interpolator(GetCurrentAnimation(), animTime, PassCurrFrame()); SetAnimationTime(animTime); return; } if( m_bIsSmashing ) SetColor(COLOR_SMASHBOT_VUL); else { SetColor(COLOR_SMASHBOT); m_fScrollTime -= fDelta; } float animTime = GetAnimationTime(); animTime += fDelta; if(GetWalking() != SMASH_WALK) animTime = min(animTime, m_fMaxAnim); CAnimationProcessor::UpdateTime(GetCurrentAnimation(), animTime); CAnimationProcessor::Interpolator(GetCurrentAnimation(), animTime, PassCurrFrame()); SetAnimationTime(animTime); if(GetWasHit() == true) { float temp = GetHitDuration(); temp += fDelta; SetHitDuration(temp); SetBeingHit(1); SetColor(COLOR_SMASHBOT_HIT); if(HIT_CAP < temp) { SetWasHit(false); SetHitDuration(0.0f); SetBeingHit(0); } } if( GetHealth() <= 0 ) { CPickup* pPickup = nullptr; if(CGame::GetInstance()->GetOF()->Create(OBJ_PICKUP,(IBaseObject**)&pPickup)) { pPickup->SetMatrix(GetMatrix()); } m_bIsSmashing = false; D3DXMATRIX d3dMat=GetMatrix(); WwiseNS::PlaySFX(WwiseNS::EVENT_SOUND_EXPLOSION); CGameplayState::GetInstance()->GetFX()->CreateEffect(EFFECT_MEDEXP,d3dMat); TAnimation* tempAnim = CAssetManager::GetInstance()->GetAnimation(GetID(), SMASH_DEATH); m_fDieTime = tempAnim->m_fDuration; m_fDying = .00001f; SetBeingHit(0); ChangeAnimation(SMASH_DEATH); SetAlive(false); return; } m_cAI.Update(fDelta); }
void LoadAnimation(AnimationData& aAnimation,FbxNode* aNode,FbxAMatrix& aParentOrientation, FbxPose* aPose, FbxAnimLayer* aCurrentAnimLayer, int parentBone) { FbxAMatrix lGlobalPosition = GetGlobalPosition(aNode, static_cast<FbxTime>(0.0f), aPose, &aParentOrientation); FbxNodeAttribute* lNodeAttribute = aNode->GetNodeAttribute(); int boneId = -1; if (lNodeAttribute) { if(lNodeAttribute->GetAttributeType() == FbxNodeAttribute::eSkeleton) { Bone newBone; newBone.myAnimationTime = GetAnimationTime(aNode,aCurrentAnimLayer); float oneFrameTime = 1.0f/24.0f; CU::Matrix44f fixMatrix; fixMatrix.myMatrix[0] = -1; FbxAMatrix lLocalTransform = aNode->EvaluateLocalTransform(); newBone.myBaseOrientation = fixMatrix * CreateMatrix(lLocalTransform) * fixMatrix; char buffer[32]; _itoa_s<32>(parentBone,buffer,10); newBone.myName = aNode->GetName(); newBone.myName += buffer; int lNodeIndex = aPose->Find(aNode); auto bindPoseMatrix = aPose->GetMatrix(lNodeIndex); FbxAMatrix bindMatrix; memcpy((double*)bindMatrix, (double*)bindPoseMatrix, sizeof(bindMatrix.mData)); FbxAMatrix localPosOffset; memcpy((double*)localPosOffset, (double*)bindPoseMatrix, sizeof(localPosOffset.mData)); localPosOffset = localPosOffset * aParentOrientation.Inverse(); newBone.myBindMatrix = fixMatrix * CreateMatrix(lGlobalPosition.Inverse()) * fixMatrix; CU::Matrix44f localStartOffset = CreateMatrix(bindMatrix.Inverse()); for(float currentFrameTime = 0.0f;currentFrameTime < newBone.myAnimationTime;currentFrameTime+= oneFrameTime) { KeyFrame keyFrame; keyFrame.myTime = currentFrameTime; FbxTime time; time.SetSecondDouble(currentFrameTime); keyFrame.myMatrix = fixMatrix * CreateMatrix(aNode->EvaluateLocalTransform(time)) * fixMatrix; newBone.myFrames.push_back(keyFrame); } FbxAMatrix animationMatrix; FbxSkeleton* sekeleton = aNode->GetSkeleton(); if(sekeleton->IsSkeletonRoot()) { aAnimation.myBindMatrix = CU::Matrix44<float>(); aAnimation.myRootBone = aAnimation.myBones.size(); } boneId = aAnimation.myBones.size(); aNode->SetUserDataPtr((void*)boneId); if(parentBone != -1) { aAnimation.myBones[parentBone].myChilds.push_back(boneId); } newBone.myId = boneId; aAnimation.myBones.push_back(newBone); } } const int lChildCount = aNode->GetChildCount(); for (int lChildIndex = 0; lChildIndex < lChildCount; ++lChildIndex) { LoadAnimation( aAnimation, aNode->GetChild(lChildIndex), lGlobalPosition , aPose, aCurrentAnimLayer, boneId); } }
void CBurnBot::Update(float fDelta) { if(m_fDying) { m_fDying += fDelta; if( m_fDying > m_fDieTime ) { CGame::GetInstance()->GetOF()->Destroy(this); SetIsActive(false); } float animTime = GetAnimationTime(); animTime += fDelta; if(animTime > m_fDieTime) animTime = m_fDieTime; CAnimationProcessor::UpdateTime(GetCurrentAnimation(), animTime); CAnimationProcessor::Interpolator(GetCurrentAnimation(), animTime, PassCurrFrame()); SetAnimationTime(animTime); return; } if(m_bDontDropPool && m_fDropWait > 0.0f) { m_fDropWait -= fDelta; if(m_fDropWait <= 0.0f) { m_fDropWait = 0.0f; m_bDontDropPool = false; } } KillCurrFrame(); if(GetWasHit() == true) { float ftemp = GetHitDuration(); ftemp += fDelta; SetHitDuration(ftemp); SetBeingHit(1); SetColor(COLOR_PATROLBOT_HIT); if(HIT_CAP < ftemp) { SetWasHit(false); SetHitDuration(0.0f); SetBeingHit(0); SetColor(COLOR_PATROLBOT); } } m_cAI.Update(fDelta); if( GetHealth() <= 0 ) { WwiseNS::PlaySFX(WwiseNS::EVENT_SOUND_EXPLOSION); CGameplayState::GetInstance()->GetFX()->CreateEffect(EFFECT_DMGEXPLOSION,GetMatrix()); if(!m_bDontDropPool) { CMoltenPool* pMoltenPool = nullptr; if(CGame::GetInstance()->GetOF()->Create(OBJ_POOL, (IBaseObject**)&pMoltenPool)) { pMoltenPool->SetMatrix(GetMatrix()); pMoltenPool->SetOriginalMatrix(GetMatrix()); pMoltenPool->SetRadius(1.0f); pMoltenPool->SetScale(1.25f); pMoltenPool->SetScaleMod(1.4f); pMoltenPool->SetScaleTimer(1.0f); pMoltenPool->SetPoolStage(1); pMoltenPool->SetScalingMod(0.0f); pMoltenPool->SetDroppedID(1); } } CGameplayState::GetInstance()->GetFX()->CreateEffect(EFFECT_SMALLEXP,GetMatrix()); SetBeingHit(0); TAnimation* tempAnim = CAssetManager::GetInstance()->GetAnimation(GetID(), 1); m_fDieTime = tempAnim->m_fDuration; m_fDying = .00001f; ChangeAnimation(1); SetAlive(false); } if(m_bCloseToTarget) { int nTemp = ((int)(m_fExplodeTimer*10)%2); float animTime = GetAnimationTime(); animTime += fDelta; CAnimationProcessor::UpdateTime(GetCurrentAnimation(), animTime); CAnimationProcessor::Interpolator(GetCurrentAnimation(), animTime, PassCurrFrame()); SetAnimationTime(animTime); if(nTemp) SetBeingHit(NOTHIT); else SetBeingHit(BURNEXPLODE); } }