Added entity-spawn and kill
This commit is contained in:
parent
3b7457ef1c
commit
1ef7a24142
1 changed files with 24 additions and 8 deletions
|
@ -2,15 +2,31 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Entity : MonoBehaviour {
|
public class Entity {
|
||||||
|
EntityObjective referringObjective;
|
||||||
// Use this for initialization
|
GameObject entityPrefab;
|
||||||
void Start () {
|
GameObject instance;
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
public Entity(EntityObjective referringObjective, GameObject entityPrefab)
|
||||||
|
{
|
||||||
|
this.referringObjective = referringObjective;
|
||||||
|
this.entityPrefab = entityPrefab;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
// spawns the entity
|
||||||
void Update () {
|
public void Spawn(Transform spawnPoint)
|
||||||
|
{
|
||||||
|
instance = GameObject.Instantiate (entityPrefab);
|
||||||
|
instance.transform = spawnPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
// kills the entity
|
||||||
|
public void Kill()
|
||||||
|
{
|
||||||
|
GameObject.Destroy (instance);
|
||||||
|
referringObjective.Remove (this);
|
||||||
|
|
||||||
|
instance = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue