dev-jjjjjeong-bin / Invaders-SDP

3 stars 15 forks source link

[BUG] (Enemy Team) Purple Enemy Item Drop Issue with Exploding Enemy Ships #54

Closed Dream-no24 closed 4 days ago

Dream-no24 commented 1 week ago

Problem Description

Currently, purple enemies are supposed to drop items upon death. However, when they are killed by exploding enemy ships, they do not drop any items.

Todo List

Feature Description

Ensure purple enemies drop items in all situations, including when killed by exploding enemy ships.

Additional Information

Purple enemies that drop items and explosive enemyship are developed by Team Enemy. The interaction between exploding ships and item drops may need additional logic.

HSHyun commented 5 days ago

The method for dropping items from magenta mobs works as follows:

  1. The collision between the enemy and bullets is detected in the _manageCollisions_add_item_ method of the GameScreen class.
  2. If a collision is found, the _destroy function of the EnemyShipFormation class is executed.
  3. Afterward, if the destroyed enemy is magenta, an item is dropped in _manageCollisions_additem.

However, enemies that die due to the explosive mob are not killed by the _destroy called from _manageCollisions_additem but rather by the chain explosion method explosive from the EnemyShipFormation class. In other words, magenta mobs killed by the explosion method in EnemyShipFormation didn’t drop items because they were not detected as dead in GameScreen.

To fix this, I modified the code so that instead of dropping an item when a collision occurs, items are dropped when _destroy is called and the magenta mob dies.

Dream-no24 commented 4 days ago

After testing, I confirmed that when the Magenta enemy is destroyed by an explosive enemy, the item is dropped correctly.

Excellent work, thank you!

https://github.com/user-attachments/assets/afa43f08-8185-4541-8dd0-54449e8e633f