void IMovable::processImage(DrawType type) { if (NODRAW) return; if (!GetSprite() || GetSprite()->Fail() || !GetMetadata()) return; if (GetMetadata()->dirs >= 4) { DrawMain(helpers::dir_to_byond(dMove), GetDrawX() + mob_position::get_shift_x(), GetDrawY() + mob_position::get_shift_y()); } else { DrawMain(0, GetDrawX() + mob_position::get_shift_x(), GetDrawY() + mob_position::get_shift_y()); } }
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; } }