- using MyCollections.Managers;
- using UnityEngine;
- public class Blacksmith : InteractableNPC
- {
- [SerializeField] private GameObject shopObjectPrefab;
- [SerializeField] private StoryData storyData;
- private GameObject shop;
- private bool hasMetPlayer;
- public bool hasGreetPlayer;
- protected override void Start()
- {
- base.Start();
- currentStory = storyData.GetStory();
- currentStory.BindExternalFunction("OpenShop", OpenShop);
- }
- protected override void Update()
- {
- base.Update();
- }
- protected override void AnimationController()
- {
- base.AnimationController();
- if (agentFOV.GetTarget() != null)
- {
- Vector2 dir = agentFOV.TargetDirection;
- animator.SetFloat("TargetDirectionX", dir.x);
- animator.SetFloat("TargetDirectionY", dir.y);
- }
- }
-
- private void OpenShop()
- {
- NotifyObservers(NotificationType.UI, ("UIObject", shopObjectPrefab));
- NotifyObservers(NotificationType.Dialogue, ("ExitStory", null));
- }
-
- public void CloseShop()
- {
- if (shop != null)
- {
- Destroy(shop);
- }
- }
- public void ResetStory()
- {
-
- object hasMetPlayerValue = currentStory.variablesState["has_met_player"];
- if (hasMetPlayerValue is bool)
- {
- hasMetPlayer = (bool)hasMetPlayerValue;
- }
-
- currentStory.ResetState();
-
- currentStory.variablesState["has_met_player"] = hasMetPlayer;
- }
- public override void OnInteract()
- {
- ResetStory();
- NotifyObservers(NotificationType.Dialogue, ("Story", currentStory), ("NPCname", npcName));
- }
- }