add all mechanics
This commit is contained in:
parent
87383d5b8c
commit
0e2a7cc7c3
434 changed files with 238349 additions and 2092 deletions
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class WaveManager : MonoBehaviour
|
||||
|
|
@ -31,8 +32,7 @@ public class WaveManager : MonoBehaviour
|
|||
public Enemy[] enemies;
|
||||
public bool bossWave;
|
||||
public Enemy bossEnemy; //optional
|
||||
public string bossName;
|
||||
public string bossDescription;
|
||||
public Texture bossName;
|
||||
//public DialogueScript bossDialogue;
|
||||
}
|
||||
|
||||
|
|
@ -46,30 +46,46 @@ public class WaveManager : MonoBehaviour
|
|||
[SerializeField] private Transform enemyBRPoint;
|
||||
public Transform enemySpawnPoint;
|
||||
[Header("Waves")]
|
||||
[SerializeField] protected TextMeshProUGUI waveUI;
|
||||
public int wave = 1;
|
||||
public Wave[] waveList;
|
||||
[Header("Boss")]
|
||||
public Enemy bossInstance;
|
||||
public GameObject bossUI;
|
||||
[SerializeField] private TextMeshProUGUI bossNameUI;
|
||||
[SerializeField] private TextMeshProUGUI bossDescriptionUI;
|
||||
[SerializeField] private RawImage bossNameUI;
|
||||
[SerializeField] private Transform bossHPBar;
|
||||
[SerializeField] private TextMeshProUGUI bossHPText;
|
||||
|
||||
[Header("Final Boss")]
|
||||
[SerializeField] private Prismriver lunasa;
|
||||
[SerializeField] private Prismriver merlin;
|
||||
[SerializeField] private Prismriver lyrica;
|
||||
public Prismriver lunasaInstance;
|
||||
public Prismriver merlinInstance;
|
||||
public Prismriver lyricaInstance;
|
||||
public int prismMaxHP;
|
||||
public int prismHP;
|
||||
public DialogueScript prismriverDialogue;
|
||||
[Header("Enemies")]
|
||||
public Transform enemyFolder;
|
||||
public List<Enemy> enemiesInPlay = new();
|
||||
[SerializeField] private float enemyCheckRadius;
|
||||
[SerializeField] private LayerMask enemyLayer;
|
||||
[Header("Audio")]
|
||||
public AudioClip bossDialogueLoop;
|
||||
public AudioClip bossMusic;
|
||||
public float bossVolume;
|
||||
public AudioClip finalDialogueLoop;
|
||||
public AudioClip finalMusic;
|
||||
public float finalVolume;
|
||||
public AudioSource audioSource;
|
||||
[SerializeField] private AudioSource musicSource;
|
||||
public AudioSource musicSource;
|
||||
[SerializeField] private AudioClip musicIntro;
|
||||
public AudioClip musicLoop;
|
||||
public float musicVolume;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpawnWave();
|
||||
//SpawnFinalBoss();
|
||||
musicSource.volume = musicVolume;
|
||||
musicSource.PlayOneShot(musicIntro, musicVolume);
|
||||
StartCoroutine(WaitForLoop());
|
||||
|
|
@ -84,10 +100,17 @@ public class WaveManager : MonoBehaviour
|
|||
public Vector3 GetRandomEnemyPoint()
|
||||
{
|
||||
Vector3 randomPoint;
|
||||
int currentAttempts = 0;
|
||||
do
|
||||
{
|
||||
randomPoint = new Vector3(Random.Range(enemyTLPoint.position.x, enemyBRPoint.position.x),
|
||||
Random.Range(enemyBRPoint.position.y, enemyTLPoint.position.y), 0);
|
||||
currentAttempts++;
|
||||
if (currentAttempts > 50)
|
||||
{
|
||||
return new Vector3(Random.Range(enemyTLPoint.position.x, enemyBRPoint.position.x),
|
||||
Random.Range(enemyBRPoint.position.y, enemyTLPoint.position.y), 0);
|
||||
}
|
||||
} while (CheckEnemyOverlap(randomPoint));
|
||||
return randomPoint;
|
||||
}
|
||||
|
|
@ -104,13 +127,16 @@ public class WaveManager : MonoBehaviour
|
|||
|
||||
protected virtual void SpawnWave()
|
||||
{
|
||||
waveUI.text = $"Wave: {wave}";
|
||||
foreach (Enemy enemy in waveList[wave-1].enemies)
|
||||
{
|
||||
SpawnEnemy(enemy);
|
||||
}
|
||||
|
||||
if (waveList[wave-1].bossWave)
|
||||
if (wave == waveList.Length)
|
||||
{
|
||||
SpawnFinalBoss();
|
||||
Debug.Log("here");
|
||||
}
|
||||
else if (waveList[wave-1].bossWave)
|
||||
{
|
||||
SpawnBoss(waveList[wave-1].bossEnemy);
|
||||
}
|
||||
|
|
@ -121,14 +147,26 @@ public class WaveManager : MonoBehaviour
|
|||
{
|
||||
Enemy newBoss = SpawnEnemy(boss);
|
||||
bossInstance = newBoss;
|
||||
bossUI.SetActive(true);
|
||||
bossNameUI.text = waveList[wave - 1].bossName;
|
||||
bossDescriptionUI.text = waveList[wave - 1].bossDescription;
|
||||
bossNameUI.texture = waveList[wave - 1].bossName;
|
||||
bossNameUI.SetNativeSize();
|
||||
UpdateBossUI();
|
||||
player.isStalled = true; //wait for boss to enter then start dialogue
|
||||
player.invulnerable = true;
|
||||
}
|
||||
|
||||
private void SpawnFinalBoss()
|
||||
{
|
||||
lunasaInstance = SpawnPrism(lunasa);
|
||||
merlinInstance = SpawnPrism(merlin);
|
||||
lyricaInstance = SpawnPrism(lyrica);
|
||||
//DialogueManager.instance.StartDialogue(prismriverDialogue);
|
||||
lunasaInstance.isStalled = true;
|
||||
merlinInstance.isStalled = true;
|
||||
lyricaInstance.isStalled = true;
|
||||
player.isStalled = true; //wait for boss to enter then start dialogue
|
||||
player.invulnerable = true;
|
||||
bossNameUI.texture = waveList[wave - 1].bossName;
|
||||
bossNameUI.SetNativeSize();
|
||||
}
|
||||
public Enemy SpawnEnemy(Enemy enemy)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, enemyFolder);
|
||||
|
|
@ -141,24 +179,40 @@ public class WaveManager : MonoBehaviour
|
|||
return newEnemy;
|
||||
}
|
||||
|
||||
public Prismriver SpawnPrism(Prismriver prism)
|
||||
{
|
||||
Prismriver newEnemy = Instantiate(prism, enemyFolder);
|
||||
Vector3 movepos = GetRandomEnemyPoint();
|
||||
newEnemy.currentMovementRoutine = newEnemy.StartCoroutine(newEnemy.MoveToPosition(enemySpawnPoint.position,movepos, newEnemy.moveSpeed));
|
||||
newEnemy.originalPosition = movepos;
|
||||
enemiesInPlay.Add(newEnemy);
|
||||
newEnemy.isStalled = true;
|
||||
newEnemy.invulnerable = true;
|
||||
return newEnemy;
|
||||
}
|
||||
|
||||
public void UpdateBossUI()
|
||||
{
|
||||
bossHPText.text = $"{bossInstance.health}/{bossInstance.maxHealth}";
|
||||
bossHPBar.localScale = new Vector3((float)bossInstance.health / bossInstance.maxHealth, 1f, 1f);
|
||||
if (lyricaInstance)
|
||||
{
|
||||
bossHPBar.localScale = new Vector3(1 - (float)prismHP / prismMaxHP, 1f, 1f);
|
||||
return;
|
||||
}
|
||||
bossHPBar.localScale = new Vector3(1 - (float)bossInstance.health / bossInstance.maxHealth, 1f, 1f);
|
||||
}
|
||||
|
||||
public virtual void UpdateKills()
|
||||
{
|
||||
if (enemiesInPlay.Count == 0)
|
||||
{
|
||||
if (wave > waveList.Length)
|
||||
if (waveList[wave - 1].bossEnemy)
|
||||
{
|
||||
GameManager.instance.WinGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnWave();
|
||||
}
|
||||
SpawnWave();
|
||||
}
|
||||
if (lunasaInstance && prismHP <= 0)
|
||||
{
|
||||
GameManager.instance.WinGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue