final commit?
This commit is contained in:
parent
0e2a7cc7c3
commit
3f53e2caa8
59 changed files with 3989 additions and 1668 deletions
|
|
@ -45,7 +45,7 @@ public class ReisenShoot : Ability
|
|||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
if (currentMouseHoldTime >= 0)
|
||||
if (currentMouseHoldTime > 0)
|
||||
{
|
||||
currentMouseHoldTime -= Time.deltaTime;
|
||||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(0) && currentChargeTime <= 0)
|
||||
|
|
@ -55,13 +55,15 @@ public class ReisenShoot : Ability
|
|||
}
|
||||
else if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
currentMouseHoldTime = 0;
|
||||
isCharging = false;
|
||||
ShootBullet(projectile, power);
|
||||
}
|
||||
}
|
||||
if (isCharging && Input.GetMouseButton(0)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
chargeMeter.localScale = new Vector3(Math.Clamp(currentChargeTime, 0, maxChargeTime)/maxChargeTime, 1f, 1f);
|
||||
chargeMeter.localScale = new Vector3(1f, Math.Clamp(currentChargeTime, 0, maxChargeTime)/maxChargeTime, 1f);
|
||||
}
|
||||
else if (currentChargeTime > 0 && isCharging && Input.GetMouseButtonUp(0))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ public class YoumuDeflect : Ability
|
|||
{
|
||||
base.Update();
|
||||
|
||||
if (currentMouseHoldTime >= 0)
|
||||
if (currentMouseHoldTime > 0)
|
||||
{
|
||||
currentMouseHoldTime -= Time.deltaTime;
|
||||
if (currentMouseHoldTime <= 0 && Input.GetMouseButton(1) && currentChargeTime <= 0)
|
||||
|
|
@ -140,12 +140,14 @@ public class YoumuDeflect : Ability
|
|||
else if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
RegularDeflection();
|
||||
currentMouseHoldTime = 0;
|
||||
isCharging = false;
|
||||
}
|
||||
}
|
||||
if (isCharging && Input.GetMouseButton(1)) //this code REEKS
|
||||
{
|
||||
currentChargeTime += Time.deltaTime;
|
||||
chargeMeter.localScale = new Vector3(Math.Clamp(currentChargeTime, 0, maxChargeTime)/maxChargeTime, 1f, 1f);
|
||||
chargeMeter.localScale = new Vector3(1f, Math.Clamp(currentChargeTime, 0, maxChargeTime)/maxChargeTime, 1f);
|
||||
}
|
||||
else if (isCharging && Input.GetMouseButtonUp(1))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,18 +53,19 @@ public class DialogueManager : MonoBehaviour
|
|||
|
||||
public void StartDialogue(DialogueScript newDialogue)
|
||||
{
|
||||
GameManager.instance.canPause = false;
|
||||
dialogueUI.SetActive(true);
|
||||
WaveManager.instance.bossUI.SetActive(false);
|
||||
dialogueActive = true;
|
||||
currentText = 0;
|
||||
scriptToShow = newDialogue;
|
||||
WaveManager.instance.player.invulnerable = true;
|
||||
battleUIAnimator.SetTrigger(dialogueStartTrigger);
|
||||
DialogueScript.Dialogue currentDialogue = scriptToShow.dialogueList[currentText];
|
||||
if (WaveManager.instance.bossInstance)
|
||||
{
|
||||
bossSpeechBubble.position = WaveManager.instance.bossInstance.transform.position + offset;
|
||||
WaveManager.instance.musicSource.clip = WaveManager.instance.bossDialogueLoop;
|
||||
WaveManager.instance.musicSource.volume = WaveManager.instance.bossVolume;
|
||||
WaveManager.instance.musicSource.Play();
|
||||
}
|
||||
if (WaveManager.instance.lyricaInstance)
|
||||
|
|
@ -74,7 +75,6 @@ public class DialogueManager : MonoBehaviour
|
|||
merlinSpeechBubble.transform.position = WaveManager.instance.merlinInstance.transform.position + offset;
|
||||
lyricaSpeechBubble.transform.position = WaveManager.instance.lyricaInstance.transform.position + offset;
|
||||
WaveManager.instance.musicSource.clip = WaveManager.instance.finalDialogueLoop;
|
||||
WaveManager.instance.musicSource.volume = WaveManager.instance.finalVolume;
|
||||
WaveManager.instance.musicSource.Play();
|
||||
}
|
||||
SetDialogue(currentDialogue);
|
||||
|
|
@ -101,6 +101,7 @@ public class DialogueManager : MonoBehaviour
|
|||
dialogueUI.SetActive(false);
|
||||
WaveManager.instance.player.isStalled = false;
|
||||
WaveManager.instance.player.invulnerable = false;
|
||||
GameManager.instance.canPause = true;
|
||||
battleUIAnimator.SetTrigger(dialogueEndTrigger);
|
||||
if (WaveManager.instance.bossInstance)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -104,7 +104,6 @@ public class Enemy : Entity
|
|||
{
|
||||
DialogueManager.instance.battleUIAnimator.SetTrigger(DialogueManager.instance.nobossTrigger);
|
||||
WaveManager.instance.musicSource.clip = WaveManager.instance.musicLoop;
|
||||
WaveManager.instance.musicSource.volume = WaveManager.instance.musicVolume;
|
||||
WaveManager.instance.musicSource.Play();
|
||||
}
|
||||
}
|
||||
|
|
@ -134,7 +133,7 @@ public class Enemy : Entity
|
|||
if (isBossEnemy && !hasStartedDialogue)
|
||||
{
|
||||
hasStartedDialogue = true;
|
||||
if (thisBossDialogue)
|
||||
if (thisBossDialogue && !GameManager.instance.isEndless)
|
||||
{
|
||||
DialogueManager.instance.StartDialogue(thisBossDialogue); //the worst code ever
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class Entity : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public void Heal(int healing)
|
||||
public virtual void Heal(int healing)
|
||||
{
|
||||
health += healing;
|
||||
health = Math.Clamp(health, 0, maxHealth);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@ public class Player : Entity
|
|||
[SerializeField] private float hurtVolume = 1f;
|
||||
[SerializeField] private AudioClip gameOverSound;
|
||||
[SerializeField] private float gameOverVolume = 1f;
|
||||
[SerializeField] private AudioClip healSound;
|
||||
[SerializeField] private float healVolume = 1f;
|
||||
private void Update()
|
||||
{
|
||||
if (!isStalled)
|
||||
|
|
@ -62,6 +64,13 @@ public class Player : Entity
|
|||
}
|
||||
}
|
||||
|
||||
public override void Heal(int healing)
|
||||
{
|
||||
base.Heal(healing);
|
||||
UpdateLivesUI();
|
||||
WaveManager.instance.audioSource.PlayOneShot(healSound, healVolume);
|
||||
}
|
||||
|
||||
public override void TakeDamage(int damage)
|
||||
{
|
||||
base.TakeDamage(damage);
|
||||
|
|
|
|||
|
|
@ -5,17 +5,20 @@ public class ZombieFairy : Enemy
|
|||
[SerializeField] private Ability deathAbility;
|
||||
[SerializeField] private bool hasDiedOnce;
|
||||
[SerializeField] private float disappearanceTime;
|
||||
[SerializeField] private Color disappearanceColor;
|
||||
[SerializeField] private BoxCollider2D boxCollider;
|
||||
private float currentDisappearanceTime;
|
||||
protected override void OnDeath()
|
||||
{
|
||||
if (!hasDiedOnce)
|
||||
{
|
||||
hasDiedOnce = true;
|
||||
health = maxHealth;
|
||||
invulnerable = true;
|
||||
isStalled = true;
|
||||
hasDiedOnce = true;
|
||||
boxCollider.enabled = false;
|
||||
currentDisappearanceTime = disappearanceTime;
|
||||
sprite.color = Color.black;
|
||||
sprite.color = disappearanceColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -34,6 +37,7 @@ public class ZombieFairy : Enemy
|
|||
currentDisappearanceTime -= Time.deltaTime;
|
||||
if (currentDisappearanceTime <= 0)
|
||||
{
|
||||
boxCollider.enabled = true;
|
||||
invulnerable = false;
|
||||
isStalled = false;
|
||||
sprite.color = Color.white;
|
||||
|
|
|
|||
|
|
@ -31,27 +31,27 @@ public class GameManager : MonoBehaviour
|
|||
public string accuracy;
|
||||
public int livesLost;
|
||||
[Header("Pause UI")]
|
||||
[SerializeField] private GameObject pauseMenu;
|
||||
|
||||
public bool canPause = true;
|
||||
public bool isEndless = false;
|
||||
[Header("Game Over")]
|
||||
[SerializeField] private DialogueScript winCutscene;
|
||||
[SerializeField] private GameObject loseUI;
|
||||
[SerializeField] private StatsUI statsUI;
|
||||
private bool gameOver;
|
||||
public bool gameOver;
|
||||
|
||||
public void EndGame()
|
||||
{
|
||||
SetPause(true);
|
||||
gameOver = true;
|
||||
canPause = false;
|
||||
time = TimeSpan.FromSeconds(Time.timeSinceLevelLoad).ToString(@"mm\:ss");
|
||||
wave = WaveManager.instance.wave-1;
|
||||
WaveManager.instance.musicSource.Stop();
|
||||
accuracy = ((float)projectilesHit / projectilesShot).ToString(@"P");
|
||||
}
|
||||
public void LoseGame()
|
||||
{
|
||||
loseUI.SetActive(true);
|
||||
WaveManager.instance.loseUI.SetActive(true);
|
||||
EndGame();
|
||||
statsUI.SetUI();
|
||||
WaveManager.instance.statsUI.SetUI();
|
||||
}
|
||||
|
||||
public void WinGame()
|
||||
|
|
@ -65,23 +65,41 @@ public class GameManager : MonoBehaviour
|
|||
{
|
||||
LevelSwitcher.instance.SwitchLevel(0);
|
||||
SetPause(false);
|
||||
canPause = true;
|
||||
ClearStats();
|
||||
}
|
||||
|
||||
public void RestartGame()
|
||||
{
|
||||
LevelSwitcher.instance.SwitchLevel(1);
|
||||
canPause = true;
|
||||
SetPause(false);
|
||||
ClearStats();
|
||||
}
|
||||
|
||||
public void ContinueGame()
|
||||
{
|
||||
gameOver = false;
|
||||
loseUI.SetActive(false);
|
||||
canPause = true;
|
||||
WaveManager.instance.loseUI.SetActive(false);
|
||||
SetPause(false);
|
||||
WaveManager.instance.musicSource.Play();
|
||||
WaveManager.instance.player.health = WaveManager.instance.player.maxHealth;
|
||||
continues++;
|
||||
}
|
||||
|
||||
private void ClearStats()
|
||||
{
|
||||
continues = 0;
|
||||
wave = 0;
|
||||
projectilesHit = 0;
|
||||
projectilesShot = 0;
|
||||
accuracy = "";
|
||||
deflections = 0;
|
||||
livesLost = 0;
|
||||
time = "";
|
||||
}
|
||||
|
||||
public void SetPause(bool state)
|
||||
{
|
||||
if (state)
|
||||
|
|
@ -96,16 +114,16 @@ public class GameManager : MonoBehaviour
|
|||
|
||||
public void SetPauseMenu()
|
||||
{
|
||||
if (!gameOver && !DialogueManager.instance.dialogueActive)
|
||||
if (!gameOver && canPause && WaveManager.instance)
|
||||
{
|
||||
if (!pauseMenu.activeSelf)
|
||||
if (!WaveManager.instance.pauseMenu.activeSelf)
|
||||
{
|
||||
pauseMenu.SetActive(true);
|
||||
WaveManager.instance.pauseMenu.SetActive(true);
|
||||
SetPause(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
pauseMenu.SetActive(false);
|
||||
WaveManager.instance.pauseMenu.SetActive(false);
|
||||
SetPause(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,19 @@ public class MainMenuHandler : MonoBehaviour
|
|||
screenFade.gameObject.SetActive(true);
|
||||
screenFade.color = Color.clear;
|
||||
StartCoroutine(FadeScreen(2, startingScript));
|
||||
GameManager.instance.gameOver = false;
|
||||
GameManager.instance.canPause = true;
|
||||
GameManager.instance.isEndless = false;
|
||||
}
|
||||
|
||||
public void StartEndless()
|
||||
{
|
||||
|
||||
screenFade.gameObject.SetActive(true);
|
||||
screenFade.color = Color.clear;
|
||||
StartCoroutine(FadeScreen(1, startingScript));
|
||||
GameManager.instance.gameOver = false;
|
||||
GameManager.instance.canPause = true;
|
||||
GameManager.instance.isEndless = true;
|
||||
}
|
||||
|
||||
public void QuitGame()
|
||||
|
|
|
|||
|
|
@ -30,12 +30,20 @@ public class SettingsMenu : MonoBehaviour
|
|||
{
|
||||
sfxLabel.text = $"SFX ({(sfxSlider.value * 100).ToString("F1")}%);";
|
||||
mainMixer.SetFloat("SFXVolume", Mathf.Log10(sfxSlider.value) * 20);
|
||||
if (sfxSlider.value <= 0f)
|
||||
{
|
||||
mainMixer.SetFloat("SFXVolume", Mathf.Log10(0.01f) * 20);
|
||||
}
|
||||
PlayerPrefs.SetFloat("SFXVolume", sfxSlider.value);
|
||||
}
|
||||
public void UpdateMusic()
|
||||
{
|
||||
musicLabel.text = $"Music ({(musicSlider.value * 100).ToString("F1")}%);";
|
||||
mainMixer.SetFloat("MusicVolume", Mathf.Log10(musicSlider.value) * 20);
|
||||
if (musicSlider.value <= 0f)
|
||||
{
|
||||
mainMixer.SetFloat("MusicVolume", Mathf.Log10(0.01f) * 20);
|
||||
}
|
||||
PlayerPrefs.SetFloat("MusicVolume", musicSlider.value);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ public class WaveManager : MonoBehaviour
|
|||
public Texture bossName;
|
||||
//public DialogueScript bossDialogue;
|
||||
}
|
||||
|
||||
public GameObject pauseMenu;
|
||||
[Header("Player Point")]
|
||||
public Player player; //only for continues lol
|
||||
[SerializeField] private Transform tlPoint;
|
||||
|
|
@ -52,7 +52,7 @@ public class WaveManager : MonoBehaviour
|
|||
public Enemy bossInstance;
|
||||
public GameObject bossUI;
|
||||
[SerializeField] private RawImage bossNameUI;
|
||||
[SerializeField] private Transform bossHPBar;
|
||||
[SerializeField] private Image bossHPBar;
|
||||
|
||||
[Header("Final Boss")]
|
||||
[SerializeField] private Prismriver lunasa;
|
||||
|
|
@ -69,25 +69,41 @@ public class WaveManager : MonoBehaviour
|
|||
public List<Enemy> enemiesInPlay = new();
|
||||
[SerializeField] private float enemyCheckRadius;
|
||||
[SerializeField] private LayerMask enemyLayer;
|
||||
public int healInterval;
|
||||
[Header("Audio")]
|
||||
public AudioClip bossDialogueLoop;
|
||||
public AudioClip bossMusic;
|
||||
public float bossVolume;
|
||||
public AudioClip finalDialogueLoop;
|
||||
public AudioClip finalMusic;
|
||||
public float finalVolume;
|
||||
public AudioSource audioSource;
|
||||
public AudioSource musicSource;
|
||||
[SerializeField] private AudioClip musicIntro;
|
||||
public AudioClip musicLoop;
|
||||
public float musicVolume;
|
||||
[Header("UI")]
|
||||
public GameObject loseUI;
|
||||
public StatsUI statsUI;
|
||||
[Header("Endless")]
|
||||
[SerializeField] private Enemy[] enemyList;
|
||||
[SerializeField] private Enemy[] bossList;
|
||||
[SerializeField] private int bossWaveInterval;
|
||||
[Header("Enemy Count Calculations")]
|
||||
[SerializeField] private float baseSpawnAmount;
|
||||
[SerializeField] private float exponentIncrease;
|
||||
public float exponentHealthIncrease;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
SpawnWave();
|
||||
if (GameManager.instance.isEndless)
|
||||
{
|
||||
SpawnEndlessWave();
|
||||
}
|
||||
else
|
||||
{
|
||||
SpawnWave();
|
||||
}
|
||||
//SpawnFinalBoss();
|
||||
musicSource.volume = musicVolume;
|
||||
musicSource.PlayOneShot(musicIntro, musicVolume);
|
||||
musicSource.PlayOneShot(musicIntro);
|
||||
StartCoroutine(WaitForLoop());
|
||||
}
|
||||
|
||||
|
|
@ -115,6 +131,25 @@ public class WaveManager : MonoBehaviour
|
|||
return randomPoint;
|
||||
}
|
||||
|
||||
public void CallPauseMenu()
|
||||
{
|
||||
GameManager.instance.SetPauseMenu();
|
||||
}
|
||||
public void CallExitGame()
|
||||
{
|
||||
GameManager.instance.ExitGame();
|
||||
}
|
||||
|
||||
public void CallRestartGame()
|
||||
{
|
||||
GameManager.instance.RestartGame();
|
||||
}
|
||||
|
||||
public void CallContinue()
|
||||
{
|
||||
GameManager.instance.ContinueGame();
|
||||
}
|
||||
|
||||
private bool CheckEnemyOverlap(Vector3 areaToCheck)
|
||||
{
|
||||
if (Physics2D.OverlapCircle(areaToCheck, enemyCheckRadius, enemyLayer))
|
||||
|
|
@ -142,6 +177,20 @@ public class WaveManager : MonoBehaviour
|
|||
}
|
||||
wave++;
|
||||
}
|
||||
private void SpawnEndlessWave()
|
||||
{
|
||||
//waveUI.text = $"Wave: {wave}";
|
||||
int amountToSpawn = Mathf.FloorToInt(baseSpawnAmount * Mathf.Pow(wave, exponentIncrease));
|
||||
for (int i = 0; i < amountToSpawn; i++)
|
||||
{
|
||||
SpawnEnemy(enemyList[Random.Range(0, enemyList.Length)]);
|
||||
}
|
||||
if (wave % bossWaveInterval == 0)
|
||||
{
|
||||
SpawnBoss(bossList[Random.Range(0, bossList.Length)]);
|
||||
}
|
||||
wave++;
|
||||
}
|
||||
|
||||
protected void SpawnBoss(Enemy boss)
|
||||
{
|
||||
|
|
@ -150,8 +199,16 @@ public class WaveManager : MonoBehaviour
|
|||
bossNameUI.texture = waveList[wave - 1].bossName;
|
||||
bossNameUI.SetNativeSize();
|
||||
UpdateBossUI();
|
||||
player.isStalled = true; //wait for boss to enter then start dialogue
|
||||
player.invulnerable = true;
|
||||
if (!GameManager.instance.isEndless)
|
||||
{
|
||||
player.isStalled = true; //wait for boss to enter then start dialogue
|
||||
player.invulnerable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
newBoss.maxHealth = Mathf.FloorToInt(newBoss.maxHealth * Mathf.Pow(wave, exponentHealthIncrease));
|
||||
newBoss.health = newBoss.maxHealth;
|
||||
}
|
||||
}
|
||||
private void SpawnFinalBoss()
|
||||
{
|
||||
|
|
@ -171,6 +228,11 @@ public class WaveManager : MonoBehaviour
|
|||
{
|
||||
Enemy newEnemy = Instantiate(enemy, enemyFolder);
|
||||
Vector3 movepos = GetRandomEnemyPoint();
|
||||
if (GameManager.instance.isEndless)
|
||||
{
|
||||
newEnemy.maxHealth = Mathf.FloorToInt(newEnemy.maxHealth * Mathf.Pow(wave, exponentHealthIncrease));
|
||||
newEnemy.health = newEnemy.maxHealth;
|
||||
}
|
||||
newEnemy.currentMovementRoutine = newEnemy.StartCoroutine(newEnemy.MoveToPosition(enemySpawnPoint.position,movepos, newEnemy.moveSpeed));
|
||||
newEnemy.originalPosition = movepos;
|
||||
enemiesInPlay.Add(newEnemy);
|
||||
|
|
@ -195,18 +257,26 @@ public class WaveManager : MonoBehaviour
|
|||
{
|
||||
if (lyricaInstance)
|
||||
{
|
||||
bossHPBar.localScale = new Vector3(1 - (float)prismHP / prismMaxHP, 1f, 1f);
|
||||
bossHPBar.fillAmount = 1 - (float)prismHP / prismMaxHP;
|
||||
return;
|
||||
}
|
||||
bossHPBar.localScale = new Vector3(1 - (float)bossInstance.health / bossInstance.maxHealth, 1f, 1f);
|
||||
bossHPBar.fillAmount = 1 - (float)bossInstance.health / bossInstance.maxHealth;
|
||||
}
|
||||
|
||||
public virtual void UpdateKills()
|
||||
{
|
||||
if (enemiesInPlay.Count == 0)
|
||||
{
|
||||
if (waveList[wave - 1].bossEnemy)
|
||||
Debug.Log("interval: " + ((wave+1) % healInterval));
|
||||
if ((wave + 1) % healInterval == 0)
|
||||
{
|
||||
Debug.Log("here");
|
||||
player.Heal(1);
|
||||
}
|
||||
if (GameManager.instance.isEndless)
|
||||
{
|
||||
SpawnEndlessWave();
|
||||
return;
|
||||
}
|
||||
SpawnWave();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue