添加坦克压人逻辑

This commit is contained in:
aozhiwei 2019-08-29 15:44:26 +08:00
parent 559eec5146
commit 6917e2f42b
5 changed files with 6 additions and 9 deletions

View File

@ -108,12 +108,7 @@ void Bullet::ProcBomb()
std::set<Entity*> objects; std::set<Entity*> objects;
for (auto& grid : grid_list) { for (auto& grid : grid_list) {
for (Human* hum: grid->human_list) { for (Human* hum: grid->human_list) {
#if 1 if (!is_tank_skin || player->team_id != hum->team_id) {
{
#else
if (hum != player &&
(hum->team_id == 0 || player->team_id != hum->team_id)) {
#endif
if (TestCollision(hum)) { if (TestCollision(hum)) {
objects.insert(hum); objects.insert(hum);
} }

View File

@ -25,6 +25,7 @@ class Bullet : public Entity
a8::Vec2 born_pos; a8::Vec2 born_pos;
a8::Vec2 born_dir; a8::Vec2 born_dir;
float fly_distance = 0.0f; float fly_distance = 0.0f;
bool is_tank_skin = false;
MovementComponent* movement = nullptr; MovementComponent* movement = nullptr;
Bullet(); Bullet();

View File

@ -349,7 +349,7 @@ void Human::TankShot(a8::Vec2& target_dir)
bullet_dir.Rotate(bullet_angle / 180.0f); bullet_dir.Rotate(bullet_angle / 180.0f);
room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance); room->frame_event.AddBullet(this, bullet_born_pos, bullet_dir, fly_distance);
if (room->BattleStarted() || (room->gas_data.gas_mode == GasJump && !a8::HasBitFlag(status, HS_Jump))) { if (room->BattleStarted() || (room->gas_data.gas_mode == GasJump && !a8::HasBitFlag(status, HS_Jump))) {
room->CreateBullet(this, &tank_weapon, bullet_born_pos, bullet_dir, fly_distance); room->CreateBullet(this, &tank_weapon, bullet_born_pos, bullet_dir, fly_distance, true);
} }
} }
--tank_weapon.ammo; --tank_weapon.ammo;

View File

@ -541,7 +541,7 @@ int Room::CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv)
} }
void Room::CreateBullet(Human* hum, Weapon* weapon, void Room::CreateBullet(Human* hum, Weapon* weapon,
a8::Vec2 pos, a8::Vec2 dir, float fly_distance) a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin)
{ {
Bullet* bullet = new Bullet(); Bullet* bullet = new Bullet();
bullet->player = hum; bullet->player = hum;
@ -554,6 +554,7 @@ void Room::CreateBullet(Human* hum, Weapon* weapon,
bullet->born_pos = pos; bullet->born_pos = pos;
bullet->born_dir = dir; bullet->born_dir = dir;
bullet->fly_distance = fly_distance; bullet->fly_distance = fly_distance;
bullet->is_tank_skin = is_tank_skin;
bullet->entity_uniid = AllocUniid(); bullet->entity_uniid = AllocUniid();
bullet->Initialize(); bullet->Initialize();
AddObjectLater(bullet); AddObjectLater(bullet);

View File

@ -78,7 +78,7 @@ public:
Hero* CreateHero(Human* hum); Hero* CreateHero(Human* hum);
int CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv); int CreateLoot(int equip_id, a8::Vec2 pos, int count, int equip_lv);
void CreateBullet(Human* hum, Weapon* weapon, void CreateBullet(Human* hum, Weapon* weapon,
a8::Vec2 pos, a8::Vec2 dir, float fly_distance); a8::Vec2 pos, a8::Vec2 dir, float fly_distance, bool is_tank_skin = false);
void OnHumanDie(Human* hum); void OnHumanDie(Human* hum);
bool OverBorder(const a8::Vec2 pos, float radius); bool OverBorder(const a8::Vec2 pos, float radius);