using UnityEngine; using System.Collections; public class BossFighthandlerScript : MonoBehaviour { public GameObject Boundry; public GameObject Boss1; public BossCameraScript BossCamera; DialogueScript dialogueScript; public GameObject DestroyAnimation; // only trigger for once bool triggered; // Use this for initialization void Start () { dialogueScript = GameObject.FindGameObjectWithTag("DialogueSystem").GetComponent(); } // Update is called once per frame void Update () { } private void OnTriggerEnter2D(Collider2D collision) { if (collision.tag == "PlayerCollider" && !triggered) { triggered = true; StartCoroutine(start()); } } IEnumerator start() { Boundry.gameObject.SetActive(true); BossCamera.EnableBossCamera(); yield return new WaitForSeconds(2); Boss1.SetActive(true); yield return new WaitForSeconds(.5f); dialogueScript.ShowDialogue("You'll have to kill me to go beyond this point"); dialogueScript.FromBoss1 = true; } // Wait for Dialogue Panel to be dismissed public void StartBossFight() { Boss1.GetComponent().EnableBoss1Movement(); Boss1.GetComponentInChildren().EnableBoss1Fire(); } // Called by Boss1HealthScript public void EndBossFight() { var animation = Instantiate(DestroyAnimation, Boss1.transform.position, Quaternion.identity); Boss1.GetComponent().DisableBoss1Movement(); Boss1.GetComponentInChildren().DisableBoss1Fire(); Boss1.GetComponentInChildren().DisableBoss1Attack(); Destroy(animation, 4f); Destroy(Boss1, 4f); StartCoroutine(end()); } IEnumerator end() { yield return new WaitForSeconds(3); BossCamera.DisableBossCamera(); Boundry.gameObject.SetActive(false); } }