New dice logic + fixes.
This commit is contained in:
parent
f8eed62a9f
commit
14d4a562a4
@ -26,9 +26,12 @@ public class Dice : MonoBehaviour, IBase, IBootLoader
|
|||||||
transform.localPosition = new Vector3(0, 20, 0);
|
transform.localPosition = new Vector3(0, 20, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Roll()
|
public void Roll(Action<int> onComplete, bool isBot)
|
||||||
{
|
{
|
||||||
if (!rolling)
|
if (!rolling)
|
||||||
|
{
|
||||||
|
Debug.Log($"isBot: {isBot}");
|
||||||
|
onRollingComplete = onComplete;
|
||||||
StartCoroutine(RollRoutine());
|
StartCoroutine(RollRoutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,5 +95,12 @@ public class Dice : MonoBehaviour, IBase, IBootLoader
|
|||||||
rb.angularVelocity = Vector3.zero;
|
rb.angularVelocity = Vector3.zero;
|
||||||
transform.localPosition = new Vector3(0, 20, 0);
|
transform.localPosition = new Vector3(0, 20, 0);
|
||||||
rolling = false;
|
rolling = false;
|
||||||
|
|
||||||
|
Invoke(nameof(ResetEvent), 0.5f);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ResetEvent()
|
||||||
|
{
|
||||||
|
onRollingComplete = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,8 +89,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
|
|
||||||
CanRollDice = true;
|
|
||||||
|
|
||||||
// initialize the player list from UI.
|
// initialize the player list from UI.
|
||||||
|
|
||||||
// InitPlayerTypesForLAN(null);
|
// InitPlayerTypesForLAN(null);
|
||||||
@ -106,6 +104,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
|
|
||||||
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||||
@ -121,6 +121,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
InitBotRuntimeData();
|
InitBotRuntimeData();
|
||||||
AssignPlayerAndBotStates(selectedPlayerType);
|
AssignPlayerAndBotStates(selectedPlayerType);
|
||||||
|
|
||||||
|
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitBotRuntimeData()
|
private void InitBotRuntimeData()
|
||||||
@ -238,7 +240,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
Debug.Log($"Switching player");
|
Debug.Log($"Switching player");
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
SetCanRollDiceForUser(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -270,7 +271,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
// What happens when you get a 6
|
// What happens when you get a 6
|
||||||
private void SelectPawnFromBotBase()
|
private void SelectPawnFromBotBase()
|
||||||
{
|
{
|
||||||
if (canSwitchPlayer || availPlayers.Count() < 1 && !CanRollDiceAgain || !botTypesInGame.Contains(currentPlayerTypeTurn)) return; // Have a better check here
|
if (canSwitchPlayer || availPlayers.Count() < 1 && !CanRollDiceAgain || !botTypesInGame.Contains(currentPlayerTypeTurn))
|
||||||
|
{
|
||||||
|
Debug.Log($"returning from SelectPawnFromBotBase");
|
||||||
|
return; // Have a better check here
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log($"CallTest: SelectPawnFromBotBase: {currentPlayerTypeTurn}");
|
Debug.Log($"CallTest: SelectPawnFromBotBase: {currentPlayerTypeTurn}");
|
||||||
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
|
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
|
||||||
@ -449,7 +454,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"### AreAllPawnsInFinishingPath");
|
Debug.Log($"### AreAllPawnsInFinishingPath");
|
||||||
if (AreAllPawnsInFinishingPath())
|
if (AreAllPawnsInFinishingPath())
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -790,10 +795,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
SwitchPlayer(playerPawn);
|
SwitchPlayer(playerPawn);
|
||||||
if (!CanRollDiceAgain)
|
|
||||||
{
|
|
||||||
SetCanRollDiceForUser(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
@ -901,20 +902,19 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
if (playerPawn.IsBotPlayer)
|
if (playerPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot(playerPawn);
|
CheckDiceRollForBot(playerPawn);
|
||||||
|
else
|
||||||
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(true);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCanRollDiceForUser(true);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
@ -922,8 +922,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void SetCanRollDiceForUser(bool state)
|
private void SetCanRollDiceForUser(bool state)
|
||||||
{
|
{
|
||||||
// if (botTypesInGame.Contains(playerType)) return;
|
CanRollDiceForUser = state;
|
||||||
|
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||||
CanRollDice = state;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,8 +30,18 @@ public class DiceRoller : MonoBehaviour
|
|||||||
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 HandleDiceViewForUser()
|
||||||
|
{
|
||||||
|
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
||||||
|
|
||||||
|
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||||
|
{
|
||||||
|
diceView.Roll(onComplete: (val) => onComplete?.Invoke(val), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user