1
0
Fork 0
Bildschirmflausch-LD41/Assets/Scripts/Objectives/StartObjective.cs
Saibotk e35c70e002 Generation integration Part 1
Fix Texture Unit size
Added Root tags
Fixed NullPointers
Todo: 
- Fix sprite rotation
- Fix processing of hallways
- Put doors in their own root GameObject
2018-04-22 17:52:20 +02:00

47 lines
1.5 KiB
C#

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>
public override void ActivateGoal(Player player) {
Debug.Log(room == null);
if ( room.GetSpawnpoints().Count > 0 ) {
GameObject ply = GameObject.Instantiate(playerPrefab);
ply.transform.position = room.GetSpawnpoints()[0].position;
player = ply.GetComponent<Player>();
base.ActivateGoal(player);
}
}
/// <summary>
/// Returns the created Player object. Call this after <see cref="ActivateGoal(Player)"/> !
/// </summary>
/// <returns>Player</returns>
public Player GetPlayer() {
Debug.Log(player == null);
return player;
}
/// <summary>
/// Code executed if the goal is reached eg. opening doors.
/// </summary>
public override void UpdateGoal() {
ReachedGoal();
}
}