CEnemyDemon::CEnemyDemon() { COptions *op = COptions::GetInstance(); CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance(); SetHP(25 * op->GetDifficulty()); SetVelX(100.0f * op->GetDifficulty()); SetVelY(100.0f * op->GetDifficulty()); SetXFlip(-1); SetHeight(64); SetWidth(64); SetPosX(500); SetPosY(500); SetType(ACTOR_ENEMY); SetPower(5 * op->GetDifficulty()); SetScoreValue(100 * op->GetDifficulty()); SetHit(false); rEnemyRect.top = 65; rEnemyRect.bottom = 123; rEnemyRect.left = 0; rEnemyRect.right = 60; m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Bark.wav"); CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID,COptions::GetInstance()->GetSFXVolume()-40); }
void CEnemyBusiness::HandleEvent(CEvent *pEvent) { CSGD_ObjectFactory<string, CBase> *pOF = CSGD_ObjectFactory<string, CBase>::GetInstance(); CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); COptions *op = COptions::GetInstance(); if (pEvent->GetEventID() == "businessman fire") { m_fFireReady = 5.0f; bIsFiring = true; pBullet = pOF->CreateObject("CBulletPaper"); pBullet->SetImageID(GetImageID()); if (GetXFlip() == -1) pBullet->SetVelX(500); else pBullet->SetVelX(-500); pBullet->SetVelY(0); pBullet->SetPosX(GetPosX() - (GetXFlip() * 48)); pBullet->SetPosY(GetPosY()); pBullet->SetType(ACTOR_BULLET); pBullet->SetHeight(20); pBullet->SetWidth(20); pBullet->SetPower(5 * op->GetDifficulty()); pOM->AddObject(pBullet); } }
CEnemyPsycrow::CEnemyPsycrow() { CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance(); CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); COptions *op = COptions::GetInstance(); pES->RegisterClient("psycrow fire", this); pES->RegisterClient("state transition 1", this); pES->RegisterClient("state transition 2", this); pES->RegisterClient("state transition 3", this); pES->RegisterClient("state transition 4", this); m_nState = PSYCROW_STATE1; m_nSoundID = CSGD_WaveManager::GetInstance()->LoadWave("Resource/sounds/JoA_Squawk.wav"); CSGD_WaveManager::GetInstance()->SetVolume(m_nSoundID, op->GetSFXVolume() - 40); m_fFireReady = 5.0f; m_fHitTimer = 0.4f; m_nOffset = 0; bIsFired = false; m_fFiringTimer = 0.5f; m_fSineFloat = 3.14f; m_nColor = 255; m_nScale = 1.5f; SetHP(250 * op->GetDifficulty()); SetVelX(75 * op->GetDifficulty()); SetVelY(0.0f); SetXFlip(-1); SetHeight(84); SetWidth(70); SetPosX(320); SetPosY(240); SetPower(0); SetType(ACTOR_ENEMY); SetScoreValue(1000 * op->GetDifficulty()); SetHit(false); pBullet = NULL; bIsFiring = false; }
CEnemyBusiness::CEnemyBusiness() { CSGD_EventSystem *pES = CSGD_EventSystem::GetInstance(); CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); COptions *op = COptions::GetInstance(); CSGD_WaveManager *pWM = CSGD_WaveManager::GetInstance(); pES->RegisterClient("businessman fire", this); SetHP(50 *op->GetDifficulty()); SetVelX(-50.0f * op->GetDifficulty()); SetVelY(0.0f); SetXFlip(-1); SetHeight(63); SetWidth(86); SetPosX(1000); SetPosY(220); SetPower(0); SetType(ACTOR_ENEMY); SetScoreValue(200 * op->GetDifficulty()); SetHit(false); pBullet = NULL; bIsFiring = false; m_fFireReady = 5.0f; m_fHitTimer = 1.0f; m_nOffset = 0; m_fFiringTimer = 1.0f; rEnemyRect.top = 18; rEnemyRect.bottom = 61; rEnemyRect.left = 2; rEnemyRect.right = 54; m_nSoundID = pWM->LoadWave("Resource/sounds/JoA_Scream.wav"); pWM->SetVolume(m_nSoundID,op->GetSFXVolume() - 25); }
void CEnemyPsycrow::Update(float fElapsedTime) { COptions *op = COptions::GetInstance(); CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_MessageSystem *pMS = CSGD_MessageSystem::GetInstance(); CSGD_EventSystem *pES= CSGD_EventSystem::GetInstance(); CGame *theGame = CGame::GetInstance(); if (m_nState % 2 == 0) { SetVelY(sin(m_fSineFloat) * 50 * op->GetDifficulty() * (m_nState + 0.5)); rEnemyRect.top = 507; rEnemyRect.bottom = 561; rEnemyRect.left = 584; rEnemyRect.right = 650; if (!bIsFiring) m_fFireReady -= fElapsedTime; if (m_fFireReady <= 0) bIsFiring = true; if (bIsFiring) { m_fFiringTimer -= fElapsedTime; if (m_fFiringTimer <= 0.5f && m_fFiringTimer > 0.4f) { rEnemyRect.top = 507; rEnemyRect.bottom = 561; rEnemyRect.left = 494; rEnemyRect.right = 566; if (!bIsFired) { pES->SendEvent("psycrow fire", NULL); bIsFired = true; } } else if (m_fFiringTimer <= 0.4f && m_fFiringTimer > 0.3f) { rEnemyRect.top = 507; rEnemyRect.bottom = 567; rEnemyRect.left = 790; rEnemyRect.right = 856; } else if (m_fFiringTimer <= 0.3f && m_fFiringTimer > 0.2f) { rEnemyRect.top = 511; rEnemyRect.bottom = 564; rEnemyRect.left = 873; rEnemyRect.right = 935; } else if (m_fFiringTimer <= 0.2f && m_fFiringTimer > 0.1f) { rEnemyRect.top = 581; rEnemyRect.bottom = 641; rEnemyRect.left = 502; rEnemyRect.right = 573; } else if (m_fFiringTimer <= 0.1f) { rEnemyRect.top = 579; rEnemyRect.bottom = 639; rEnemyRect.left = 601; rEnemyRect.right = 673; bIsFiring = false; bIsFired = false; m_fFireReady = 5.0f; m_fFiringTimer = 0.5f; } } } else if (m_nState % 2 == 1) { rEnemyRect.top = 666; rEnemyRect.bottom = 726; DWORD timer = GetTickCount(); if (timer % 300 <= 100) { rEnemyRect.left = 494; rEnemyRect.right = 533; } else if (timer % 300 > 100 && timer % 300 <= 200) { rEnemyRect.left = 542; rEnemyRect.right = 581; } else if (timer % 300 > 200) { rEnemyRect.left = 591; rEnemyRect.right = 630; } } if (GetHP() < op->GetDifficulty() * 200 && m_nState == PSYCROW_STATE1) { rEnemyRect.top = 674; rEnemyRect.bottom = 726; m_fHitTimer -= fElapsedTime; if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f) { CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0); rEnemyRect.left = 649; rEnemyRect.right = 708; } else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f) { rEnemyRect.left = 719; rEnemyRect.right = 772; } else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f) { rEnemyRect.left = 787; rEnemyRect.right = 844; } else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f) { rEnemyRect.left = 861; rEnemyRect.right = 912; } if (m_fHitTimer < 0) pES->SendEvent("state transition 1"); } if (GetHP() < op->GetDifficulty() * 150 && m_nState == PSYCROW_STATE2) { rEnemyRect.top = 674; rEnemyRect.bottom = 726; m_fHitTimer -= fElapsedTime; if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f) { CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0); rEnemyRect.left = 649; rEnemyRect.right = 708; } else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f) { rEnemyRect.left = 719; rEnemyRect.right = 772; } else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f) { rEnemyRect.left = 787; rEnemyRect.right = 844; } else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f) { rEnemyRect.left = 861; rEnemyRect.right = 912; } if (m_fHitTimer < 0) pES->SendEvent("state transition 2"); } if (GetHP() < op->GetDifficulty() * 100 && m_nState == PSYCROW_STATE3) { rEnemyRect.top = 674; rEnemyRect.bottom = 726; m_fHitTimer -= fElapsedTime; if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f) { CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0); rEnemyRect.left = 649; rEnemyRect.right = 708; } else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f) { rEnemyRect.left = 719; rEnemyRect.right = 772; } else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f) { rEnemyRect.left = 787; rEnemyRect.right = 844; } else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f) { rEnemyRect.left = 861; rEnemyRect.right = 912; } if (m_fHitTimer < 0) pES->SendEvent("state transition 3"); } if (GetHP() < op->GetDifficulty() * 50 && m_nState == PSYCROW_STATE4) { rEnemyRect.top = 674; rEnemyRect.bottom = 726; m_fHitTimer -= fElapsedTime; if (m_fHitTimer <= 0.4f && m_fHitTimer > 0.3f) { CSGD_WaveManager::GetInstance()->Play(m_nSoundID,0); rEnemyRect.left = 649; rEnemyRect.right = 708; } else if (m_fHitTimer <= 0.3f && m_fHitTimer > 0.2f) { rEnemyRect.left = 719; rEnemyRect.right = 772; } else if (m_fHitTimer <= 0.2f && m_fHitTimer > 0.1f) { rEnemyRect.left = 787; rEnemyRect.right = 844; } else if (m_fHitTimer <= 0.1f && m_fHitTimer > 0.0f) { rEnemyRect.left = 861; rEnemyRect.right = 912; } if (m_fHitTimer < 0) pES->SendEvent("state transition 4"); } if (GetHP() <= 0 && m_nState == PSYCROW_STATE5) { pMS->SendMsg(new CDestroyMessage(this)); } if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX()) SetXFlip(-1); else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX()) SetXFlip(1); SetPosX(GetPosX() + GetVelX() * fElapsedTime); SetPosY(GetPosY() + GetVelY() * fElapsedTime); if (m_fSineFloat <= -3.14f) m_fSineFloat = 3.14f; m_fSineFloat -= fElapsedTime; rCollisionRect.left = GetPosX(); rCollisionRect.right = GetPosX() + GetWidth(); rCollisionRect.top = GetPosY(); rCollisionRect.bottom = GetPosY() + GetHeight(); SetCollisionRect(rCollisionRect); if (GetPosX() < -32) { SetVelX(-1 * GetVelX()); SetPosX(-31); } else if (GetPosX() > 600) { SetVelX(-1 * GetVelX()); SetPosX(599); } if (GetPosY() < 0) { SetVelY(-1 * GetVelY()); SetPosY(1); } else if (GetPosY() > 400) { SetVelY(-abs(GetVelY())); SetPosY(399); } DWORD timer = GetTickCount(); }
void CEnemyPsycrow::HandleEvent(CEvent *pEvent) { CSGD_ObjectFactory<string, CBase> *pOF = CSGD_ObjectFactory<string, CBase>::GetInstance(); CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); COptions *op = COptions::GetInstance(); if (pEvent->GetEventID() == "psycrow fire") { pBullet = pOF->CreateObject("CBulletHook"); pBullet->SetImageID(GetImageID()); if (GetState() == PSYCROW_STATE1) { if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX()) pBullet->SetVelX(op->GetDifficulty() * 150); else pBullet->SetVelX(op->GetDifficulty() * -150); if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY()) pBullet->SetVelY(op->GetDifficulty() * 150); else pBullet->SetVelY(op->GetDifficulty() * -150); pBullet->SetScoreValue(1); } else if (GetState() == PSYCROW_STATE3) { if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX()) pBullet->SetVelX(0); else pBullet->SetVelX(0); if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY()) pBullet->SetVelY(0); else pBullet->SetVelY(0); pBullet->SetScoreValue(2); } else if (GetState() == PSYCROW_STATE5) { if (CPlayerCharacter::GetInstance()->GetPosX() > GetPosX()) pBullet->SetVelX(op->GetDifficulty() * 50); else pBullet->SetVelX(op->GetDifficulty() * -50); if (CPlayerCharacter::GetInstance()->GetPosY() > GetPosY()) pBullet->SetVelY(op->GetDifficulty() * 50); else pBullet->SetVelY(op->GetDifficulty() * -50); pBullet->SetScoreValue(3); } pBullet->SetPosX(GetPosX() + (GetXFlip() * 64)); pBullet->SetPosY(GetPosY() + 48); pBullet->SetType(ACTOR_BULLET); pBullet->SetHeight(12); pBullet->SetWidth(28); pBullet->SetPower(5 * op->GetDifficulty()); pOM->AddObject(pBullet); } else if (pEvent->GetEventID() == "state transition 1") { m_nState = PSYCROW_STATE2; m_nColor = 200; m_fHitTimer = 0.4f; SetVelX(100 * op->GetDifficulty()); SetVelY(150 * op->GetDifficulty()); SetPower(5 * COptions::GetInstance()->GetDifficulty()); CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 50); if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX()) SetXFlip(-1); else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX()) SetXFlip(1); } else if (pEvent->GetEventID() == "state transition 2") { m_nState = PSYCROW_STATE3; m_nColor = 150; m_fHitTimer = 0.4f; SetPower(0); SetVelX(75 * op->GetDifficulty() * m_nState); CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 75); if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX()) SetXFlip(-1); else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX()) SetXFlip(1); } else if (pEvent->GetEventID() == "state transition 3") { m_nState = PSYCROW_STATE4; m_nColor = 100; m_fHitTimer = 0.4f; SetVelX(250 * op->GetDifficulty()); SetVelY(150 * op->GetDifficulty()); SetPower(5 * COptions::GetInstance()->GetDifficulty()); CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 100); if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX()) SetXFlip(-1); else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX()) SetXFlip(1); } else if (pEvent->GetEventID() == "state transition 4") { m_nState = PSYCROW_STATE5; m_nColor = 50; m_fHitTimer = 0.4f; SetPower(0); SetVelX(75 * op->GetDifficulty() * m_nState); CGamePlay::GetInstance()->SetBridgeVelocity(COptions::GetInstance()->GetDifficulty() * 125); if (CPlayerCharacter::GetInstance()->GetPosX() < GetPosX()) SetXFlip(-1); else if (CPlayerCharacter::GetInstance()->GetPosX() >= GetPosX()) SetXFlip(1); } }
void CGamePlay::Enter() { COptions *op = COptions::GetInstance(); CSGD_ObjectFactory<string, CBase> *pOF = CSGD_ObjectFactory<string, CBase>::GetInstance(); CSGD_ObjectManager *pOM = CSGD_ObjectManager::GetInstance(); CSGD_TextureManager *pTM = CSGD_TextureManager::GetInstance(); CPlayerCharacter *pPC = CPlayerCharacter::GetInstance(); CSGD_EventSystem *pEM = CSGD_EventSystem::GetInstance(); CSGD_DirectSound *pDS = CSGD_DirectSound::GetInstance(); CSGD_WaveManager* pWM = CSGD_WaveManager::GetInstance(); m_nBridgeOffset = 0; m_nSpaceOffset = 0; m_nEnemyCounter = 0; m_nTotalSpawns = 0; stateTimer = 6.0f; m_fSpawnPowerupTimer = 15.0f; // Register classes with ObjectFactory pEM->RegisterClient("scroll right", this); pEM->RegisterClient("scroll left", this); pEM->RegisterClient("spawn enemies",this); pEM->RegisterClient("spawn powerups",this); pOF->RegisterClassType<CPlayerCharacter>("CPlayerCharacter"); pOF->RegisterClassType<CBullet>("CBullet"); pOF->RegisterClassType<CEnemyDemon>("CEnemyDemon"); pOF->RegisterClassType<CEnemyBusiness>("CEnemyBusiness"); pOF->RegisterClassType<CBulletPaper>("CBulletPaper"); pOF->RegisterClassType<CEnemyMeat>("CEnemyMeat"); pOF->RegisterClassType<CBulletFire>("CBulletFire"); pOF->RegisterClassType<CEnemyBooger>("CEnemyBooger"); pOF->RegisterClassType<CPowerup1up>("CPowerup1up"); pOF->RegisterClassType<CPowerupHealth>("CPowerupHealth"); pOF->RegisterClassType<CPowerupRapidFire>("CPowerupRapidFire"); pOF->RegisterClassType<CPowerupThreeWay>("CPowerupThreeWay"); pOF->RegisterClassType<CEnemyPsycrow>("CEnemyPsycrow"); pOF->RegisterClassType<CBulletHook>("CBulletHook"); m_nImageID[0] = pTM->LoadTexture("Resource\\JoA_EarthwormJim.bmp", D3DCOLOR_XRGB(80,192,64)); m_nImageID[1] = pTM->LoadTexture("Resource\\JoA_jim_level2enemies.png",D3DCOLOR_XRGB(0,64,128)); m_nImageID[2] = pTM->LoadTexture("Resource\\JoA_ewj2-flaminyawn.png",D3DCOLOR_XRGB(0,64,128)); m_nImageID[3] = pTM->LoadTexture("Resource\\JoA_earthwormjim-items.png",D3DCOLOR_XRGB(0,128,255)); m_nImageID[4] = pTM->LoadTexture("Resource\\JoA_ewj_forpete.png",D3DCOLOR_XRGB(0,64,128)); m_nBGID = pTM->LoadTexture("Resource\\JoA_jim_psycro.png", D3DCOLOR_XRGB(0,64,128)); pOM->AddObject(CPlayerCharacter::GetInstance()); m_fFinishedTimer = 5.0f; m_Font.SetFontImageID( CSGD_TextureManager::GetInstance()->LoadTexture("resource/JoA_023 - small.bmp", D3DCOLOR_XRGB(0, 0, 0)) ); m_Font.SetCharWidth( 16 ); m_Font.SetCharHeight( 16 ); m_Font.SetNumCols( 10 ); m_Font.SetStartChar( ' ' ); m_Font2.SetFontImageID( CSGD_TextureManager::GetInstance()->LoadTexture("resource/JoA_023 - large.bmp", D3DCOLOR_XRGB(0, 0, 0)) ); m_Font2.SetCharWidth( 32 ); m_Font2.SetCharHeight( 32 ); m_Font2.SetNumCols( 10 ); m_Font2.SetStartChar( ' ' ); pPC->SetBulletScale(1.0f); pPC->SetRateOfFire(7); pPC->SetHP(100); pPC->SetPosX( 100.0f ); pPC->SetImageID(m_nImageID[0]); pPC->SetThreeWay(false); pPC->SetGodMode(false); pPC->SetVelX(0.00000004f); pPC->SetVelY(0.00000004f); pPC->SetInvulnerable(false); pPC->SetRapidFireTimer(0.0f); pPC->SetThreeWayTimer(0.0f); if (GetLevel() == 1) { pPC->SetPosY( 202.0f ); SetRemainingEnemies(10); m_nBGMusicID = pWM->LoadWave("Resource/sounds/JoA_Song3.wav"); pWM->SetVolume(m_nBGMusicID,op->GetMusicVolume() - 25); } else if (GetLevel() == 2) { pPC->SetPosY(375.0f); SetRemainingEnemies(10); m_nBGMusicID = pWM->LoadWave("Resource/sounds/JoA_Song4.wav"); pWM->SetVolume(m_nBGMusicID,op->GetMusicVolume() - 25); } else if (GetLevel() == 3) { pPC->SetPosY(250.0f); SetRemainingEnemies(1); m_nBridgeOffsetY = 300; m_nBridgeVelocityY = 25 * op->GetDifficulty(); pEM->SendEvent("spawn enemies", NULL); m_nBGMusicID = pWM->LoadWave("Resource/sounds/JoA_Song2.wav"); pWM->SetVolume(m_nBGMusicID,op->GetMusicVolume() - 25); } pWM->Play(m_nBGMusicID,1); }