Untitled

 avatar
unknown
plain_text
5 months ago
681 B
5
Indexable
// QUESTION 4

	@Override
	public void onHit(GameObject other) {
		/* Q4 */
		if (other.getClass() == PacmanPlayer.class) {
			EventManager.getEventManager().notifyEvent("potionCollected",this,null);
		}
	}



// QUESTION 5 

public PacmanGhost(PacmanGridComponent initialPosition) {
		super(initialPosition);
		regularImageComponent = new ImageComponent("ghost");
		scaredImageComponent = new ImageComponent("ghost-scared");
		setScared(false);

		/* Q5 */
		EventManager.getEventManager().subscribe("potionCollected", this, (EventData x) -> {
			System.out.println("Collected potion @ " + this.getTransformComponent().position.toString());
			setScared(!getScared());
		});

	}

Editor is loading...
Leave a Comment