2021-09-26 02:21:16 +02:00
|
|
|
using Cinemachine;
|
2022-07-28 15:16:08 +03:00
|
|
|
using Demonics.Manager;
|
2022-12-07 12:13:57 +02:00
|
|
|
using SharedGame;
|
2023-10-11 02:25:05 +03:00
|
|
|
using System;
|
2021-08-21 02:57:59 +02:00
|
|
|
using System.Collections;
|
2022-08-06 17:18:10 +03:00
|
|
|
using System.Collections.Generic;
|
2022-10-21 21:20:37 +03:00
|
|
|
using System.Linq;
|
2021-08-21 02:57:59 +02:00
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
2022-08-09 16:02:14 +03:00
|
|
|
using UnityEngine.InputSystem;
|
2021-09-24 21:03:17 +02:00
|
|
|
using UnityEngine.SceneManagement;
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-12-04 21:35:31 +02:00
|
|
|
public class GameplayManager : MonoBehaviour
|
2021-08-21 02:57:59 +02:00
|
|
|
{
|
2022-09-14 23:06:52 +03:00
|
|
|
[Header("Debug")]
|
|
|
|
|
[SerializeField] private StageTypeEnum _stage = default;
|
|
|
|
|
[SerializeField] private CharacterTypeEnum _characterOne = default;
|
|
|
|
|
[SerializeField] private CharacterTypeEnum _characterTwo = default;
|
|
|
|
|
[SerializeField] private AssistTypeEnum _assistOne = default;
|
|
|
|
|
[SerializeField] private AssistTypeEnum _assistTwo = default;
|
|
|
|
|
[Range(-1, 3)]
|
|
|
|
|
[SerializeField] private int _controllerOne = default;
|
|
|
|
|
[SerializeField] private ControllerTypeEnum _controllerOneType = default;
|
|
|
|
|
[Range(-1, 3)]
|
|
|
|
|
[SerializeField] private int _controllerTwo = default;
|
|
|
|
|
[SerializeField] private ControllerTypeEnum _controllerTwoType = default;
|
|
|
|
|
[SerializeField] private MusicTypeEnum _music = default;
|
|
|
|
|
[Range(0, 10)]
|
|
|
|
|
[SerializeField] private int _playerOneSkin = default;
|
|
|
|
|
[Range(0, 10)]
|
|
|
|
|
[SerializeField] private int _playerTwoSkin = default;
|
|
|
|
|
[SerializeField] private bool _isTrainingMode = default;
|
|
|
|
|
[SerializeField] private bool _1BitOn = default;
|
|
|
|
|
[Range(1, 10)]
|
|
|
|
|
[SerializeField] private int _gameSpeed = 1;
|
|
|
|
|
[Range(10, 300)]
|
|
|
|
|
[SerializeField] private int _countdownTime = 99;
|
2022-11-05 16:08:03 +02:00
|
|
|
[SerializeField] private float _leftSpawn = 9;
|
|
|
|
|
[SerializeField] private float _rightSpawn = 6;
|
2022-12-01 00:21:24 +02:00
|
|
|
[SerializeField] private PlayerInput _uiInput = default;
|
2022-11-03 13:09:06 +02:00
|
|
|
[SerializeField] private float[] _spawnPositionsX = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
[Header("Data")]
|
2022-12-07 12:13:57 +02:00
|
|
|
[SerializeField] private ConnectionWidget _connectionWidget = default;
|
2022-10-15 15:01:06 +02:00
|
|
|
[SerializeField] private CinemachineTargetGroup _targetGroup = default;
|
2023-04-30 14:36:29 +03:00
|
|
|
[SerializeField] private DisconnectMenu _disconnectMenu = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
[SerializeField] private IntroUI _introUI = default;
|
|
|
|
|
[SerializeField] private FadeHandler _fadeHandler = default;
|
|
|
|
|
[SerializeField] protected PlayerUI _playerOneUI = default;
|
|
|
|
|
[SerializeField] protected PlayerUI _playerTwoUI = default;
|
|
|
|
|
[SerializeField] private PlayerDialogue _playerOneDialogue = default;
|
|
|
|
|
[SerializeField] private PlayerDialogue _playerTwoDialogue = default;
|
|
|
|
|
[SerializeField] private Animator _timerAnimator = default;
|
|
|
|
|
[SerializeField] private Animator _timerMainAnimator = default;
|
|
|
|
|
[SerializeField] protected TextMeshProUGUI _countdownText = default;
|
|
|
|
|
[SerializeField] protected TextMeshProUGUI _readyText = default;
|
|
|
|
|
[SerializeField] protected TextMeshProUGUI _winnerNameText = default;
|
|
|
|
|
[SerializeField] protected TextMeshProUGUI _winsText = default;
|
|
|
|
|
[SerializeField] protected GameObject _keyboardPrompts = default;
|
|
|
|
|
[SerializeField] protected GameObject _controllerPrompts = default;
|
|
|
|
|
[SerializeField] protected GameObject _xboxPrompts = default;
|
|
|
|
|
[SerializeField] protected GameObject[] _readyObjects = default;
|
|
|
|
|
[SerializeField] protected GameObject[] _arcanaObjects = default;
|
2022-12-05 03:15:48 +02:00
|
|
|
[SerializeField] protected GameObject _debugNetwork = default;
|
2022-12-06 12:22:07 +02:00
|
|
|
[SerializeField] protected GameObject _networkCanvas = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
[SerializeField] protected GameObject _infiniteTime = default;
|
|
|
|
|
[SerializeField] protected GameObject _winsImage = default;
|
|
|
|
|
[SerializeField] private GameObject[] _hearts = default;
|
|
|
|
|
[SerializeField] private GameObject _trainingPrompts = default;
|
|
|
|
|
[SerializeField] private MusicMenu _musicMenu = default;
|
|
|
|
|
[SerializeField] private InputHistory[] _inputHistories = default;
|
2023-07-01 23:48:47 +03:00
|
|
|
[SerializeField] private InputDisplay[] _inputDisplays = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
[SerializeField] private PlayerStatsSO[] _playerStats = default;
|
|
|
|
|
[SerializeField] private TrainingMenu _trainingMenu = default;
|
|
|
|
|
[SerializeField] private GameObject[] _stages = default;
|
|
|
|
|
[SerializeField] private AssistStatsSO[] _assists = default;
|
|
|
|
|
[SerializeField] private BaseMenu _matchOverMenu = default;
|
|
|
|
|
[SerializeField] private BaseMenu _matchOverReplayMenu = default;
|
2023-01-30 15:36:37 +02:00
|
|
|
[SerializeField] private BaseMenu _matchOverOnlineMenu = default;
|
2022-09-14 23:06:52 +03:00
|
|
|
[SerializeField] private Animator _readyAnimator = default;
|
|
|
|
|
[SerializeField] private Audio _musicAudio = default;
|
|
|
|
|
[SerializeField] private Audio _uiAudio = default;
|
2023-12-03 02:36:58 +02:00
|
|
|
public BrainController PlayerOneController { get; set; }
|
|
|
|
|
public BrainController PlayerTwoController { get; set; }
|
2022-09-14 23:06:52 +03:00
|
|
|
private PlayerAnimator _playerOneAnimator;
|
|
|
|
|
private PlayerAnimator _playerTwoAnimator;
|
|
|
|
|
private PlayerInput _playerOneInput;
|
|
|
|
|
private PlayerInput _playerTwoInput;
|
|
|
|
|
private Coroutine _roundOverTrainingCoroutine;
|
|
|
|
|
private GameObject _currentStage;
|
|
|
|
|
private List<IHitstop> _hitstopList = new();
|
2023-07-02 23:17:37 +03:00
|
|
|
private DemonVector2 _cachedOneResetPosition;
|
|
|
|
|
private DemonVector2 _cachedTwoResetPosition;
|
2022-09-14 23:06:52 +03:00
|
|
|
private int _countdown;
|
|
|
|
|
private int _currentRound = 1;
|
|
|
|
|
private bool _reverseReset;
|
|
|
|
|
private bool _hasSwitchedCharacters;
|
|
|
|
|
private bool _canCallSwitchCharacter = true;
|
|
|
|
|
private bool _finalRound;
|
|
|
|
|
private int _playerOneWins;
|
|
|
|
|
private int _playerTwoWins;
|
|
|
|
|
public Sound CurrentMusic { get; private set; }
|
|
|
|
|
public bool IsDialogueRunning { get; set; }
|
|
|
|
|
public bool HasGameStarted { get; set; }
|
|
|
|
|
public bool IsTrainingMode { get { return _isTrainingMode; } set { } }
|
|
|
|
|
public bool InfiniteHealth { get; set; }
|
|
|
|
|
public bool InfiniteArcana { get; set; }
|
|
|
|
|
public bool InfiniteAssist { get; set; }
|
|
|
|
|
public Player PlayerOne { get; private set; }
|
|
|
|
|
public Player PlayerTwo { get; private set; }
|
2023-10-11 02:25:05 +03:00
|
|
|
public CinemachineTargetGroup TargetGroup { get { return _targetGroup; } private set { } }
|
2022-09-14 23:06:52 +03:00
|
|
|
public PauseMenu PauseMenu { get; set; }
|
2022-12-04 21:35:31 +02:00
|
|
|
public static GameplayManager Instance { get; private set; }
|
2022-12-01 00:21:24 +02:00
|
|
|
public BrainController PausedController { get; set; }
|
2022-09-14 23:06:52 +03:00
|
|
|
public float GameSpeed { get; set; }
|
2022-09-25 00:18:34 +03:00
|
|
|
private Keyboard keyboardTwo;
|
2022-09-14 23:06:52 +03:00
|
|
|
void Awake()
|
|
|
|
|
{
|
2023-12-04 15:56:46 +02:00
|
|
|
MouseSetup.Instance.SetLock(true);
|
2022-09-25 01:28:32 +03:00
|
|
|
keyboardTwo = InputSystem.AddDevice<Keyboard>("KeyboardTwo");
|
2022-09-14 23:06:52 +03:00
|
|
|
HasGameStarted = false;
|
|
|
|
|
GameSpeed = _gameSpeed;
|
|
|
|
|
CheckInstance();
|
|
|
|
|
if (!SceneSettings.SceneSettingsDecide)
|
|
|
|
|
{
|
2022-12-05 03:15:48 +02:00
|
|
|
_debugNetwork.SetActive(true);
|
2023-03-11 16:35:39 +02:00
|
|
|
if (!SceneSettings.ReplayMode)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-03-11 16:35:39 +02:00
|
|
|
if (_controllerOne >= 0)
|
|
|
|
|
{
|
|
|
|
|
SceneSettings.ControllerOne = InputSystem.devices[_controllerOne];
|
|
|
|
|
}
|
|
|
|
|
if (_controllerTwo >= 0)
|
|
|
|
|
{
|
|
|
|
|
SceneSettings.ControllerTwo = InputSystem.devices[_controllerTwo];
|
|
|
|
|
}
|
|
|
|
|
SceneSettings.ControllerOneScheme = _controllerOneType.ToString();
|
|
|
|
|
SceneSettings.ControllerTwoScheme = _controllerTwoType.ToString();
|
|
|
|
|
SceneSettings.PlayerOne = (int)_characterOne;
|
|
|
|
|
SceneSettings.PlayerTwo = (int)_characterTwo;
|
|
|
|
|
SceneSettings.AssistOne = (int)_assistOne;
|
|
|
|
|
SceneSettings.AssistTwo = (int)_assistTwo;
|
|
|
|
|
SceneSettings.StageIndex = (int)_stage;
|
|
|
|
|
SceneSettings.ColorOne = _playerOneSkin;
|
|
|
|
|
SceneSettings.ColorTwo = _playerTwoSkin;
|
|
|
|
|
SceneSettings.IsTrainingMode = _isTrainingMode;
|
|
|
|
|
SceneSettings.Bit1 = _1BitOn;
|
|
|
|
|
SceneSettings.MusicName = _music.ToString();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-12-05 03:15:48 +02:00
|
|
|
_debugNetwork.SetActive(false);
|
2022-12-07 12:13:57 +02:00
|
|
|
if (!SceneSettings.IsOnline)
|
|
|
|
|
{
|
2022-12-11 02:21:16 +02:00
|
|
|
NetworkInput.IS_LOCAL = true;
|
|
|
|
|
GameManager.Instance.StartLocalGame();
|
2022-12-07 12:13:57 +02:00
|
|
|
_isTrainingMode = SceneSettings.IsTrainingMode;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_isTrainingMode = false;
|
2023-01-01 12:50:59 +02:00
|
|
|
_connectionWidget.StartGGPO(SceneSettings.OnlineOneIp, SceneSettings.OnlineTwoIp, SceneSettings.PrivateOneIp, SceneSettings.PrivateTwoIp,
|
|
|
|
|
SceneSettings.PortOne, SceneSettings.PortTwo, SceneSettings.OnlineIndex);
|
2023-04-30 14:36:29 +03:00
|
|
|
StartCoroutine(CheckIfConnectedCoroutine());
|
2022-12-07 12:13:57 +02:00
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
CheckSceneSettings();
|
|
|
|
|
}
|
2022-02-13 19:34:02 +01:00
|
|
|
|
2023-04-30 14:36:29 +03:00
|
|
|
IEnumerator CheckIfConnectedCoroutine()
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSecondsRealtime(5f);
|
|
|
|
|
if (!_uiInput.gameObject.activeSelf)
|
|
|
|
|
{
|
|
|
|
|
DisableAllInput(true, true);
|
|
|
|
|
_uiInput.gameObject.SetActive(true);
|
|
|
|
|
_disconnectMenu.Show();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-02-13 19:34:02 +01:00
|
|
|
|
2022-12-13 01:44:28 +02:00
|
|
|
public PlayerStatsSO[] GetPlayerStats()
|
|
|
|
|
{
|
|
|
|
|
List<PlayerStatsSO> playerStats = new List<PlayerStatsSO>();
|
|
|
|
|
playerStats.Add(_playerStats[SceneSettings.PlayerOne]);
|
|
|
|
|
playerStats.Add(_playerStats[SceneSettings.PlayerTwo]);
|
|
|
|
|
return playerStats.ToArray();
|
|
|
|
|
}
|
2023-01-13 15:28:18 +02:00
|
|
|
public AssistStatsSO[] GetAssistStats()
|
|
|
|
|
{
|
|
|
|
|
List<AssistStatsSO> assistStats = new List<AssistStatsSO>();
|
|
|
|
|
assistStats.Add(_assists[SceneSettings.AssistOne]);
|
|
|
|
|
assistStats.Add(_assists[SceneSettings.AssistTwo]);
|
|
|
|
|
return assistStats.ToArray();
|
|
|
|
|
}
|
2022-12-13 01:44:28 +02:00
|
|
|
|
|
|
|
|
public float[] GetSpawnPositions()
|
|
|
|
|
{
|
|
|
|
|
List<float> spawnPositions = new List<float>();
|
|
|
|
|
spawnPositions.Add(_spawnPositionsX[0]);
|
|
|
|
|
spawnPositions.Add(_spawnPositionsX[1]);
|
|
|
|
|
return spawnPositions.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-04 21:35:31 +02:00
|
|
|
public void InitializePlayers(GameObject playerOneObject, GameObject playerTwoObject)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-04 21:35:31 +02:00
|
|
|
playerOneObject.GetComponent<Player>().playerStats = _playerStats[SceneSettings.PlayerOne];
|
|
|
|
|
playerTwoObject.GetComponent<Player>().playerStats = _playerStats[SceneSettings.PlayerTwo];
|
|
|
|
|
Time.timeScale = GameplayManager.Instance.GameSpeed;
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController = playerOneObject.GetComponent<BrainController>();
|
|
|
|
|
PlayerTwoController = playerTwoObject.GetComponent<BrainController>();
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerOne = playerOneObject.GetComponent<Player>();
|
|
|
|
|
PlayerTwo = playerTwoObject.GetComponent<Player>();
|
|
|
|
|
playerOneObject.GetComponent<CpuController>().SetOtherPlayer(playerTwoObject.transform);
|
|
|
|
|
playerTwoObject.GetComponent<CpuController>().SetOtherPlayer(playerOneObject.transform);
|
|
|
|
|
playerOneObject.SetActive(true);
|
|
|
|
|
playerTwoObject.SetActive(true);
|
|
|
|
|
if (SceneSettings.ControllerOne != null && _controllerOneType != ControllerTypeEnum.Cpu)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToPlayer(0);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToCpu(0);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (SceneSettings.ControllerTwo != null && _controllerTwoType != ControllerTypeEnum.Cpu)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerTwoController.SetControllerToPlayer(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerTwoController.SetControllerToCpu(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
PlayerOne.SetController();
|
|
|
|
|
PlayerTwo.SetController();
|
|
|
|
|
_playerOneAnimator = PlayerOne.transform.GetChild(1).GetComponent<PlayerAnimator>();
|
|
|
|
|
_playerTwoAnimator = PlayerTwo.transform.GetChild(1).GetComponent<PlayerAnimator>();
|
|
|
|
|
_playerOneAnimator.SetSpriteLibraryAsset(SceneSettings.ColorOne);
|
|
|
|
|
if (SceneSettings.ColorTwo == SceneSettings.ColorOne && PlayerOne.PlayerStats.characterName == PlayerTwo.PlayerStats.characterName)
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.ColorOne == 3)
|
|
|
|
|
{
|
|
|
|
|
SceneSettings.ColorTwo = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
SceneSettings.ColorTwo++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_playerTwoAnimator.SetSpriteLibraryAsset(SceneSettings.ColorTwo);
|
2022-10-16 11:57:35 +02:00
|
|
|
_trainingMenu.ConfigurePlayers(PlayerOne, PlayerTwo);
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.IsPlayerOne = true;
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerOne.SetPlayerUI(_playerOneUI);
|
|
|
|
|
PlayerTwo.SetPlayerUI(_playerTwoUI);
|
|
|
|
|
PlayerOne.SetAssist(_assists[SceneSettings.AssistOne]);
|
|
|
|
|
PlayerTwo.SetAssist(_assists[SceneSettings.AssistTwo]);
|
|
|
|
|
PlayerOne.SetOtherPlayer(PlayerTwo);
|
|
|
|
|
PlayerOne.IsPlayerOne = true;
|
|
|
|
|
if (SceneSettings.ControllerOne != null && _controllerOneType != ControllerTypeEnum.Cpu)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.ControllerInputName = SceneSettings.ControllerOne.displayName;
|
|
|
|
|
PlayerOneController.InputDevice = SceneSettings.ControllerOne;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.ControllerInputName = ControllerTypeEnum.Cpu.ToString();
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerTwo.SetOtherPlayer(PlayerOne);
|
|
|
|
|
PlayerTwo.IsPlayerOne = false;
|
|
|
|
|
if (SceneSettings.ControllerTwo != null && _controllerTwoType != ControllerTypeEnum.Cpu)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerTwoController.ControllerInputName = SceneSettings.ControllerTwo.displayName;
|
|
|
|
|
PlayerTwoController.InputDevice = SceneSettings.ControllerTwo;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerTwoController.ControllerInputName = ControllerTypeEnum.Cpu.ToString();
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerOne.name = $"{_playerStats[SceneSettings.PlayerOne].name}({SceneSettings.ControllerOne})_player";
|
|
|
|
|
PlayerTwo.name = $"{_playerStats[SceneSettings.PlayerTwo].name}({SceneSettings.ControllerTwo})_player";
|
2023-07-01 23:48:47 +03:00
|
|
|
PlayerOne.GetComponent<InputBuffer>().Initialize(_inputHistories[0], _inputDisplays[0]);
|
|
|
|
|
PlayerTwo.GetComponent<InputBuffer>().Initialize(_inputHistories[1], _inputDisplays[1]);
|
2022-09-14 23:06:52 +03:00
|
|
|
string inputSchemeOne = "";
|
|
|
|
|
string inputSchemeTwo = "";
|
|
|
|
|
if (SceneSettings.ControllerOne != null && SceneSettings.ControllerOneScheme != ControllerTypeEnum.Cpu.ToString())
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.InputDevice != null)
|
|
|
|
|
inputSchemeOne = PlayerOneController.InputDevice.displayName;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (SceneSettings.ControllerTwo != null && SceneSettings.ControllerTwoScheme != ControllerTypeEnum.Cpu.ToString())
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerTwoController.InputDevice != null)
|
|
|
|
|
inputSchemeTwo = PlayerTwoController.InputDevice.displayName;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (inputSchemeOne.Contains("Keyboard"))
|
|
|
|
|
{
|
|
|
|
|
_keyboardPrompts.SetActive(true);
|
|
|
|
|
_xboxPrompts.SetActive(false);
|
|
|
|
|
_controllerPrompts.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
else if (inputSchemeOne.Contains("Xbox"))
|
|
|
|
|
{
|
|
|
|
|
_keyboardPrompts.SetActive(false);
|
|
|
|
|
_xboxPrompts.SetActive(true);
|
|
|
|
|
_controllerPrompts.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_keyboardPrompts.SetActive(false);
|
|
|
|
|
_xboxPrompts.SetActive(false);
|
|
|
|
|
_controllerPrompts.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
_playerOneInput = PlayerOne.GetComponent<PlayerInput>();
|
|
|
|
|
_playerTwoInput = PlayerTwo.GetComponent<PlayerInput>();
|
2022-09-26 19:12:12 +03:00
|
|
|
if (SceneSettings.ControllerOneScheme == "Keyboard" && SceneSettings.ControllerTwoScheme == "Keyboard"
|
2023-12-03 02:36:58 +02:00
|
|
|
&& PlayerOneController.ControllerInputName == "Keyboard" && PlayerTwoController.ControllerInputName == "Keyboard")
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
SceneSettings.ControllerOneScheme = "Keyboard";
|
|
|
|
|
SceneSettings.ControllerTwoScheme = "KeyboardTwo";
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
|
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.InputDevice != null && _controllerOneType != ControllerTypeEnum.Cpu)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerTwoController.InputDevice != null && _controllerTwoType != ControllerTypeEnum.Cpu)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_inputHistories[0].PlayerController = PlayerOne.GetComponent<PlayerController>();
|
|
|
|
|
_inputHistories[1].PlayerController = PlayerTwo.GetComponent<PlayerController>();
|
2023-10-11 02:25:05 +03:00
|
|
|
TargetGroup.AddMember(PlayerOne.CameraPoint, 0.5f, 0.5f);
|
|
|
|
|
TargetGroup.AddMember(PlayerTwo.CameraPoint, 0.5f, 0.5f);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCameraTargets(float targetOne, float targetTwo, float time = 0.12f)
|
|
|
|
|
{
|
|
|
|
|
_targetGroup.m_Targets[0].weight = targetOne;
|
|
|
|
|
StartCoroutine(SetCameraTargetsCoroutine(targetOne, targetTwo, time));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private IEnumerator SetCameraTargetsCoroutine(float targetOne, float targetTwo, float time)
|
|
|
|
|
{
|
|
|
|
|
float elapsedTime = 0;
|
|
|
|
|
float waitTime = time;
|
|
|
|
|
float currentTargetOne = _targetGroup.m_Targets[0].weight;
|
|
|
|
|
float currentTargetTwo = _targetGroup.m_Targets[1].weight;
|
|
|
|
|
while (elapsedTime < waitTime)
|
|
|
|
|
{
|
|
|
|
|
_targetGroup.m_Targets[0].weight = Mathf.Lerp(currentTargetOne, targetOne, elapsedTime / waitTime);
|
|
|
|
|
_targetGroup.m_Targets[1].weight = Mathf.Lerp(currentTargetTwo, targetTwo, elapsedTime / waitTime);
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
|
|
|
|
_targetGroup.m_Targets[0].weight = targetOne;
|
|
|
|
|
_targetGroup.m_Targets[1].weight = targetTwo;
|
|
|
|
|
yield return null;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
private void CheckInstance()
|
|
|
|
|
{
|
|
|
|
|
if (Instance != null && Instance != this)
|
|
|
|
|
Destroy(gameObject);
|
|
|
|
|
else
|
|
|
|
|
Instance = this;
|
|
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void CheckSceneSettings()
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _stages.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_stages[i].SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
_currentStage = _stages[SceneSettings.StageIndex];
|
|
|
|
|
foreach (Transform stageColor in _currentStage.transform)
|
|
|
|
|
{
|
|
|
|
|
stageColor.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
_currentStage.SetActive(true);
|
|
|
|
|
int stageColorIndex = SceneSettings.Bit1 ? 1 : 0;
|
|
|
|
|
_currentStage.transform.GetChild(stageColorIndex).gameObject.SetActive(true);
|
|
|
|
|
}
|
2021-09-06 14:38:59 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void ActivateCpus()
|
|
|
|
|
{
|
2022-12-21 16:07:24 +02:00
|
|
|
if (IsTrainingMode && PlayerOne != null)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.ActivateCpu();
|
|
|
|
|
PlayerTwoController.ActivateCpu();
|
2022-12-21 16:07:24 +02:00
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void DeactivateCpus()
|
|
|
|
|
{
|
2022-12-11 02:21:16 +02:00
|
|
|
if (IsTrainingMode && PlayerOne != null)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.DeactivateCpu();
|
|
|
|
|
PlayerTwoController.DeactivateCpu();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-11 22:46:46 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void MaxHealths()
|
|
|
|
|
{
|
2022-12-11 02:21:16 +02:00
|
|
|
if (IsTrainingMode && PlayerOne != null)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-11 02:21:16 +02:00
|
|
|
PlayerOne.MaxHealthStats();
|
|
|
|
|
PlayerTwo.MaxHealthStats();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-12-04 21:35:31 +02:00
|
|
|
|
|
|
|
|
public void SetupGame()
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-23 03:17:40 +02:00
|
|
|
GameSimulation._players[0].player = GameplayManager.Instance.PlayerOne;
|
|
|
|
|
GameSimulation._players[1].player = GameplayManager.Instance.PlayerTwo;
|
2022-12-02 22:48:58 +02:00
|
|
|
_uiInput.gameObject.SetActive(true);
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.MusicName == "Random")
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic = _musicAudio.SoundGroup("Music").PlayInRandom();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic = _musicAudio.SoundGroup("Music").Sound(SceneSettings.MusicName);
|
|
|
|
|
CurrentMusic.Play();
|
|
|
|
|
}
|
|
|
|
|
if (_isTrainingMode)
|
|
|
|
|
{
|
2023-04-11 16:22:19 +03:00
|
|
|
_networkCanvas.SetActive(!NetworkInput.IS_LOCAL);
|
2022-11-13 17:02:23 +02:00
|
|
|
_cachedOneResetPosition = PlayerOne.GetComponent<PlayerMovement>().Physics.Position;
|
|
|
|
|
_cachedTwoResetPosition = PlayerTwo.GetComponent<PlayerMovement>().Physics.Position;
|
2022-09-14 23:06:52 +03:00
|
|
|
_countdownText.gameObject.SetActive(false);
|
|
|
|
|
_hearts[0].gameObject.SetActive(false);
|
|
|
|
|
_hearts[1].gameObject.SetActive(false);
|
|
|
|
|
_winsImage.SetActive(false);
|
|
|
|
|
_trainingPrompts.gameObject.SetActive(true);
|
|
|
|
|
HasGameStarted = true;
|
2022-10-15 14:34:31 +02:00
|
|
|
StartTrainingRound();
|
2023-01-01 02:09:37 +02:00
|
|
|
GameSimulation.Run = true;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_musicMenu.ShowMusicMenu(CurrentMusic.name);
|
|
|
|
|
_inputHistories[0].transform.GetChild(0).gameObject.SetActive(false);
|
|
|
|
|
_inputHistories[1].transform.GetChild(0).gameObject.SetActive(false);
|
|
|
|
|
_trainingPrompts.gameObject.SetActive(false);
|
|
|
|
|
StartIntro();
|
|
|
|
|
}
|
2023-01-23 18:31:58 +02:00
|
|
|
ReplayManager.Instance.StartReplay();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2021-09-11 22:46:46 +02:00
|
|
|
|
2022-12-06 16:30:03 +02:00
|
|
|
public void SetOnlineNames(string playerOne, string playerTwo)
|
|
|
|
|
{
|
|
|
|
|
_playerOneUI.SetPlayerName(playerOne);
|
|
|
|
|
_playerTwoUI.SetPlayerName(playerTwo);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
void FixedUpdate()
|
|
|
|
|
{
|
|
|
|
|
RunHitStop();
|
|
|
|
|
RunReady();
|
|
|
|
|
RunRoundOver();
|
|
|
|
|
}
|
2023-09-26 14:24:48 +03:00
|
|
|
|
2023-01-27 02:16:02 +02:00
|
|
|
public void SetCountdown(int timer)
|
|
|
|
|
{
|
2023-01-27 15:20:51 +02:00
|
|
|
if (!_isTrainingMode && GameSimulation.Run)
|
2023-01-27 02:16:02 +02:00
|
|
|
{
|
|
|
|
|
_countdownText.text = timer.ToString();
|
2023-01-28 03:45:14 +02:00
|
|
|
if (timer <= 0)
|
2023-01-27 02:16:02 +02:00
|
|
|
{
|
|
|
|
|
_timerMainAnimator.Rebind();
|
|
|
|
|
RoundOver(true);
|
|
|
|
|
}
|
2023-01-28 03:45:14 +02:00
|
|
|
else if (timer <= 10)
|
2023-01-27 02:16:02 +02:00
|
|
|
_timerMainAnimator.SetTrigger("TimerLow");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void SkipIntro()
|
|
|
|
|
{
|
2023-01-23 18:31:58 +02:00
|
|
|
if (IsDialogueRunning || !NetworkInput.IS_LOCAL)
|
2022-12-08 03:28:59 +02:00
|
|
|
{
|
|
|
|
|
ReplayManager.Instance.Skip = DemonicsWorld.Frame;
|
|
|
|
|
_playerOneDialogue.StopDialogue();
|
|
|
|
|
_playerTwoDialogue.StopDialogue();
|
|
|
|
|
StartRound();
|
|
|
|
|
_introUI.SkipIntro();
|
|
|
|
|
IsDialogueRunning = false;
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-07-17 21:37:50 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void StartIntro()
|
|
|
|
|
{
|
2022-11-10 15:50:46 +02:00
|
|
|
PlayerOne.ResetPlayer(new Vector2(_spawnPositionsX[0], (float)DemonicsPhysics.GROUND_POINT));
|
|
|
|
|
PlayerTwo.ResetPlayer(new Vector2(_spawnPositionsX[1], (float)DemonicsPhysics.GROUND_POINT));
|
2022-09-14 23:06:52 +03:00
|
|
|
for (int i = 0; i < _arcanaObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_arcanaObjects[i].SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
_introUI.SetPlayerNames(_playerStats[SceneSettings.PlayerOne].characterName.ToString(), _playerStats[SceneSettings.PlayerTwo].characterName.ToString());
|
|
|
|
|
_playerOneDialogue.Initialize(true, _playerStats[SceneSettings.PlayerOne]._dialogue, _playerStats[SceneSettings.PlayerTwo].characterName);
|
|
|
|
|
_playerTwoDialogue.Initialize(false, _playerStats[SceneSettings.PlayerTwo]._dialogue, _playerStats[SceneSettings.PlayerOne].characterName);
|
2022-11-14 14:20:37 +02:00
|
|
|
_introUI.StartIntro();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-05-03 23:45:28 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
private void MatchOver()
|
|
|
|
|
{
|
|
|
|
|
_finalRound = false;
|
|
|
|
|
_winnerNameText.text = "";
|
|
|
|
|
_readyText.text = "";
|
|
|
|
|
_currentRound = 1;
|
2023-11-11 18:00:20 +02:00
|
|
|
MouseSetup.Instance.SetCursor(true);
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.ReplayMode)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
GameplayManager.Instance.PausedController = PlayerOneController;
|
2023-01-27 15:20:51 +02:00
|
|
|
DisableAllInput(true);
|
2022-09-14 23:06:52 +03:00
|
|
|
_matchOverReplayMenu.Show();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-01-02 19:59:46 +02:00
|
|
|
if (!NetworkInput.IS_LOCAL)
|
|
|
|
|
{
|
|
|
|
|
if (GameManager.Instance.IsRunning)
|
|
|
|
|
{
|
2023-01-30 15:36:37 +02:00
|
|
|
// GameManager.Instance.Shutdown();
|
2023-01-02 19:59:46 +02:00
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
GameplayManager.Instance.PausedController = PlayerOneController;
|
2023-01-30 15:36:37 +02:00
|
|
|
DisableAllInput(true);
|
|
|
|
|
_matchOverOnlineMenu.Show();
|
2023-01-02 19:59:46 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
GameplayManager.Instance.PausedController = PlayerOneController;
|
2023-01-27 15:20:51 +02:00
|
|
|
DisableAllInput(true);
|
2023-01-02 19:59:46 +02:00
|
|
|
_matchOverMenu.Show();
|
|
|
|
|
}
|
2022-10-25 10:53:09 +03:00
|
|
|
// if (_controllerOneType != ControllerTypeEnum.Cpu && _controllerTwoType != ControllerTypeEnum.Cpu)
|
|
|
|
|
// {
|
|
|
|
|
// if (_controllerTwoType != ControllerTypeEnum.Keyboard)
|
|
|
|
|
// {
|
|
|
|
|
// _matchOverSecondMenu.Show();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-11-23 15:03:45 +02:00
|
|
|
if (SceneSettings.ControllerOne != null && SceneSettings.ControllerTwo != null)
|
2022-11-22 17:02:55 +02:00
|
|
|
{
|
|
|
|
|
ReplayManager.Instance.SaveReplay();
|
|
|
|
|
}
|
2022-10-24 01:35:53 +03:00
|
|
|
Time.timeScale = 0;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-09-12 22:52:04 +03:00
|
|
|
|
2023-01-30 15:36:37 +02:00
|
|
|
public void DisconnectOnline()
|
|
|
|
|
{
|
|
|
|
|
GameManager.Instance.DisconnectPlayer(SceneSettings.OnlineIndex);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ConnectOnline()
|
|
|
|
|
{
|
2023-02-03 17:24:21 +02:00
|
|
|
_fadeHandler.StartFadeTransition(true, 0.01f);
|
|
|
|
|
PlayerOne.ResetLives();
|
|
|
|
|
PlayerTwo.ResetLives();
|
2023-02-01 20:06:15 +02:00
|
|
|
_targetGroup.m_Targets[0].weight = 0.5f;
|
|
|
|
|
_targetGroup.m_Targets[1].weight = 0.5f;
|
2023-01-31 23:01:31 +02:00
|
|
|
EnableAllInput();
|
|
|
|
|
Time.timeScale = 1;
|
2023-01-30 15:36:37 +02:00
|
|
|
GameManager.Instance.Shutdown();
|
|
|
|
|
_matchOverOnlineMenu.Hide();
|
2023-02-12 16:35:54 +02:00
|
|
|
_connectionWidget.RematchConnection();
|
2023-01-30 15:36:37 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public virtual void StartRound()
|
|
|
|
|
{
|
2023-04-11 16:22:19 +03:00
|
|
|
_networkCanvas.SetActive(!NetworkInput.IS_LOCAL);
|
2023-11-26 05:34:18 +02:00
|
|
|
if (!IsDialogueRunning)
|
|
|
|
|
_fadeHandler.StartFadeTransition(false);
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.ReplayMode)
|
|
|
|
|
ReplayManager.Instance.ShowReplayPrompts();
|
|
|
|
|
_timerMainAnimator.Rebind();
|
|
|
|
|
IsDialogueRunning = false;
|
|
|
|
|
for (int i = 0; i < _arcanaObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_arcanaObjects[i].SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
_countdown = _countdownTime;
|
|
|
|
|
_countdownText.text = Mathf.Round(_countdown).ToString();
|
2022-10-15 15:01:06 +02:00
|
|
|
_targetGroup.m_Targets[0].weight = 0.5f;
|
|
|
|
|
_targetGroup.m_Targets[1].weight = 0.5f;
|
2022-11-03 13:09:06 +02:00
|
|
|
PlayerOne.ResetPlayer(new Vector2(_spawnPositionsX[0], (float)DemonicsPhysics.GROUND_POINT));
|
|
|
|
|
PlayerTwo.ResetPlayer(new Vector2(_spawnPositionsX[1], (float)DemonicsPhysics.GROUND_POINT));
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerOne.StopComboTimer();
|
|
|
|
|
PlayerTwo.StopComboTimer();
|
|
|
|
|
_showFrame = 30;
|
|
|
|
|
_readyFrame = 60;
|
|
|
|
|
_readyEndFrame = 60;
|
|
|
|
|
_showEnd = false;
|
|
|
|
|
_readyEnd = false;
|
|
|
|
|
_startRun = true;
|
|
|
|
|
}
|
2022-09-12 22:52:04 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
private void StartTrainingRound()
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
PlayerOne.ResetPlayer(new Vector2(_spawnPositionsX[0], (float)DemonicsPhysics.GROUND_POINT));
|
|
|
|
|
PlayerTwo.ResetPlayer(new Vector2(_spawnPositionsX[1], (float)DemonicsPhysics.GROUND_POINT));
|
2022-09-14 23:06:52 +03:00
|
|
|
PlayerOne.ResetLives();
|
|
|
|
|
PlayerTwo.ResetLives();
|
|
|
|
|
_playerOneUI.FadeIn();
|
|
|
|
|
_playerTwoUI.FadeIn();
|
|
|
|
|
_timerAnimator.SetTrigger("FadeIn");
|
|
|
|
|
_infiniteTime.SetActive(true);
|
|
|
|
|
HasGameStarted = true;
|
|
|
|
|
}
|
|
|
|
|
private int _showFrame = 30;
|
|
|
|
|
private int _readyFrame = 60;
|
|
|
|
|
private int _readyEndFrame = 60;
|
|
|
|
|
private bool _showEnd;
|
|
|
|
|
private bool _readyEnd;
|
|
|
|
|
private bool _startRun;
|
|
|
|
|
private void RunReady()
|
|
|
|
|
{
|
|
|
|
|
if (_startRun)
|
|
|
|
|
{
|
|
|
|
|
Time.timeScale = GameSpeed;
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _showFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_showEnd = true;
|
|
|
|
|
_uiAudio.Sound("TextSound").Play();
|
2022-10-24 01:35:53 +03:00
|
|
|
_readyAnimator.Play("RoundShow");
|
2022-09-14 23:06:52 +03:00
|
|
|
if (_currentRound == 4)
|
|
|
|
|
{
|
|
|
|
|
_finalRound = true;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < _readyObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_readyObjects[i].SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
if (_finalRound)
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = $"Final Round";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = $"Round {_currentRound}";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (_showEnd)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _readyFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-10-24 01:35:53 +03:00
|
|
|
_readyAnimator.Play("FightShow");
|
2022-09-14 23:06:52 +03:00
|
|
|
_uiAudio.Sound("TextSound").Play();
|
|
|
|
|
_readyText.text = "Fight!";
|
|
|
|
|
_countdownText.gameObject.SetActive(true);
|
|
|
|
|
_playerOneUI.FadeIn();
|
|
|
|
|
_playerTwoUI.FadeIn();
|
|
|
|
|
_timerAnimator.SetTrigger("FadeIn");
|
|
|
|
|
_readyEnd = true;
|
2024-01-23 03:42:14 +02:00
|
|
|
if (_currentRound == 1)
|
|
|
|
|
if (SceneSettings.IsOnline)
|
|
|
|
|
if (SceneSettings.OnlineIndex == 0)
|
|
|
|
|
_playerOneUI.ShowYouOverhead();
|
|
|
|
|
else
|
|
|
|
|
_playerTwoUI.ShowYouOverhead();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (_readyEnd)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _readyEndFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_startRun = false;
|
|
|
|
|
for (int i = 0; i < _readyObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_readyObjects[i].SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
_readyText.text = "";
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.ActivateInput();
|
|
|
|
|
PlayerTwoController.ActivateInput();
|
2022-09-14 23:06:52 +03:00
|
|
|
HasGameStarted = true;
|
|
|
|
|
if (_currentRound == 1)
|
|
|
|
|
{
|
|
|
|
|
if (SceneSettings.ReplayMode)
|
|
|
|
|
{
|
|
|
|
|
ReplayManager.Instance.StartLoadReplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-12 22:52:04 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public virtual void RoundOver(bool timeout)
|
|
|
|
|
{
|
|
|
|
|
if (HasGameStarted)
|
|
|
|
|
{
|
2022-10-24 22:08:59 +03:00
|
|
|
_playerOneWon = false;
|
|
|
|
|
_playerTwoWon = false;
|
2022-09-14 23:06:52 +03:00
|
|
|
if (_isTrainingMode)
|
|
|
|
|
{
|
|
|
|
|
_roundOverTrainingCoroutine = StartCoroutine(RoundOverTrainingCoroutine());
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
string roundOverCause;
|
2023-03-11 15:57:01 +02:00
|
|
|
if (GameSimulation._players[0].health <= 0 && GameSimulation._players[1].health <= 0
|
|
|
|
|
|| GameSimulation._players[0].health > 0 && GameSimulation._players[1].health > 0)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
roundOverCause = "DOUBLE KO";
|
2023-03-11 15:57:01 +02:00
|
|
|
if (PlayerOne.Lives > 1 || PlayerTwo.Lives > 1)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-03-11 15:57:01 +02:00
|
|
|
if (GameSimulation._players[0].health < GameSimulation._players[1].health)
|
|
|
|
|
{
|
|
|
|
|
_playerTwoWon = true;
|
|
|
|
|
PlayerOne.LoseLife();
|
|
|
|
|
}
|
|
|
|
|
else if (GameSimulation._players[1].health < GameSimulation._players[0].health)
|
|
|
|
|
{
|
|
|
|
|
_playerOneWon = true;
|
|
|
|
|
PlayerTwo.LoseLife();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerOne.LoseLife();
|
|
|
|
|
PlayerTwo.LoseLife();
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else if (PlayerOne.Lives == 1 && PlayerTwo.Lives == 1 && _finalRound)
|
|
|
|
|
{
|
2023-03-11 15:57:01 +02:00
|
|
|
if (GameSimulation._players[0].health < GameSimulation._players[1].health)
|
|
|
|
|
{
|
|
|
|
|
_playerTwoWon = true;
|
|
|
|
|
PlayerOne.LoseLife();
|
|
|
|
|
}
|
|
|
|
|
else if (GameSimulation._players[1].health < GameSimulation._players[0].health)
|
|
|
|
|
{
|
|
|
|
|
_playerOneWon = true;
|
|
|
|
|
PlayerTwo.LoseLife();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerOne.LoseLife();
|
|
|
|
|
PlayerTwo.LoseLife();
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_finalRound = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-03-11 15:57:01 +02:00
|
|
|
if (PlayerOne.PlayerStats.maxHealth == GameSimulation._players[0].health && GameSimulation._players[1].health <= 0
|
|
|
|
|
|| PlayerTwo.PlayerStats.maxHealth == GameSimulation._players[1].health && GameSimulation._players[0].health <= 0)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-10-15 17:05:57 +03:00
|
|
|
roundOverCause = "PERFECT\nKO";
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
roundOverCause = "KO";
|
|
|
|
|
}
|
2023-01-27 02:16:02 +02:00
|
|
|
if (GameSimulation._players[0].health > GameSimulation._players[1].health)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_playerOneWon = true;
|
|
|
|
|
PlayerTwo.LoseLife();
|
2022-09-12 22:52:04 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2023-01-27 02:16:02 +02:00
|
|
|
else if (GameSimulation._players[1].health > GameSimulation._players[0].health)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_playerTwoWon = true;
|
|
|
|
|
PlayerOne.LoseLife();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-11 15:57:01 +02:00
|
|
|
if (timeout)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_readyText.text = "TIME UP";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = roundOverCause;
|
|
|
|
|
}
|
|
|
|
|
for (int i = 0; i < _readyObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_readyObjects[i].SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
_uiAudio.Sound("TextSound").Play();
|
2022-10-24 01:35:53 +03:00
|
|
|
_readyAnimator.Play("ReadyTextShow");
|
2022-09-14 23:06:52 +03:00
|
|
|
_roundOver = true;
|
2022-10-24 09:40:51 +03:00
|
|
|
_roundOverSecondFrame = 120;
|
2022-10-24 01:35:53 +03:00
|
|
|
_roundOverThirdFrame = 120;
|
2023-11-26 05:34:18 +02:00
|
|
|
_roundOverFourthFrame = 130;
|
2022-10-24 01:35:53 +03:00
|
|
|
_roundOverSecond = false;
|
|
|
|
|
_roundOverThird = false;
|
|
|
|
|
_startRoundOver = false;
|
|
|
|
|
_timeout = timeout;
|
|
|
|
|
HasGameStarted = false;
|
|
|
|
|
_uiAudio.Sound("Round").Play();
|
|
|
|
|
_startRoundOver = true;
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.DeactivateInput();
|
|
|
|
|
PlayerTwoController.DeactivateInput();
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-10-24 01:35:53 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int _roundOverSecondFrame = 60;
|
|
|
|
|
private int _roundOverThirdFrame = 120;
|
2023-11-26 05:34:18 +02:00
|
|
|
private int _roundOverFourthFrame = 130;
|
2022-10-24 01:35:53 +03:00
|
|
|
private bool _roundOver;
|
|
|
|
|
private bool _roundOverSecond;
|
|
|
|
|
private bool _roundOverThird;
|
|
|
|
|
private bool _startRoundOver;
|
|
|
|
|
private bool _timeout;
|
|
|
|
|
private bool _playerOneWon;
|
|
|
|
|
private bool _playerTwoWon;
|
|
|
|
|
private void RunRoundOver()
|
|
|
|
|
{
|
|
|
|
|
if (_startRoundOver)
|
|
|
|
|
{
|
2022-09-14 23:06:52 +03:00
|
|
|
if (_roundOver)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _roundOverSecondFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_uiAudio.Sound("TextSound").Play();
|
2022-10-24 01:35:53 +03:00
|
|
|
_readyAnimator.Play("ReadyTextShow");
|
2022-09-14 23:06:52 +03:00
|
|
|
_currentRound++;
|
|
|
|
|
if (_playerOneWon)
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = "WINNER";
|
|
|
|
|
_winnerNameText.text = $"{_playerOneUI.PlayerName}";
|
|
|
|
|
}
|
|
|
|
|
else if (_playerTwoWon)
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = "WINNER";
|
|
|
|
|
_winnerNameText.text = $"{_playerTwoUI.PlayerName}";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_readyText.text = "DRAW";
|
|
|
|
|
}
|
|
|
|
|
_roundOverSecond = true;
|
|
|
|
|
}
|
|
|
|
|
if (_roundOverSecond)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _roundOverThirdFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
if (_playerOneWon)
|
2022-10-15 15:01:06 +02:00
|
|
|
StartCoroutine(CameraCenterCoroutine(1));
|
2022-09-14 23:06:52 +03:00
|
|
|
else if (_playerTwoWon)
|
2022-10-15 15:01:06 +02:00
|
|
|
StartCoroutine(CameraCenterCoroutine(0));
|
2022-09-14 23:06:52 +03:00
|
|
|
else
|
|
|
|
|
{
|
2022-12-24 23:21:00 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
_roundOverThird = true;
|
|
|
|
|
}
|
|
|
|
|
if (_roundOverThird)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _roundOverFourthFrame))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _readyObjects.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
_readyObjects[i].SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
_winnerNameText.text = "";
|
|
|
|
|
_readyText.text = "";
|
|
|
|
|
if (_playerOneWon)
|
|
|
|
|
{
|
|
|
|
|
if (PlayerTwo.Lives == 0)
|
|
|
|
|
{
|
|
|
|
|
_playerOneWins++;
|
2023-09-26 01:27:40 +03:00
|
|
|
_winsText.text = $"{_playerOneWins} - {_playerTwoWins}";
|
2022-09-14 23:06:52 +03:00
|
|
|
MatchOver();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_fadeHandler.StartFadeTransition(true);
|
|
|
|
|
_fadeHandler.onFadeEnd.AddListener(() => StartRound());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (_playerTwoWon)
|
|
|
|
|
{
|
|
|
|
|
if (PlayerOne.Lives == 0)
|
|
|
|
|
{
|
|
|
|
|
_playerTwoWins++;
|
2023-09-26 01:27:40 +03:00
|
|
|
_winsText.text = $"{_playerOneWins} - {_playerTwoWins}";
|
2022-09-14 23:06:52 +03:00
|
|
|
MatchOver();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_fadeHandler.StartFadeTransition(true);
|
|
|
|
|
_fadeHandler.onFadeEnd.AddListener(() => StartRound());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (PlayerTwo.Lives == 0 || PlayerOne.Lives == 0)
|
|
|
|
|
{
|
|
|
|
|
MatchOver();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
_fadeHandler.StartFadeTransition(true);
|
|
|
|
|
_fadeHandler.onFadeEnd.AddListener(() => StartRound());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
_startRoundOver = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-10-15 15:01:06 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IEnumerator CameraCenterCoroutine(int player)
|
|
|
|
|
{
|
|
|
|
|
yield return new WaitForSeconds(0.2f);
|
|
|
|
|
float waitTime = 0.5f;
|
|
|
|
|
float elapsedTime = 0;
|
|
|
|
|
while (elapsedTime < waitTime)
|
|
|
|
|
{
|
|
|
|
|
_targetGroup.m_Targets[player].weight = Mathf.Lerp(0.5f, 0, (elapsedTime / waitTime));
|
|
|
|
|
elapsedTime += Time.deltaTime;
|
|
|
|
|
yield return null;
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2021-09-06 16:44:49 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
IEnumerator RoundOverTrainingCoroutine()
|
|
|
|
|
{
|
|
|
|
|
HasGameStarted = false;
|
2022-10-24 22:08:59 +03:00
|
|
|
Time.timeScale = 0.5f;
|
|
|
|
|
yield return new WaitForSecondsRealtime(1.5f);
|
|
|
|
|
Time.timeScale = 1f;
|
|
|
|
|
_fadeHandler.StartFadeTransition(true);
|
|
|
|
|
_fadeHandler.onFadeEnd.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
_fadeHandler.StartFadeTransition(false);
|
|
|
|
|
StartTrainingRound();
|
|
|
|
|
});
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void SwitchCharacters()
|
|
|
|
|
{
|
2022-10-23 18:03:59 +03:00
|
|
|
if (IsTrainingMode && _canCallSwitchCharacter && Time.timeScale > 0)
|
2022-09-14 23:06:52 +03:00
|
|
|
StartCoroutine(SwitchCharactersCoroutine());
|
|
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
IEnumerator SwitchCharactersCoroutine()
|
|
|
|
|
{
|
|
|
|
|
PlayerStatsSO playerStatsOneTemp = PlayerOne.PlayerStats;
|
|
|
|
|
PlayerOne.PlayerStats = PlayerTwo.PlayerStats;
|
|
|
|
|
PlayerTwo.PlayerStats = playerStatsOneTemp;
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerTwoController.IsPlayerOne = !PlayerTwoController.IsPlayerOne;
|
|
|
|
|
PlayerOneController.IsPlayerOne = !PlayerOneController.IsPlayerOne;
|
2022-09-14 23:06:52 +03:00
|
|
|
_playerOneUI.ShowPlayerIcon();
|
|
|
|
|
_playerTwoUI.ShowPlayerIcon();
|
|
|
|
|
_canCallSwitchCharacter = false;
|
|
|
|
|
if (_hasSwitchedCharacters)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.ControllerInputName != ControllerTypeEnum.Cpu.ToString() && PlayerTwoController.ControllerInputName == ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToCpu(0);
|
|
|
|
|
PlayerTwoController.SetControllerToPlayer(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
_playerOneInput.enabled = false;
|
|
|
|
|
_playerTwoInput.enabled = true;
|
|
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
else if (PlayerTwoController.ControllerInputName != ControllerTypeEnum.Cpu.ToString() && PlayerOneController.ControllerInputName == ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToPlayer(0);
|
|
|
|
|
PlayerTwoController.SetControllerToCpu(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
_playerOneInput.enabled = true;
|
|
|
|
|
_playerTwoInput.enabled = false;
|
|
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
string a = PlayerOneController.ControllerInputName;
|
|
|
|
|
string b = PlayerTwoController.ControllerInputName;
|
|
|
|
|
PlayerOneController.ControllerInputName = b;
|
|
|
|
|
PlayerTwoController.ControllerInputName = a;
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.ControllerOne != null && _playerOneInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (SceneSettings.ControllerTwo != null && _playerTwoInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.ControllerInputName != ControllerTypeEnum.Cpu.ToString() && PlayerTwoController.ControllerInputName == ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToCpu(0);
|
|
|
|
|
PlayerTwoController.SetControllerToPlayer(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
_playerOneInput.enabled = false;
|
|
|
|
|
_playerTwoInput.enabled = true;
|
|
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
else if (PlayerTwoController.ControllerInputName != ControllerTypeEnum.Cpu.ToString() && PlayerOneController.ControllerInputName == ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
PlayerOneController.SetControllerToPlayer(0);
|
|
|
|
|
PlayerTwoController.SetControllerToCpu(1);
|
2022-09-14 23:06:52 +03:00
|
|
|
_playerOneInput.enabled = true;
|
|
|
|
|
_playerTwoInput.enabled = false;
|
|
|
|
|
}
|
2023-12-03 02:36:58 +02:00
|
|
|
string a = PlayerOneController.ControllerInputName;
|
|
|
|
|
string b = PlayerTwoController.ControllerInputName;
|
|
|
|
|
PlayerOneController.ControllerInputName = b;
|
|
|
|
|
PlayerTwoController.ControllerInputName = a;
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.ControllerTwo != null && _playerOneInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
if (SceneSettings.ControllerOne != null && _playerTwoInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
_hasSwitchedCharacters = !_hasSwitchedCharacters;
|
|
|
|
|
yield return new WaitForSecondsRealtime(0.1f);
|
|
|
|
|
_canCallSwitchCharacter = true;
|
|
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public virtual void ResetRound(Vector2 movementInput)
|
|
|
|
|
{
|
2022-10-23 18:03:59 +03:00
|
|
|
if (_isTrainingMode && Time.timeScale > 0)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_fadeHandler.StartFadeTransition(true);
|
|
|
|
|
_fadeHandler.onFadeEnd.AddListener(() =>
|
|
|
|
|
{
|
|
|
|
|
HasGameStarted = true;
|
|
|
|
|
Time.timeScale = GameSpeed;
|
|
|
|
|
if (_roundOverTrainingCoroutine != null)
|
|
|
|
|
{
|
|
|
|
|
StopCoroutine(_roundOverTrainingCoroutine);
|
|
|
|
|
}
|
|
|
|
|
PlayerOne.ResetLives();
|
|
|
|
|
PlayerTwo.ResetLives();
|
2023-07-02 23:17:37 +03:00
|
|
|
if (_cachedOneResetPosition == DemonVector2.Zero)
|
2022-11-13 17:02:23 +02:00
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
_cachedOneResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[0], DemonicsPhysics.GROUND_POINT);
|
|
|
|
|
_cachedTwoResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[1], DemonicsPhysics.GROUND_POINT);
|
2022-11-13 17:02:23 +02:00
|
|
|
}
|
2023-07-02 23:17:37 +03:00
|
|
|
DemonVector2 playerOneResetPosition = _cachedOneResetPosition;
|
|
|
|
|
DemonVector2 playerTwoResetPosition = _cachedTwoResetPosition;
|
2022-09-14 23:06:52 +03:00
|
|
|
ObjectPoolingManager.Instance.DisableAllObjects();
|
2022-11-13 17:02:23 +02:00
|
|
|
|
|
|
|
|
if (movementInput.y == -1)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
playerOneResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[0], DemonicsPhysics.GROUND_POINT);
|
|
|
|
|
playerTwoResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[1], DemonicsPhysics.GROUND_POINT);
|
2022-11-13 17:02:23 +02:00
|
|
|
}
|
|
|
|
|
else if (movementInput.x == 1)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
playerOneResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[0] + _leftSpawn, DemonicsPhysics.GROUND_POINT);
|
|
|
|
|
playerTwoResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[1] + _rightSpawn, DemonicsPhysics.GROUND_POINT);
|
2022-11-13 17:02:23 +02:00
|
|
|
}
|
|
|
|
|
else if (movementInput.x == -1)
|
|
|
|
|
{
|
2023-07-02 23:17:37 +03:00
|
|
|
playerOneResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[0] - _rightSpawn, DemonicsPhysics.GROUND_POINT);
|
|
|
|
|
playerTwoResetPosition = new DemonVector2((DemonFloat)_spawnPositionsX[1] - _leftSpawn, DemonicsPhysics.GROUND_POINT);
|
2022-11-13 17:02:23 +02:00
|
|
|
}
|
|
|
|
|
else if (movementInput.y == 1)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_reverseReset = !_reverseReset;
|
|
|
|
|
}
|
2022-11-13 17:02:23 +02:00
|
|
|
if (_reverseReset)
|
|
|
|
|
{
|
|
|
|
|
PlayerOne.ResetPlayer(new Vector2((float)playerTwoResetPosition.x, (float)playerTwoResetPosition.y));
|
|
|
|
|
PlayerTwo.ResetPlayer(new Vector2((float)playerOneResetPosition.x, (float)playerOneResetPosition.y));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
PlayerOne.ResetPlayer(new Vector2((float)playerOneResetPosition.x, (float)playerOneResetPosition.y));
|
|
|
|
|
PlayerTwo.ResetPlayer(new Vector2((float)playerTwoResetPosition.x, (float)playerTwoResetPosition.y));
|
|
|
|
|
}
|
2023-01-19 17:07:46 +02:00
|
|
|
GameSimulation._players[0].CurrentState.ResetPlayerTraining(GameSimulation._players[0]);
|
|
|
|
|
GameSimulation._players[1].CurrentState.ResetPlayerTraining(GameSimulation._players[1]);
|
2022-11-13 17:02:23 +02:00
|
|
|
_cachedOneResetPosition = playerOneResetPosition;
|
|
|
|
|
_cachedTwoResetPosition = playerTwoResetPosition;
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
_fadeHandler.StartFadeTransition(false);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-09 21:48:58 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void StartMatch()
|
|
|
|
|
{
|
2023-11-11 18:00:20 +02:00
|
|
|
MouseSetup.Instance.SetCursor(false);
|
2022-09-19 19:30:16 +03:00
|
|
|
Time.timeScale = 1;
|
2023-01-27 15:20:51 +02:00
|
|
|
GameplayManager.Instance.EnableAllInput();
|
2022-09-14 23:06:52 +03:00
|
|
|
if (SceneSettings.RandomStage)
|
|
|
|
|
{
|
|
|
|
|
_currentStage.SetActive(false);
|
2023-10-11 02:25:05 +03:00
|
|
|
int randomStageIndex = UnityEngine.Random.Range(0, _stages.Length);
|
2022-09-14 23:06:52 +03:00
|
|
|
_currentStage = _stages[randomStageIndex];
|
|
|
|
|
_currentStage.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
_matchOverMenu.Hide();
|
|
|
|
|
PlayerOne.ResetLives();
|
|
|
|
|
PlayerTwo.ResetLives();
|
|
|
|
|
CurrentMusic.Stop();
|
|
|
|
|
if (SceneSettings.MusicName == "Random")
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic = _musicAudio.SoundGroup("Music").PlayInRandom();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic = _musicAudio.SoundGroup("Music").Sound(SceneSettings.MusicName);
|
|
|
|
|
CurrentMusic.Play();
|
|
|
|
|
}
|
|
|
|
|
StartRound();
|
|
|
|
|
}
|
2021-10-01 17:57:35 +02:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void PauseMusic()
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic.Pause();
|
|
|
|
|
}
|
2021-11-30 17:13:58 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void PlayMusic()
|
|
|
|
|
{
|
|
|
|
|
CurrentMusic.Play();
|
|
|
|
|
}
|
2021-11-30 17:13:58 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void LoadScene(int index)
|
|
|
|
|
{
|
2022-10-24 01:35:53 +03:00
|
|
|
Time.timeScale = 1;
|
2022-09-14 23:06:52 +03:00
|
|
|
SceneManager.LoadScene(index);
|
|
|
|
|
}
|
2023-04-30 14:36:29 +03:00
|
|
|
public void DisableAllInput(bool isPlayerOne = false, bool skipSwitch = false)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
PlayerInput = _uiInput;
|
2022-09-14 23:06:52 +03:00
|
|
|
if (_playerOneInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.ControllerInputName != ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
_playerOneInput.enabled = false;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2021-12-01 17:52:38 +01:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
if (_playerTwoInput.enabled)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerTwoController.ControllerInputName != ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
_playerTwoInput.enabled = false;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2023-04-30 14:36:29 +03:00
|
|
|
if (skipSwitch)
|
|
|
|
|
return;
|
2022-12-01 00:21:24 +02:00
|
|
|
if (isPlayerOne)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_uiInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_uiInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-12-01 00:21:24 +02:00
|
|
|
public PlayerInput PlayerInput { get; set; }
|
2022-09-14 23:06:52 +03:00
|
|
|
public void EnableAllInput()
|
|
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
if (!_playerOneInput.enabled)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerOneController.ControllerInputName != ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
_playerOneInput.enabled = true;
|
|
|
|
|
if (_hasSwitchedCharacters)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerOneInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2022-07-17 14:36:52 +03:00
|
|
|
|
2022-12-01 00:21:24 +02:00
|
|
|
if (!_playerTwoInput.enabled)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
if (PlayerTwoController.ControllerInputName != ControllerTypeEnum.Cpu.ToString())
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-12-01 00:21:24 +02:00
|
|
|
_playerTwoInput.enabled = true;
|
|
|
|
|
if (_hasSwitchedCharacters)
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerOneScheme, PlayerOneController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-12-03 02:36:58 +02:00
|
|
|
_playerTwoInput.SwitchCurrentControlScheme(SceneSettings.ControllerTwoScheme, PlayerTwoController.InputDevice);
|
2022-12-01 00:21:24 +02:00
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-08-30 22:04:55 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
public void AddHitstop(IHitstop hitstop)
|
|
|
|
|
{
|
|
|
|
|
_hitstopList.Add(hitstop);
|
|
|
|
|
}
|
2022-10-21 21:20:37 +03:00
|
|
|
|
|
|
|
|
public void GlobalHitstop(int hitstopFrames)
|
|
|
|
|
{
|
|
|
|
|
var hitstopItems = FindObjectsOfType<MonoBehaviour>().OfType<IHitstop>();
|
|
|
|
|
foreach (IHitstop hitstop in hitstopItems)
|
|
|
|
|
{
|
|
|
|
|
_hitstopList.Add(hitstop);
|
|
|
|
|
}
|
|
|
|
|
HitStop(hitstopFrames);
|
|
|
|
|
}
|
2022-10-24 09:40:51 +03:00
|
|
|
private int _superFreezeOverFrame;
|
|
|
|
|
private bool _superFreezeOver;
|
2022-09-14 23:06:52 +03:00
|
|
|
public void SuperFreeze()
|
|
|
|
|
{
|
2022-10-24 22:08:59 +03:00
|
|
|
if (!IsTrainingMode)
|
|
|
|
|
{
|
|
|
|
|
GlobalHitstop(120);
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-08-30 22:04:55 +03:00
|
|
|
|
2022-10-15 23:52:35 +02:00
|
|
|
public int _hitstop;
|
2022-10-21 21:20:37 +03:00
|
|
|
public void HitStop(int hitstopFrames)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
2022-10-21 21:20:37 +03:00
|
|
|
if (hitstopFrames > 0)
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
for (int i = 0; i < _hitstopList.Count; i++)
|
|
|
|
|
{
|
2022-09-25 10:41:05 +03:00
|
|
|
if (!_hitstopList[i].IsInHitstop())
|
|
|
|
|
{
|
|
|
|
|
_hitstopList[i].EnterHitstop();
|
|
|
|
|
}
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
2022-10-21 21:20:37 +03:00
|
|
|
_hitstop = hitstopFrames;
|
2022-09-14 23:06:52 +03:00
|
|
|
}
|
|
|
|
|
}
|
2022-07-17 14:36:52 +03:00
|
|
|
|
2022-09-14 23:06:52 +03:00
|
|
|
private void RunHitStop()
|
|
|
|
|
{
|
|
|
|
|
if (_hitstop > 0)
|
|
|
|
|
{
|
2022-11-03 13:09:06 +02:00
|
|
|
if (DemonicsWorld.WaitFramesOnce(ref _hitstop))
|
2022-09-14 23:06:52 +03:00
|
|
|
{
|
|
|
|
|
_hitstop = 0;
|
|
|
|
|
for (int i = 0; i < _hitstopList.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
_hitstopList[i].ExitHitstop();
|
|
|
|
|
}
|
|
|
|
|
_hitstopList.Clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-09-25 10:41:05 +03:00
|
|
|
|
2022-09-25 01:28:32 +03:00
|
|
|
private void OnDisable()
|
2022-09-25 00:18:34 +03:00
|
|
|
{
|
2022-09-25 01:28:32 +03:00
|
|
|
if (keyboardTwo != null)
|
|
|
|
|
{
|
|
|
|
|
InputSystem.RemoveDevice(keyboardTwo);
|
|
|
|
|
}
|
2023-04-06 15:16:02 +03:00
|
|
|
GameSimulation.Run = false;
|
2023-03-22 01:25:58 +02:00
|
|
|
ObjectPoolingManager.Instance.DestroyAllObjects();
|
2022-09-25 00:18:34 +03:00
|
|
|
}
|
2023-01-02 19:59:46 +02:00
|
|
|
|
|
|
|
|
void OnApplicationQuit()
|
|
|
|
|
{
|
|
|
|
|
if (GameManager.Instance.IsRunning)
|
|
|
|
|
GameManager.Instance.Shutdown();
|
|
|
|
|
}
|
2021-08-21 02:57:59 +02:00
|
|
|
}
|
2022-09-10 12:36:37 +03:00
|
|
|
|
|
|
|
|
|