2018-04-23 02:23:06 +02:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public abstract class Objective {
|
2018-04-22 15:59:14 +02:00
|
|
|
|
protected Room room;
|
|
|
|
|
protected Player player;
|
2018-04-23 02:23:06 +02:00
|
|
|
|
protected bool activated;
|
|
|
|
|
protected bool finished;
|
2018-04-21 12:22:17 +02:00
|
|
|
|
|
2018-04-22 15:59:14 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Constructs a new Objective instance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="caller"></param>
|
|
|
|
|
public Objective(Room caller) {
|
|
|
|
|
this.room = caller;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handle activation code for a goal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ply">Player</param>
|
|
|
|
|
public virtual void ActivateGoal(Player ply) {
|
|
|
|
|
if ( activated )
|
|
|
|
|
return;
|
|
|
|
|
activated = true;
|
|
|
|
|
player = ply;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Tracks / Updates the progess of a goal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public abstract void UpdateGoal();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Code executed if the goal is reached eg. opening doors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
protected virtual void ReachedGoal() {
|
|
|
|
|
finished = true;
|
|
|
|
|
room.Unlock();
|
2018-04-23 02:23:06 +02:00
|
|
|
|
Debug.Log("[ROOM] Goal reached. Doors will open.");
|
2018-04-22 15:59:14 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns wether the goal was reached or not.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool GetFinished() {
|
|
|
|
|
return finished;
|
|
|
|
|
}
|
2018-04-21 12:22:17 +02:00
|
|
|
|
|
2018-04-23 23:14:55 +02:00
|
|
|
|
public Player GetPlayer() {
|
|
|
|
|
return player;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-21 15:18:53 +02:00
|
|
|
|
|
2018-04-21 12:22:17 +02:00
|
|
|
|
}
|