CHero::CHero(void) : CUnit(UT_HERO) { SetHP(100); SetMaxHP(100); SetAttack(9); SetSpeed(4); SetRange(1); SetEXPValue(0); SetHasAttacked(false); SetShielded(false); SetIsMoving(false); // TODO: Setup abilities when they are in place5 // Finds specified spell for the Hero CAbilityManager * pAM = CAbilityManager::GetInstance(); GiveSpell(SP_BLANK); GiveSpell(SP_BLANK); GiveSpell(SP_BLANK); GiveSpell(SP_BLANK); for (int i=0; i<4;++i) m_ncooldown[i]=0; }
void AttackDisplay::Update( float fDelta ) { ActorFrame::Update( fDelta ); if( GAMESTATE->m_PlayMode != PLAY_MODE_BATTLE && GAMESTATE->m_PlayMode != PLAY_MODE_RAVE ) return; if( !GAMESTATE->m_bAttackBeganThisUpdate[m_PlayerNumber] ) return; // don't handle this again for( unsigned s=0; s<GAMESTATE->m_ActiveAttacks[m_PlayerNumber].size(); s++ ) { if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].fStartSecond >= 0 ) continue; /* hasn't started yet */ if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].fSecsRemaining <= 0 ) continue; /* ended already */ if( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].IsBlank() ) continue; SetAttack( GAMESTATE->m_ActiveAttacks[m_PlayerNumber][s].sModifier ); break; } }
void CHeavyInfantry::HandleEvent(CEvent* pEvent) { if( pEvent->GetEventID() == "big.bang" && GetTarget() == NULL ) { CPlayer* player = (CPlayer*)pEvent->GetParam(); tVector2D distanceToPlayer; distanceToPlayer.fX = player->GetPosX()-GetPosX(); distanceToPlayer.fY = player->GetPosY()-GetPosY(); player->GetCurrWeapon(); if( Vector2DLength(distanceToPlayer) <= player->GetCurrWeapon()->GetSoundDistance()) { ChangeState(CAttackState::GetInstance()); SetTarget(player); CEventSystem::GetInstance()->SendEvent("player.detected",this); } } if( pEvent->GetEventID() == "player.detected" && pEvent->GetParam() != this ) { CEnemy* pEnemy = (CEnemy*)pEvent->GetParam(); tVector2D toTarget; toTarget.fX = pEnemy->GetPosX() - GetPosX(); toTarget.fY = pEnemy->GetPosY() - GetPosY(); if( Vector2DLength(toTarget) < 200 ) { CEventSystem::GetInstance()->SendEvent("join.squad",this); } } if( pEvent->GetEventID() == "form.up" ) { SetAttack(false); } if( pEvent->GetEventID() == "engage.player") { SetAttack(true); } if( pEvent->GetEventID() == "fire.bullet" ) { GetWeapon()->FireWeapon(this); } }
CSwordsman::CSwordsman(void) : CUnit(UT_SWORDSMAN) { SetHP(25); SetMaxHP(25); SetAttack(8); SetSpeed(3); SetRange(1); SetEXPValue(75); SetHasAttacked(false); SetShielded(false); SetIsMoving(false); // TODO: Setup abilities when they are in place }
CObject_Appletree::CObject_Appletree(int GHandle, double x, double y, int Width, int Height, unsigned int Type) : CObject_Enemy(GHandle, x, y, Width, Height, Type) { GraphHandle = ResourceManager::getResourceManager()->GetRes(GHandle); Stand = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_STAND), 1, 0, 0, 1, 1, 358, 482, 100, TRUE); Hit = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_HIT), 1, 0, 0, 1, 1, 358, 482, 100, TRUE); Death = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_DEAD), 7, 0, 0, 7, 1, 2506, 482, 65, TRUE); Poison = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLETREE_POISON), 8, 0, 0, 8, 1, 3200, 480, 120, TRUE); Apple[0]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 50, TRUE); Apple[1]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 50, TRUE); Break[0]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 64, TRUE); Break[1]= new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BREAK), 6, 0, 0, 6, 1, 696, 108, 64, TRUE); Boom[0] = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BOOM), 7, 0, 0, 7, 1, 1610, 230, 128, TRUE); Boom[1] = new CSprite(GetResourceWithKey(IMAGE_OBJECT_APPLE_BOOM), 7, 0, 0, 7, 1, 1610, 230, 128, TRUE); b_left = true; b_right = false; Center = WorldX + 133; RecognizeRange = 550; AttackRange = 225; //PatrolRange = -1; SetMove(false); SetAttack(false); SetHit(false); AttackDelay = 270; AttackCount = -1; HeroKnockbackCount = -1; KnockbackCount = -1; HitCount = -1; Stat_ST = 40; Damage = Stat_ST * 0.5f; Stat_HP = 8; MaxHP = Stat_HP * 3; HP = MaxHP; Speed = 0; Exp = 0; tempY[0] = (int)fDrawY; tempY[1] = (int)fDrawY; b_apple[0] = false; b_apple[1] = false; }
//----------------------------------------------------------- // //----------------------------------------------------------- SynthEG::SynthEG(Real _a, Real _d, Real _s, Real _r) : m_phase(), m_state(EGState::OFF), m_attack(), m_decay(), m_sustain(), m_release(), m_delta_phase_decay(), m_delta_phase_release(), m_release_level(), m_attack_rate(), m_last_val() { SetAttack(_a); SetDecay(_d); SetSustain(_s); SetRelease(_r); }
void CObject_Appletree::Update() { Center = WorldX + GetWidth()/2; SetAttackBox(0, 0, 0, 0); if(HeroForEnemy->GetWorldX()+100 < Center && !b_Attack) // Hero가 왼쪽에 있을 때 { b_left = true; b_right = false; } else if(HeroForEnemy->GetWorldX()+100 > Center && !b_Attack) { b_left = false; b_right = true; } // 인식범위 설정 int RcnzX = Center; if(b_left) { RcnzX -= RecognizeRange; } else if(b_right) { RcnzX += RecognizeRange; } // 공격범위 설정 int AtkX = Center; if(b_left) { AtkX -= AttackRange; } else if(b_right) { AtkX += AttackRange; } // 인식범위 내에서의 행동따윈 필요없다. // 공격범위 내에서의 행동 if(GetHP() > 0) { if(HeroForEnemy->GetWorldX()+100 > AtkX && b_left) { if(AttackCount == -1 ) { SetAttack(true); AttackCount = 0; } if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) { SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 191, 220); } for(int i=0; i<2; i++) { if(Break[i]->GetCount() >=1 && Break[i]->GetCount() <= 3) { SetAttackBox((int)GetDrawX()+25, (int)GetDrawY()+400, 180, 100); } } b_apple[0] = true; } else if(HeroForEnemy->GetWorldX()+100 < AtkX && b_right) { if(AttackCount == -1 ) { SetAttack(true); AttackCount = 0; } if(Poison->GetCount() >= 1 && Poison->GetCount() <= 2) { SetAttackBox((int)GetDrawX()+30, (int)GetDrawY()+250, 250, 220); } } if(AttackCount != -1) { AttackCount++; } if(Poison->GetCount() >= 6) { Poison->SetCount(0); SetAttack(false); } if(AttackCount > AttackDelay) { AttackCount = -1; Poison->SetCount(0); SetAttack(false); } } // 충돌박스 설정 SetBoundBox((int)GetDrawX()+100, (int)GetDrawY()+50, 158, 400); // Hero와의 충돌판정 if(GetHP() > 0) { if(CCollision::GetCollision()->Box_n_Box( HeroForEnemy->GetBoundX()-1, HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth()+1, HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(), GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight())) { if(HeroForEnemy->GetWorldX()+100 < Center) // Hero가 왼쪽에 있을 때 { //HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - HeroForEnemy->GetWidth() + (int)((HeroForEnemy->GetWidth() - HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY()); HeroForEnemy->MoveTo(GetWorldX() + (int)((GetWidth()-GetBoundWidth())/2) - 115, HeroForEnemy->GetWorldY()); } else if(HeroForEnemy->GetWorldX()+100 >= Center) // Hero가 오른쪽에 있을 때 { HeroForEnemy->MoveTo(GetWorldX() + GetWidth() - (int)((GetWidth()-GetBoundWidth())/2) - (int)((HeroForEnemy->GetWidth()-HeroForEnemy->GetBoundWidth())/2), HeroForEnemy->GetWorldY()); } } } // Hero에게 공격판정 if(CCollision::GetCollision()->Box_n_Box( HeroForEnemy->GetBoundX(), HeroForEnemy->GetBoundY(), HeroForEnemy->GetBoundX()+HeroForEnemy->GetBoundWidth(), HeroForEnemy->GetBoundY()+HeroForEnemy->GetBoundHeight(), GetAttackX(), GetAttackY(), GetAttackX()+GetAttackWidth(), GetAttackY()+GetAttackHeight())) { if(!HeroForEnemy->GetHit()) { int dmg = (int)GetDmg(); if(b_left) { if(HeroForEnemy->GetWay() == 1 && HeroForEnemy->GetGuard()) { dmg = (int)(dmg * 0.3f); HeroForEnemy->SetGuardHit(TRUE); } } else if(b_right) { if(HeroForEnemy->GetWay() == 0 && HeroForEnemy->GetGuard()) { dmg = (int)(dmg * 0.3f); HeroForEnemy->SetGuardHit(TRUE); } } HeroForEnemy->SetHP(HeroForEnemy->GetHP() - dmg); HeroForEnemy->SetHit(true); //SetAttack(false); if(HeroKnockbackCount == -1) { HeroKnockbackCount = 0; } } } // 넉백 if(HeroKnockbackCount != -1) { if(HeroForEnemy->GetWorldX()+100 < Center) // Hero가 왼쪽에 있을 때 { if(HeroForEnemy->GetGuard()) { HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-2, HeroForEnemy->GetWorldY()); } else { HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()-3, HeroForEnemy->GetWorldY()); } } else if(HeroForEnemy->GetWorldX()+100 > Center) // Hero가 오른쪽에 있을 때 { if(HeroForEnemy->GetGuard()) { HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+2, HeroForEnemy->GetWorldY()); } else { HeroForEnemy->MoveTo(HeroForEnemy->GetWorldX()+3, HeroForEnemy->GetWorldY()); } } if(HeroKnockbackCount >= 15) { HeroKnockbackCount = -1; Hit->SetCount(0); } else { HeroKnockbackCount++; } } // Hero에게 피격판정 if(GetHP() > 0) { if(CCollision::GetCollision()->Box_n_Box( HeroForEnemy->GetAttackX(), HeroForEnemy->GetAttackY(), HeroForEnemy->GetAttackX()+HeroForEnemy->GetAttackWidth(), HeroForEnemy->GetAttackY()+HeroForEnemy->GetAttackHeight(), GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) || CCollision::GetCollision()->Box_n_Box( HeroForEnemy->GetSkillX(), HeroForEnemy->GetSkillY(), HeroForEnemy->GetSkillX()+HeroForEnemy->GetSkillWidth(), HeroForEnemy->GetSkillY()+HeroForEnemy->GetSkillHeight(), GetBoundX(), GetBoundY(), GetBoundX()+GetBoundWidth(), GetBoundY()+GetBoundHeight()) ) { b_apple[1] = true; Poison->SetCount(0); SetHit(true); if(HitCount == -1) { HitCount = 0; SetHP(GetHP() - HeroForEnemy->GetDmg()); } if(KnockbackCount == -1) { KnockbackCount = 0; } } /* if(KnockbackCount != -1) { if(HeroForEnemy->GetWorldX()+100 < Center) // Hero가 왼쪽에 있을 때 { MoveTo(GetWorldX()+2, GetWorldY()); } else if(HeroForEnemy->GetWorldX()+100 > Center) // Hero가 오른쪽에 있을 때 { MoveTo(GetWorldX()-2, GetWorldY()); } if(KnockbackCount >= 10) { KnockbackCount = -1; } else { KnockbackCount++; } } if(GetHP() <= 0) { HeroForEnemy->SetExp(HeroForEnemy->GetExp() + GetExp()); } */ if(HitCount >= 0) { HitCount++; if(HitCount >= 20) { HitCount = -1; SetHit(false); //HitEffect->SetCount(0); } } } /* // 벽 if(GetWorldX() < -76) { WorldX = -76; } */ if(GetHP() < 0) { Opacity -= 6; b_Move = false; b_Attack = false; } }