Compare commits
3 Commits
c42db86e28
...
f7c2f4c612
| Author | SHA1 | Date | |
|---|---|---|---|
| f7c2f4c612 | |||
| 9eef3eb04c | |||
| 14d4a562a4 |
@ -25,10 +25,11 @@ public class DiceView : MonoBehaviour, IBase
|
||||
transform.localPosition = new Vector3(0, 20, 0);
|
||||
}
|
||||
|
||||
public void Roll(Action<int> onComplete)
|
||||
public void Roll(Action<int> onComplete, bool isBot)
|
||||
{
|
||||
if (!rolling)
|
||||
{
|
||||
Debug.Log($"isBot: {isBot}");
|
||||
onRollingComplete = onComplete;
|
||||
StartCoroutine(RollRoutine());
|
||||
}
|
||||
@ -96,5 +97,12 @@ public class DiceView : MonoBehaviour, IBase
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
transform.localPosition = new Vector3(0, 20, 0);
|
||||
rolling = false;
|
||||
|
||||
Invoke(nameof(ResetEvent), 0.5f);
|
||||
}
|
||||
|
||||
private void ResetEvent()
|
||||
{
|
||||
onRollingComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,8 +96,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
|
||||
CanRollDiceForUser = true;
|
||||
|
||||
InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
||||
}
|
||||
|
||||
@ -109,6 +107,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||
@ -124,6 +124,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
InitCurrentGamePlayerInfo();
|
||||
InitBotRuntimeData();
|
||||
AssignPlayerAndBotStates(selectedPlayerType);
|
||||
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
||||
}
|
||||
|
||||
private void InitBotRuntimeData()
|
||||
@ -244,7 +246,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
Debug.Log($"Switching player");
|
||||
SwitchPlayer();
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -276,7 +277,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
// What happens when you get a 6
|
||||
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}");
|
||||
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
|
||||
@ -452,7 +457,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"### AreAllPawnsInFinishingPath");
|
||||
if (AreAllPawnsInFinishingPath())
|
||||
{
|
||||
SetCanRollDiceForUser(true);
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -800,10 +805,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
|
||||
SwitchPlayer(playerPawn);
|
||||
if (!CanRollDiceAgain)
|
||||
{
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
}
|
||||
},
|
||||
index);
|
||||
@ -925,20 +926,19 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
CanRollDiceAgain = true;
|
||||
if (playerPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot(playerPawn);
|
||||
else
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
SetCanRollDiceForUser(true);
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchPlayer();
|
||||
}
|
||||
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
},
|
||||
index);
|
||||
@ -946,8 +946,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private void SetCanRollDiceForUser(bool state)
|
||||
{
|
||||
// if (botTypesInGame.Contains(playerType)) return;
|
||||
|
||||
CanRollDiceForUser = state;
|
||||
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,11 +34,11 @@ public class DiceRollHandler : MonoBehaviour
|
||||
{
|
||||
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
||||
|
||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal));
|
||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
}
|
||||
|
||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||
{
|
||||
diceView.Roll(onComplete: onComplete);
|
||||
diceView.Roll(onComplete: (val) => onComplete?.Invoke(val), true);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user