PvP & PvBot changes.

This commit is contained in:
Ashby Issac 2026-01-30 19:14:08 +05:30
parent d20503fd9b
commit 41c2fdbee5
5 changed files with 270 additions and 92 deletions

View File

@ -582,7 +582,7 @@ MonoBehaviour:
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 0.2264151, g: 0.2264151, b: 0.2264151, a: 0.78431374}
m_NormalColor: {r: 1, g: 1, b: 1, a: 0.78431374}
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0.88235295}
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
m_SelectedColor: {r: 1, g: 1, b: 1, a: 1}

View File

@ -122,6 +122,17 @@ NavMeshSettings:
debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!114 &16179158 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8065952316906327149, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
m_PrefabInstance: {fileID: 2049814614}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &28556634
GameObject:
m_ObjectHideFlags: 0
@ -2500,6 +2511,17 @@ MeshFilter:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 224854105}
m_Mesh: {fileID: 4300004, guid: 25e0b84f10949354b96b98b3742acdde, type: 3}
--- !u!114 &232996781 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8065952317181319405, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
m_PrefabInstance: {fileID: 2049814614}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &241691679
GameObject:
m_ObjectHideFlags: 0
@ -4213,6 +4235,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 429754881}
- component: {fileID: 429754882}
m_Layer: 0
m_Name: GameMode
m_TagString: Untagged
@ -4235,6 +4258,18 @@ Transform:
m_Father: {fileID: 1332468941}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &429754882
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 429754880}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2d8a94cfc31bb45f9a403db0c1f4c116, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &433034049
GameObject:
m_ObjectHideFlags: 0
@ -8166,6 +8201,17 @@ Transform:
m_Father: {fileID: 2090077059}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &876481615 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8065952316677608095, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
m_PrefabInstance: {fileID: 2049814614}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &884011400
GameObject:
m_ObjectHideFlags: 0
@ -10449,7 +10495,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: m_RootOrder
value: 7
value: 5
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: m_AnchorMax.x
@ -10523,6 +10569,38 @@ PrefabInstance:
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnNormalColor.a
value: 0.78431374
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnNormalColor.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnNormalColor.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnNormalColor.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnSelectedColor.a
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnSelectedColor.b
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnSelectedColor.g
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: playerBtnSelectedColor.r
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8050308181185231130, guid: b04f48863fc6c4f75821857086cea347, type: 3}
propertyPath: m_AnchorMax.y
value: 1
@ -14721,6 +14799,7 @@ MonoBehaviour:
- {fileID: 247469677}
- {fileID: 875086323}
- {fileID: 896127049}
- {fileID: 429754880}
- {fileID: 1954289399}
- {fileID: 1107252688}
- {fileID: 1406544794}
@ -18202,6 +18281,17 @@ Transform:
m_Father: {fileID: 491039299}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
--- !u!114 &1811366701 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8065952316882128052, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
m_PrefabInstance: {fileID: 2049814614}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &1820161969
GameObject:
m_ObjectHideFlags: 0
@ -20298,6 +20388,26 @@ PrefabInstance:
m_Modification:
m_TransformParent: {fileID: 5608193481910428232}
m_Modifications:
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: inputFields.Array.size
value: 4
objectReference: {fileID: 0}
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: inputFields.Array.data[0]
value:
objectReference: {fileID: 876481615}
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: inputFields.Array.data[1]
value:
objectReference: {fileID: 1811366701}
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: inputFields.Array.data[2]
value:
objectReference: {fileID: 232996781}
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: inputFields.Array.data[3]
value:
objectReference: {fileID: 16179158}
- target: {fileID: 8065952316435045038, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: m_Name
value: Player V Player Popup
@ -20316,7 +20426,7 @@ PrefabInstance:
objectReference: {fileID: 0}
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: m_RootOrder
value: 6
value: 4
objectReference: {fileID: 0}
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
propertyPath: m_AnchorMax.x

View File

@ -97,7 +97,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
// InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 });
// InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2})
}
// TODO :: Call when the UI selection is made and game starts
@ -118,6 +118,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
allPlayerTypes.Clear();
AssignBotTypes(selectedPlayerType, botCount);
allPlayerTypes.Add(selectedPlayerType);
allPlayerTypes.AddRange(botTypesInGame);
@ -204,6 +205,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
continue;
Debug.Log($"playerGameData.playerType: {playerGameData.playerType}");
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new Dictionary<int, PlayerPawn>();
@ -913,6 +915,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
{
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
playerPawn.MoveToTile(
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
onComplete: () =>
@ -932,6 +936,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
}
else
{
Debug.Log($"CurrentTileIndex: {playerPawn.CurrentTileIndex} == lastIndex: {tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1}");
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
{
@ -975,6 +980,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
}
else
{
// activate here
if (CheckForMaxDiceRollAttempt())
{
return;

View File

@ -1,9 +1,13 @@
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class PvAIModePopup : PopupBase
{
[SerializeField] private Color playerBtnNormalColor;
[SerializeField] private Color playerBtnSelectedColor;
[Header("Bot Selection Buttons")]
[SerializeField] private Button twoPlayerBtn;
[SerializeField] private Button threePlayerBtn;
@ -33,20 +37,27 @@ public class PvAIModePopup : PopupBase
private int selectedPlayerCount;
private PlayerType playerType;
private Button currPlayerCountBtn, prevPlayerCountBtn;
private Button currPlayerTypeBtn, prePlayerTypeBtn;
private void OnEnable()
{
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2, twoPlayerBtn));
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3, threePlayerBtn));
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4, fourPlayerBtn));
playBtn.onClick.AddListener(OnClick_PlayButton);
closeBtn.onClick.AddListener(OnClick_CloseButton);
redBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player1));
blueBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player2));
greyBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player3));
greenBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player4));
redBtn.Select();
twoPlayerBtn.Select();
redBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player1, redBtn));
blueBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player2, blueBtn));
greyBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player3, greyBtn));
greenBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player4, greenBtn));
}
private void Start()
{
OnPlayerCountSelected(2, twoPlayerBtn);
}
private void OnDisable()
@ -54,12 +65,29 @@ public class PvAIModePopup : PopupBase
twoPlayerBtn.onClick.RemoveAllListeners();
threePlayerBtn.onClick.RemoveAllListeners();
fourPlayerBtn.onClick.RemoveAllListeners();
playBtn.onClick.RemoveAllListeners();
closeBtn.onClick.RemoveAllListeners();
}
private void OnPlayerCountSelected(int count)
private void OnPlayerCountSelected(int count, Button button)
{
selectedPlayerCount = count;
prevPlayerCountBtn = currPlayerCountBtn;
currPlayerCountBtn = button;
ColorBlock colorBlock;
if (prevPlayerCountBtn)
{
colorBlock = prevPlayerCountBtn.colors;
colorBlock.normalColor = playerBtnNormalColor;
prevPlayerCountBtn.colors = colorBlock;
}
colorBlock = currPlayerCountBtn.colors;
colorBlock.normalColor = playerBtnSelectedColor;
currPlayerCountBtn.colors = colorBlock;
}
private void OnClick_PlayButton()
@ -74,6 +102,8 @@ public class PvAIModePopup : PopupBase
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
Debug.Log($"Player 1: {playerName}");
popupManager.HidePopup(popupType);
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
}
@ -88,8 +118,23 @@ public class PvAIModePopup : PopupBase
Hide();
}
public void OnColorSelected(PlayerType type)
private void OnColorSelected(PlayerType type, Button button)
{
playerType = type;
prePlayerTypeBtn = currPlayerTypeBtn;
currPlayerTypeBtn = button;
ColorBlock colorBlock;
if (prePlayerTypeBtn)
{
colorBlock = prePlayerTypeBtn.colors;
colorBlock.normalColor = playerBtnNormalColor;
prePlayerTypeBtn.colors = colorBlock;
}
colorBlock = currPlayerTypeBtn.colors;
colorBlock.normalColor = playerBtnSelectedColor;
currPlayerTypeBtn.colors = colorBlock;
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@ -19,12 +20,6 @@ public class PvPModePopup : PopupBase
[SerializeField] private TMP_InputField playerThreeNameInput;
[SerializeField] private TMP_InputField playerFourNameInput;
[Header("Player Names")]
private string playerOneName;
private string playerTwoName;
private string playerThreeName;
private string playerFourName;
[Header("References")]
[SerializeField] private GameObject playerNameInputParent1;
[SerializeField] private GameObject playerNameInputParent2;
@ -34,6 +29,13 @@ public class PvPModePopup : PopupBase
[SerializeField] private TMP_Text playerTwoPlaceholder;
[SerializeField] private TMP_Text playerThreePlaceholder;
[SerializeField] private TMP_Text playerFourPlaceholder;
[SerializeField] private List<TMP_InputField> inputFields = new List<TMP_InputField>();
[Header("Player Names")]
private string playerOneName;
private string playerTwoName;
private string playerThreeName;
private string playerFourName;
private ScreenManager screenManager;
private SoundManager soundManager;
@ -43,19 +45,23 @@ public class PvPModePopup : PopupBase
public int SelectedPlayerCount => selectedPlayerCount;
[Header("Horizontal Rows (P1P4)")]
public List<GameObject> rows;
private int hiddenIndex = 0;
Dictionary<PlayerType, string> playerNameMap = new();
private List<int> hiddenIndexes = new List<int>();
private Dictionary<PlayerType, string> playerNameMap = new();
private void OnEnable()
{
twoPlayerBtn.onClick.AddListener(OnClick_TwoPlayerBtn);
threePlayerBtn.onClick.AddListener(OnClick_ThreePlayerBtn);
fourPlayerBtn.onClick.AddListener(OnClick_FourPlayerBtn);
playBtn.onClick.AddListener(OnClick_PlayBtn);
closeBtn.onClick.AddListener(OnClick_CloseBtn);
switchBtn.onClick.AddListener(OnClick_SwitchBtn);
playBtn.onClick.AddListener(OnClick_PlayButton);
closeBtn.onClick.AddListener(OnClick_CloseButton);
switchBtn.onClick.AddListener(OnClick_SwitchButton);
}
private void Start()
@ -68,33 +74,44 @@ public class PvPModePopup : PopupBase
twoPlayerBtn.onClick.RemoveListener(OnClick_TwoPlayerBtn);
threePlayerBtn.onClick.RemoveListener(OnClick_ThreePlayerBtn);
fourPlayerBtn.onClick.RemoveAllListeners();
playBtn.onClick.RemoveListener(OnClick_PlayBtn);
closeBtn.onClick.RemoveListener(OnClick_CloseBtn);
switchBtn.onClick.RemoveListener(OnClick_SwitchBtn);
playBtn.onClick.RemoveListener(OnClick_PlayButton);
closeBtn.onClick.RemoveListener(OnClick_CloseButton);
switchBtn.onClick.RemoveListener(OnClick_SwitchButton);
}
private void OnClick_TwoPlayerBtn()
{
switchBtn.gameObject.SetActive(true);
selectedPlayerCount = 2;
OnPlayerCountsSwitched();
switchBtn.gameObject.SetActive(true);
playerNameInputParent2.SetActive(false);
}
private void OnClick_ThreePlayerBtn()
{
switchBtn.gameObject.SetActive(true);
selectedPlayerCount = 3;
OnPlayerCountsSwitched();
switchBtn.gameObject.SetActive(true);
playerNameInputParent1.SetActive(true);
playerNameInputParent2.SetActive(true);
UpdateInputFieldsVisibility();
}
private void OnClick_FourPlayerBtn()
{
switchBtn.gameObject.SetActive(false);
selectedPlayerCount = 4;
switchBtn.gameObject.SetActive(false);
playerNameInputParent1.SetActive(true);
playerNameInputParent2.SetActive(true);
UpdateInputFieldsVisibility();
}
@ -106,84 +123,51 @@ public class PvPModePopup : PopupBase
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
}
private void OnClick_PlayBtn()
private void OnClick_PlayButton()
{
int logicalIndex = 0;
foreach (GameObject row in rows)
playerNameMap.Clear();
for (int idx = 0; idx < inputFields.Count; idx++)
{
if (!row.activeSelf)
PlayerType playerType = (PlayerType)idx;
if (!inputFields[idx].transform.parent.gameObject.activeInHierarchy)
{
continue;
}
TMP_InputField input = row.GetComponentInChildren<TMP_InputField>();
PlayerType playerType = (PlayerType)logicalIndex;
string playerName = string.IsNullOrWhiteSpace(input.text)
? playerType.ToString()
: input.text;
playerNameMap[playerType] = playerName;
logicalIndex++;
playerNameMap.Add(playerType, string.IsNullOrWhiteSpace(inputFields[idx].text) ? $"{playerType}" : inputFields[idx].text);
}
// 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;
playerOneName = playerNameMap.GetValueOrDefault(PlayerType.Player1, Ludo_3D_Constants.Player1_Name);
playerTwoName = playerNameMap.GetValueOrDefault(PlayerType.Player2, Ludo_3D_Constants.Player2_Name);
playerThreeName = playerNameMap.GetValueOrDefault(PlayerType.Player3, Ludo_3D_Constants.Player3_Name);
playerFourName = playerNameMap.GetValueOrDefault(PlayerType.Player4, Ludo_3D_Constants.Player4_Name);
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
//TODO: Start PVP Game with the selected player count and names
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<PlayerType> playerTypes = new List<PlayerType>();
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);
popupManager.HidePopup(popupType);
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
gameModeHandler.InitPVPModeData(playerTypes);
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList());
}
private void OnClick_SwitchBtn()
private void OnClick_SwitchButton()
{
hiddenIndexes.Clear();
if (SelectedPlayerCount == 2)
{
if (playerNameInputParent1.activeSelf)
if (playerNameInputParent1.activeInHierarchy)
{
playerNameInputParent1.SetActive(false);
playerNameInputParent2.SetActive(true);
playerOnePlaceholder.text = "Player 1";
playerThreePlaceholder.text = "Player 2";
hiddenIndexes.Add((int)PlayerType.Player1);
hiddenIndexes.Add((int)PlayerType.Player3);
}
else
{
@ -191,30 +175,63 @@ public class PvPModePopup : PopupBase
playerNameInputParent2.SetActive(false);
playerTwoPlaceholder.text = "Player 1";
playerFourPlaceholder.text = "Player 2";
hiddenIndexes.Add((int)PlayerType.Player2);
hiddenIndexes.Add((int)PlayerType.Player4);
}
}
else if (SelectedPlayerCount == 3)
{
hiddenIndex = (hiddenIndex + 1) % rows.Count;
UpdateRows();
hiddenIndex = (hiddenIndex + 1) % inputFields.Count;
hiddenIndexes.Add(hiddenIndex);
}
UpdateRows();
}
private void OnPlayerCountsSwitched()
{
hiddenIndexes.Clear();
if (SelectedPlayerCount == 2)
{
if (playerNameInputParent1.activeInHierarchy)
{
playerOnePlaceholder.text = "Player 1";
playerThreePlaceholder.text = "Player 2";
hiddenIndexes.Add((int)PlayerType.Player2);
hiddenIndexes.Add((int)PlayerType.Player4);
}
else if (playerNameInputParent2.activeInHierarchy)
{
playerTwoPlaceholder.text = "Player 1";
playerFourPlaceholder.text = "Player 2";
hiddenIndexes.Add((int)PlayerType.Player1);
hiddenIndexes.Add((int)PlayerType.Player3);
}
}
else if (SelectedPlayerCount == 3)
{
hiddenIndex = (hiddenIndex + 1) % inputFields.Count;
hiddenIndexes.Add(hiddenIndex);
}
UpdateRows();
}
private void UpdateRows()
{
int visiblePlayerIndex = 1;
for (int i = 0; i < rows.Count; i++)
for (int i = 0; i < inputFields.Count; i++)
{
bool isHidden = (i == hiddenIndex);
rows[i].SetActive(!isHidden);
bool isHidden = hiddenIndexes.Contains(i);
inputFields[i].transform.parent.gameObject.SetActive(!isHidden);
if (!isHidden)
{
TMP_InputField input =
rows[i].GetComponentInChildren<TMP_InputField>();
TMP_Text placeholder = input.placeholder as TMP_Text;
TMP_Text placeholder = inputFields[i].placeholder as TMP_Text;
if (placeholder != null)
{
placeholder.text = $"Player {visiblePlayerIndex}";
@ -224,7 +241,7 @@ public class PvPModePopup : PopupBase
}
}
private void OnClick_CloseBtn()
private void OnClick_CloseButton()
{
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
screenManager.ShowScreen(ScreenType.MenuScreen);