package com.ezardlabs.lostsector.missions;

import com.ezardlabs.lostsector.objects.enemies.Enemy;

public abstract class Mission {
	protected int enemiesKilled = 0;
	private long missionStart = 0;
	private EnemyStatusListener enemyStatusListener;

	public void startMission() {
		missionStart = System.currentTimeMillis();
	}

	public long getMissionTime() {
		return System.currentTimeMillis() - missionStart;
	}

	public abstract void load();

	public final void notifyEnemySpawn(Enemy enemy) {
		if (enemyStatusListener != null) {
			enemyStatusListener.onEnemySpawned(enemy);
		}
	}

	public final void notifyEnemyDeath(Enemy enemy) {
		enemiesKilled++;
		if (enemyStatusListener != null) {
			enemyStatusListener.onEnemyKilled(enemy);
		}
	}

	void setEnemyStatusListener(EnemyStatusListener enemyStatusListener) {
		this.enemyStatusListener = enemyStatusListener;
	}

	protected interface EnemyStatusListener {
		void onEnemySpawned(Enemy enemy);

		void onEnemyKilled(Enemy enemy);
	}
}

@@ -204,33 +204,123 @@
 ate 
-EnemyStatusListener enemy
+boolean completed = false;%0A%09private EnemyStatusListener enemyStatusListener;%0A%09private MissionStatusListener mission
 Stat
@@ -530,16 +530,173 @@
 oad();%0A%0A
+%09protected final void completedMission() %7B%0A%09%09completed = true;%0A%09%09if (missionStatusListener != null) %7B%0A%09%09%09missionStatusListener.onMissionCompleted();%0A%09%09%7D%0A%09%7D%0A%0A
 %09public 
@@ -1115,16 +1115,126 @@
 er;%0A%09%7D%0A%0A
+%09void setMissionStatusListener(MissionStatusListener listener) %7B%0A%09%09this.missionStatusListener = listener;%0A%09%7D%0A%0A
 %09protect
@@ -1342,11 +1342,89 @@
 emy);%0A%09%7D
+%0A%0A%09protected interface MissionStatusListener %7B%0A%09%09void onMissionCompleted();%0A%09%7D
 %0A%7D%0A

Add listener for mission status