-
Notifications
You must be signed in to change notification settings - Fork 0
/
BossHealth.cs
66 lines (53 loc) · 1.46 KB
/
BossHealth.cs
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BossHealth : MonoBehaviour
{
public int maxHealth = 100;
public int health;
//public GameObject deathEffect;
private Animator bossAnimator;
private SpriteRenderer bossSprite;
public bool isInvulnerable = false;
public static bool isSecondPhaseActive = false;
public static bool isThirdPhaseActive = false;
private void Start()
{
health = maxHealth;
bossAnimator = GetComponent<Animator>();
bossSprite = GetComponent<SpriteRenderer>();
}
public void TakeDamage(int damage)
{
if (isInvulnerable)
return;
health -= damage;
bossAnimator.SetTrigger("Hit");
if(health <= maxHealth / 2 && !isSecondPhaseActive)
{
bossAnimator.SetBool("isSecondPhaseActive", true);
bossSprite.color = new Color(255, 185, 185);
BossCombat.attackDamage += 10;
isSecondPhaseActive = true;
}
if (health <= maxHealth / 3 && !isThirdPhaseActive)
{
bossAnimator.SetBool("isThirdPhaseActive", true);
bossSprite.color = new Color(255, 0, 0);
BossCombat.attackDamage += 10;
BossCombat.castDamage += 10;
isThirdPhaseActive = true;
}
if (health <= 0)
{
bossAnimator.SetBool("isDead", true);
Die();
}
}
void Die()
{
//Instantiate(deathEffect, transform.position, Quaternion.identity);
GameManager.instance.EndBossBattle();
Destroy(gameObject);
}
}