2018-04-22 15:59:14 +02:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
public class StartObjective : Objective {
|
|
|
|
|
GameObject playerPrefab;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a new StartObjective instance.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="room"></param>
|
|
|
|
|
/// <param name="playerPrefab"></param>
|
|
|
|
|
public StartObjective(Room room, GameObject playerPrefab) : base(room) {
|
|
|
|
|
this.playerPrefab = playerPrefab;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO not as good as possible. Should Objectives ActivateGoal method require a player obj?
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Handle activation code for a goal.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ply">Player is ignored </param>
|
2018-04-22 17:52:20 +02:00
|
|
|
|
public override void ActivateGoal(Player player) {
|
2018-04-23 02:23:06 +02:00
|
|
|
|
if ( activated )
|
|
|
|
|
return;
|
2018-04-22 15:59:14 +02:00
|
|
|
|
if ( room.GetSpawnpoints().Count > 0 ) {
|
|
|
|
|
GameObject ply = GameObject.Instantiate(playerPrefab);
|
|
|
|
|
ply.transform.position = room.GetSpawnpoints()[0].position;
|
|
|
|
|
player = ply.GetComponent<Player>();
|
|
|
|
|
base.ActivateGoal(player);
|
2018-04-23 02:23:06 +02:00
|
|
|
|
UpdateGoal();
|
2018-04-22 15:59:14 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Code executed if the goal is reached eg. opening doors.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public override void UpdateGoal() {
|
|
|
|
|
ReachedGoal();
|
|
|
|
|
}
|
|
|
|
|
}
|