2021-09-05 22:55:57 +02:00
|
|
|
using System.Collections;
|
2022-06-13 16:51:55 +02:00
|
|
|
using System.Text.RegularExpressions;
|
2021-09-05 22:55:57 +02:00
|
|
|
using TMPro;
|
2021-08-21 02:57:59 +02:00
|
|
|
using UnityEngine;
|
2021-10-30 01:05:05 +02:00
|
|
|
using UnityEngine.SceneManagement;
|
2021-08-21 02:57:59 +02:00
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
public class PlayerUI : MonoBehaviour
|
|
|
|
|
{
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Animator[] _lostLivesAnimator = default;
|
2024-02-05 16:28:15 +02:00
|
|
|
[SerializeField] private GameObject _overlayUI = default;
|
|
|
|
|
[SerializeField] private GameObject _otherOverlayUI = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Slider _healthSlider = default;
|
|
|
|
|
[SerializeField] private Slider _healthDamagedSlider = default;
|
2022-10-22 20:01:10 +03:00
|
|
|
[SerializeField] private Slider _healthRecoverableSlider = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Slider _arcanaSlider = default;
|
|
|
|
|
[SerializeField] private Slider _assistSlider = default;
|
2023-10-16 13:39:36 +03:00
|
|
|
[SerializeField] private Image _arcanaBackground = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Image _portraitImage = default;
|
|
|
|
|
[SerializeField] private Image _assistBorder = default;
|
|
|
|
|
[SerializeField] private Notification _notification = default;
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _characterName = default;
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _playerName = default;
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _assistName = default;
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _arcanaAmountText = default;
|
|
|
|
|
[SerializeField] private TextMeshProUGUI _hitsNumberText = default;
|
2023-05-28 14:10:29 +03:00
|
|
|
[SerializeField] private TextMeshProUGUI _maxArcanaText = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Animator _arcanaAnimator = default;
|
2024-01-15 23:31:17 +02:00
|
|
|
[SerializeField] private Animator _comboAnimator = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Slider _pauseSlider = default;
|
|
|
|
|
[SerializeField] private Slider _comboTimerSlider = default;
|
|
|
|
|
[SerializeField] private Image _comboTimerImage = default;
|
2023-05-28 14:10:29 +03:00
|
|
|
[SerializeField] private Image _arcanaFill = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Image _comboTimerLock = default;
|
|
|
|
|
[SerializeField] private Image _borderHealth = default;
|
|
|
|
|
[SerializeField] private Image _borderPortrait = default;
|
2024-02-05 16:28:15 +02:00
|
|
|
[SerializeField] private Image _darkScreen = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Sprite _assistEmpty = default;
|
|
|
|
|
[SerializeField] private Sprite _assistHalf = default;
|
|
|
|
|
[SerializeField] private Sprite _assistFull = default;
|
|
|
|
|
[SerializeField] private PauseMenu _pauseMenu = default;
|
|
|
|
|
[SerializeField] private PauseMenu _trainingPauseMenu = default;
|
|
|
|
|
[SerializeField] private PauseMenu _replayPauseMenu = default;
|
|
|
|
|
[SerializeField] private TrainingMenu _trainingMenu = default;
|
2022-12-30 14:07:58 +02:00
|
|
|
[SerializeField] private DisconnectMenu _disconnectMenu = default;
|
2024-01-22 23:42:05 +00:00
|
|
|
[SerializeField] private TextMeshProUGUI _overheadText = default;
|
2023-06-12 10:40:01 +03:00
|
|
|
[SerializeField] private Audio _audio = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[SerializeField] private Color _healthNormalColor = default;
|
|
|
|
|
[SerializeField] private Color _healthLimitColor = default;
|
|
|
|
|
[SerializeField] private Color _healthDamagedColor = default;
|
2023-05-28 02:32:31 +03:00
|
|
|
[SerializeField] private Color _arcanaAvailableColor = default;
|
|
|
|
|
[SerializeField] private Color _arcanaUnavailableColor = default;
|
2023-10-16 13:39:36 +03:00
|
|
|
[SerializeField] private Color _arcanaMeterBackColor = default;
|
|
|
|
|
[SerializeField] private Color _arcanaMeter1Color = default;
|
|
|
|
|
[SerializeField] private Color _arcanaMeter2Color = default;
|
|
|
|
|
[SerializeField] private Color _arcanaMeter3Color = default;
|
2022-09-24 13:29:28 +03:00
|
|
|
[Header("1BitVisuals")]
|
|
|
|
|
[SerializeField] private Image _healthImage = default;
|
|
|
|
|
private Coroutine _openPauseHoldCoroutine;
|
|
|
|
|
private Coroutine _notificiationCoroutine;
|
|
|
|
|
private Coroutine _resetComboCoroutine;
|
|
|
|
|
private Coroutine _showPlayerIconCoroutine;
|
2022-10-22 20:01:10 +03:00
|
|
|
private Coroutine _healthCoroutine;
|
2022-09-24 13:29:28 +03:00
|
|
|
private Coroutine _damagedHealthCoroutine;
|
|
|
|
|
private Coroutine _damagedCoroutine;
|
2023-05-28 14:10:29 +03:00
|
|
|
private Coroutine _arcanaCoroutine;
|
2022-09-24 13:29:28 +03:00
|
|
|
private Animator _animator;
|
|
|
|
|
private BrainController _controller;
|
|
|
|
|
private RectTransform _comboGroup;
|
|
|
|
|
private Color _healthCurrentColor;
|
|
|
|
|
private float _currentEndDamageValue;
|
|
|
|
|
private int _currentLifeIndex;
|
|
|
|
|
private bool _hasComboEnded;
|
|
|
|
|
private bool _initializedStats;
|
|
|
|
|
public string PlayerName { get; private set; }
|
|
|
|
|
public string CharacterName { get; private set; }
|
2021-10-02 02:21:06 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public int CurrentComboCount { get; private set; }
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
_animator = GetComponent<Animator>();
|
2024-01-15 05:39:11 +02:00
|
|
|
_hitsNumberText.transform.parent.parent.gameObject.SetActive(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
_notification.gameObject.SetActive(false);
|
|
|
|
|
_comboTimerSlider.transform.GetChild(0).gameObject.SetActive(false);
|
|
|
|
|
_comboTimerSlider.transform.GetChild(1).gameObject.SetActive(false);
|
2024-01-15 05:39:11 +02:00
|
|
|
_comboGroup = _hitsNumberText.transform.parent.parent.GetComponent<RectTransform>();
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2021-10-21 23:17:10 +02:00
|
|
|
|
2024-01-22 23:42:05 +00:00
|
|
|
public void InitializeUI(PlayerStatsSO playerStats, BrainController controller, TextMeshProUGUI overhead)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
2024-01-22 23:42:05 +00:00
|
|
|
_overheadText = overhead;
|
2022-09-24 13:29:28 +03:00
|
|
|
_borderHealth.color = Color.white;
|
|
|
|
|
_borderPortrait.color = Color.white;
|
|
|
|
|
_healthCurrentColor = _healthNormalColor;
|
|
|
|
|
_healthImage.color = _healthCurrentColor;
|
|
|
|
|
_controller = controller;
|
|
|
|
|
if (!_initializedStats)
|
|
|
|
|
{
|
|
|
|
|
if (_controller.IsPlayerOne)
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.NameOne == "")
|
|
|
|
|
{
|
2022-01-18 23:53:40 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
if (SceneSettings.ControllerOne == null)
|
|
|
|
|
{
|
|
|
|
|
PlayerName = "Cpu 1";
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerName = "Player 1";
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerName = SceneSettings.NameOne;
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
2022-01-18 23:53:40 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.NameTwo == "")
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.ControllerTwo == null)
|
|
|
|
|
{
|
|
|
|
|
PlayerName = "Cpu 2";
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerName = "Player 2";
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerName = SceneSettings.NameTwo;
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
CharacterName = Regex.Replace(playerStats.characterName.ToString(), "([a-z])([A-Z])", "$1 $2");
|
|
|
|
|
_characterName.text = CharacterName;
|
|
|
|
|
if (_controller.IsPlayerOne)
|
|
|
|
|
{
|
|
|
|
|
SetPortrait(playerStats.portraits[SceneSettings.ColorOne]);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SetPortrait(playerStats.portraits[SceneSettings.ColorTwo]);
|
|
|
|
|
}
|
|
|
|
|
SetMaxHealth(playerStats.maxHealth);
|
2023-05-28 02:32:31 +03:00
|
|
|
SetMaxArcana(PlayerStatsSO.ARCANA_MULTIPLIER);
|
2022-09-24 13:29:28 +03:00
|
|
|
_initializedStats = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2024-02-05 16:28:15 +02:00
|
|
|
public void SetDarkScreen(bool state)
|
|
|
|
|
{
|
|
|
|
|
_darkScreen.gameObject.SetActive(state);
|
|
|
|
|
_overlayUI.gameObject.SetActive(!state);
|
|
|
|
|
_otherOverlayUI.gameObject.SetActive(!state);
|
|
|
|
|
_trainingMenu.CanvasGroup.alpha = state ? 0 : 1;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-06 12:22:07 +02:00
|
|
|
public void SetPlayerName(string name)
|
|
|
|
|
{
|
|
|
|
|
PlayerName = name;
|
|
|
|
|
_playerName.text = PlayerName;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void SetAssistName(string name)
|
|
|
|
|
{
|
|
|
|
|
_assistName.text = name;
|
|
|
|
|
}
|
2022-01-15 12:59:43 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
private void SetPortrait(Sprite portrait)
|
|
|
|
|
{
|
|
|
|
|
_portraitImage.sprite = portrait;
|
|
|
|
|
}
|
2021-10-21 23:17:10 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
private void SetMaxHealth(float value)
|
|
|
|
|
{
|
|
|
|
|
_healthSlider.maxValue = value;
|
|
|
|
|
_healthDamagedSlider.maxValue = value;
|
|
|
|
|
_healthDamagedSlider.value = value;
|
2022-10-22 20:01:10 +03:00
|
|
|
_healthRecoverableSlider.maxValue = value;
|
|
|
|
|
_healthRecoverableSlider.value = value;
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2021-10-21 23:17:10 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
private void SetMaxArcana(float value)
|
|
|
|
|
{
|
|
|
|
|
float arcanaSliderWidth = _arcanaSlider.GetComponent<RectTransform>().sizeDelta.x;
|
|
|
|
|
_arcanaSlider.maxValue = value;
|
|
|
|
|
}
|
2021-10-21 23:17:10 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void FadeIn()
|
|
|
|
|
{
|
|
|
|
|
_animator.SetTrigger("FadeIn");
|
|
|
|
|
}
|
2021-10-29 01:20:08 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void FadeOut()
|
|
|
|
|
{
|
|
|
|
|
_animator.SetTrigger("FadeOut");
|
|
|
|
|
}
|
2021-09-28 21:09:42 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void DecreaseArcana()
|
|
|
|
|
{
|
|
|
|
|
_arcanaAnimator.SetTrigger("Decrease");
|
|
|
|
|
}
|
2021-11-21 20:14:08 +01:00
|
|
|
|
2024-01-23 03:42:14 +02:00
|
|
|
public void ShowYouOverhead()
|
|
|
|
|
{
|
|
|
|
|
StartCoroutine(ShowYouOverheadCoroutine());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator ShowYouOverheadCoroutine()
|
|
|
|
|
{
|
|
|
|
|
_overheadText.text = "You";
|
|
|
|
|
_overheadText.gameObject.SetActive(true);
|
|
|
|
|
yield return new WaitForSecondsRealtime(2.5f);
|
|
|
|
|
_overheadText.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void SetArcana(float value)
|
|
|
|
|
{
|
2023-05-28 02:32:31 +03:00
|
|
|
int arcana = Mathf.FloorToInt(value / PlayerStatsSO.ARCANA_MULTIPLIER);
|
|
|
|
|
if (value != 3000)
|
2023-05-28 14:10:29 +03:00
|
|
|
{
|
2023-05-28 02:32:31 +03:00
|
|
|
value = value - (PlayerStatsSO.ARCANA_MULTIPLIER * arcana);
|
2023-05-28 14:10:29 +03:00
|
|
|
_maxArcanaText.gameObject.SetActive(false);
|
|
|
|
|
}
|
2023-06-12 10:40:01 +03:00
|
|
|
else if (!_maxArcanaText.gameObject.activeSelf)
|
|
|
|
|
{
|
2023-11-19 13:04:52 +02:00
|
|
|
_arcanaBackground.color = _arcanaMeter2Color;
|
|
|
|
|
_arcanaFill.color = _arcanaMeter3Color;
|
2023-06-12 10:40:01 +03:00
|
|
|
_audio.Sound("MaxArcana").Play();
|
2023-05-28 14:10:29 +03:00
|
|
|
_maxArcanaText.gameObject.SetActive(true);
|
2023-06-12 10:40:01 +03:00
|
|
|
}
|
2022-09-24 13:29:28 +03:00
|
|
|
_arcanaSlider.value = value;
|
2023-05-28 02:32:31 +03:00
|
|
|
_arcanaAmountText.text = arcana.ToString();
|
|
|
|
|
if (arcana == 0)
|
2023-05-28 14:10:29 +03:00
|
|
|
{
|
2023-05-28 02:32:31 +03:00
|
|
|
_arcanaAmountText.color = _arcanaUnavailableColor;
|
2023-10-16 13:39:36 +03:00
|
|
|
_arcanaBackground.color = _arcanaMeterBackColor;
|
|
|
|
|
_arcanaFill.color = _arcanaMeter1Color;
|
2023-05-28 14:10:29 +03:00
|
|
|
}
|
2023-05-28 02:32:31 +03:00
|
|
|
else
|
2023-05-28 14:10:29 +03:00
|
|
|
{
|
2023-05-28 02:32:31 +03:00
|
|
|
_arcanaAmountText.color = _arcanaAvailableColor;
|
2023-10-16 13:39:36 +03:00
|
|
|
if (arcana == 1)
|
2023-06-12 10:40:01 +03:00
|
|
|
{
|
2023-10-16 13:39:36 +03:00
|
|
|
_arcanaBackground.color = _arcanaMeter1Color;
|
|
|
|
|
_arcanaFill.color = _arcanaMeter2Color;
|
|
|
|
|
}
|
2023-11-19 13:04:52 +02:00
|
|
|
else if (arcana == 2)
|
2023-10-16 13:39:36 +03:00
|
|
|
{
|
|
|
|
|
_arcanaBackground.color = _arcanaMeter2Color;
|
|
|
|
|
_arcanaFill.color = _arcanaMeter3Color;
|
2023-06-12 10:40:01 +03:00
|
|
|
}
|
2023-05-28 14:10:29 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-01-09 18:16:00 +02:00
|
|
|
public void SetAssist(int value)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
2023-08-12 22:32:45 +03:00
|
|
|
if (value >= GameSimulation.maxShadowGauge)
|
2022-09-24 13:29:28 +03:00
|
|
|
_assistBorder.sprite = _assistFull;
|
2023-08-12 22:32:45 +03:00
|
|
|
else if (value >= GameSimulation.maxShadowGauge / 2)
|
2022-09-24 13:29:28 +03:00
|
|
|
_assistBorder.sprite = _assistHalf;
|
|
|
|
|
else
|
|
|
|
|
_assistBorder.sprite = _assistEmpty;
|
|
|
|
|
_assistSlider.value = value;
|
|
|
|
|
}
|
2021-08-21 11:41:23 +02:00
|
|
|
|
2023-01-06 03:10:59 +02:00
|
|
|
public void SetHealth(int value)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
|
|
|
|
if (value <= 3000)
|
|
|
|
|
{
|
|
|
|
|
_borderHealth.color = Color.red;
|
|
|
|
|
_borderPortrait.color = Color.red;
|
|
|
|
|
_healthCurrentColor = _healthLimitColor;
|
|
|
|
|
}
|
|
|
|
|
_healthImage.color = _healthCurrentColor;
|
|
|
|
|
_healthSlider.value = value;
|
|
|
|
|
}
|
2021-09-05 22:55:57 +02:00
|
|
|
|
2023-01-08 18:48:39 +02:00
|
|
|
public void CheckDemonLimit(int value)
|
2022-10-22 20:01:10 +03:00
|
|
|
{
|
|
|
|
|
if (value > 3000)
|
|
|
|
|
{
|
|
|
|
|
_borderHealth.color = Color.white;
|
|
|
|
|
_borderPortrait.color = Color.white;
|
|
|
|
|
_healthCurrentColor = _healthNormalColor;
|
|
|
|
|
_healthImage.color = _healthCurrentColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void UpdateHealth()
|
|
|
|
|
{
|
|
|
|
|
if (_healthCoroutine != null)
|
|
|
|
|
{
|
|
|
|
|
StopCoroutine(_healthCoroutine);
|
|
|
|
|
}
|
|
|
|
|
_healthCoroutine = StartCoroutine(SetHealthCoroutine());
|
|
|
|
|
}
|
2022-12-30 14:07:58 +02:00
|
|
|
public void Disconnected()
|
|
|
|
|
{
|
|
|
|
|
Time.timeScale = 0;
|
|
|
|
|
GameplayManager.Instance.DisableAllInput(true);
|
|
|
|
|
GameplayManager.Instance.PauseMusic();
|
|
|
|
|
_disconnectMenu.Show();
|
|
|
|
|
}
|
2022-10-22 20:01:10 +03:00
|
|
|
|
|
|
|
|
IEnumerator SetHealthCoroutine()
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(0.1f);
|
|
|
|
|
float startValue = _healthSlider.value;
|
|
|
|
|
float endValue = _healthRecoverableSlider.value;
|
|
|
|
|
float elapsedTime = 0;
|
|
|
|
|
float duration = 0.1f;
|
|
|
|
|
while (elapsedTime < duration)
|
|
|
|
|
{
|
|
|
|
|
_healthSlider.value = Mathf.Lerp(startValue, endValue, elapsedTime / duration);
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
_healthSlider.value = endValue;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-06 03:10:59 +02:00
|
|
|
public void SetRecoverableHealth(int value)
|
2022-10-22 20:01:10 +03:00
|
|
|
{
|
|
|
|
|
_healthRecoverableSlider.value = value;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void MaxHealth(float value)
|
|
|
|
|
{
|
|
|
|
|
_healthSlider.value = value;
|
|
|
|
|
_healthDamagedSlider.value = value;
|
|
|
|
|
if (_damagedHealthCoroutine != null)
|
|
|
|
|
{
|
|
|
|
|
StopCoroutine(_damagedHealthCoroutine);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-06-11 02:16:42 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void Damaged()
|
|
|
|
|
{
|
|
|
|
|
if (_damagedCoroutine != null)
|
|
|
|
|
StopCoroutine(_damagedCoroutine);
|
|
|
|
|
_damagedCoroutine = StartCoroutine(DamagedCoroutine());
|
|
|
|
|
}
|
2022-07-03 14:05:51 +03:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator DamagedCoroutine()
|
|
|
|
|
{
|
|
|
|
|
_healthImage.color = _healthDamagedColor;
|
|
|
|
|
_portraitImage.color = _healthDamagedColor;
|
2022-09-25 16:08:45 +03:00
|
|
|
yield return new WaitForSecondsRealtime(0.04f);
|
2022-09-24 13:29:28 +03:00
|
|
|
_healthImage.color = _healthCurrentColor;
|
|
|
|
|
_portraitImage.color = Color.white;
|
|
|
|
|
}
|
2022-07-03 14:05:51 +03:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ResetHealthDamaged()
|
|
|
|
|
{
|
|
|
|
|
if (_damagedHealthCoroutine != null)
|
|
|
|
|
StopCoroutine(_damagedHealthCoroutine);
|
|
|
|
|
_healthDamagedSlider.value = _healthSlider.maxValue;
|
|
|
|
|
}
|
2022-10-22 20:01:10 +03:00
|
|
|
public void SetHealthDamaged(float value)
|
|
|
|
|
{
|
|
|
|
|
if (_damagedHealthCoroutine != null)
|
|
|
|
|
StopCoroutine(_damagedHealthCoroutine);
|
|
|
|
|
_healthDamagedSlider.value = value;
|
|
|
|
|
}
|
2022-04-21 07:55:22 +02:00
|
|
|
|
2023-01-10 18:39:07 +02:00
|
|
|
public void UpdateHealthDamaged(int healthRecoverable)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
2023-01-10 18:39:07 +02:00
|
|
|
SetRecoverableHealth(healthRecoverable);
|
2022-09-24 13:29:28 +03:00
|
|
|
if (_damagedHealthCoroutine != null)
|
|
|
|
|
StopCoroutine(_damagedHealthCoroutine);
|
2022-10-22 20:01:10 +03:00
|
|
|
_damagedHealthCoroutine = StartCoroutine(SetHealthDamagedCoroutine(_healthRecoverableSlider.value));
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2022-04-21 07:55:22 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator SetHealthDamagedCoroutine(float value)
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(0.5f);
|
|
|
|
|
float startValue = _healthDamagedSlider.value;
|
|
|
|
|
_currentEndDamageValue = value;
|
|
|
|
|
float elapsedTime = 0.0f;
|
|
|
|
|
float duration = 0.2f;
|
|
|
|
|
while (elapsedTime < duration)
|
|
|
|
|
{
|
|
|
|
|
_healthDamagedSlider.value = Mathf.Lerp(startValue, _currentEndDamageValue, elapsedTime / duration);
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
_healthDamagedSlider.value = _currentEndDamageValue;
|
|
|
|
|
}
|
2022-04-21 07:55:22 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void SetLives()
|
|
|
|
|
{
|
|
|
|
|
_lostLivesAnimator[_currentLifeIndex].Play("LifeLost");
|
|
|
|
|
_currentLifeIndex++;
|
|
|
|
|
}
|
2021-10-01 20:10:24 +02:00
|
|
|
|
2023-07-02 23:17:37 +03:00
|
|
|
public void SetComboTimer(DemonFloat value, Color color)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
|
|
|
|
_comboTimerImage.color = color;
|
2022-11-18 14:51:34 +02:00
|
|
|
_comboTimerSlider.value = (float)value;
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2022-07-09 01:21:59 +03:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void SetComboTimerActive(bool state)
|
|
|
|
|
{
|
|
|
|
|
_comboTimerSlider.transform.GetChild(0).gameObject.SetActive(state);
|
|
|
|
|
_comboTimerSlider.transform.GetChild(1).gameObject.SetActive(state);
|
|
|
|
|
}
|
2022-07-09 01:21:59 +03:00
|
|
|
|
2023-08-12 22:32:45 +03:00
|
|
|
public void SetComboTimerLock(bool state) => _comboTimerLock.gameObject.SetActive(state);
|
2022-07-21 17:03:27 +03:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ResetLives()
|
|
|
|
|
{
|
|
|
|
|
_lostLivesAnimator[0].Rebind();
|
|
|
|
|
_lostLivesAnimator[1].Rebind();
|
|
|
|
|
_currentLifeIndex = 0;
|
|
|
|
|
}
|
2021-09-24 23:14:06 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void OpenPauseHold(bool isPlayerOne)
|
|
|
|
|
{
|
|
|
|
|
_pauseSlider.gameObject.SetActive(true);
|
|
|
|
|
_openPauseHoldCoroutine = StartCoroutine(OpenPauseHoldCoroutine(isPlayerOne));
|
|
|
|
|
}
|
2021-09-24 23:14:06 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator OpenPauseHoldCoroutine(bool isPlayerOne)
|
|
|
|
|
{
|
|
|
|
|
float t = 0.0f;
|
|
|
|
|
while (_pauseSlider.value < _pauseSlider.maxValue)
|
|
|
|
|
{
|
|
|
|
|
_pauseSlider.value = Mathf.Lerp(0.0f, _pauseSlider.maxValue, t);
|
|
|
|
|
t += Time.deltaTime;
|
|
|
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
|
}
|
|
|
|
|
_pauseSlider.value = 0.0f;
|
|
|
|
|
_pauseSlider.gameObject.SetActive(false);
|
|
|
|
|
OpenPause(isPlayerOne);
|
|
|
|
|
}
|
2021-10-31 19:37:04 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ClosePauseHold()
|
|
|
|
|
{
|
|
|
|
|
if (_openPauseHoldCoroutine != null)
|
|
|
|
|
{
|
|
|
|
|
_pauseSlider.gameObject.SetActive(false);
|
|
|
|
|
StopCoroutine(_openPauseHoldCoroutine);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-24 16:28:18 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ChangeCharacter()
|
|
|
|
|
{
|
|
|
|
|
_trainingMenu.ResetTrainingOptions();
|
|
|
|
|
Time.timeScale = 1.0f;
|
|
|
|
|
SceneSettings.SceneSettingsDecide = false;
|
|
|
|
|
SceneSettings.ChangeCharacter = true;
|
2023-07-03 17:57:46 +03:00
|
|
|
SceneManager.LoadScene(0);
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2021-09-24 21:03:17 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void QuitMatch()
|
|
|
|
|
{
|
|
|
|
|
_trainingMenu.ResetTrainingOptions();
|
|
|
|
|
Time.timeScale = 1.0f;
|
|
|
|
|
SceneSettings.SceneSettingsDecide = false;
|
|
|
|
|
SceneSettings.ChangeCharacter = false;
|
|
|
|
|
SceneSettings.ReplayMode = false;
|
2023-07-03 17:57:46 +03:00
|
|
|
SceneManager.LoadScene(0);
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2021-11-02 15:28:40 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void OpenPause(bool isPlayerOne)
|
|
|
|
|
{
|
2023-12-04 15:56:46 +02:00
|
|
|
MouseSetup.Instance.SetLock(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
_pauseMenu.SetWhoPaused(isPlayerOne);
|
2022-10-23 18:03:59 +03:00
|
|
|
Time.timeScale = 0;
|
2022-12-04 21:35:31 +02:00
|
|
|
GameplayManager.Instance.PausedController = _controller;
|
|
|
|
|
GameplayManager.Instance.DisableAllInput(isPlayerOne);
|
|
|
|
|
GameplayManager.Instance.PauseMusic();
|
|
|
|
|
_pauseMenu.PlayerInput = GameplayManager.Instance.PlayerInput;
|
2022-09-24 13:29:28 +03:00
|
|
|
_pauseMenu.Show();
|
|
|
|
|
}
|
2021-09-24 21:03:17 +02:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void OpenTrainingPause(bool isPlayerOne)
|
|
|
|
|
{
|
2023-12-04 15:56:46 +02:00
|
|
|
MouseSetup.Instance.SetLock(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
_trainingPauseMenu.SetWhoPaused(isPlayerOne);
|
2022-10-23 18:03:59 +03:00
|
|
|
Time.timeScale = 0;
|
2022-12-04 21:35:31 +02:00
|
|
|
GameplayManager.Instance.PausedController = _controller;
|
|
|
|
|
GameplayManager.Instance.DisableAllInput(isPlayerOne);
|
|
|
|
|
GameplayManager.Instance.PauseMusic();
|
|
|
|
|
_trainingPauseMenu.PlayerInput = GameplayManager.Instance.PlayerInput;
|
2022-09-24 13:29:28 +03:00
|
|
|
_trainingPauseMenu.Show();
|
|
|
|
|
}
|
2021-11-04 16:50:25 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ClosePause()
|
|
|
|
|
{
|
2023-12-04 15:56:46 +02:00
|
|
|
MouseSetup.Instance.SetLock(true);
|
2022-12-04 21:35:31 +02:00
|
|
|
Time.timeScale = GameplayManager.Instance.GameSpeed;
|
|
|
|
|
GameplayManager.Instance.EnableAllInput();
|
|
|
|
|
GameplayManager.Instance.PlayMusic();
|
2022-09-24 13:29:28 +03:00
|
|
|
_pauseMenu.Hide();
|
|
|
|
|
_trainingPauseMenu.Hide();
|
|
|
|
|
_replayPauseMenu.Hide();
|
|
|
|
|
}
|
2021-11-04 16:50:25 +01:00
|
|
|
|
2023-01-06 04:04:42 +02:00
|
|
|
public void IncreaseCombo(int combo)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
|
|
|
|
if (_hasComboEnded)
|
|
|
|
|
{
|
2024-01-15 23:31:17 +02:00
|
|
|
_comboAnimator.Rebind();
|
2022-09-24 13:29:28 +03:00
|
|
|
StopCoroutine(_resetComboCoroutine);
|
|
|
|
|
_hasComboEnded = false;
|
2024-01-15 05:39:11 +02:00
|
|
|
_hitsNumberText.transform.parent.parent.gameObject.SetActive(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
_hitsNumberText.text = "0 Hits";
|
|
|
|
|
if (_comboGroup.anchoredPosition.x == -110.0f)
|
|
|
|
|
{
|
|
|
|
|
_comboGroup.anchoredPosition = new Vector2(-40.0f, _comboGroup.anchoredPosition.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-01-06 04:04:42 +02:00
|
|
|
_hitsNumberText.text = combo.ToString();
|
|
|
|
|
if (combo > 1)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
2024-01-15 05:39:11 +02:00
|
|
|
_hitsNumberText.transform.parent.parent.gameObject.SetActive(false);
|
|
|
|
|
_hitsNumberText.transform.parent.parent.gameObject.SetActive(true);
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2023-01-06 04:04:42 +02:00
|
|
|
if (combo >= 10 && _comboGroup.anchoredPosition.x == -40.0f)
|
2022-09-24 13:29:28 +03:00
|
|
|
{
|
|
|
|
|
_comboGroup.anchoredPosition = new Vector2(-110.0f, _comboGroup.anchoredPosition.y);
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-04 16:50:25 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ResetCombo()
|
|
|
|
|
{
|
|
|
|
|
_hasComboEnded = true;
|
|
|
|
|
_resetComboCoroutine = StartCoroutine(ResetComboCoroutine());
|
|
|
|
|
}
|
2021-11-04 14:06:55 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void DisplayNotification(NotificationTypeEnum notificationType)
|
|
|
|
|
{
|
|
|
|
|
_notification.SetNotification(notificationType);
|
|
|
|
|
_notification.gameObject.SetActive(false);
|
|
|
|
|
_notification.gameObject.SetActive(true);
|
|
|
|
|
if (_notificiationCoroutine != null)
|
|
|
|
|
StopCoroutine(_notificiationCoroutine);
|
|
|
|
|
_notificiationCoroutine = StartCoroutine(ResetDisplayNotificationCoroutine());
|
|
|
|
|
}
|
2021-11-10 00:32:14 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator ResetDisplayNotificationCoroutine()
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(1.1f);
|
|
|
|
|
_notification.gameObject.SetActive(false);
|
|
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator ResetComboCoroutine()
|
|
|
|
|
{
|
2024-01-15 23:31:17 +02:00
|
|
|
_comboAnimator.Play("ComboEnded");
|
2022-09-24 13:29:28 +03:00
|
|
|
yield return new WaitForSeconds(1.0f);
|
2024-01-15 05:39:11 +02:00
|
|
|
_hitsNumberText.transform.parent.parent.gameObject.SetActive(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
CurrentComboCount = 0;
|
|
|
|
|
_hitsNumberText.text = "";
|
|
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
public void ShowPlayerIcon()
|
|
|
|
|
{
|
2024-01-23 03:42:14 +02:00
|
|
|
if (!SceneSettings.IsTrainingMode)
|
|
|
|
|
return;
|
2022-09-24 13:29:28 +03:00
|
|
|
if (_showPlayerIconCoroutine != null)
|
|
|
|
|
{
|
2024-01-22 23:42:05 +00:00
|
|
|
_overheadText.gameObject.SetActive(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
StopCoroutine(_showPlayerIconCoroutine);
|
|
|
|
|
}
|
|
|
|
|
_showPlayerIconCoroutine = StartCoroutine(ShowPlayerIconCoroutine());
|
|
|
|
|
}
|
2021-11-10 00:32:14 +01:00
|
|
|
|
2022-09-24 13:29:28 +03:00
|
|
|
IEnumerator ShowPlayerIconCoroutine()
|
|
|
|
|
{
|
|
|
|
|
int index = _controller.IsPlayerOne == true ? 0 : 1;
|
2024-01-23 03:42:14 +02:00
|
|
|
_overheadText.text = $"P{index + 1}";
|
2024-01-22 23:42:05 +00:00
|
|
|
_overheadText.gameObject.SetActive(true);
|
2022-09-24 13:29:28 +03:00
|
|
|
yield return new WaitForSeconds(1.0f);
|
2024-01-22 23:42:05 +00:00
|
|
|
_overheadText.gameObject.SetActive(false);
|
2022-09-24 13:29:28 +03:00
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
}
|