2023-04-25 10:22:38 -07:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class SpawnPointBehavior : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
// set in inspector
|
|
|
|
[Header("Sprites")]
|
|
|
|
[SerializeField] private Sprite deactivatedSprite;
|
|
|
|
[SerializeField] private Sprite activatedSprite;
|
|
|
|
|
2023-04-25 13:27:12 -07:00
|
|
|
[Header("Initialization")]
|
|
|
|
[SerializeField] public bool firstSpawnPoint;
|
|
|
|
|
2023-04-25 10:22:38 -07:00
|
|
|
// not set in inspector
|
|
|
|
private SpriteRenderer _sr;
|
|
|
|
private StateController stateController;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
void Start()
|
|
|
|
{
|
|
|
|
_sr = this.gameObject.GetComponent<SpriteRenderer>();
|
|
|
|
stateController = GameObject.Find("StateController").GetComponent<StateController>();
|
2023-04-25 13:27:12 -07:00
|
|
|
if (firstSpawnPoint) {
|
|
|
|
ActivateSpawnPoint();
|
|
|
|
}
|
2023-04-25 10:22:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
public void ActivateSpawnPoint() {
|
|
|
|
_sr.sprite = activatedSprite;
|
|
|
|
stateController.spawnPoint = this.gameObject;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DeactivateSpawnPoint() {
|
|
|
|
_sr.sprite = deactivatedSprite;
|
|
|
|
}
|
|
|
|
}
|