summaryrefslogtreecommitdiff
path: root/Assets/Scripts/BossFighthandlerScript.cs
blob: b95095ba2ff380df60ccf3912d03e9fb973b4c8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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<DialogueScript>();
    }
	
	// 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<Boss1MovementSCript>().EnableBoss1Movement();
        Boss1.GetComponentInChildren<Boss1FireScript>().EnableBoss1Fire();
    }


    // Called by Boss1HealthScript
    public void EndBossFight()
    {
        var animation = Instantiate(DestroyAnimation, Boss1.transform.position, Quaternion.identity);
        Boss1.GetComponent<Boss1MovementSCript>().DisableBoss1Movement();
        Boss1.GetComponentInChildren<Boss1FireScript>().DisableBoss1Fire();
        Boss1.GetComponentInChildren<Boss1AttackScript>().DisableBoss1Attack();
        Destroy(animation, 4f);
        Destroy(Boss1, 4f);
        StartCoroutine(end());
    }    
    IEnumerator end()
    {
        yield return new WaitForSeconds(3);
        BossCamera.DisableBossCamera();
        Boundry.gameObject.SetActive(false);
    }


}