Compare commits
No commits in common. "c42db86e28b16de1fa21765c25e100ad93fea45e" and "224c29f19d3fb549ee341ef399dd394c07a507f3" have entirely different histories.
c42db86e28
...
224c29f19d
Binary file not shown.
|
Before Width: | Height: | Size: 77 KiB |
@ -1,147 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 34e3d7c5f315b46f9b3481e3ea797ffe
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 12
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 0
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMasterTextureLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 1
|
|
||||||
wrapV: 1
|
|
||||||
wrapW: 0
|
|
||||||
nPOTScale: 0
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 1
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 1
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 1
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 8
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: iPhone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: WebGL
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Android
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID: 5e97eb03825dee720800000000000000
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
spritePackingTag:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
pSDShowRemoveMatteOption: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,8 +1,7 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class DiceView : MonoBehaviour, IBase
|
public class Dice : MonoBehaviour, IBase, IBootLoader
|
||||||
{
|
{
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
private bool rolling;
|
private bool rolling;
|
||||||
@ -16,49 +15,48 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
[SerializeField] private float liftForce = 0.1f;
|
[SerializeField] private float liftForce = 0.1f;
|
||||||
|
|
||||||
|
|
||||||
private Action<int> onRollingComplete = null;
|
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
rb = GetComponent<Rigidbody>();
|
rb = GetComponent<Rigidbody>();
|
||||||
rb.useGravity = false;
|
rb.useGravity = false;
|
||||||
|
}
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
InterfaceManager.Instance?.RegisterInterface<Dice>(this);
|
||||||
transform.localPosition = new Vector3(0, 20, 0);
|
transform.localPosition = new Vector3(0, 20, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Roll(Action<int> onComplete)
|
public void Roll()
|
||||||
{
|
{
|
||||||
if (!rolling)
|
if (!rolling)
|
||||||
{
|
|
||||||
onRollingComplete = onComplete;
|
|
||||||
StartCoroutine(RollRoutine());
|
StartCoroutine(RollRoutine());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator RollRoutine()
|
IEnumerator RollRoutine()
|
||||||
{
|
{
|
||||||
rolling = true;
|
rolling = true;
|
||||||
|
|
||||||
// MICRO DELAY → breaks physics sync between dice
|
// MICRO DELAY → breaks physics sync between dice
|
||||||
yield return new WaitForSeconds(UnityEngine.Random.Range(0.01f, 0.06f));
|
yield return new WaitForSeconds(Random.Range(0.01f, 0.06f));
|
||||||
|
|
||||||
rb.useGravity = true;
|
rb.useGravity = true;
|
||||||
|
|
||||||
// PER-DICE FORCE MULTIPLIER
|
// PER-DICE FORCE MULTIPLIER
|
||||||
float spinMultiplier = UnityEngine.Random.Range(0.8f, 1.25f);
|
float spinMultiplier = Random.Range(0.8f, 1.25f);
|
||||||
|
|
||||||
// RANDOM TORQUE
|
// RANDOM TORQUE
|
||||||
rb.AddTorque(
|
rb.AddTorque(
|
||||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||||
ForceMode.Impulse
|
ForceMode.Impulse
|
||||||
);
|
);
|
||||||
|
|
||||||
// RANDOM SIDE FORCE
|
// RANDOM SIDE FORCE
|
||||||
Vector3 sideDir = new Vector3(
|
Vector3 sideDir = new Vector3(
|
||||||
UnityEngine.Random.Range(-1f, 1f),
|
Random.Range(-1f, 1f),
|
||||||
0f,
|
0f,
|
||||||
UnityEngine.Random.Range(-1f, 1f)
|
Random.Range(-1f, 1f)
|
||||||
).normalized;
|
).normalized;
|
||||||
|
|
||||||
rb.AddForce(sideDir * sideForce, ForceMode.Impulse);
|
rb.AddForce(sideDir * sideForce, ForceMode.Impulse);
|
||||||
@ -73,8 +71,6 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
//TODO: Use the dice value as needed
|
//TODO: Use the dice value as needed
|
||||||
Debug.Log($"Dice rolled: {value}");
|
Debug.Log($"Dice rolled: {value}");
|
||||||
|
|
||||||
onRollingComplete?.Invoke(value);
|
|
||||||
|
|
||||||
ResetDice();
|
ResetDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,18 +237,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_Layer
|
propertyPath: m_Layer
|
||||||
value: 3
|
value: 3
|
||||||
objectReference: {fileID: 0}
|
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}
|
- target: {fileID: 1804238606659730489, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 0
|
value: 0
|
||||||
|
|||||||
12156
Assets/Prefabs/UI/Canvas.prefab
Normal file
12156
Assets/Prefabs/UI/Canvas.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: b04f48863fc6c4f75821857086cea347
|
guid: a0f4457742bfd4c61bd436792af64064
|
||||||
PrefabImporter:
|
PrefabImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
userData:
|
userData:
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
15974
Assets/Scenes/Game.unity
15974
Assets/Scenes/Game.unity
File diff suppressed because it is too large
Load Diff
@ -5,9 +5,4 @@ using UnityEngine;
|
|||||||
public static class Ludo_3D_Constants
|
public static class Ludo_3D_Constants
|
||||||
{
|
{
|
||||||
public const int Max_Dice_Rolls = 6;
|
public const int Max_Dice_Rolls = 6;
|
||||||
|
|
||||||
public const string Player1_Name = "Player1";
|
|
||||||
public const string Player2_Name = "Player2";
|
|
||||||
public const string Player3_Name = "Player3";
|
|
||||||
public const string Player4_Name = "Player4";
|
|
||||||
}
|
}
|
||||||
@ -1,40 +0,0 @@
|
|||||||
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<GameModeHandler>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeData()
|
|
||||||
{
|
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitPVPModeData(List<PlayerType> types)
|
|
||||||
{
|
|
||||||
GameModeType = GameModeType.PVP;
|
|
||||||
gameplayManager.InitPlayerTypesForPVP(types);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
|
||||||
{
|
|
||||||
GameModeType = GameModeType.Bot;
|
|
||||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 2d8a94cfc31bb45f9a403db0c1f4c116
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -43,8 +43,6 @@ public enum BotMove
|
|||||||
|
|
||||||
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
[SerializeField] DiceRollHandler diceRollHandler;
|
|
||||||
|
|
||||||
[SerializeField] private int diceValue = 0;
|
[SerializeField] private int diceValue = 0;
|
||||||
|
|
||||||
[SerializeField] private TextMeshProUGUI diceText;
|
[SerializeField] private TextMeshProUGUI diceText;
|
||||||
@ -61,8 +59,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
private int currentPlayerTurnIndex = 0;
|
private int currentPlayerTurnIndex = 0;
|
||||||
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
||||||
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
||||||
private List<PlayerType> playerRankings = new List<PlayerType>();
|
|
||||||
|
|
||||||
|
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
||||||
|
|
||||||
// private Dictionary<PlayerTypes, > playerPawnsDict = new Dictionary<PlayerTypes, List<PlayerPawn>>();
|
// private Dictionary<PlayerTypes, > playerPawnsDict = new Dictionary<PlayerTypes, List<PlayerPawn>>();
|
||||||
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||||
@ -73,18 +71,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
private TilesManager tilesManager;
|
private TilesManager tilesManager;
|
||||||
|
|
||||||
private int diceRolledValue;
|
private int diceRolledValue;
|
||||||
|
public bool CanRollDice
|
||||||
private bool CanRollDiceAgain = false; // used for when you get a 6 or when you reach the finish point
|
|
||||||
private int diceSixRollCounter = 0;
|
|
||||||
|
|
||||||
private List<PlayerPawn> availPlayers = new List<PlayerPawn>();
|
|
||||||
private bool canSwitchPlayer = false;
|
|
||||||
|
|
||||||
public bool CanRollDiceForUser
|
|
||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
|
||||||
|
private bool CanRollDiceAgain = false; // used for when you get a 6 or when you reach the finish point
|
||||||
|
private int diceSixRollCounter = 0;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
@ -96,16 +89,20 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
|
|
||||||
CanRollDiceForUser = true;
|
CanRollDice = true;
|
||||||
|
|
||||||
|
// initialize the player list from UI.
|
||||||
|
|
||||||
|
// InitPlayerTypesForLAN(null);
|
||||||
InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO :: Call when the UI selection is made and game starts
|
// TODO :: Call when the UI selection is made and game starts
|
||||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
public void InitPlayerTypesForLAN(List<PlayerType> types)
|
||||||
{
|
{
|
||||||
// TODO :: 2P, 3P, 4P
|
// TODO :: 2P, 3P, 4P
|
||||||
allPlayerTypes = new List<PlayerType>(types);
|
allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 };
|
||||||
|
// allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player3 };
|
||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
@ -226,13 +223,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDiceInteracted()
|
|
||||||
{
|
|
||||||
diceRollHandler.HandleDiceViewForUser();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void RollDiceForPlayer(int rolledVal)
|
public void RollDiceForPlayer(int rolledVal)
|
||||||
{
|
{
|
||||||
|
if (botTypesInGame.Contains(currentPlayerTypeTurn)) return;
|
||||||
|
|
||||||
OnDiceRolled(rolledVal);
|
OnDiceRolled(rolledVal);
|
||||||
OnNoMovesLeft();
|
OnNoMovesLeft();
|
||||||
}
|
}
|
||||||
@ -260,12 +254,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RollDiceForBot(int rolledVal)
|
private void RollDiceForBot()
|
||||||
{
|
{
|
||||||
Debug.Log($"CallTest: RollDiceForBot");
|
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);
|
OnDiceRolled(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||||
|
|
||||||
SelectPawnFromBotBase();
|
SelectPawnFromBotBase();
|
||||||
|
|
||||||
@ -426,6 +420,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<PlayerPawn> availPlayers = new List<PlayerPawn>();
|
||||||
|
private bool canSwitchPlayer = false;
|
||||||
|
|
||||||
public void OnDiceRolled(int rolledVal)
|
public void OnDiceRolled(int rolledVal)
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(false);
|
SetCanRollDiceForUser(false);
|
||||||
@ -545,14 +542,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
||||||
{
|
{
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
{
|
RollDiceForBot();
|
||||||
HandleDiceRoll();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleDiceRoll()
|
|
||||||
{
|
|
||||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||||
@ -696,7 +686,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
if (botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||||
{
|
{
|
||||||
Debug.Log($"Invoking RollDiceForBot");
|
Debug.Log($"Invoking RollDiceForBot");
|
||||||
Invoke(nameof(HandleDiceRoll), 1f);
|
Invoke(nameof(RollDiceForBot), 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -900,21 +890,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CanRollDiceAgain = false;
|
CanRollDiceAgain = false;
|
||||||
|
|
||||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||||
{
|
|
||||||
playerRankings.Add(currentPlayerTypeTurn);
|
|
||||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||||
}
|
|
||||||
|
|
||||||
if (allPlayerTypes.Count == 1)
|
|
||||||
{
|
|
||||||
// Game is over
|
|
||||||
playerRankings.Add(allPlayerTypes[0]);
|
|
||||||
allPlayerTypes.Remove(0);
|
|
||||||
|
|
||||||
// Show Game Over panel
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
|
|
||||||
@ -948,6 +924,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
// if (botTypesInGame.Contains(playerType)) return;
|
// if (botTypesInGame.Contains(playerType)) return;
|
||||||
|
|
||||||
CanRollDiceForUser = state;
|
CanRollDice = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -104,7 +104,6 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
// when he is defeated
|
// when he is defeated
|
||||||
public void MoveBackToHome(Transform transformData)
|
public void MoveBackToHome(Transform transformData)
|
||||||
{
|
{
|
||||||
Debug.Log($"MoveBackToHome");
|
|
||||||
transform.position = transformData.position;
|
transform.position = transformData.position;
|
||||||
transform.rotation = transformData.rotation;
|
transform.rotation = transformData.rotation;
|
||||||
SetPlayerState(PlayerState.InHome);
|
SetPlayerState(PlayerState.InHome);
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class DiceRollHandler : MonoBehaviour
|
public class DiceRoller : MonoBehaviour
|
||||||
{
|
{
|
||||||
[SerializeField] private DiceView diceView;
|
|
||||||
[SerializeField] private int diceTestValue = 0;
|
[SerializeField] private int diceTestValue = 0;
|
||||||
|
|
||||||
private InputManager inputManager;
|
private InputManager inputManager;
|
||||||
@ -13,32 +11,27 @@ public class DiceRollHandler : MonoBehaviour
|
|||||||
private void OnMouseDown()
|
private void OnMouseDown()
|
||||||
{
|
{
|
||||||
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
||||||
|
if (!inputManager.GameplayManager.CanRollDice) return;
|
||||||
|
|
||||||
// RollDiceOnClick();
|
OnDiceRolled();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
||||||
|
if (!inputManager.GameplayManager.CanRollDice) return;
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.Space))
|
||||||
|
OnDiceRolled();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUserDiceRollComplete(int rolledVal)
|
private void OnDiceRolled()
|
||||||
{
|
{
|
||||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||||
|
|
||||||
inputManager.SetDiceRollValue(rolledVal);
|
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);
|
||||||
public void HandleDiceViewForUser()
|
|
||||||
{
|
|
||||||
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
|
||||||
|
|
||||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
|
||||||
{
|
|
||||||
diceView.Roll(onComplete: onComplete);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: a7e3406fc0f8a4b3abf3913c7655f3f1
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public enum GameState
|
|
||||||
{
|
|
||||||
InMenu,
|
|
||||||
InGame,
|
|
||||||
}
|
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
||||||
{
|
|
||||||
private UIManager uiManager;
|
|
||||||
|
|
||||||
public GameState GameState
|
|
||||||
{
|
|
||||||
get; private set;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Initialize()
|
|
||||||
{
|
|
||||||
InterfaceManager.Instance.RegisterInterface<GameManager>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeData()
|
|
||||||
{
|
|
||||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
|
||||||
|
|
||||||
GameState = GameState.InMenu;
|
|
||||||
OnGameStateChanged(GameState);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnGameStateChanged(GameState gameState)
|
|
||||||
{
|
|
||||||
switch (gameState)
|
|
||||||
{
|
|
||||||
case GameState.InMenu:
|
|
||||||
uiManager.OnInMenuScreen();
|
|
||||||
break;
|
|
||||||
case GameState.InGame:
|
|
||||||
uiManager.OnInGameScreen();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 39da8f399f9774587bd1d0c7977e556b
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -57,12 +57,6 @@ public class ScreenManager : MonoBehaviour, IBase, IBootLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HideAllScreens()
|
|
||||||
{
|
|
||||||
foreach (var screenPair in screensDict)
|
|
||||||
if (screenPair.Value.isActiveAndEnabled) screenPair.Value.Hide();
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void OnScreenEventExecute(ScreenResultEvent screenResultEvent)
|
// public void OnScreenEventExecute(ScreenResultEvent screenResultEvent)
|
||||||
// {
|
// {
|
||||||
// switch (screenResultEvent)
|
// switch (screenResultEvent)
|
||||||
|
|||||||
@ -1,42 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
||||||
{
|
|
||||||
private GameplayManager gameplayManager;
|
|
||||||
private ScreenManager screenManager;
|
|
||||||
|
|
||||||
public void Initialize()
|
|
||||||
{
|
|
||||||
InterfaceManager.Instance.RegisterInterface<UIManager>(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InitializeData()
|
|
||||||
{
|
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnDiceViewInteracted()
|
|
||||||
{
|
|
||||||
gameplayManager.OnDiceInteracted();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInMenuScreen()
|
|
||||||
{
|
|
||||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
|
||||||
screenManager.HideAllScreens();
|
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnInGameScreen()
|
|
||||||
{
|
|
||||||
screenManager.HideAllScreens();
|
|
||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateSelectedPlayerCount(int playersCount)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: bebcbb45c745a4006be9ef5b25e12cd5
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -10,7 +10,8 @@ public enum ScreenType
|
|||||||
LoadingScreen,
|
LoadingScreen,
|
||||||
LevelsScreen,
|
LevelsScreen,
|
||||||
InGameHUDScreen,
|
InGameHUDScreen,
|
||||||
MenuScreen,
|
MenuHUDScreen,
|
||||||
|
GlobalHUDScreen
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ScreenBase : UIBase, IUIBase
|
public class ScreenBase : UIBase, IUIBase
|
||||||
|
|||||||
@ -21,7 +21,7 @@ public class InstructionsPopup : PopupBase
|
|||||||
private void OnClick_closeBtn()
|
private void OnClick_closeBtn()
|
||||||
{
|
{
|
||||||
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
|
|||||||
@ -29,7 +29,7 @@ public class OptionsPopup : PopupBase
|
|||||||
private void OnClick_closeBtn()
|
private void OnClick_closeBtn()
|
||||||
{
|
{
|
||||||
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
ScreenManager screenManager = InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>();
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||||
|
|
||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,18 +20,16 @@ public class PvAIModePopup : PopupBase
|
|||||||
|
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private GameModeHandler gameModeHandler;
|
|
||||||
|
|
||||||
private int selectedPlayerCount;
|
private int selectedPlayerCount;
|
||||||
private PlayerType playerType;
|
public int SelectedPlayerCount => selectedPlayerCount;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
|
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
|
||||||
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
|
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
|
||||||
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
|
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
|
||||||
playBtn.onClick.AddListener(OnClick_PlayButton);
|
playBtn.onClick.AddListener(OnClick_playBtn);
|
||||||
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
closeBtn.onClick.AddListener(OnClick_closeBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
@ -47,9 +45,9 @@ public class PvAIModePopup : PopupBase
|
|||||||
selectedPlayerCount = count;
|
selectedPlayerCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_PlayButton()
|
private void OnClick_playBtn()
|
||||||
{
|
{
|
||||||
playerName = string.IsNullOrWhiteSpace(playerNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerNameInput.text;
|
playerName = playerNameInput.text;
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
@ -59,14 +57,11 @@ public class PvAIModePopup : PopupBase
|
|||||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||||
Debug.Log($"Player 1: {playerName}");
|
Debug.Log($"Player 1: {playerName}");
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
|
||||||
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
|
|
||||||
}
|
}
|
||||||
|
private void OnClick_closeBtn()
|
||||||
private void OnClick_CloseButton()
|
|
||||||
{
|
{
|
||||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
|
|||||||
@ -1,232 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class PvPModePopup : PopupBase
|
|
||||||
{
|
|
||||||
[Header("Buttons")]
|
|
||||||
[SerializeField] private Button twoPlayerBtn;
|
|
||||||
[SerializeField] private Button threePlayerBtn;
|
|
||||||
[SerializeField] private Button fourPlayerBtn;
|
|
||||||
[SerializeField] private Button switchBtn;
|
|
||||||
[SerializeField] private Button playBtn;
|
|
||||||
[SerializeField] private Button closeBtn;
|
|
||||||
|
|
||||||
[Header("Input Field")]
|
|
||||||
[SerializeField] private TMP_InputField playerOneNameInput;
|
|
||||||
[SerializeField] private TMP_InputField playerTwoNameInput;
|
|
||||||
[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;
|
|
||||||
|
|
||||||
[Header("Placeholders")]
|
|
||||||
[SerializeField] private TMP_Text playerOnePlaceholder;
|
|
||||||
[SerializeField] private TMP_Text playerTwoPlaceholder;
|
|
||||||
[SerializeField] private TMP_Text playerThreePlaceholder;
|
|
||||||
[SerializeField] private TMP_Text playerFourPlaceholder;
|
|
||||||
|
|
||||||
private ScreenManager screenManager;
|
|
||||||
private SoundManager soundManager;
|
|
||||||
private GameModeHandler gameModeHandler;
|
|
||||||
|
|
||||||
private int selectedPlayerCount;
|
|
||||||
public int SelectedPlayerCount => selectedPlayerCount;
|
|
||||||
|
|
||||||
[Header("Horizontal Rows (P1–P4)")]
|
|
||||||
public List<GameObject> rows;
|
|
||||||
private int hiddenIndex = 0;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_TwoPlayerBtn()
|
|
||||||
{
|
|
||||||
switchBtn.gameObject.SetActive(true);
|
|
||||||
selectedPlayerCount = 2;
|
|
||||||
playerNameInputParent2.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_ThreePlayerBtn()
|
|
||||||
{
|
|
||||||
switchBtn.gameObject.SetActive(true);
|
|
||||||
selectedPlayerCount = 3;
|
|
||||||
playerNameInputParent1.SetActive(true);
|
|
||||||
playerNameInputParent2.SetActive(true);
|
|
||||||
UpdateInputFieldsVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_FourPlayerBtn()
|
|
||||||
{
|
|
||||||
switchBtn.gameObject.SetActive(false);
|
|
||||||
selectedPlayerCount = 4;
|
|
||||||
playerNameInputParent1.SetActive(true);
|
|
||||||
playerNameInputParent2.SetActive(true);
|
|
||||||
UpdateInputFieldsVisibility();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateInputFieldsVisibility()
|
|
||||||
{
|
|
||||||
playerOneNameInput.transform.parent.gameObject.SetActive(true);
|
|
||||||
playerTwoNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 3);
|
|
||||||
playerThreeNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 2);
|
|
||||||
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_PlayBtn()
|
|
||||||
{
|
|
||||||
int logicalIndex = 0;
|
|
||||||
|
|
||||||
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}");
|
|
||||||
|
|
||||||
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);
|
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
|
||||||
gameModeHandler.InitPVPModeData(playerTypes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_SwitchBtn()
|
|
||||||
{
|
|
||||||
if (SelectedPlayerCount == 2)
|
|
||||||
{
|
|
||||||
if (playerNameInputParent1.activeSelf)
|
|
||||||
{
|
|
||||||
playerNameInputParent1.SetActive(false);
|
|
||||||
playerNameInputParent2.SetActive(true);
|
|
||||||
playerOnePlaceholder.text = "Player 1";
|
|
||||||
playerThreePlaceholder.text = "Player 2";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
playerNameInputParent1.SetActive(true);
|
|
||||||
playerNameInputParent2.SetActive(false);
|
|
||||||
playerTwoPlaceholder.text = "Player 1";
|
|
||||||
playerFourPlaceholder.text = "Player 2";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (SelectedPlayerCount == 3)
|
|
||||||
{
|
|
||||||
hiddenIndex = (hiddenIndex + 1) % rows.Count;
|
|
||||||
UpdateRows();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateRows()
|
|
||||||
{
|
|
||||||
int visiblePlayerIndex = 1;
|
|
||||||
|
|
||||||
for (int i = 0; i < rows.Count; i++)
|
|
||||||
{
|
|
||||||
bool isHidden = (i == hiddenIndex);
|
|
||||||
rows[i].SetActive(!isHidden);
|
|
||||||
|
|
||||||
if (!isHidden)
|
|
||||||
{
|
|
||||||
TMP_InputField input =
|
|
||||||
rows[i].GetComponentInChildren<TMP_InputField>();
|
|
||||||
|
|
||||||
TMP_Text placeholder = input.placeholder as TMP_Text;
|
|
||||||
if (placeholder != null)
|
|
||||||
{
|
|
||||||
placeholder.text = $"Player {visiblePlayerIndex}";
|
|
||||||
visiblePlayerIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnClick_CloseBtn()
|
|
||||||
{
|
|
||||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
|
||||||
|
|
||||||
Hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -12,19 +12,18 @@ public class GameHUDS : ScreenBase
|
|||||||
[SerializeField] private TMP_Text diceCountText;
|
[SerializeField] private TMP_Text diceCountText;
|
||||||
[SerializeField] private TMP_Text playerTurnText;
|
[SerializeField] private TMP_Text playerTurnText;
|
||||||
|
|
||||||
private SoundManager soundManager;
|
SoundManager soundManager;
|
||||||
private UIManager uiManager;
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
pauseBtn.onClick.AddListener(OnClick_pauseBtn);
|
pauseBtn.onClick.AddListener(OnClick_pauseBtn);
|
||||||
diceBtn.onClick.AddListener(OnClick_DiceBtn);
|
diceBtn.onClick.AddListener(OnClick_diceBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
{
|
{
|
||||||
pauseBtn.onClick.RemoveListener(OnClick_pauseBtn);
|
pauseBtn.onClick.RemoveListener(OnClick_pauseBtn);
|
||||||
diceBtn.onClick.RemoveListener(OnClick_DiceBtn);
|
diceBtn.onClick.RemoveListener(OnClick_diceBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_pauseBtn()
|
private void OnClick_pauseBtn()
|
||||||
@ -38,9 +37,9 @@ public class GameHUDS : ScreenBase
|
|||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_DiceBtn()
|
private void OnClick_diceBtn()
|
||||||
{
|
{
|
||||||
uiManager = uiManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<UIManager>() : uiManager;
|
Dice dice = InterfaceManager.Instance?.GetInterfaceInstance<Dice>();
|
||||||
uiManager.OnDiceViewInteracted();
|
dice?.Roll();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
93
Assets/Scripts/UI/Pages/Screens/PVPModePopup.cs
Normal file
93
Assets/Scripts/UI/Pages/Screens/PVPModePopup.cs
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class PvPModePopup : PopupBase
|
||||||
|
{
|
||||||
|
[Header("Buttons")]
|
||||||
|
[SerializeField] private Button twoPlayerBtn;
|
||||||
|
[SerializeField] private Button threePlayerBtn;
|
||||||
|
[SerializeField] private Button fourPlayerBtn;
|
||||||
|
[SerializeField] private Button playBtn;
|
||||||
|
[SerializeField] private Button closeBtn;
|
||||||
|
|
||||||
|
[Header("Input Field")]
|
||||||
|
[SerializeField] private TMP_InputField playerOneNameInput;
|
||||||
|
[SerializeField] private TMP_InputField playerTwoNameInput;
|
||||||
|
[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;
|
||||||
|
|
||||||
|
private ScreenManager screenManager;
|
||||||
|
private SoundManager soundManager;
|
||||||
|
private int selectedPlayerCount;
|
||||||
|
public int SelectedPlayerCount => selectedPlayerCount;
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
twoPlayerBtn.onClick.RemoveAllListeners();
|
||||||
|
threePlayerBtn.onClick.RemoveAllListeners();
|
||||||
|
fourPlayerBtn.onClick.RemoveAllListeners();
|
||||||
|
playBtn.onClick.RemoveAllListeners();
|
||||||
|
closeBtn.onClick.RemoveAllListeners();
|
||||||
|
}
|
||||||
|
private void OnPlayerCountSelected(int count)
|
||||||
|
{
|
||||||
|
selectedPlayerCount = count;
|
||||||
|
UpdateInputFieldsVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateInputFieldsVisibility()
|
||||||
|
{
|
||||||
|
playerOneNameInput.transform.parent.gameObject.SetActive(true);
|
||||||
|
playerTwoNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 2);
|
||||||
|
playerThreeNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 3);
|
||||||
|
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClick_playBtn()
|
||||||
|
{
|
||||||
|
playerOneName = playerOneNameInput.text;
|
||||||
|
playerTwoName = playerTwoNameInput.text;
|
||||||
|
playerThreeName = playerThreeNameInput.text;
|
||||||
|
playerFourName = playerFourNameInput.text;
|
||||||
|
|
||||||
|
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}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnClick_closeBtn()
|
||||||
|
{
|
||||||
|
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||||
|
screenManager.ShowScreen(ScreenType.MenuHUDScreen);
|
||||||
|
|
||||||
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
|
|
||||||
|
Hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user