basically the whole game
This commit is contained in:
parent
949135cecb
commit
96dcfa9064
315 changed files with 34386 additions and 396 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
|
@ -28,8 +29,15 @@ public class WaveManager : MonoBehaviour
|
|||
public class Wave
|
||||
{
|
||||
public Enemy[] enemies;
|
||||
public bool bossWave;
|
||||
public Enemy bossEnemy; //optional
|
||||
public string bossName;
|
||||
public string bossDescription;
|
||||
//public DialogueScript bossDialogue;
|
||||
}
|
||||
[Header("Player Point")]
|
||||
|
||||
[Header("Player Point")]
|
||||
public Player player; //only for continues lol
|
||||
[SerializeField] private Transform tlPoint;
|
||||
[SerializeField] private Transform brPoint;
|
||||
|
||||
|
|
@ -38,18 +46,33 @@ public class WaveManager : MonoBehaviour
|
|||
[SerializeField] private Transform enemyBRPoint;
|
||||
public Transform enemySpawnPoint;
|
||||
[Header("Waves")]
|
||||
[SerializeField] private TextMeshProUGUI waveUI;
|
||||
[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 Transform bossHPBar;
|
||||
[SerializeField] private TextMeshProUGUI bossHPText;
|
||||
[Header("Enemies")]
|
||||
public Transform enemyFolder;
|
||||
public List<Enemy> enemiesInPlay = new();
|
||||
[SerializeField] private float enemyCheckRadius;
|
||||
[SerializeField] private LayerMask enemyLayer;
|
||||
[Header("Audio")]
|
||||
public AudioSource audioSource;
|
||||
[SerializeField] private AudioSource musicSource;
|
||||
[SerializeField] private AudioClip musicIntro;
|
||||
public float musicVolume;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpawnWave();
|
||||
musicSource.volume = musicVolume;
|
||||
musicSource.PlayOneShot(musicIntro, musicVolume);
|
||||
StartCoroutine(WaitForLoop());
|
||||
}
|
||||
|
||||
public Vector3 GetRandomPlayerPoint()
|
||||
|
|
@ -58,7 +81,7 @@ public class WaveManager : MonoBehaviour
|
|||
Random.Range(brPoint.position.y, tlPoint.position.y), 0);
|
||||
}
|
||||
|
||||
private Vector3 GetRandomEnemyPoint()
|
||||
public Vector3 GetRandomEnemyPoint()
|
||||
{
|
||||
Vector3 randomPoint;
|
||||
do
|
||||
|
|
@ -79,24 +102,79 @@ public class WaveManager : MonoBehaviour
|
|||
return false;
|
||||
}
|
||||
|
||||
private void SpawnWave()
|
||||
protected virtual void SpawnWave()
|
||||
{
|
||||
waveUI.text = $"Wave: {wave}";
|
||||
foreach (Enemy enemy in waveList[wave-1].enemies)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, enemyFolder);
|
||||
newEnemy.StartCoroutine(newEnemy.MoveToPosition(GetRandomEnemyPoint()));
|
||||
enemiesInPlay.Add(newEnemy);
|
||||
newEnemy.isStalled = true;
|
||||
SpawnEnemy(enemy);
|
||||
}
|
||||
|
||||
if (waveList[wave-1].bossWave)
|
||||
{
|
||||
SpawnBoss(waveList[wave-1].bossEnemy);
|
||||
}
|
||||
wave++;
|
||||
}
|
||||
|
||||
public void UpdateKills()
|
||||
protected void SpawnBoss(Enemy boss)
|
||||
{
|
||||
Enemy newBoss = SpawnEnemy(boss);
|
||||
bossInstance = newBoss;
|
||||
bossUI.SetActive(true);
|
||||
bossNameUI.text = waveList[wave - 1].bossName;
|
||||
bossDescriptionUI.text = waveList[wave - 1].bossDescription;
|
||||
UpdateBossUI();
|
||||
player.isStalled = true; //wait for boss to enter then start dialogue
|
||||
}
|
||||
|
||||
public Enemy SpawnEnemy(Enemy enemy)
|
||||
{
|
||||
Enemy newEnemy = Instantiate(enemy, 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);
|
||||
}
|
||||
|
||||
public virtual void UpdateKills()
|
||||
{
|
||||
if (enemiesInPlay.Count == 0)
|
||||
{
|
||||
SpawnWave();
|
||||
if (wave > waveList.Length)
|
||||
{
|
||||
GameManager.instance.WinGame();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnWave();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator WaitForLoop()
|
||||
{
|
||||
bool stopped = false;
|
||||
while (!stopped)
|
||||
{
|
||||
if (musicSource.isPlaying)
|
||||
{
|
||||
yield return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
stopped = true;
|
||||
musicSource.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue