using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; [RequireComponent(typeof(AStarPathfindingAgent))] class GetScroolWizard : MonoBehaviour { public Item RequiredItem; public MissionReward Reward; public Transform teleportPosition; public bool canEscape = false; private void Start() { teleportPosition = GameObject.Find("DoorToHell").transform; } public void EscapeToDungeon() { var wizardOnScene = GameObject.FindGameObjectsWithTag("NPC").ToList().Where(el => el.name == gameObject.name).First(); wizardOnScene.GetComponent().point = wizardOnScene.GetComponent().teleportPosition.position; Debug.Log(wizardOnScene.GetComponent().point); Debug.Log(Vector2.Distance(wizardOnScene.GetComponent().point, wizardOnScene.transform.position)); wizardOnScene.GetComponent().FindPoint(); wizardOnScene.GetComponent().Escape(); } public void Escape() { Debug.Log("Start courtine"); StartCoroutine(gameObject.GetComponent().FollowPath()); } // CHANGE THIS - we dupplicated herelogic from mission!!! public void CheckCondition() { // CHECK CONDITION JEST WYWOŁYWANE W SUROWYM OBIEKCIE scriptable boject // TO SIE DOWOŁUJE DO prefaba wizarda wiec musimy sila szuakc obietow na scenie heh if(InventoryUIManager.Instance.FindItemInWarehouseByName(RequiredItem.name).Any()) { var wizardOnScene = GameObject.FindGameObjectsWithTag("NPC").ToList().Where(el => el.name == gameObject.name).First(); wizardOnScene.GetComponent().Dialogue.GoToNextSentence(); } else { var wizardOnScene = GameObject.FindGameObjectsWithTag("NPC").ToList().Where(el => el.name == gameObject.name).First(); wizardOnScene.GetComponent().Dialogue.BreakDialogueStep(); } } // Move to npc action bucket (Action script) public void TakeItem() { if(-1 != InventoryUIManager.Instance.RemoveOneByItemName(RequiredItem.name)) { TaskUIManager.Instance.RemoveByName("Wizard Quest"); // go to next sentence var wizardOnScene = GameObject.FindGameObjectsWithTag("NPC").ToList().Where(el => el.name == gameObject.name).First(); wizardOnScene.GetComponent().Dialogue.GoToNextSentence(); } else { var wizardOnScene = GameObject.FindGameObjectsWithTag("NPC").ToList().Where(el => el.name == gameObject.name).First(); // Beacuse we have CheckCondition this should be uselles if (wizardOnScene.GetComponent().Dialogue) wizardOnScene.gameObject.GetComponent().Dialogue.BreakDialogueStep(); } } // copied from mission public void GetReward() { var Player = GameObject.FindGameObjectWithTag("Player"); if (!Player) Debug.LogError("GetScroolWizard::GetReward - There is no player on scene!!!"); Player.GetComponent().GetReward(Reward); } public void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "SceneTransition") { // basically useless xd DungeonManager.SetTeleported(); collision.gameObject.GetComponent().isEnabled = true; Destroy(gameObject); } } }