Scriptum/Assets/Scripts/NPCs' Scripts/NPCQuest.cs

61 lines
1.5 KiB
C#
Raw Normal View History

2022-06-13 23:33:19 +02:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NPCQuest : MonoBehaviour
{
[SerializeField] public Task quest;
public Task Quest
{
get { return quest; }
set { quest = value; }
}
[SerializeField] public GameObject axe;
2022-06-13 23:33:19 +02:00
[SerializeField] private bool isTaskAccepted = false;
// Start is called before the first frame update
void Start()
{
this.Quest = new Task(1, "Help the Lumberjack", "Find his axe in the forest and bring it back to him.", TaskHardship.Easy);
}
// Update is called once per frame
2022-06-13 23:33:19 +02:00
void Update()
{
}
public Task AcceptTask()
{
this.isTaskAccepted = true;
return this.Quest;
}
public bool IsTaskAccepted()
{
return this.isTaskAccepted;
}
public void DropItem()
{
GameObject globalGUI = GameObject.FindGameObjectsWithTag("GUI")[0];
if(globalGUI)
{
// 1. Drop item on map
GameObject _axe = Instantiate(axe, new Vector3(37.1f, -31.7f, 0), Quaternion.identity, globalGUI.transform);
// 1.2 Fix names (prevent add "(Clone)" postfix)
_axe.name = axe.name;
_axe.GetComponent<PickableController>().item.name = axe.name;
// 2. Add object to DynamicList in LocalSceneManager
SceneEquippableItemManager.Instance.AddDynamicItem(_axe);
} else {
Debug.Log("Can't find global GUI object!!!");
}
}
2022-06-13 23:33:19 +02:00
}