Minor changes
Fixed magic weapons using the wrong sound Made some changes to better detect the weapon used to attack
This commit is contained in:
@@ -29,6 +29,7 @@ import inf101.v18.rogue101.map.IMapView;
|
||||
import inf101.v18.rogue101.map.MapReader;
|
||||
import inf101.v18.rogue101.objects.*;
|
||||
import inf101.v18.rogue101.shared.NPC;
|
||||
import inf101.v18.rogue101.states.Attack;
|
||||
import javafx.scene.canvas.GraphicsContext;
|
||||
import javafx.scene.input.KeyCode;
|
||||
import javafx.scene.paint.Color;
|
||||
@@ -182,8 +183,7 @@ public class Game implements IGame {
|
||||
if (!map.has(loc, target)) {
|
||||
throw new IllegalMoveException("Target isn't there!");
|
||||
}
|
||||
//TODO: Detect the weapon used, and use its sound
|
||||
IWeapon weapon = (IWeapon) currentActor.getItem(IWeapon.class);
|
||||
IWeapon weapon = (IWeapon) currentActor.getItem(IMeleeWeapon.class);
|
||||
if (weapon != null) {
|
||||
NPC.playSound(weapon.getSound());
|
||||
} else {
|
||||
@@ -209,9 +209,16 @@ public class Game implements IGame {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocation rangedAttack(GridDirection dir, IItem target) {
|
||||
public ILocation rangedAttack(GridDirection dir, IItem target, Attack type) {
|
||||
ILocation loc = currentLocation;
|
||||
IWeapon weapon = (IWeapon) currentActor.getItem(IWeapon.class);
|
||||
IWeapon weapon = null;
|
||||
switch (type) {
|
||||
case MAGIC:
|
||||
weapon = (IWeapon) currentActor.getItem(IMagicWeapon.class);
|
||||
break;
|
||||
case RANGED:
|
||||
weapon = (IWeapon) currentActor.getItem(IRangedWeapon.class);
|
||||
}
|
||||
if (weapon != null) {
|
||||
NPC.playSound(weapon.getSound());
|
||||
} else {
|
||||
|
@@ -12,6 +12,7 @@ import inf101.v18.rogue101.objects.IItem;
|
||||
import inf101.v18.rogue101.objects.IActor;
|
||||
import inf101.v18.rogue101.objects.INonPlayer;
|
||||
import inf101.v18.rogue101.objects.IPlayer;
|
||||
import inf101.v18.rogue101.states.Attack;
|
||||
|
||||
/**
|
||||
* Game interface
|
||||
@@ -320,7 +321,7 @@ public interface IGame {
|
||||
* A target item, which should in some square in the given direction
|
||||
* @return Your new location if the attack resulted in you moving (unlikely)
|
||||
*/
|
||||
ILocation rangedAttack(GridDirection dir, IItem target);
|
||||
ILocation rangedAttack(GridDirection dir, IItem target, Attack type);
|
||||
|
||||
/**
|
||||
* @return A random generator
|
||||
|
Reference in New Issue
Block a user