-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBossLevelManager.cs
More file actions
62 lines (49 loc) · 1.82 KB
/
BossLevelManager.cs
File metadata and controls
62 lines (49 loc) · 1.82 KB
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
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class BossLevelManager : MonoBehaviour
{
public Transform bossSpawnPoint;
[SerializeField] private Transform leftSpawnPoint;
[SerializeField] private Transform rightSpawnPoint;
[SerializeField] private BossFactory bossFactory;
[HideInInspector] public Boss currentBoss;
private BossView bossView;
public BossStats[] stats;
public GameObject winPanel;
public GameObject losePanel;
public bool isPlayerDead = false;
private void Awake()
{
bossView = GetComponent<BossView>();
}
private void Start()
{
// Get current boss level data
BossLevelData currentLevelData = GameManager.Instance.currentBossLevelData;
if (currentLevelData != null)
{
// Spawn the boss
currentBoss = bossFactory.CreateBoss(currentLevelData.bossType, bossSpawnPoint.position);
// Initialize the boss with level data
if (currentBoss != null)
{
if(stats.Length <= 0 && stats == null) { Debug.LogError("stats array is null"); }
currentBoss.Initialize(stats[currentLevelData.levelIndex-1]);
currentBoss.leftPoint = leftSpawnPoint;
currentBoss.rightPoint = rightSpawnPoint;
bossView.UpdateHealthSlider();
}
else
{
Debug.LogError("Failed to spawn boss!");
}
}
else
{
Debug.LogError("No boss level data found!");
}
winPanel.transform.Find("RewardText").GetComponent<TextMeshProUGUI>().text = $"Reward: +{GameManager.Instance.currentBossLevelData.rewardAmount}";
}
}