Merge remote-tracking branch 'origin/gamelib' into gamelib
This commit is contained in:
@ -42,6 +42,8 @@ public class Character extends Entity {
|
||||
*/
|
||||
public Character(EntityID id, IntVector2 position, String name, int hp, int mp, int ap, int attackRange, int rangedDamage, int meleeDamage) {
|
||||
super(id, position);
|
||||
solid = false;
|
||||
opaque = true;
|
||||
this.name = name;
|
||||
this.hp = new Stat(StatType.HP, hp);
|
||||
this.mp = new Stat(StatType.MP, mp);
|
||||
|
@ -9,6 +9,12 @@ public abstract class Entity {
|
||||
/** Whether or not the entity is currently active in the game */
|
||||
protected boolean active = true;
|
||||
|
||||
/** Whether or not the entity blocks movement */
|
||||
protected boolean solid = false;
|
||||
|
||||
/** Whether or not the entity blocks vision */
|
||||
protected boolean opaque = false;
|
||||
|
||||
/** The position of the entity */
|
||||
protected IntVector2 position;
|
||||
|
||||
@ -35,6 +41,14 @@ public abstract class Entity {
|
||||
return active;
|
||||
}
|
||||
|
||||
public boolean blocksMovement() {
|
||||
return solid;
|
||||
}
|
||||
|
||||
public boolean blocksVision() {
|
||||
return opaque;
|
||||
}
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
@ -29,6 +29,17 @@ public class EntityID {
|
||||
return type == other;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj){
|
||||
if(this == obj) return true;
|
||||
|
||||
if(!(obj instanceof EntityID)) return false;
|
||||
|
||||
EntityID other = (EntityID)obj;
|
||||
|
||||
return this.id == other.id && this.type == other.type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones this entity id.
|
||||
* @return The cloned {@link EntityID}
|
||||
|
@ -15,6 +15,8 @@ public class InfinityStone extends Entity {
|
||||
*/
|
||||
public InfinityStone(EntityID id, IntVector2 position, StoneType type) {
|
||||
super(id, position);
|
||||
solid = false;
|
||||
opaque = false;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,8 @@ public class NPC extends Entity {
|
||||
*/
|
||||
public NPC(EntityID id, IntVector2 position, ArrayList<StoneType> inventory) {
|
||||
super(id, position);
|
||||
solid = false;
|
||||
opaque = true;
|
||||
this.inventory = new Inventory(inventory);
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,8 @@ public class Rock extends Entity {
|
||||
*/
|
||||
public Rock(EntityID id, IntVector2 position, int hp) {
|
||||
super(id, position);
|
||||
solid = true;
|
||||
opaque = true;
|
||||
this.maxHP = hp;
|
||||
this.hp = hp;
|
||||
}
|
||||
|
Reference in New Issue
Block a user