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;

    [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.", TaskDifficultyEnum.Easy);
    }

        // Update is called once per frame
    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.GetComponent<PickableController>().item.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!!!");
        }
    }
}