Compare commits
No commits in common. "0aa1f1880113f59b90f8d4bdd3b5dd5f164eb0f0" and "d20503fd9bed0fddf2f3f8c867771b9127025332" have entirely different histories.
0aa1f18801
...
d20503fd9b
@ -582,7 +582,7 @@ MonoBehaviour:
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||
m_NormalColor: {r: 0.2264151, g: 0.2264151, b: 0.2264151, 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}
|
||||
|
||||
@ -122,17 +122,6 @@ 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
|
||||
@ -2511,17 +2500,6 @@ 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
|
||||
@ -4235,7 +4213,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 429754881}
|
||||
- component: {fileID: 429754882}
|
||||
m_Layer: 0
|
||||
m_Name: GameMode
|
||||
m_TagString: Untagged
|
||||
@ -4258,18 +4235,6 @@ 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
|
||||
@ -8201,17 +8166,6 @@ 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
|
||||
@ -10495,7 +10449,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 5
|
||||
value: 7
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
@ -10569,38 +10523,6 @@ 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
|
||||
@ -14799,7 +14721,6 @@ MonoBehaviour:
|
||||
- {fileID: 247469677}
|
||||
- {fileID: 875086323}
|
||||
- {fileID: 896127049}
|
||||
- {fileID: 429754880}
|
||||
- {fileID: 1954289399}
|
||||
- {fileID: 1107252688}
|
||||
- {fileID: 1406544794}
|
||||
@ -18281,17 +18202,6 @@ 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
|
||||
@ -20388,26 +20298,6 @@ 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
|
||||
@ -20426,7 +20316,7 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 4
|
||||
value: 6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||
propertyPath: m_AnchorMax.x
|
||||
@ -22667,7 +22557,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5608193481571390226}
|
||||
- component: {fileID: 5608193481571390228}
|
||||
m_Layer: 5
|
||||
m_Name: GameOverPopup
|
||||
m_TagString: Untagged
|
||||
@ -22675,31 +22564,6 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &5608193481571390228
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5608193481571390227}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 178d988f5211b4ef5b8c2df230b708d4, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
popupScaleContent: {fileID: 5608193481571390226}
|
||||
zoomDuration: 0.5
|
||||
popupType: 5
|
||||
popupScalerType: 1
|
||||
canvasGroup: {fileID: 0}
|
||||
fadeDuration: 0
|
||||
playAgainBtn: {fileID: 5608193482985030359}
|
||||
mainMenuBtn: {fileID: 5608193483181475110}
|
||||
texts:
|
||||
- {fileID: 5608193483287721217}
|
||||
- {fileID: 28556636}
|
||||
- {fileID: 300136906}
|
||||
- {fileID: 1260155923}
|
||||
--- !u!1 &5608193481588389864
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -26201,7 +26065,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!222 &5608193482973815122
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -27412,7 +27276,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!222 &5608193483354237948
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -27564,7 +27428,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!222 &5608193483406443892
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -8,28 +7,11 @@ public enum GameModeType
|
||||
Bot,
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class PVPModeData
|
||||
{
|
||||
public List<PlayerType> types;
|
||||
public List<string> names;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class BotModeData
|
||||
{
|
||||
public PlayerData playerData;
|
||||
public int botCount;
|
||||
}
|
||||
|
||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
private PVPModeData pvpModeData;
|
||||
private BotModeData botModeData;
|
||||
|
||||
public GameModeType CurrentGameModeType
|
||||
public GameModeType GameModeType
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
@ -44,39 +26,15 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitPVPModeData(List<PlayerType> types, List<string> names)
|
||||
public void InitPVPModeData(List<PlayerType> types)
|
||||
{
|
||||
pvpModeData = new PVPModeData
|
||||
{
|
||||
types = types, names = names
|
||||
};
|
||||
|
||||
CurrentGameModeType = GameModeType.PVP;
|
||||
gameplayManager.InitPlayerTypesForPVP(types, names);
|
||||
GameModeType = GameModeType.PVP;
|
||||
gameplayManager.InitPlayerTypesForPVP(types);
|
||||
}
|
||||
|
||||
public void InitBotModeData(PlayerData playerData, int botCount)
|
||||
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
||||
{
|
||||
botModeData = new BotModeData
|
||||
{
|
||||
playerData = playerData,
|
||||
botCount = botCount
|
||||
};
|
||||
|
||||
CurrentGameModeType = GameModeType.Bot;
|
||||
gameplayManager.InitPlayerTypesForBotMatch(playerData, botCount);
|
||||
}
|
||||
|
||||
public void OnGameRestarted()
|
||||
{
|
||||
switch (CurrentGameModeType)
|
||||
{
|
||||
case GameModeType.PVP:
|
||||
InitPVPModeData(pvpModeData.types, pvpModeData.names);
|
||||
break;
|
||||
case GameModeType.Bot:
|
||||
InitBotModeData(botModeData.playerData, botModeData.botCount);
|
||||
break;
|
||||
}
|
||||
GameModeType = GameModeType.Bot;
|
||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,33 @@ using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public enum PlayerType
|
||||
{
|
||||
Player1 = 0,
|
||||
Player2 = 1,
|
||||
Player3 = 2,
|
||||
Player4 = 3
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerGameData
|
||||
{
|
||||
public PlayerType playerType;
|
||||
public int startIndex;
|
||||
public int endIndex;
|
||||
public Transform playersParent;
|
||||
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
||||
public int totalPawnsInHome = 0;
|
||||
public int totalPawnsFinished = 0;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public enum MatchType
|
||||
{
|
||||
PVP,
|
||||
Bot
|
||||
}
|
||||
|
||||
public enum BotMove
|
||||
{
|
||||
FinishingPathMove = 0,
|
||||
@ -32,18 +59,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private PlayerType currentPlayerTypeTurn;
|
||||
private int currentPlayerTurnIndex = 0;
|
||||
|
||||
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
||||
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
||||
|
||||
private List<PlayerData> playerDatas = new List<PlayerData>();
|
||||
private List<PlayerType> playerRankings = new List<PlayerType>();
|
||||
|
||||
|
||||
// private Dictionary<PlayerTypes, > playerPawnsDict = new Dictionary<PlayerTypes, List<PlayerPawn>>();
|
||||
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||
|
||||
// botRuntimeMovementData: where can the bot move if a particular dice value is thrown, and based on the value set the bot move for each using a predictive approach and select based on the the priority
|
||||
private Dictionary<PlayerType, Dictionary<int, BotMove>> botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||
|
||||
private TilesManager tilesManager;
|
||||
private GameManager gameManager;
|
||||
|
||||
private int diceRolledValue;
|
||||
|
||||
@ -57,13 +84,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public int TotalPlayersInGame
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public List<PlayerData> PlayerDatas => playerDatas;
|
||||
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
||||
|
||||
public void Initialize()
|
||||
@ -75,26 +95,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
|
||||
// InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
||||
InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 });
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
||||
// TODO :: Call when the UI selection is made and game starts
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
||||
{
|
||||
// TODO :: 2P, 3P, 4P
|
||||
allPlayerTypes = new List<PlayerType>(types);
|
||||
playerDatas.Clear();
|
||||
|
||||
TotalPlayersInGame = types.Count;
|
||||
|
||||
for (int i=0; i<types.Count; i++)
|
||||
{
|
||||
playerDatas.Add(new PlayerData
|
||||
{
|
||||
playerType = types[i],
|
||||
playerName = names[i],
|
||||
});
|
||||
}
|
||||
|
||||
tilesManager.InitTilesData();
|
||||
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
@ -102,46 +112,26 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||
{
|
||||
playerDatas = new List<PlayerData>();
|
||||
botTypesInGame = new List<PlayerType>();
|
||||
allPlayerTypes = new List<PlayerType>();
|
||||
botTypesInGame.Clear();
|
||||
allPlayerTypes.Clear();
|
||||
AssignBotTypes(selectedPlayerType, botCount);
|
||||
|
||||
TotalPlayersInGame = botCount + 1;
|
||||
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
||||
allPlayerTypes.Add(selectedPlayerType);
|
||||
allPlayerTypes.AddRange(botTypesInGame);
|
||||
|
||||
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
||||
{
|
||||
if (botTypesInGame.Contains(playerType))
|
||||
{
|
||||
allPlayerTypes.Add(playerType);
|
||||
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{playerType}" });
|
||||
}
|
||||
else if (selectedPlayerData.playerType == playerType)
|
||||
{
|
||||
allPlayerTypes.Add(selectedPlayerData.playerType);
|
||||
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{selectedPlayerData.playerName}" });
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var type in allPlayerTypes)
|
||||
Debug.Log($"allPlayerTypes ::: {type}");
|
||||
|
||||
tilesManager.InitTilesData();
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
InitBotRuntimeData();
|
||||
AssignPlayerAndBotStates(selectedPlayerData.playerType);
|
||||
AssignPlayerAndBotStates(selectedPlayerType);
|
||||
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(allPlayerTypes[0]));
|
||||
if (botTypesInGame.Contains(allPlayerTypes[0]))
|
||||
Invoke(nameof(HandleDiceRoll), 1f);
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
||||
}
|
||||
|
||||
private void InitBotRuntimeData()
|
||||
{
|
||||
botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||
botRuntimeMovementData.Clear();
|
||||
|
||||
foreach (var botType in botTypesInGame)
|
||||
{
|
||||
@ -208,15 +198,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||
|
||||
// initialize the board based on the player types
|
||||
playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||
|
||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||
{
|
||||
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
||||
continue;
|
||||
|
||||
Debug.Log($"playerGameData.playerType: {playerGameData.playerType}");
|
||||
|
||||
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new Dictionary<int, PlayerPawn>();
|
||||
|
||||
@ -453,7 +440,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
||||
diceRolledValue = rolledVal;
|
||||
diceText.text = $"{diceRolledValue}";
|
||||
availPlayers = new List<PlayerPawn>();
|
||||
availPlayers.Clear();
|
||||
|
||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||
{
|
||||
@ -926,8 +913,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
|
||||
{
|
||||
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
|
||||
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.MoveToTile(
|
||||
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
|
||||
onComplete: () =>
|
||||
@ -947,7 +932,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
Debug.Log($"CurrentTileIndex: {playerPawn.CurrentTileIndex} == lastIndex: {tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1}");
|
||||
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
||||
{
|
||||
@ -961,18 +945,17 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||
{
|
||||
playerRankings.Add(currentPlayerTypeTurn);
|
||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
}
|
||||
|
||||
if (allPlayerTypes.Count == 1)
|
||||
{
|
||||
// Game is over
|
||||
allPlayerTypes.RemoveAt(0);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
playerRankings.Add(allPlayerTypes[0]);
|
||||
allPlayerTypes.Remove(0);
|
||||
|
||||
// Show Game Over panel
|
||||
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -992,7 +975,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
// activate here
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
@ -1031,15 +1013,5 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
||||
}
|
||||
|
||||
public void ResetData()
|
||||
{
|
||||
playerDatas = null;
|
||||
botTypesInGame = null;
|
||||
allPlayerTypes = null;
|
||||
|
||||
botRuntimeMovementData = null;
|
||||
playerGameDatasDict = null;
|
||||
playerDatas = null;
|
||||
availPlayers = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ public class PlayerBase : MonoBehaviour
|
||||
{
|
||||
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
||||
{
|
||||
playerPawns[idx].Init(basePlacementDatas[idx], playerType);
|
||||
playerPawns[idx].Init(basePlacementDatas[idx].playerBaseId, playerType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,30 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum PlayerType
|
||||
{
|
||||
Player1 = 0,
|
||||
Player2 = 1,
|
||||
Player3 = 2,
|
||||
Player4 = 3
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerGameData
|
||||
{
|
||||
public PlayerType playerType;
|
||||
public int startIndex;
|
||||
public int endIndex;
|
||||
public Transform playersParent;
|
||||
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
||||
public int totalPawnsInHome = 0;
|
||||
public int totalPawnsFinished = 0;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerData
|
||||
{
|
||||
public PlayerType playerType;
|
||||
public string playerName;
|
||||
public int ranking = 0;
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9f4a588284ad4839bff99f31d6d402c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -135,12 +135,10 @@ public class PlayerPawn : MonoBehaviour
|
||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void Init(BasePlacementData basePlacementData, PlayerType playerType)
|
||||
public void Init(int id, PlayerType playerType)
|
||||
{
|
||||
PlayerId = basePlacementData.playerBaseId;
|
||||
PlayerId = id;
|
||||
PlayerType = playerType;
|
||||
|
||||
MoveBackToHome(basePlacementData.placementTransform);
|
||||
}
|
||||
|
||||
public void ShowPlayerCountCanvas(bool show)
|
||||
|
||||
@ -4,13 +4,11 @@ public enum GameState
|
||||
{
|
||||
InMenu,
|
||||
InGame,
|
||||
GameOver,
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private UIManager uiManager;
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameState GameState
|
||||
{
|
||||
@ -25,26 +23,21 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
|
||||
OnGameStateChanged(GameState.InMenu);
|
||||
GameState = GameState.InMenu;
|
||||
OnGameStateChanged(GameState);
|
||||
}
|
||||
|
||||
public void OnGameStateChanged(GameState gameState)
|
||||
{
|
||||
GameState = gameState;
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.InMenu:
|
||||
gameplayManager.ResetData();
|
||||
uiManager.OnInMenuScreen();
|
||||
break;
|
||||
case GameState.InGame:
|
||||
uiManager.OnInGameScreen();
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
uiManager.OnGameOver();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,10 +28,7 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitTilesData()
|
||||
{
|
||||
foreach (var tileData in tileDatas)
|
||||
{
|
||||
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
||||
|
||||
@ -6,7 +6,6 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
private ScreenManager screenManager;
|
||||
private PopupManager popupManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@ -16,7 +15,6 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
||||
}
|
||||
|
||||
public void OnDiceViewInteracted()
|
||||
@ -37,9 +35,8 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||
}
|
||||
|
||||
public void OnGameOver()
|
||||
public void UpdateSelectedPlayerCount(int playersCount)
|
||||
{
|
||||
popupManager.GetPopup<GameOverPopup>(PopupType.GameOverPopup).InitData(gameplayManager.PlayerDatas);
|
||||
popupManager.ShowPopup(PopupType.GameOverPopup);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,7 @@ public enum PopupType
|
||||
PvAIModePopup,
|
||||
OptionsPopup,
|
||||
InstructionsPopup,
|
||||
PauseMenuPopup,
|
||||
GameOverPopup
|
||||
PauseMenuPopup
|
||||
}
|
||||
|
||||
public enum PopupScalerType
|
||||
|
||||
@ -1,64 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameOverPopup : PopupBase
|
||||
{
|
||||
[SerializeField] private Button playAgainBtn;
|
||||
[SerializeField] private Button mainMenuBtn;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI[] texts;
|
||||
|
||||
private GameModeHandler gameModeHandler;
|
||||
private ScreenManager screenManager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
||||
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
playAgainBtn.onClick.RemoveAllListeners();
|
||||
mainMenuBtn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
public void OnPlayAgainClicked()
|
||||
{
|
||||
HidePopup();
|
||||
|
||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||
gameModeHandler.OnGameRestarted();
|
||||
}
|
||||
|
||||
private void HidePopup()
|
||||
{
|
||||
popupManager = popupManager == null ? InterfaceManager.Instance.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||
popupManager.HidePopup(popupType);
|
||||
}
|
||||
|
||||
public void OnMainMenuClicked()
|
||||
{
|
||||
HidePopup();
|
||||
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
}
|
||||
|
||||
public void InitData(List<PlayerData> playerDatas)
|
||||
{
|
||||
for (int i = 0; i < playerDatas.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
texts[i].text = $"{playerDatas[i].playerName} Wins";
|
||||
continue;
|
||||
}
|
||||
|
||||
texts[i].text = $"{(i+1)}. {playerDatas[i].playerName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 178d988f5211b4ef5b8c2df230b708d4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,13 +1,9 @@
|
||||
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,33 +29,24 @@ public class PvAIModePopup : PopupBase
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
private GameManager gameManager;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
private PlayerType playerType;
|
||||
|
||||
private Button currPlayerCountBtn, prevPlayerCountBtn;
|
||||
private Button currPlayerTypeBtn, prePlayerTypeBtn;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2, twoPlayerBtn));
|
||||
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3, threePlayerBtn));
|
||||
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4, fourPlayerBtn));
|
||||
|
||||
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
|
||||
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
|
||||
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
|
||||
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.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);
|
||||
OnColorSelected(PlayerType.Player1, redBtn);
|
||||
redBtn.Select();
|
||||
twoPlayerBtn.Select();
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -67,29 +54,12 @@ public class PvAIModePopup : PopupBase
|
||||
twoPlayerBtn.onClick.RemoveAllListeners();
|
||||
threePlayerBtn.onClick.RemoveAllListeners();
|
||||
fourPlayerBtn.onClick.RemoveAllListeners();
|
||||
|
||||
playBtn.onClick.RemoveAllListeners();
|
||||
closeBtn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
private void OnPlayerCountSelected(int count, Button button)
|
||||
private void OnPlayerCountSelected(int count)
|
||||
{
|
||||
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()
|
||||
@ -104,13 +74,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(new PlayerData{ playerType = playerType, playerName = playerName }, selectedPlayerCount - 1);
|
||||
|
||||
gameManager = gameManager == null ? InterfaceManager.Instance.GetInterfaceInstance<GameManager>() : gameManager;
|
||||
gameManager.OnGameStateChanged(GameState.InGame);
|
||||
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
|
||||
}
|
||||
|
||||
private void OnClick_CloseButton()
|
||||
@ -123,23 +88,8 @@ public class PvAIModePopup : PopupBase
|
||||
Hide();
|
||||
}
|
||||
|
||||
private void OnColorSelected(PlayerType type, Button button)
|
||||
public void OnColorSelected(PlayerType type)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@ -20,6 +19,12 @@ 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;
|
||||
@ -29,13 +34,6 @@ 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;
|
||||
@ -45,23 +43,19 @@ public class PvPModePopup : PopupBase
|
||||
public int SelectedPlayerCount => selectedPlayerCount;
|
||||
|
||||
[Header("Horizontal Rows (P1–P4)")]
|
||||
|
||||
public List<GameObject> rows;
|
||||
private int hiddenIndex = 0;
|
||||
|
||||
private List<int> hiddenIndexes = new List<int>();
|
||||
private Dictionary<PlayerType, string> playerNameMap = new();
|
||||
|
||||
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_PlayButton);
|
||||
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
||||
|
||||
switchBtn.onClick.AddListener(OnClick_SwitchButton);
|
||||
playBtn.onClick.AddListener(OnClick_PlayBtn);
|
||||
closeBtn.onClick.AddListener(OnClick_CloseBtn);
|
||||
switchBtn.onClick.AddListener(OnClick_SwitchBtn);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@ -74,44 +68,33 @@ public class PvPModePopup : PopupBase
|
||||
twoPlayerBtn.onClick.RemoveListener(OnClick_TwoPlayerBtn);
|
||||
threePlayerBtn.onClick.RemoveListener(OnClick_ThreePlayerBtn);
|
||||
fourPlayerBtn.onClick.RemoveAllListeners();
|
||||
|
||||
playBtn.onClick.RemoveListener(OnClick_PlayButton);
|
||||
closeBtn.onClick.RemoveListener(OnClick_CloseButton);
|
||||
|
||||
switchBtn.onClick.RemoveListener(OnClick_SwitchButton);
|
||||
playBtn.onClick.RemoveListener(OnClick_PlayBtn);
|
||||
closeBtn.onClick.RemoveListener(OnClick_CloseBtn);
|
||||
switchBtn.onClick.RemoveListener(OnClick_SwitchBtn);
|
||||
}
|
||||
|
||||
private void OnClick_TwoPlayerBtn()
|
||||
{
|
||||
selectedPlayerCount = 2;
|
||||
|
||||
OnPlayerCountsSwitched();
|
||||
|
||||
switchBtn.gameObject.SetActive(true);
|
||||
selectedPlayerCount = 2;
|
||||
playerNameInputParent2.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnClick_ThreePlayerBtn()
|
||||
{
|
||||
selectedPlayerCount = 3;
|
||||
|
||||
OnPlayerCountsSwitched();
|
||||
|
||||
switchBtn.gameObject.SetActive(true);
|
||||
selectedPlayerCount = 3;
|
||||
playerNameInputParent1.SetActive(true);
|
||||
playerNameInputParent2.SetActive(true);
|
||||
|
||||
UpdateInputFieldsVisibility();
|
||||
}
|
||||
|
||||
private void OnClick_FourPlayerBtn()
|
||||
{
|
||||
selectedPlayerCount = 4;
|
||||
|
||||
switchBtn.gameObject.SetActive(false);
|
||||
selectedPlayerCount = 4;
|
||||
playerNameInputParent1.SetActive(true);
|
||||
playerNameInputParent2.SetActive(true);
|
||||
|
||||
UpdateInputFieldsVisibility();
|
||||
}
|
||||
|
||||
@ -123,51 +106,84 @@ public class PvPModePopup : PopupBase
|
||||
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
|
||||
}
|
||||
|
||||
private void OnClick_PlayButton()
|
||||
private void OnClick_PlayBtn()
|
||||
{
|
||||
playerNameMap.Clear();
|
||||
for (int idx = 0; idx < inputFields.Count; idx++)
|
||||
{
|
||||
PlayerType playerType = (PlayerType)idx;
|
||||
if (!inputFields[idx].transform.parent.gameObject.activeInHierarchy)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
int logicalIndex = 0;
|
||||
|
||||
playerNameMap.Add(playerType, string.IsNullOrWhiteSpace(inputFields[idx].text) ? $"{playerType}" : inputFields[idx].text);
|
||||
foreach (GameObject row in rows)
|
||||
{
|
||||
if (!row.activeSelf)
|
||||
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++;
|
||||
}
|
||||
|
||||
// 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}");
|
||||
|
||||
popupManager.HidePopup(popupType);
|
||||
if (selectedPlayerCount >= 3)
|
||||
Debug.Log($"Player 3: {playerThreeName}");
|
||||
if (selectedPlayerCount == 4)
|
||||
Debug.Log($"Player 4: {playerFourName}");
|
||||
|
||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList(), playerNameMap.Values.ToList());
|
||||
InitPlayers();
|
||||
}
|
||||
|
||||
private void OnClick_SwitchButton()
|
||||
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);
|
||||
|
||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||
gameModeHandler.InitPVPModeData(playerTypes);
|
||||
}
|
||||
|
||||
private void OnClick_SwitchBtn()
|
||||
{
|
||||
hiddenIndexes.Clear();
|
||||
if (SelectedPlayerCount == 2)
|
||||
{
|
||||
if (playerNameInputParent1.activeInHierarchy)
|
||||
if (playerNameInputParent1.activeSelf)
|
||||
{
|
||||
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
|
||||
{
|
||||
@ -175,63 +191,30 @@ 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) % inputFields.Count;
|
||||
hiddenIndexes.Add(hiddenIndex);
|
||||
hiddenIndex = (hiddenIndex + 1) % rows.Count;
|
||||
UpdateRows();
|
||||
}
|
||||
|
||||
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 < inputFields.Count; i++)
|
||||
for (int i = 0; i < rows.Count; i++)
|
||||
{
|
||||
bool isHidden = hiddenIndexes.Contains(i);
|
||||
inputFields[i].transform.parent.gameObject.SetActive(!isHidden);
|
||||
bool isHidden = (i == hiddenIndex);
|
||||
rows[i].SetActive(!isHidden);
|
||||
|
||||
if (!isHidden)
|
||||
{
|
||||
TMP_Text placeholder = inputFields[i].placeholder as TMP_Text;
|
||||
TMP_InputField input =
|
||||
rows[i].GetComponentInChildren<TMP_InputField>();
|
||||
|
||||
TMP_Text placeholder = input.placeholder as TMP_Text;
|
||||
if (placeholder != null)
|
||||
{
|
||||
placeholder.text = $"Player {visiblePlayerIndex}";
|
||||
@ -241,7 +224,7 @@ public class PvPModePopup : PopupBase
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClick_CloseButton()
|
||||
private void OnClick_CloseBtn()
|
||||
{
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user