I was wondering if this made sense. I want to have a player Ship who has a skill called "Drain Bullet". This skill fires a bullet and will drain the health of a ship that the bullet hits.
I will be polling for for bullet collision in the Game class, and I want it so when it callsSkill slowBullet = new Skill(10, 1, 5, "Drain Bullet") { public void affect(Ship shooter) { final Ship player = shooter; Bullet bullet = new Bullet(BulletType.PLAYER, shooter, 10, -1, new Skill(0, 0, 0, "Drain Bullet") { public void affect(Ship target) { target.takeDamage(10); player.heal(10); } }); Game.addBullet(bullet); } };
the Player will heal, and the enemy will take damage.bullet.affect(enemy); // enemy is the ship that gets hit by the bullet
Does this code actually make sense? Seems really confusing and I don't know if it will work.