IT代写 package dungeonmania.entities;

package dungeonmania.entities;

import dungeonmania.entities.enemies.Spider;
import dungeonmania.map.GameMap;

Copyright By PowCoder代写 加微信 powcoder

import dungeonmania.util.Direction;
import dungeonmania.util.Position;

public class Boulder extends Entity {

public Boulder(Position position) {
super(position.asLayer(Entity.CHARACTER_LAYER));

public boolean canMoveOnto(GameMap map, Entity entity) {
if (entity instanceof Spider) return false;
if (entity instanceof Player && canPush(map, entity.getFacing())) return true;
return false;

public void onOverlap(GameMap map, Entity entity) {
if (entity instanceof Player) {
map.moveTo(this, entity.getFacing());

private boolean canPush(GameMap map, Direction direction) {
Position newPosition = Position.translateBy(this.getPosition(), direction);
for (Entity e : map.getEntities(newPosition)) {
if (!e.canMoveOnto(map, this)) return false;
return true;

public void onMovedAway(GameMap map, Entity entity) {

public void onDestroy(GameMap gameMap) {

程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com