Added logic for connecting pvp and bot ui with gameplay.
This commit is contained in:
parent
9af9ac09fb
commit
6f374f0d21
@ -1,7 +1,8 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class DiceView : MonoBehaviour, IBase, IBootLoader
|
public class DiceView : MonoBehaviour, IBase
|
||||||
{
|
{
|
||||||
private Rigidbody rb;
|
private Rigidbody rb;
|
||||||
private bool rolling;
|
private bool rolling;
|
||||||
@ -15,48 +16,49 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader
|
|||||||
[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<DiceView>(this);
|
|
||||||
transform.localPosition = new Vector3(0, 20, 0);
|
transform.localPosition = new Vector3(0, 20, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Roll()
|
public void Roll(Action<int> onComplete)
|
||||||
{
|
{
|
||||||
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(Random.Range(0.01f, 0.06f));
|
yield return new WaitForSeconds(UnityEngine.Random.Range(0.01f, 0.06f));
|
||||||
|
|
||||||
rb.useGravity = true;
|
rb.useGravity = true;
|
||||||
|
|
||||||
// PER-DICE FORCE MULTIPLIER
|
// PER-DICE FORCE MULTIPLIER
|
||||||
float spinMultiplier = Random.Range(0.8f, 1.25f);
|
float spinMultiplier = UnityEngine.Random.Range(0.8f, 1.25f);
|
||||||
|
|
||||||
// RANDOM TORQUE
|
// RANDOM TORQUE
|
||||||
rb.AddTorque(
|
rb.AddTorque(
|
||||||
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,
|
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||||
ForceMode.Impulse
|
ForceMode.Impulse
|
||||||
);
|
);
|
||||||
|
|
||||||
// RANDOM SIDE FORCE
|
// RANDOM SIDE FORCE
|
||||||
Vector3 sideDir = new Vector3(
|
Vector3 sideDir = new Vector3(
|
||||||
Random.Range(-1f, 1f),
|
UnityEngine.Random.Range(-1f, 1f),
|
||||||
0f,
|
0f,
|
||||||
Random.Range(-1f, 1f)
|
UnityEngine.Random.Range(-1f, 1f)
|
||||||
).normalized;
|
).normalized;
|
||||||
|
|
||||||
rb.AddForce(sideDir * sideForce, ForceMode.Impulse);
|
rb.AddForce(sideDir * sideForce, ForceMode.Impulse);
|
||||||
@ -71,6 +73,8 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader
|
|||||||
//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,6 +237,18 @@ 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
|
||||||
|
|||||||
@ -4046,6 +4046,37 @@ Transform:
|
|||||||
m_Father: {fileID: 491039299}
|
m_Father: {fileID: 491039299}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
|
--- !u!1 &429754880
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 429754881}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: GameMode
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!4 &429754881
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 429754880}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1332468941}
|
||||||
|
m_RootOrder: 3
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &433034049
|
--- !u!1 &433034049
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -7795,7 +7826,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
diceRollHandler: {fileID: 1013177415}
|
diceRollHandler: {fileID: 1013177415}
|
||||||
diceValue: 6
|
diceValue: 0
|
||||||
diceText: {fileID: 953941044}
|
diceText: {fileID: 953941044}
|
||||||
pointerDebug: {fileID: 102349503}
|
pointerDebug: {fileID: 102349503}
|
||||||
pointerMeshRend: {fileID: 102349501}
|
pointerMeshRend: {fileID: 102349501}
|
||||||
@ -10520,7 +10551,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
diceView: {fileID: 1619592888}
|
diceView: {fileID: 1619592888}
|
||||||
diceTestValue: 6
|
diceTestValue: 0
|
||||||
--- !u!4 &1039618837 stripped
|
--- !u!4 &1039618837 stripped
|
||||||
Transform:
|
Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3}
|
m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3}
|
||||||
@ -13896,6 +13927,7 @@ Transform:
|
|||||||
- {fileID: 1954289400}
|
- {fileID: 1954289400}
|
||||||
- {fileID: 896127050}
|
- {fileID: 896127050}
|
||||||
- {fileID: 1013177414}
|
- {fileID: 1013177414}
|
||||||
|
- {fileID: 429754881}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 5
|
m_RootOrder: 5
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@ -22049,10 +22081,10 @@ RectTransform:
|
|||||||
m_Father: {fileID: 5608193482000915565}
|
m_Father: {fileID: 5608193482000915565}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 439.5, y: -62.5}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 249, y: 76}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!1 &5608193481682591349
|
--- !u!1 &5608193481682591349
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -23753,7 +23785,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!222 &5608193481910428234
|
--- !u!222 &5608193481910428234
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -24810,10 +24842,10 @@ RectTransform:
|
|||||||
m_Father: {fileID: 5608193482000915565}
|
m_Father: {fileID: 5608193482000915565}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 170.5, y: -62.5}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 249, y: 76}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!1 &5608193482091674333
|
--- !u!1 &5608193482091674333
|
||||||
GameObject:
|
GameObject:
|
||||||
@ -25052,9 +25084,9 @@ RectTransform:
|
|||||||
m_Father: {fileID: 5608193481540211365}
|
m_Father: {fileID: 5608193481540211365}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 487.5, y: -150}
|
||||||
m_SizeDelta: {x: 250, y: 250}
|
m_SizeDelta: {x: 250, y: 250}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!1 &5608193482123643061
|
--- !u!1 &5608193482123643061
|
||||||
@ -26731,7 +26763,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!114 &5608193482405246783
|
--- !u!114 &5608193482405246783
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -29762,9 +29794,9 @@ RectTransform:
|
|||||||
m_Father: {fileID: 5608193481540211365}
|
m_Father: {fileID: 5608193481540211365}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 162.5, y: -150}
|
||||||
m_SizeDelta: {x: 250, y: 250}
|
m_SizeDelta: {x: 250, y: 250}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!1 &5608193482885172033
|
--- !u!1 &5608193482885172033
|
||||||
@ -32611,10 +32643,10 @@ RectTransform:
|
|||||||
m_Father: {fileID: 5608193482000915565}
|
m_Father: {fileID: 5608193482000915565}
|
||||||
m_RootOrder: 2
|
m_RootOrder: 2
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 0}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 0, y: 0}
|
m_AnchoredPosition: {x: 708.5, y: -62.5}
|
||||||
m_SizeDelta: {x: 0, y: 0}
|
m_SizeDelta: {x: 249, y: 76}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &5608193483470603110
|
--- !u!222 &5608193483470603110
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
|
|||||||
40
Assets/Scripts/Gameplay/GameModeHandler.cs
Normal file
40
Assets/Scripts/Gameplay/GameModeHandler.cs
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public enum GameModeType
|
||||||
|
{
|
||||||
|
PVP,
|
||||||
|
Bot,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
|
{
|
||||||
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
|
public GameModeType GameModeType
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Initialize()
|
||||||
|
{
|
||||||
|
InterfaceManager.Instance.RegisterInterface<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);
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Gameplay/GameModeHandler.cs.meta
Normal file
11
Assets/Scripts/Gameplay/GameModeHandler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d8a94cfc31bb45f9a403db0c1f4c116
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -80,7 +80,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
private List<PlayerPawn> availPlayers = new List<PlayerPawn>();
|
private List<PlayerPawn> availPlayers = new List<PlayerPawn>();
|
||||||
private bool canSwitchPlayer = false;
|
private bool canSwitchPlayer = false;
|
||||||
|
|
||||||
public bool CanRollDice
|
public bool CanRollDiceForUser
|
||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
@ -96,20 +96,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
|
|
||||||
CanRollDice = true;
|
CanRollDiceForUser = 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 InitPlayerTypesForLAN(List<PlayerType> types)
|
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
||||||
{
|
{
|
||||||
// TODO :: 2P, 3P, 4P
|
// TODO :: 2P, 3P, 4P
|
||||||
allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 };
|
allPlayerTypes = new List<PlayerType>(types);
|
||||||
// allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player3 };
|
|
||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
@ -232,7 +228,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void OnDiceInteracted()
|
public void OnDiceInteracted()
|
||||||
{
|
{
|
||||||
diceRollHandler.HandleDiceView();
|
diceRollHandler.HandleDiceViewForUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RollDiceForPlayer(int rolledVal)
|
public void RollDiceForPlayer(int rolledVal)
|
||||||
@ -264,12 +260,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RollDiceForBot()
|
private void RollDiceForBot(int rolledVal)
|
||||||
{
|
{
|
||||||
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(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
OnDiceRolled(rolledVal);
|
||||||
|
|
||||||
SelectPawnFromBotBase();
|
SelectPawnFromBotBase();
|
||||||
|
|
||||||
@ -549,7 +545,14 @@ 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)
|
||||||
@ -693,7 +696,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(RollDiceForBot), 1f);
|
Invoke(nameof(HandleDiceRoll), 1f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -945,6 +948,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
// if (botTypesInGame.Contains(playerType)) return;
|
// if (botTypesInGame.Contains(playerType)) return;
|
||||||
|
|
||||||
CanRollDice = state;
|
CanRollDiceForUser = state;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
@ -12,32 +13,32 @@ 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();
|
// RollDiceOnClick();
|
||||||
}
|
}
|
||||||
|
|
||||||
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))
|
|
||||||
RollDiceOnClick();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RollDiceOnClick()
|
public void OnUserDiceRollComplete(int rolledVal)
|
||||||
{
|
{
|
||||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||||
|
|
||||||
int currentRolledVal = // Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
|
inputManager.SetDiceRollValue(rolledVal);
|
||||||
diceTestValue != 0 ? diceTestValue : Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
|
|
||||||
inputManager.SetDiceRollValue(currentRolledVal);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleDiceView()
|
public void HandleDiceViewForUser()
|
||||||
{
|
{
|
||||||
diceView.Roll();
|
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
||||||
|
|
||||||
|
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||||
|
{
|
||||||
|
diceView.Roll(onComplete: onComplete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,6 @@ using UnityEngine;
|
|||||||
public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
private PopupManager popupManager;
|
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
@ -16,8 +15,6 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDiceViewInteracted()
|
public void OnDiceViewInteracted()
|
||||||
@ -38,7 +35,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPlayButtonClicked()
|
public void UpdateSelectedPlayerCount(int playersCount)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,16 +20,18 @@ 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;
|
||||||
public int SelectedPlayerCount => selectedPlayerCount;
|
private PlayerType playerType;
|
||||||
|
|
||||||
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_playBtn);
|
playBtn.onClick.AddListener(OnClick_PlayButton);
|
||||||
closeBtn.onClick.AddListener(OnClick_closeBtn);
|
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
@ -45,9 +47,9 @@ public class PvAIModePopup : PopupBase
|
|||||||
selectedPlayerCount = count;
|
selectedPlayerCount = count;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_playBtn()
|
private void OnClick_PlayButton()
|
||||||
{
|
{
|
||||||
playerName = playerNameInput.text;
|
playerName = string.IsNullOrWhiteSpace(playerNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerNameInput.text;
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
@ -57,10 +59,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.MenuScreen);
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -24,8 +25,9 @@ public class PvPModePopup : PopupBase
|
|||||||
private string playerFourName;
|
private string playerFourName;
|
||||||
|
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
private GameManager gameManager;
|
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
|
private GameModeHandler gameModeHandler;
|
||||||
|
|
||||||
private int selectedPlayerCount;
|
private int selectedPlayerCount;
|
||||||
public int SelectedPlayerCount => selectedPlayerCount;
|
public int SelectedPlayerCount => selectedPlayerCount;
|
||||||
|
|
||||||
@ -63,9 +65,9 @@ public class PvPModePopup : PopupBase
|
|||||||
private void OnClick_playBtn()
|
private void OnClick_playBtn()
|
||||||
{
|
{
|
||||||
playerOneName = string.IsNullOrWhiteSpace(playerOneNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerOneNameInput.text;
|
playerOneName = string.IsNullOrWhiteSpace(playerOneNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerOneNameInput.text;
|
||||||
playerTwoName = string.IsNullOrWhiteSpace(playerTwoNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerTwoNameInput.text;
|
playerTwoName = string.IsNullOrWhiteSpace(playerTwoNameInput.text) ? Ludo_3D_Constants.Player2_Name : playerTwoNameInput.text;
|
||||||
playerThreeName = string.IsNullOrWhiteSpace(playerThreeNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerThreeNameInput.text;
|
playerThreeName = string.IsNullOrWhiteSpace(playerThreeNameInput.text) ? Ludo_3D_Constants.Player3_Name : playerThreeNameInput.text;
|
||||||
playerFourName = string.IsNullOrWhiteSpace(playerFourNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerFourNameInput.text;
|
playerFourName = string.IsNullOrWhiteSpace(playerFourNameInput.text) ? Ludo_3D_Constants.Player4_Name : playerFourNameInput.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);
|
||||||
@ -74,10 +76,33 @@ public class PvPModePopup : PopupBase
|
|||||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||||
Debug.Log($"Player 1: {playerOneName}");
|
Debug.Log($"Player 1: {playerOneName}");
|
||||||
Debug.Log($"Player 2: {playerTwoName}");
|
Debug.Log($"Player 2: {playerTwoName}");
|
||||||
|
|
||||||
if (selectedPlayerCount >= 3)
|
if (selectedPlayerCount >= 3)
|
||||||
Debug.Log($"Player 3: {playerThreeName}");
|
Debug.Log($"Player 3: {playerThreeName}");
|
||||||
if (selectedPlayerCount == 4)
|
if (selectedPlayerCount == 4)
|
||||||
Debug.Log($"Player 4: {playerFourName}");
|
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_closeBtn()
|
private void OnClick_closeBtn()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user