package dungeonmania.entities;
import java.util.ArrayList;
import java.util.List;
Copyright By PowCoder代写 加微信 powcoder
import dungeonmania.entities.collectables.Bomb;
import dungeonmania.map.GameMap;
import dungeonmania.util.Position;
public class Switch extends Entity {
private boolean activated;
private List
public Switch(Position position) {
super(position.asLayer(Entity.ITEM_LAYER));
public void subscribe(Bomb b) {
bombs.add(b);
public void subscribe(Bomb bomb, GameMap map) {
bombs.add(bomb);
if (activated) {
bombs.stream().forEach(b -> b.notify(map));
public void unsubscribe(Bomb b) {
bombs.remove(b);
public boolean canMoveOnto(GameMap map, Entity entity) {
return true;
public void onOverlap(GameMap map, Entity entity) {
if (entity instanceof Boulder) {
activated = true;
bombs.stream().forEach(b -> b.notify(map));
public void onMovedAway(GameMap map, Entity entity) {
if (entity instanceof Boulder) {
activated = false;
public boolean isActivated() {
return activated;
public void onDestroy(GameMap gameMap) {
程序代写 CS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com