53 lines
1.4 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scripts
{
public class NPC : MonoBehaviour
{
bool hasQuest = true;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void interact()
{
if (hasQuest)
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("SUCCESS;You got a quest from this NPC!");
GameObject.Find("QuestLog").GetComponent<QuestLog>().addQuest();
hasQuest = false;
}
else
{
GameObject.Find("UIHandler").GetComponent<UIHandler>().showMessage("ERROR;You already got the quest from this NPC!");
}
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;
}
}
}