优化 attack_type

This commit is contained in:
aozhiwei 2020-07-06 16:15:37 +08:00
parent d34c6d0800
commit a8df40d694
5 changed files with 17 additions and 5 deletions

View File

@ -77,7 +77,7 @@ void Bullet::OnHit(std::set<Entity*>& objects)
case ET_Obstacle: case ET_Obstacle:
{ {
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) && obstacle->meta->i->attack_type() == 1) { if (!obstacle->IsDead(room) && obstacle->Attackable()) {
float dmg = GetAtk() * (1 + player->GetBuffAttrRate(kHAT_Atk)) + float dmg = GetAtk() * (1 + player->GetBuffAttrRate(kHAT_Atk)) +
player->GetBuffAttrAbs(kHAT_Atk); player->GetBuffAttrAbs(kHAT_Atk);
float def = 0; float def = 0;

View File

@ -495,7 +495,7 @@ bool Human::IsCollisionInMapService()
#endif #endif
if (last_collision_door_ != collider->owner) { if (last_collision_door_ != collider->owner) {
if (!obstacle->IsDead(room) && if (!obstacle->IsDead(room) &&
obstacle->meta->i->attack_type() == 1 && obstacle->Attackable() &&
obstacle->meta->i->drop() != 0 && obstacle->meta->i->drop() != 0 &&
room->GetGasData().gas_mode != GasInactive room->GetGasData().gas_mode != GasInactive
) { ) {

View File

@ -62,7 +62,7 @@ void Obstacle::RecalcSelfCollider()
} }
SetPos(old_pos); SetPos(old_pos);
} }
} else if (meta->i->attack_type() != 2){ } else if (!Throughable()){
switch (meta->i->type()) { switch (meta->i->type()) {
case 1: case 1:
{ {
@ -284,7 +284,7 @@ void Obstacle::Explosion(Bullet* bullet)
case ET_Obstacle: case ET_Obstacle:
{ {
Obstacle* obstacle = (Obstacle*)target; Obstacle* obstacle = (Obstacle*)target;
if (!obstacle->IsDead(room) && obstacle->meta->i->attack_type() == 1) { if (!obstacle->IsDead(room) && obstacle->Attackable()) {
float dmg = meta->i->damage(); float dmg = meta->i->damage();
float def = 0; float def = 0;
float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K); float finaly_dmg = dmg * (1 - def/MetaMgr::Instance()->K);
@ -424,3 +424,13 @@ bool Obstacle::IsPermanent()
} }
return is_permanent; return is_permanent;
} }
bool Obstacle::Attackable()
{
return meta->i->attack_type() == 1;
}
bool Obstacle::Throughable()
{
return meta->i->attack_type() == 2;
}

View File

@ -50,6 +50,8 @@ class Obstacle : public Entity
void SetHealth(Room* room, float value); void SetHealth(Room* room, float value);
void Die(Room* room); void Die(Room* room);
bool IsPermanent(); bool IsPermanent();
bool Attackable();
bool Throughable();
protected: protected:
Obstacle(); Obstacle();

View File

@ -39,7 +39,7 @@ void RoomObstacle::Initialize()
void RoomObstacle::RecalcSelfCollider() void RoomObstacle::RecalcSelfCollider()
{ {
if (meta->i->attack_type() != 2){ if (!Throughable()){
switch (meta->i->type()) { switch (meta->i->type()) {
case 1: case 1:
{ {