void S_SheetAnimation::Notify(const Message& l_message){ if(HasEntity(l_message.m_receiver)){ EntityMessage m = (EntityMessage)l_message.m_type; switch(m){ case EntityMessage::State_Changed: { EntityState s = (EntityState)l_message.m_int; switch(s){ case EntityState::Idle: ChangeAnimation(l_message.m_receiver,"Idle",true,true); break; case EntityState::Walking: ChangeAnimation(l_message.m_receiver,"Walk",true,true); break; case EntityState::Attacking: ChangeAnimation(l_message.m_receiver,"Attack",true,false); break; case EntityState::Hurt: break; case EntityState::Dying: ChangeAnimation(l_message.m_receiver,"Death",true,false); break; } } break; } } }
void CBurnBot::CollisionResponse(IBaseObject* pObj) { int nType = pObj->GetID(); Sphere tempSphere = pObj->GetSphere(); D3DXVECTOR3 V = tempSphere.m_Center - this->GetSphere().m_Center; float Mag = D3DXVec3Length(&V); float Distance = tempSphere.m_Radius + GetSphere().m_Radius; float X = Distance/Mag + EPISILON; V = V * X; D3DXMATRIX tempMat = pObj->GetMatrix(); if(nType == OBJ_TUNNEL) tempMat._43 *= 0.85f; D3DXMATRIX tempSetMat = GetMatrix(); tempSetMat._41 = tempMat._41 - V.x; tempSetMat._43 = tempMat._43 - V.z; this->SetMatrix(tempSetMat); if( nType == OBJ_PLAYER ) { if(!m_bCloseToTarget) { m_bCloseToTarget = true; m_fExplodeTimer = BURN_CHARGETIME; SetBeingHit(BURNEXPLODE); WwiseNS::PlaySFX(WwiseNS::EVENT_SOUND_BURNALERT); ChangeAnimation(0); } } }
CCrate::CCrate(int x, int y) : CBaseObject(x,y) { renderOrder = 3; ChangeAnimation(idle); SetHP(150); lookingLeft = false; content = nothing; }
void GraphicsComponent::Draw(sf::Vector2<float> position, char * newAnimState /* = 0 */) { if(newAnimState) { ChangeAnimation(newAnimState); } this->position = position; drawThisFrame = true; }
CFluid::CFluid(int x, int y, CVectorManager * _vm, float _viscocity) : CTrapObject(x, y) { renderOrder = 4; vm = _vm; damage = 1; frequencyInMs = 150; ChangeAnimation(idle); viscocity = _viscocity; }
bool CCrate::Die() { if (!IsDying()) { ChangeAnimation(death); dying = true; } timeToDie -= g_time; if (timeToDie > 0) { return false; } else return true; }
void PlayerObject::HandleEvent(Event* pEvent) { if (pEvent->GetEventID() == "playerKeyUp.Up") { SetVelocityY(0.0); ChangeAnimation("Idle"); } else if (pEvent->GetEventID() == "playerKeyUp.Down") { SetVelocityY(0.0); ChangeAnimation("Idle"); } else if (pEvent->GetEventID() == "playerKeyUp.Right") { SetVelocityX(0.0); ChangeAnimation("Idle"); m_Animations[m_currentAnimation]->SetScale(XMFLOAT2(1.0f, 1.0f)); } else if (pEvent->GetEventID() == "playerKeyUp.Left") { SetVelocityX(0.0); ChangeAnimation("Idle"); m_Animations[m_currentAnimation]->SetScale(XMFLOAT2(-1.0f, 1.0f)); } else if (pEvent->GetEventID() == "playerKeyDown.Up") { SetVelocityY(25.0f); ChangeAnimation("Walk"); } else if (pEvent->GetEventID() == "playerKeyDown.Down") { SetVelocityY(-25.0f); ChangeAnimation("Walk"); } else if (pEvent->GetEventID() == "playerKeyDown.Right") { SetVelocityX(25.0f); ChangeAnimation("Walk"); m_Animations[m_currentAnimation]->SetScale(XMFLOAT2(1.0f, 1.0f)); } else if (pEvent->GetEventID() == "playerKeyDown.Left") { SetVelocityX(-25.0f); ChangeAnimation("Walk"); m_Animations[m_currentAnimation]->SetScale(XMFLOAT2(-1.0f, 1.0f)); } }
CCrate::CCrate(int x, int y, int _content) : CBaseObject(x, y) { if (_content < numberOfItems && _content > 0) { content = _content; } else { content = nothing; } renderOrder = 3; ChangeAnimation(idle); SetHP(150); lookingLeft = false; }
void CKrakenLeg::Init(std::string path) { CAniXfile* CreatedAniXfile = NULL; CreatedAniXfile = CObjMgr::GetInstance()->GetAniXfile(path); if( CreatedAniXfile != NULL) { m_pXAnifile = new CAniXfile(); m_pXAnifile = CreatedAniXfile; m_pAC = m_pXAnifile->GetAC(); ChangeAnimation(2); } }
bool CKrakenLeg::Run(float fElapsed) { if( m_nHp <= 0 ) { m_fDieTimer += fElapsed ; ChangeAnimation(0); if(m_fDieTimer > 0.7) { if(m_bLive) { m_bLive = false; m_pKraken->AddLegDiedCount(1); } return true; } } m_fAnimationTime += fElapsed; if(m_fAnimationTime > 10000000) { m_fAnimationTime = 0; } if(m_pAC && m_dwCurrentAnimation != -1) { m_pAC->SetTrackSpeed(m_dwCurrentTrack,m_fAnimationSpeed); m_pAC->AdvanceTime(fElapsed, NULL); } m_pXAnifile->Run(fElapsed); SwingAttack(fElapsed); return true; }
CExplosion::CExplosion(int _size, float _impulse, int _damage, int x, int y, int _type) : CBaseObject(x,y,_type,_size) { impulse = _impulse; damage = _damage; frameSizeX = 256; frameSizeY = 256; renderOrder = 4; radius = _size; impulseCentre[0] = x + (radius / 2); impulseCentre[1] = y + (radius / 2); textureId = 501; animationData[blow][frameCountData] = 17; animationData[blow][msPerFrameData] = 50; animationData[blow][startFrameData] = 0; ChangeAnimation(blow); }
void GraphicsComponent::Draw(sf::Vector2<float> camPosition, sf::RenderWindow* window, float deltaTime) { if(currAnimation) { currTime += deltaTime; float frameTime = currAnimation->frames[currFrame].time; if(currTime >= frameTime) { currTime -= frameTime; currFrame++; if(currFrame == currAnimation->numFrames) { if(currAnimation->loop) currFrame = 0; else { ChangeAnimation(currAnimation->nextAnim); currFrame = 0; } } } } else { return; } if(!drawThisFrame) return; sf::Sprite & drawing = currAnimation->frames[currFrame].toDraw; if(facing == 0xff ) // -1 int8_t { int width = (int)drawing.getLocalBounds().width; drawing.setTextureRect(sf::IntRect(width, 0,-width, (int)drawing.getLocalBounds().height )); } else { drawing.setTextureRect(sf::IntRect(0, 0, (int)drawing.getLocalBounds().width, (int)drawing.getLocalBounds().height)); } drawing.setPosition(position.x - camPosition.x, position.y - camPosition.y); window->draw(drawing); drawThisFrame = false; }
//============================================================================= //処理 //============================================================================= void CEnemyRabbit::Exec() { /*アニメカウンタの加算*/ m_fAnimTime[ANIM_NOW] += 0.5f; float fLast = m_pActorModel[m_ActorIndex]->GetAnimationLastTime( m_AnimID[ANIM_NOW] ); /*時間が最後まで到達*/ for( int Anim = 0;Anim < ANIM_MAX;++Anim ) { /*時間が最後まで到達*/ if ( m_fAnimTime[Anim] > m_pActorModel[m_ActorIndex]->GetAnimationLastTime( m_AnimID[Anim] ) ) { /*最初に戻す*/ m_fAnimTime[Anim] = 1.0f; } } /*アニメーションの切り替え*/ ChangeAnimation(); /*姿勢のリセット*/ m_pActorModel[m_ActorIndex]->TransformReset(); m_pActorModel[m_ActorIndex]->Scaling( m_vScale.x, m_vScale.y, m_vScale.z ); m_pActorModel[m_ActorIndex]->RotationY( toI( -m_vRot.x ) + DEG_TO_ANGLE(90) ); /*移動の設定*/ m_pActorModel[m_ActorIndex]->Translation( m_vPos ); // キャラに対してアニメーションを更新 m_pActorModel[m_ActorIndex]->UpdateAnimation( m_AnimID[ANIM_NOW], m_fAnimTime[ANIM_NOW] ); // キャラの変換更新 m_pActorModel[m_ActorIndex]->TransformUpdate(); }
std::string CAnimationGroupEditImp::AddAgp( std::string str ) { if (MODEL) { m_strCurAgpName = str; MODEL->StopAni(-1); std::string sAgpFile = str.substr(0, str.length()-4) + ".agp"; CEditAnimationGroup* tpAnimationGroup = new CEditAnimationGroup(sAgpFile); string strErr; tpAnimationGroup->AddRef(); if(tpAnimationGroup->BinLoad()<0) { char msg[256]; sprintf_s(msg, "动画列表%s没载入成功", sAgpFile.c_str()); return msg; } CEditSkeletalFrame* tSkeletalFrame; CSkeletalsMgr::GetInst()->GetSkeInPool(tpAnimationGroup->GetSkeletalFrameName(),(CSkeletalFrame**)&tSkeletalFrame); if(!tSkeletalFrame) { std::string msg = "没有找到骨架文件"; msg += tpAnimationGroup->GetSkeletalFrameName(); tpAnimationGroup->Release(); return msg; } if( !m_pSkeletalFrame) { EDITMODEL->ClearAnimateGroup(); EDITMODEL->SetSkeletalFrame( tSkeletalFrame ); EDITMODEL->SetEditAnimateGroup( tpAnimationGroup); m_pAnimateGroup = tpAnimationGroup; m_pAnimateGroup->AddRef(); m_pSkeletalFrame = tSkeletalFrame; SKELETAL_MASK mask; m_pSkeletalFrame->FillSkeletalMask(mask); EDITMODEL->SetSkesMask(mask); EDITMODEL->CalSkeletalSize(0); m_vtAnimName.clear(); // to mfc animation name list CAnimationGroup* pAniGrp = tpAnimationGroup; std::string strName; uint32 animateNum = pAniGrp->GetAnimateNum(); for( uint32 i = 0; i < animateNum; i++ ) { sqr::IDNAME Name = (*pAniGrp)[i]->GetName(); float sp = (*pAniGrp)[i]->GetGroundSpeed(); strName = CalName(Name,sp); m_vtAnimName.push_back(strName); } tpAnimationGroup->Release(); ChangeAnimation(string((*pAniGrp)[0]->GetName())); return "添加成功"; } string ErrSkeletal; if( m_pSkeletalFrame->IsFitForMe( *tSkeletalFrame, ErrSkeletal ) ) { CAnimationGroup::CAnimateList& NewList = tpAnimationGroup->GetAnimateList(); CAnimationGroup::CAnimateList& OrgList = m_pAnimateGroup->GetAnimateList(); for( int i = 0; i < (int)NewList.size(); i++ ) { sqr::IDNAME NewName = NewList[i]->GetName(); int j = 0; for( ; j < (int)OrgList.size(); j++ ) { sqr::IDNAME OrgName = OrgList[j]->GetName(); if( OrgName == NewName ) break; } if( j == (int)OrgList.size() ) { std::string name = NewName; OrgList.push_back( NewList[i] ); m_vtAnimName.push_back(name); } } NewList.clear(); } else { str += "文件骨骼结构和已经加入的文件骨骼结构不符, 请检查骨骼:"; str += ErrSkeletal.c_str(); return str; } ChangeAnimation(string((*m_pAnimateGroup)[0]->GetName())); return "添加成功"; } else return "添加失败"; }
void CKrakenLeg::SwingAttack(float fElapsed) { float Distance = 0; D3DXVECTOR3 CharPos = m_pInplay->GetCharacter()->GetPosition(); Distance = D3DXVec3Length( &D3DXVECTOR3(CharPos - m_vPos) ); if(Distance < 2.0) { D3DXMATRIX Rot; D3DXQUATERNION QuaRot; D3DXQUATERNION QuaStart; D3DXQUATERNION QuaSlerp; D3DXVECTOR3 ZVector(0,0,1); m_vDirection = m_pInplay->GetCharacter()->GetPosition()- m_vPos; D3DXMatrixIdentity(&Rot); Rot._11 = m_pInplay->GetCamera()->GetViewMatrix()->_11; Rot._13 = m_pInplay->GetCamera()->GetViewMatrix()->_13; Rot._31 = m_pInplay->GetCamera()->GetViewMatrix()->_31; Rot._33 = m_pInplay->GetCamera()->GetViewMatrix()->_33; Rot._41 = m_vPos.x; Rot._42 = m_vPos.y; Rot._43 = m_vPos.z; D3DXMatrixInverse( &Rot, NULL, &Rot ); D3DXQuaternionRotationMatrix( &QuaStart, &m_matRotate); D3DXQuaternionRotationMatrix( &QuaRot, &Rot); if( D3DXVec3Dot(&ZVector,&m_vDirection) < 0) { D3DXQuaternionSlerp(&QuaSlerp, &QuaRot, &QuaStart, fElapsed); } else { D3DXQuaternionSlerp(&QuaSlerp, &QuaStart, &QuaRot, fElapsed); } D3DXMatrixRotationQuaternion(&Rot,&QuaSlerp); m_matRotate = Rot; m_fAttackTimer += fElapsed; if( m_fAttackTimer >4.0f ) { ChangeAnimation(1); } if( m_fAttackTimer > 5.63f) { m_fAnimationTime = 0; m_pInplay->GetCharacter()->AddHp( -200 ) ; ChangeAnimation(2); m_fAttackTimer = 0; } } else { ChangeAnimation(2); } }
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 CEnemyMouse::Exec() { if( m_fKeyTime >= 20.0f && m_fKeyTime <= 20.1f && !m_IsStop ) { m_AnimID[ANIM_NEXT] = ANIM_STAND; } else if( m_IsStop ) { m_AnimID[ANIM_NOW] = ANIM_STUN; } else { m_AnimID[ANIM_NEXT] = ANIM_WALK; } if( m_AnimID[ANIM_NEXT] == ANIM_STAND ) { m_IsStopKeyTime = true; MovePatternStand(); } for( int Anim = 0;Anim < ANIM_MAX;++Anim ) { m_fAnimTime[Anim] += 0.5f; float fLast = m_pActorModel[m_ActorIndex]->GetAnimationLastTime( m_AnimID[Anim] ); /*時間が最後まで到達*/ while( m_fAnimTime[Anim] > fLast ) { /*最初に戻す*/ m_fAnimTime[Anim] -= fLast; } } /*アニメーションの切り替え*/ ChangeAnimation(); if( m_IsStop ) { m_pStunEffect->SetPosition( m_vPos + Math::Vector3D( 0, 1.2f, 0 ) ); } static Math::Vector3D vRot; vRot.x -= DEG_TO_ANGLE(1); vRot.y = DEG_TO_ANGLE(1); vRot.z = DEG_TO_ANGLE(1); m_pStunEffect->SetRotate( vRot ); /*処理*/ m_pStunEffect->Exec(); m_vSetFlagPos = m_vPos + Math::Vector3D( 0, 0.5f, 0 ); /*姿勢のリセット*/ m_pActorModel[m_ActorIndex]->TransformReset(); m_pActorModel[m_ActorIndex]->Scaling( m_vScale.x, m_vScale.y, m_vScale.z ); m_pActorModel[m_ActorIndex]->RotationY( toI( -m_vRot.x ) + DEG_TO_ANGLE(90) ); /*移動の設定*/ m_pActorModel[m_ActorIndex]->Translation( m_vPos ); // キャラに対してアニメーションを更新 m_pActorModel[m_ActorIndex]->UpdateAnimation( m_AnimID[ANIM_NOW], m_fAnimTime[ANIM_NOW], m_AnimID[ANIM_NEXT], m_fAnimTime[ANIM_NEXT], m_fWeight ); // キャラの変換更新 m_pActorModel[m_ActorIndex]->TransformUpdate(); }
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); } }