CRock_Fall::CRock_Fall(void) { CEntity::m_eType = ENT_ROCK_FALL; SetOwnerType(ENT_BASE); SetFlipped(true); SetSpeed(250.0f); AnimationManager::GetInstance()->LoadAnimationFile("config/Boulder_Trap.xml"); SetBaseAnimations(ENT_ROCK_FALL); GetAnimInfo()->SetAnimationName("Boulder_Trap"); }
CWrecking_Ball::CWrecking_Ball(void) { CEntity::m_eType = ENT_WRECKING_BALL; SetOwnerType(ENT_BASE); SetFlipped(true); SetSpeed(250.0f); AnimationManager::GetInstance()->LoadAnimationFile("config/Wrecking_Ball.xml"); SetBaseAnimations(ENT_WRECKING_BALL); GetAnimInfo()->SetAnimationName("Wrecking_Ball"); }
void FCSCard::User2Perl(const char *String) { SetFlipped(User2PerlFlippedStatus(String)); SetCardNumber(User2PerlCardNumber(String)); SetSuit(User2PerlSuit(String)); }
void CFighter::Update(float fElapsedTime) { // Update common properties across all enemies CEnemy::Update(fElapsedTime); // if this enemy is cc'd don't if (m_pEState->GetTimer() == true) { m_pEState->CEntityState::Update(fElapsedTime); return; } if (GetAnimInfo()->GetAnimationName() == GetAnimations("Idle") && m_bAttacking == true) m_bSecondAttackQueued = m_bAttacking = false; if (m_bAttacking == true) return; m_fUpdateOldPos += fElapsedTime; if(GetTarget() != nullptr) { float tar_pos_x = GetTarget()->GetPosX() - 32; float tar_pos_y = GetTarget()->GetPosY(); if(tar_pos_x > GetPosX()) { //set Grunt's animation's facing to the right SetFlipped( true ); } else { SetFlipped( false ); } if(m_fMoveAway <= 0) { //Simple Pathing twards the player if(tar_pos_y != GetPosY())//Above the Player { float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2); if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x) { if( tar_pos_x < GetPosX()) SetVelX(speed * fElapsedTime); else SetVelX(-speed * fElapsedTime); } else { if( tar_pos_y < GetPosY()) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); } int threshold = 5; if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold) SetVelX(0); if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold) SetVelY(0); } else { SetVelY(0); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); } } else { m_fMoveAway -= fElapsedTime; if(m_bEvadeUp) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); } //Check Colider if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0)) SetPosX(GetPosX() + GetVelX()); else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), -GetVelX(), 0)) SetPosX(GetPosX() - GetVelX()); else { if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY())) SetPosY(GetPosY() + GetVelY()); else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, -GetVelY())) SetPosY(GetPosY() - GetVelY()); else { SetPosX(m_fStartPosX); SetPosY(m_fStartPosY); } } if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY())) SetPosY(GetPosY() + GetVelY()); else if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, -GetVelY())) SetPosY(GetPosY() - GetVelY()); if(GetPosX() < 0) SetPosX(0); if(cooldown <= 0) { if((GetPosX() - tar_pos_x) < 120 && (GetPosX() - tar_pos_x) > -64 ) { if(GetPosY() - tar_pos_y < 16 && GetPosY() - tar_pos_y > -16) { GetAnimInfo()->SetAnimationName(m_vAttacks[rand() % 4]); m_bAttacking = true; cooldown = 3.0f; } } } else cooldown -= fElapsedTime; //Update/use move away if(m_fUpdateOldPos >= 0.5f) { if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX()) { if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY()) { //if(!m_bRushing) { m_bEvadeUp = !m_bEvadeUp; if(m_fMoveAway <= 0) m_fMoveAway = 3.0f; } } } m_fPosXOld = GetPosX(); m_fPosYOld = GetPosY(); m_fUpdateOldPos = 0.0f; } } }
void CEarthBoss::Update(float fElapsedTime) { CEnemy::Update(fElapsedTime); if (m_pEState->GetState() == EntityState::DEAD) { return; } m_fUpdateOldPos += fElapsedTime; if(m_nCoolDown > 0) m_nCoolDown -= fElapsedTime; if( m_fPunchCoolDown > 0.0f && m_bPunching == true) m_fPunchCoolDown -= fElapsedTime; else { m_fPunchCoolDown = 2.5f; m_bPunching = false; } if (m_fSpecialTimer > 0.0f) m_fSpecialTimer -= fElapsedTime; else { CCreate_Rock_Fall_Message* pMsg = new CCreate_Rock_Fall_Message(); CSGD_MessageSystem::GetInstance()->SendMsg(pMsg); pMsg = nullptr; m_fSpecialTimer = 15.0f; } //if not rushing do basic path finding to the player if(GetTarget() != nullptr) { float tar_pos_x = GetTarget()->GetPosX(); float tar_pos_y = GetTarget()->GetPosY(); if(tar_pos_x > GetPosX()) { //set Grunt's animation's facing to the right SetFlipped(true); } else { SetFlipped(false); } if(m_fMoveAway <= 0) { // tar_pos_x += (m_bFlipped) ? -236 : 236; //Simple Pathing twards the player if(tar_pos_y != GetPosY())//Above the Player { float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2); if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x) { if( tar_pos_x < GetPosX()) SetVelX(speed * fElapsedTime); else SetVelX(-speed * fElapsedTime); } else { if( tar_pos_y < GetPosY()) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); if( tar_pos_x > (GetPosX() - 64) && tar_pos_x < (GetPosX() + 64) ) { if( tar_pos_y > (GetPosY() - 32) && tar_pos_y < (GetPosY() + 32) && m_bPunching == false) { GetAnimInfo()->SetAnimationName("Boss1_Attack_Animation"); m_bPunching = true; //dynamic_cast<CPlayer*>(GetTarget())->SetState(CEntityState::KNOCKED_DOWN); } } } } else { SetVelY(0); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); } //if the player can be shot at. if(m_nCoolDown <= 0 && GetPosX() - tar_pos_x < 128 && GetPosX() - tar_pos_x > -128 ) { if(GetPosY() - tar_pos_y < 5 && GetPosY() - tar_pos_y > -5 && m_bPunching == false) { //GetAnimInfo()->SetAnimationName("Boss1_Shoot_Animation"); ////if in range rushing starts //CCreate_Projectile_Message* c_pProjectMSG = new CCreate_Projectile_Message(ENT_ENEMY, IsFlipped()); //c_pProjectMSG->SetPosX(this->GetPosX()); //c_pProjectMSG->SetPosY(this->GetPosY()); //CSGD_MessageSystem::GetInstance()->SendMsg(c_pProjectMSG); m_nCoolDown += 5; } } //stop 'bouncing' int threshold = 5; if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold) SetVelX(0); if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold) SetVelY(0); } else //update move away { m_fMoveAway -= fElapsedTime; if(m_bEvadeUp) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); } } //Check Colider if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0)) { SetPosX(GetPosX() + GetVelX()); if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY())) { SetPosY(GetPosY() + GetVelY()); } } else { if( GetPosY() >= 600 ) SetPosY( (GetPosY() - (GetPosY() - 599)) ); else SetPosY(GetPosY() + 1); SetVelX(0); SetVelY(0); } if(GetPosX() < 0) SetPosX(0); //Set/use Move out of the way if(m_fUpdateOldPos >= 1.0f) { if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX()) { if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY()) { if(m_nCoolDown <= 0) { m_bEvadeUp = !m_bEvadeUp; if(m_fMoveAway <= 0) m_fMoveAway = 4.0f; } } } m_fPosXOld = GetPosX(); m_fPosYOld = GetPosY(); m_fUpdateOldPos = 0.0f; } }
void CGrunt::Update(float fElapsedTime) { // Update common properties across all enemies CEnemy::Update(fElapsedTime); // if this enemy is cc'd don't if (m_pEState->GetTimer() == true) { m_pEState->CEntityState::Update(fElapsedTime); return; } m_fUpdateOldPos += fElapsedTime; if( cooldown <= 0.0f ) punching = false; if( punching == true ) cooldown -= fElapsedTime; if (GetAnimInfo()->GetAnimationName() == "Grunt_Attack_Animation") return; if(GetTarget() != nullptr) { float tar_pos_x = GetTarget()->GetPosX(); float tar_pos_y = GetTarget()->GetPosY(); if(tar_pos_x > GetPosX()) { //set Grunt's animation's facing to the right m_bFlipped = true; } else { // Set Grunt's animation to face to the left m_bFlipped = false; } SetFlipped( m_bFlipped ); if(m_fMoveAway <= 0) { tar_pos_x += (m_bFlipped) ? -66 : 66; //Simple Pathing twards the player if(tar_pos_y != GetPosY() )//Above the Player { float min_Distance = (float)(GetTarget()->GetWidth()/2 + GetWidth()/2); if(GetPosX() + min_Distance > tar_pos_x && GetPosX() - min_Distance < tar_pos_x) { if( tar_pos_x < GetPosX()) SetVelX(speed * fElapsedTime); else SetVelX(-speed * fElapsedTime); } else { if( tar_pos_y < GetPosY()) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); } } else { SetVelY(0); if( tar_pos_x < GetPosX()) SetVelX(-speed * fElapsedTime); else SetVelX(speed * fElapsedTime); } //stop 'bouncing' int threshold = 5; if(tar_pos_x - GetPosX() < threshold && tar_pos_x - GetPosX() > -1 * threshold) SetVelX(0); if(tar_pos_y - GetPosY() < threshold && tar_pos_y - GetPosY() > -1 * threshold) SetVelY(0); } else//update move away { m_fMoveAway -= fElapsedTime; if(m_bEvadeUp) SetVelY(-speed * fElapsedTime); else SetVelY(speed * fElapsedTime); } //Check Colider if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), GetVelX(), 0)) { SetPosX(GetPosX() + GetVelX()); if(TileManager::GetInstance()->CheckBlockedTiles(GetPosX(), GetPosY(), 0, GetVelY())) SetPosY(GetPosY() + GetVelY()); } else { if( GetPosY() >= 600 ) SetPosY( (GetPosY() - (GetPosY() - 599)) ); else SetPosY(GetPosY() + 1); SetVelX(0); SetVelY(0); } if(GetPosX() < 0) SetPosX(0); if(punching == false && GetPosX() - tar_pos_x < 10 && GetPosX() - tar_pos_x > - 10 ) { if(GetPosY() - tar_pos_y < 32 && GetPosY() - tar_pos_y > -32) { GetAnimInfo()->SetAnimationName("Grunt_Attack_Animation"); punching = true; cooldown = 3.0f; } } //Set/use Move out of the way if(m_fUpdateOldPos >= 1.0f) { if(m_fPosXOld + 5 > GetPosX() && m_fPosXOld - 5 < GetPosX()) { if(m_fPosYOld + 5 > GetPosY() && m_fPosYOld - 5 < GetPosY()) { if(cooldown <= 0) { m_bEvadeUp = !m_bEvadeUp; if(m_fMoveAway <= 0) m_fMoveAway = 4.0f; } } } m_fPosXOld = GetPosX(); m_fPosYOld = GetPosY(); m_fUpdateOldPos = 0.0f; } } }