diff --git a/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs b/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs index f084263..3e56ee0 100644 --- a/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs +++ b/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs @@ -1,7 +1,8 @@ +using System; using System.Collections; using UnityEngine; -public class DiceView : MonoBehaviour, IBase, IBootLoader +public class DiceView : MonoBehaviour, IBase { private Rigidbody rb; private bool rolling; @@ -15,21 +16,22 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader [SerializeField] private float liftForce = 0.1f; + private Action onRollingComplete = null; + void Awake() { rb = GetComponent(); rb.useGravity = false; - } - public void Initialize() - { - InterfaceManager.Instance?.RegisterInterface(this); transform.localPosition = new Vector3(0, 20, 0); } - - public void Roll() + + public void Roll(Action onComplete) { if (!rolling) + { + onRollingComplete = onComplete; StartCoroutine(RollRoutine()); + } } IEnumerator RollRoutine() @@ -37,26 +39,26 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader rolling = true; // MICRO DELAY → breaks physics sync between dice - yield return new WaitForSeconds(Random.Range(0.01f, 0.06f)); + yield return new WaitForSeconds(UnityEngine.Random.Range(0.01f, 0.06f)); rb.useGravity = true; // PER-DICE FORCE MULTIPLIER - float spinMultiplier = Random.Range(0.8f, 1.25f); + float spinMultiplier = UnityEngine.Random.Range(0.8f, 1.25f); // RANDOM TORQUE rb.AddTorque( - Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, - Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, - Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, + UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, + UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, + UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier, ForceMode.Impulse ); // RANDOM SIDE FORCE Vector3 sideDir = new Vector3( - Random.Range(-1f, 1f), + UnityEngine.Random.Range(-1f, 1f), 0f, - Random.Range(-1f, 1f) + UnityEngine.Random.Range(-1f, 1f) ).normalized; rb.AddForce(sideDir * sideForce, ForceMode.Impulse); @@ -71,6 +73,8 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader //TODO: Use the dice value as needed Debug.Log($"Dice rolled: {value}"); + onRollingComplete?.Invoke(value); + ResetDice(); } diff --git a/Assets/Prefabs/Dice Prefab.prefab b/Assets/Prefabs/Dice Prefab.prefab index f2375cb..093141c 100644 --- a/Assets/Prefabs/Dice Prefab.prefab +++ b/Assets/Prefabs/Dice Prefab.prefab @@ -237,6 +237,18 @@ PrefabInstance: propertyPath: m_Layer value: 3 objectReference: {fileID: 0} + - target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3} + propertyPath: liftForce + value: 0.25 + objectReference: {fileID: 0} + - target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3} + propertyPath: sideForce + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3} + propertyPath: baseSpinForce + value: 2000 + objectReference: {fileID: 0} - target: {fileID: 1804238606659730489, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3} propertyPath: m_RootOrder value: 0 diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity index 5b8c096..63e330a 100644 --- a/Assets/Scenes/Game.unity +++ b/Assets/Scenes/Game.unity @@ -4046,6 +4046,37 @@ Transform: m_Father: {fileID: 491039299} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0} +--- !u!1 &429754880 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 429754881} + m_Layer: 0 + m_Name: GameMode + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &429754881 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 429754880} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1332468941} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &433034049 GameObject: m_ObjectHideFlags: 0 @@ -7795,7 +7826,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: diceRollHandler: {fileID: 1013177415} - diceValue: 6 + diceValue: 0 diceText: {fileID: 953941044} pointerDebug: {fileID: 102349503} pointerMeshRend: {fileID: 102349501} @@ -10520,7 +10551,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: diceView: {fileID: 1619592888} - diceTestValue: 6 + diceTestValue: 0 --- !u!4 &1039618837 stripped Transform: m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3} @@ -13896,6 +13927,7 @@ Transform: - {fileID: 1954289400} - {fileID: 896127050} - {fileID: 1013177414} + - {fileID: 429754881} m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -22049,10 +22081,10 @@ RectTransform: m_Father: {fileID: 5608193482000915565} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 439.5, y: -62.5} + m_SizeDelta: {x: 249, y: 76} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &5608193481682591349 GameObject: @@ -23753,7 +23785,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 1 + m_IsActive: 0 --- !u!222 &5608193481910428234 CanvasRenderer: m_ObjectHideFlags: 0 @@ -24810,10 +24842,10 @@ RectTransform: m_Father: {fileID: 5608193482000915565} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 170.5, y: -62.5} + m_SizeDelta: {x: 249, y: 76} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &5608193482091674333 GameObject: @@ -25052,9 +25084,9 @@ RectTransform: m_Father: {fileID: 5608193481540211365} m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 487.5, y: -150} m_SizeDelta: {x: 250, y: 250} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &5608193482123643061 @@ -26731,7 +26763,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!114 &5608193482405246783 MonoBehaviour: m_ObjectHideFlags: 0 @@ -29762,9 +29794,9 @@ RectTransform: m_Father: {fileID: 5608193481540211365} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 162.5, y: -150} m_SizeDelta: {x: 250, y: 250} m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &5608193482885172033 @@ -32611,10 +32643,10 @@ RectTransform: m_Father: {fileID: 5608193482000915565} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0, y: 0} - m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 0, y: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 0, y: 1} + m_AnchoredPosition: {x: 708.5, y: -62.5} + m_SizeDelta: {x: 249, y: 76} m_Pivot: {x: 0.5, y: 0.5} --- !u!222 &5608193483470603110 CanvasRenderer: diff --git a/Assets/Scripts/Gameplay/GameModeHandler.cs b/Assets/Scripts/Gameplay/GameModeHandler.cs new file mode 100644 index 0000000..ee93c89 --- /dev/null +++ b/Assets/Scripts/Gameplay/GameModeHandler.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; +using UnityEngine; + +public enum GameModeType +{ + PVP, + Bot, +} + +public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader +{ + private GameplayManager gameplayManager; + + public GameModeType GameModeType + { + get; private set; + } + + public void Initialize() + { + InterfaceManager.Instance.RegisterInterface(this); + } + + public void InitializeData() + { + gameplayManager = InterfaceManager.Instance.GetInterfaceInstance(); + } + + public void InitPVPModeData(List types) + { + GameModeType = GameModeType.PVP; + gameplayManager.InitPlayerTypesForPVP(types); + } + + public void InitBotModeData(PlayerType selectedPlayer, int botCount) + { + GameModeType = GameModeType.Bot; + gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount); + } +} diff --git a/Assets/Scripts/Gameplay/GameModeHandler.cs.meta b/Assets/Scripts/Gameplay/GameModeHandler.cs.meta new file mode 100644 index 0000000..c3772b6 --- /dev/null +++ b/Assets/Scripts/Gameplay/GameModeHandler.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2d8a94cfc31bb45f9a403db0c1f4c116 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/GameplayManager.cs b/Assets/Scripts/Gameplay/GameplayManager.cs index d249245..169ddd3 100644 --- a/Assets/Scripts/Gameplay/GameplayManager.cs +++ b/Assets/Scripts/Gameplay/GameplayManager.cs @@ -80,7 +80,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader private List availPlayers = new List(); private bool canSwitchPlayer = false; - public bool CanRollDice + public bool CanRollDiceForUser { get; private set; } @@ -96,20 +96,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader { tilesManager = InterfaceManager.Instance.GetInterfaceInstance(); - CanRollDice = true; + CanRollDiceForUser = true; - // initialize the player list from UI. - - // InitPlayerTypesForLAN(null); InitPlayerTypesForBotMatch(PlayerType.Player1, 3); } // TODO :: Call when the UI selection is made and game starts - public void InitPlayerTypesForLAN(List types) + public void InitPlayerTypesForPVP(List types) { // TODO :: 2P, 3P, 4P - allPlayerTypes = new List { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 }; - // allPlayerTypes = new List { PlayerType.Player1, PlayerType.Player3 }; + allPlayerTypes = new List(types); playerBaseHandler.InitPlayerTypes(allPlayerTypes); InitCurrentGamePlayerInfo(); @@ -232,7 +228,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader public void OnDiceInteracted() { - diceRollHandler.HandleDiceView(); + diceRollHandler.HandleDiceViewForUser(); } public void RollDiceForPlayer(int rolledVal) @@ -264,12 +260,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader return false; } - private void RollDiceForBot() + private void RollDiceForBot(int rolledVal) { Debug.Log($"CallTest: RollDiceForBot"); // OnDiceRolled(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue); - OnDiceRolled(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue); + OnDiceRolled(rolledVal); SelectPawnFromBotBase(); @@ -549,7 +545,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader private void CheckDiceRollForBot(PlayerPawn playerPawn) { if (CanRollDiceAgain) - RollDiceForBot(); + { + HandleDiceRoll(); + } + } + + private void HandleDiceRoll() + { + diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal)); } public void OnPawnSelected(PlayerPawn playerPawn) @@ -693,7 +696,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader if (botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function { Debug.Log($"Invoking RollDiceForBot"); - Invoke(nameof(RollDiceForBot), 1f); + Invoke(nameof(HandleDiceRoll), 1f); } } @@ -945,6 +948,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader { // if (botTypesInGame.Contains(playerType)) return; - CanRollDice = state; + CanRollDiceForUser = state; } } diff --git a/Assets/Scripts/Input/DiceRollHandler.cs b/Assets/Scripts/Input/DiceRollHandler.cs index 097b958..12ca74d 100644 --- a/Assets/Scripts/Input/DiceRollHandler.cs +++ b/Assets/Scripts/Input/DiceRollHandler.cs @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Collections.Generic; using UnityEngine; @@ -12,32 +13,32 @@ public class DiceRollHandler : MonoBehaviour private void OnMouseDown() { inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance() : inputManager; - if (!inputManager.GameplayManager.CanRollDice) return; - RollDiceOnClick(); + // RollDiceOnClick(); } private void Update() { inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance() : inputManager; - if (!inputManager.GameplayManager.CanRollDice) return; - - if (Input.GetKeyDown(KeyCode.Space)) - RollDiceOnClick(); } - private void RollDiceOnClick() + public void OnUserDiceRollComplete(int rolledVal) { SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance(); soundManager?.PlayGameSoundClip(SoundType.Dice); - int currentRolledVal = // Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1); - diceTestValue != 0 ? diceTestValue : Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1); - inputManager.SetDiceRollValue(currentRolledVal); + inputManager.SetDiceRollValue(rolledVal); } - public void HandleDiceView() + public void HandleDiceViewForUser() { - diceView.Roll(); + if (!inputManager.GameplayManager.CanRollDiceForUser) return; + + diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal)); + } + + public void HandleDiceViewForBot(Action onComplete) + { + diceView.Roll(onComplete: onComplete); } } diff --git a/Assets/Scripts/UI/Managers/UIManager.cs b/Assets/Scripts/UI/Managers/UIManager.cs index 14f7fc5..9d4949a 100644 --- a/Assets/Scripts/UI/Managers/UIManager.cs +++ b/Assets/Scripts/UI/Managers/UIManager.cs @@ -5,7 +5,6 @@ using UnityEngine; public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader { private GameplayManager gameplayManager; - private PopupManager popupManager; private ScreenManager screenManager; public void Initialize() @@ -16,8 +15,6 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader public void InitializeData() { gameplayManager = InterfaceManager.Instance.GetInterfaceInstance(); - popupManager = InterfaceManager.Instance.GetInterfaceInstance(); - } public void OnDiceViewInteracted() @@ -38,7 +35,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader screenManager.ShowScreen(ScreenType.InGameHUDScreen); } - public void OnPlayButtonClicked() + public void UpdateSelectedPlayerCount(int playersCount) { } diff --git a/Assets/Scripts/UI/Pages/PopUp/PvAIModePopup.cs b/Assets/Scripts/UI/Pages/PopUp/PvAIModePopup.cs index e98aabb..232098d 100644 --- a/Assets/Scripts/UI/Pages/PopUp/PvAIModePopup.cs +++ b/Assets/Scripts/UI/Pages/PopUp/PvAIModePopup.cs @@ -20,16 +20,18 @@ public class PvAIModePopup : PopupBase private ScreenManager screenManager; private SoundManager soundManager; + private GameModeHandler gameModeHandler; + private int selectedPlayerCount; - public int SelectedPlayerCount => selectedPlayerCount; + private PlayerType playerType; private void OnEnable() { twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2)); threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3)); fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4)); - playBtn.onClick.AddListener(OnClick_playBtn); - closeBtn.onClick.AddListener(OnClick_closeBtn); + playBtn.onClick.AddListener(OnClick_PlayButton); + closeBtn.onClick.AddListener(OnClick_CloseButton); } private void OnDisable() @@ -45,9 +47,9 @@ public class PvAIModePopup : PopupBase selectedPlayerCount = count; } - private void OnClick_playBtn() + private void OnClick_PlayButton() { - playerName = playerNameInput.text; + playerName = string.IsNullOrWhiteSpace(playerNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerNameInput.text; soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance() : soundManager; soundManager?.PlayGameSoundClip(SoundType.ButtonClick); @@ -57,10 +59,11 @@ public class PvAIModePopup : PopupBase Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:"); Debug.Log($"Player 1: {playerName}"); - + gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance() : gameModeHandler; + gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1); } - private void OnClick_closeBtn() + private void OnClick_CloseButton() { screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance() : screenManager; screenManager.ShowScreen(ScreenType.MenuScreen); diff --git a/Assets/Scripts/UI/Pages/PopUp/PvPModePopup.cs b/Assets/Scripts/UI/Pages/PopUp/PvPModePopup.cs index db5fd3a..af96a0d 100644 --- a/Assets/Scripts/UI/Pages/PopUp/PvPModePopup.cs +++ b/Assets/Scripts/UI/Pages/PopUp/PvPModePopup.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using TMPro; using UnityEngine; using UnityEngine.UI; @@ -24,8 +25,9 @@ public class PvPModePopup : PopupBase private string playerFourName; private ScreenManager screenManager; - private GameManager gameManager; private SoundManager soundManager; + private GameModeHandler gameModeHandler; + private int selectedPlayerCount; public int SelectedPlayerCount => selectedPlayerCount; @@ -63,9 +65,9 @@ public class PvPModePopup : PopupBase private void OnClick_playBtn() { playerOneName = string.IsNullOrWhiteSpace(playerOneNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerOneNameInput.text; - playerTwoName = string.IsNullOrWhiteSpace(playerTwoNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerTwoNameInput.text; - playerThreeName = string.IsNullOrWhiteSpace(playerThreeNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerThreeNameInput.text; - playerFourName = string.IsNullOrWhiteSpace(playerFourNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerFourNameInput.text; + playerTwoName = string.IsNullOrWhiteSpace(playerTwoNameInput.text) ? Ludo_3D_Constants.Player2_Name : playerTwoNameInput.text; + playerThreeName = string.IsNullOrWhiteSpace(playerThreeNameInput.text) ? Ludo_3D_Constants.Player3_Name : playerThreeNameInput.text; + playerFourName = string.IsNullOrWhiteSpace(playerFourNameInput.text) ? Ludo_3D_Constants.Player4_Name : playerFourNameInput.text; soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance() : soundManager; soundManager?.PlayGameSoundClip(SoundType.ButtonClick); @@ -74,10 +76,33 @@ public class PvPModePopup : PopupBase Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:"); Debug.Log($"Player 1: {playerOneName}"); Debug.Log($"Player 2: {playerTwoName}"); + if (selectedPlayerCount >= 3) Debug.Log($"Player 3: {playerThreeName}"); if (selectedPlayerCount == 4) Debug.Log($"Player 4: {playerFourName}"); + + InitPlayers(); + } + + private void InitPlayers() + { + // update logic based on UpdateInputFieldsVisibility() + List playerTypes = new List(); + if (playerOneNameInput.gameObject.activeInHierarchy) + playerTypes.Add(PlayerType.Player1); + + if (playerTwoNameInput.gameObject.activeInHierarchy) + playerTypes.Add(PlayerType.Player2); + + if (playerThreeNameInput.gameObject.activeInHierarchy) + playerTypes.Add(PlayerType.Player3); + + if (playerFourNameInput.gameObject.activeInHierarchy) + playerTypes.Add(PlayerType.Player4); + + gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance() : gameModeHandler; + gameModeHandler.InitPVPModeData(playerTypes); } private void OnClick_closeBtn()