added boss (final commit)
This commit is contained in:
1 parent
ff19b0461e
commit
0a1cecfb4a
71 files changed
+1953
-144
No files matched your search
@@ -7,15 +7,17 @@ using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class GameplayControllerSecond : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Image deathScreen;
|
||||
[SerializeField] private Image winScreen;
|
||||
[SerializeField] private TMP_Text deathText;
|
||||
[SerializeField] private TMP_Text winText;
|
||||
[SerializeField] private Button exitButton;
|
||||
[SerializeField] private Button returnButton;
|
||||
[SerializeField] private PlayerHealth playerHealth;
|
||||
[SerializeField] private AudioSource audioSource;
|
||||
[SerializeField] private BoxCollider2D blockBorder;
|
||||
@@ -29,9 +31,11 @@ namespace Code.UI
|
||||
FindFirstObjectByType<PlayerMovement>().Construct(_inputService);
|
||||
|
||||
exitButton.onClick.AddListener(OnExitButtonPressed);
|
||||
returnButton.onClick.AddListener(OnReturnButtonPressed);
|
||||
playerHealth.OnDied += HandleDeath;
|
||||
|
||||
deathScreen.gameObject.SetActive(false);
|
||||
winScreen.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void HandleDeath()
|
||||
@@ -45,7 +49,9 @@ namespace Code.UI
|
||||
deathScreen.rectTransform.DOScale(1f, 0.3f)
|
||||
.SetEase(Ease.OutBack);
|
||||
|
||||
deathText.color = deathText.color.WithAlpha(0f);
|
||||
var color = deathText.color;
|
||||
color.a = 0;
|
||||
deathText.color = color;
|
||||
deathText.DOFade(1f, 0.6f)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
@@ -54,6 +60,29 @@ namespace Code.UI
|
||||
.SetEase(Ease.InOutSine);
|
||||
});
|
||||
}
|
||||
|
||||
public void OnBossDefeated()
|
||||
{
|
||||
var clip = Resources.Load<AudioClip>("Audio/SFX/WinSFX");
|
||||
audioSource.PlayOneShot(clip);
|
||||
_inputService.DisableMap(ActionMapping.Gameplay);
|
||||
winScreen.gameObject.SetActive(true);
|
||||
|
||||
winScreen.rectTransform.localScale = Vector3.zero;
|
||||
winScreen.rectTransform.DOScale(1f, 0.3f)
|
||||
.SetEase(Ease.OutBack);
|
||||
|
||||
var color = winText.color;
|
||||
color.a = 0;
|
||||
winText.color = color;
|
||||
winText.DOFade(1f, 0.6f)
|
||||
.OnComplete(() =>
|
||||
{
|
||||
deathText.DOFade(0.8f, 0.5f)
|
||||
.SetLoops(-1, LoopType.Yoyo)
|
||||
.SetEase(Ease.InOutSine);
|
||||
});
|
||||
}
|
||||
|
||||
private void OnExitButtonPressed()
|
||||
{
|
||||
@@ -61,15 +90,18 @@ namespace Code.UI
|
||||
DOTween.Kill(deathText);
|
||||
|
||||
exitButton.onClick.RemoveAllListeners();
|
||||
returnButton.onClick.RemoveAllListeners();
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
|
||||
private void OnReturnButtonPressed()
|
||||
{
|
||||
if (!FindAnyObjectByType<BasicEnemy>())
|
||||
{
|
||||
blockBorder.gameObject.SetActive(false);
|
||||
}
|
||||
DOTween.Kill(winScreen.rectTransform);
|
||||
DOTween.Kill(winText);
|
||||
|
||||
exitButton.onClick.RemoveAllListeners();
|
||||
returnButton.onClick.RemoveAllListeners();
|
||||
SceneManager.LoadScene("MainMenu");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user