reworked interactions, fixed health depleting from testing
This commit is contained in:
43
Assets/Scripts/InteractableObjects/NPC.cs
Normal file
43
Assets/Scripts/InteractableObjects/NPC.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.InteractableObjects
|
||||
{
|
||||
public class NPC : InteractableObject
|
||||
{
|
||||
bool hasQuest = true;
|
||||
|
||||
public override void handleInteraction(GameObject player)
|
||||
{
|
||||
keepAlive = true;
|
||||
if (hasQuest)
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;"+TextHandler.getText("gotQuest"));
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().addQuest();
|
||||
hasQuest = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;"+TextHandler.getText("noQuest"));
|
||||
}
|
||||
GameObject.Find("QuestLog").GetComponent<QuestLog>().removeQuests();
|
||||
}
|
||||
|
||||
public bool receivedQuest(){
|
||||
return !hasQuest;
|
||||
}
|
||||
|
||||
public void loadQuest(string receivedQuest){
|
||||
|
||||
this.hasQuest = !bool.Parse(receivedQuest);
|
||||
}
|
||||
|
||||
public string saveNPC(){
|
||||
string result = "";
|
||||
result = result + FileHandler.generateJSON("objectname", "\"" + name + "\",");
|
||||
result = result + FileHandler.generateJSON("receivedQuest", "\"" + !hasQuest + "\"");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user