game: fixing npc spawn references
buttons not working (push buttons)
This commit is contained in:
parent
27f278bf3a
commit
7c9f2d4df9
5 changed files with 34 additions and 8 deletions
|
@ -15,20 +15,36 @@ public class DeskButtons : MonoBehaviour
|
||||||
NPCBehaviour npcBehaviourScript;
|
NPCBehaviour npcBehaviourScript;
|
||||||
private Player playerScript;
|
private Player playerScript;
|
||||||
|
|
||||||
[SerializeField] private GameObject npcObject;
|
public GameObject npcObject;
|
||||||
|
|
||||||
private string correctDirection;
|
private string correctDirection;
|
||||||
private string directionSent;
|
private string directionSent;
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
|
{
|
||||||
|
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UpdateNPCReferences()
|
||||||
|
{
|
||||||
|
GameObject npcObject = GameManager.instance.currentNPC;
|
||||||
|
|
||||||
|
if (npcObject != null)
|
||||||
{
|
{
|
||||||
npcMoveScript = npcObject.GetComponent<NPCMovement>();
|
npcMoveScript = npcObject.GetComponent<NPCMovement>();
|
||||||
npcBehaviourScript = npcObject.GetComponent<NPCBehaviour>();
|
npcBehaviourScript = npcObject.GetComponent<NPCBehaviour>();
|
||||||
playerScript = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DirectToLeft()
|
public void DirectToLeft()
|
||||||
{
|
{
|
||||||
|
UpdateNPCReferences();
|
||||||
|
if (npcMoveScript == null || npcBehaviourScript == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("NPC references are null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
npcMoveScript.WalkToPlayerLeft();
|
npcMoveScript.WalkToPlayerLeft();
|
||||||
directionSent = "left";
|
directionSent = "left";
|
||||||
|
|
||||||
|
@ -46,6 +62,13 @@ public class DeskButtons : MonoBehaviour
|
||||||
|
|
||||||
public void DirectToRight()
|
public void DirectToRight()
|
||||||
{
|
{
|
||||||
|
UpdateNPCReferences();
|
||||||
|
if (npcMoveScript == null || npcBehaviourScript == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning("NPC references are null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
npcMoveScript.WalkToPlayerRight();
|
npcMoveScript.WalkToPlayerRight();
|
||||||
directionSent = "right";
|
directionSent = "right";
|
||||||
|
|
||||||
|
|
|
@ -19,12 +19,11 @@ public class GameManager : MonoBehaviour
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// References and Variables
|
/// References and Variables
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SerializeField]
|
|
||||||
public bool dayEnded = false;
|
public bool dayEnded = false;
|
||||||
|
|
||||||
[SerializeField]
|
|
||||||
public bool shiftStarted;
|
public bool shiftStarted;
|
||||||
|
|
||||||
|
public GameObject currentNPC;
|
||||||
|
|
||||||
[Header("Walk Points (FOR DEBUGGING")]
|
[Header("Walk Points (FOR DEBUGGING")]
|
||||||
public Transform[] frontWalkPoints;
|
public Transform[] frontWalkPoints;
|
||||||
public Transform[] leftWalkPoints;
|
public Transform[] leftWalkPoints;
|
||||||
|
|
|
@ -33,6 +33,8 @@ public class NPCMovement : MonoBehaviour
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
gm = GameManager.instance;
|
||||||
|
|
||||||
StartCoroutine(WalkingToPlayer());
|
StartCoroutine(WalkingToPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,10 @@ public class NPCSpawn : MonoBehaviour
|
||||||
void SpawnNPC()
|
void SpawnNPC()
|
||||||
{
|
{
|
||||||
StopAllCoroutines();
|
StopAllCoroutines();
|
||||||
Instantiate(npc, transform.position, Quaternion.identity);
|
GameObject spawnedNPC = Instantiate(npc, transform.position, Quaternion.identity);
|
||||||
npcSpawned = true;
|
npcSpawned = true;
|
||||||
|
|
||||||
|
GameManager.instance.currentNPC = spawnedNPC;
|
||||||
}
|
}
|
||||||
|
|
||||||
IEnumerator SpawnNPCAfterWait()
|
IEnumerator SpawnNPCAfterWait()
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class ShiftManager : MonoBehaviour
|
||||||
while (remainingTime > 0)
|
while (remainingTime > 0)
|
||||||
{
|
{
|
||||||
remainingTime -= Time.deltaTime;
|
remainingTime -= Time.deltaTime;
|
||||||
Debug.Log("Shift: " + remainingTime);
|
/*Debug.Log("Shift: " + remainingTime);*/
|
||||||
|
|
||||||
if (Player.score < 0)
|
if (Player.score < 0)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue