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); } } //Opens the shop private void OpenShop() { NotifyObservers(NotificationType.UI, ("UIObject", shopObjectPrefab)); NotifyObservers(NotificationType.Dialogue, ("ExitStory", null)); } //Closes the upgrade shop public void CloseShop() { if (shop != null) { Destroy(shop); } } public void ResetStory() { // Store the current value of has_met_player object hasMetPlayerValue = currentStory.variablesState["has_met_player"]; if (hasMetPlayerValue is bool) { hasMetPlayer = (bool)hasMetPlayerValue; } // Reset the story state currentStory.ResetState(); // Restore the has_met_player variable as a new BoolValue currentStory.variablesState["has_met_player"] = hasMetPlayer; } public override void OnInteract() { ResetStory(); NotifyObservers(NotificationType.Dialogue, ("Story", currentStory), ("NPCname", npcName)); } }