Updated with all the feedback fixes.
This commit is contained in:
parent
2563f36e7d
commit
b41e2990fc
@ -29,9 +29,11 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
[SerializeField] private Image diceImage;
|
[SerializeField] private Image diceImage;
|
||||||
[SerializeField] private Sprite defaultSprite;
|
[SerializeField] private Sprite defaultSprite;
|
||||||
[SerializeField] private Button diceButton;
|
[SerializeField] private Button diceButton;
|
||||||
|
[SerializeField] private RectTransform diceRectTransform;
|
||||||
|
[SerializeField] private int diceVal;
|
||||||
|
|
||||||
private Animator animator;
|
private Animator animator;
|
||||||
private List<int> probabilityValues = new List<int>() { 3, 4, 5 };
|
private List<int> probabilityValues = new List<int>() { 2, 3, 4 };
|
||||||
private Action<int> onRollingComplete = null;
|
private Action<int> onRollingComplete = null;
|
||||||
|
|
||||||
private IRollBase rollBase = null;
|
private IRollBase rollBase = null;
|
||||||
@ -43,7 +45,6 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
animator = GetComponent<Animator>();
|
animator = GetComponent<Animator>();
|
||||||
Debug.Log($"Dice roll test: StartRollingAction: animator: {animator}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Roll(Action<int> onComplete, bool isBot)
|
public void Roll(Action<int> onComplete, bool isBot)
|
||||||
@ -61,7 +62,6 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
|
|
||||||
private void StartRollingAction()
|
private void StartRollingAction()
|
||||||
{
|
{
|
||||||
Debug.Log($"Dice roll test: StartRollingAction: animator: {animator}, {gameObject.name}");
|
|
||||||
rolling = true;
|
rolling = true;
|
||||||
rolledVal = 0;
|
rolledVal = 0;
|
||||||
// start animation
|
// start animation
|
||||||
@ -81,6 +81,8 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
{
|
{
|
||||||
rolledVal = GetDiceValue();
|
rolledVal = GetDiceValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (diceVal != 0) rolledVal = diceVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -90,30 +92,27 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
public void OnDiceRollingCompleted()
|
public void OnDiceRollingCompleted()
|
||||||
{
|
{
|
||||||
animator.ResetTrigger(Ludo_3D_Constants.RollDiceTriggerString);
|
animator.ResetTrigger(Ludo_3D_Constants.RollDiceTriggerString);
|
||||||
Debug.Log($"Dice roll test: OnDiceRollingCompleted");
|
|
||||||
|
|
||||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||||
ResetRollData();
|
ResetRollData();
|
||||||
|
|
||||||
ResetData();
|
ResetData();
|
||||||
Debug.Log($"Dice roll test: Dice rolled: {rolledVal}");
|
|
||||||
onRollingComplete?.Invoke(rolledVal);
|
onRollingComplete?.Invoke(rolledVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnReturnedToIdle()
|
public void OnReturnedToIdle()
|
||||||
{
|
{
|
||||||
Debug.Log($"Dice roll test: OnReturnedToIdle: rolled: {rolledVal}");
|
Debug.Log($"DiceView :: OnReturnedToIdle: {rolledVal}");
|
||||||
|
|
||||||
animator.enabled = false;
|
animator.enabled = false;
|
||||||
if (rolledVal == 0)
|
if (rolledVal == 0)
|
||||||
{
|
{
|
||||||
diceImage.sprite = defaultSprite;
|
ShowDefaultSprite();
|
||||||
Debug.Log($"Dice roll test: OnReturnedToIdle: setting default sprite");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
diceImage.sprite = diceSideDatas[rolledVal - 1].sprite;
|
diceImage.sprite = diceSideDatas[rolledVal - 1].sprite;
|
||||||
}
|
}
|
||||||
Debug.Log($"Dice roll test: OnReturnedToIdle: diceImage.sprite: {diceImage.sprite.name}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetDiceValue()
|
private int GetDiceValue()
|
||||||
@ -135,12 +134,17 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
public void SetDiceButtonInteraction(bool status)
|
public void SetDiceButtonInteraction(bool status)
|
||||||
{
|
{
|
||||||
diceButton.interactable = status;
|
diceButton.interactable = status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetOnSessionEnd()
|
public void ResetOnSessionEnd()
|
||||||
{
|
{
|
||||||
ResetData();
|
ResetData();
|
||||||
|
|
||||||
|
rolledVal = 0;
|
||||||
|
OnReturnedToIdle();
|
||||||
|
|
||||||
|
diceRectTransform.rotation = Quaternion.identity;
|
||||||
|
diceRectTransform.localScale = Vector3.one;
|
||||||
onRollingComplete = null;
|
onRollingComplete = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,4 +156,10 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
|
|
||||||
this.rollBase = rollBase;
|
this.rollBase = rollBase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ShowDefaultSprite()
|
||||||
|
{
|
||||||
|
Debug.Log($"DiceView :: ShowDefaultSprite");
|
||||||
|
diceImage.sprite = defaultSprite;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -629,7 +629,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
playerState: 0
|
playerState: 0
|
||||||
animator: {fileID: 5526766409186502679}
|
animator: {fileID: 5526766409186502679}
|
||||||
playerCountCanvas: {fileID: 5728752331380905399}
|
playerIndicatorCanvas: {fileID: 5728752331380905399}
|
||||||
--- !u!1 &4818123989977612668
|
--- !u!1 &4818123989977612668
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -629,7 +629,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
playerState: 0
|
playerState: 0
|
||||||
animator: {fileID: 5274388487207906813}
|
animator: {fileID: 5274388487207906813}
|
||||||
playerCountCanvas: {fileID: 7923051124467737897}
|
playerIndicatorCanvas: {fileID: 7923051124467737897}
|
||||||
--- !u!1 &5059623752267150313
|
--- !u!1 &5059623752267150313
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -201,7 +201,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
playerState: 0
|
playerState: 0
|
||||||
animator: {fileID: 232863433340697214}
|
animator: {fileID: 232863433340697214}
|
||||||
playerCountCanvas: {fileID: 1920934309388072333}
|
playerIndicatorCanvas: {fileID: 1920934309388072333}
|
||||||
--- !u!136 &1627116187348267135
|
--- !u!136 &1627116187348267135
|
||||||
CapsuleCollider:
|
CapsuleCollider:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1258,7 +1258,7 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
playerState: 0
|
playerState: 0
|
||||||
animator: {fileID: 7800412279828783518}
|
animator: {fileID: 7800412279828783518}
|
||||||
playerCountCanvas: {fileID: 941219433310479660}
|
playerIndicatorCanvas: {fileID: 941219433310479660}
|
||||||
--- !u!1 &7074820051352815849
|
--- !u!1 &7074820051352815849
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -248,3 +248,6 @@ MonoBehaviour:
|
|||||||
sprite: {fileID: -387705599, guid: bbe0ebcb7b6854733a0dd63492c4d57d, type: 3}
|
sprite: {fileID: -387705599, guid: bbe0ebcb7b6854733a0dd63492c4d57d, type: 3}
|
||||||
diceImage: {fileID: 3592825875980183606}
|
diceImage: {fileID: 3592825875980183606}
|
||||||
defaultSprite: {fileID: 1572130339, guid: 2c0526d99bc3843a4b73e6eb2f3b1376, type: 3}
|
defaultSprite: {fileID: 1572130339, guid: 2c0526d99bc3843a4b73e6eb2f3b1376, type: 3}
|
||||||
|
diceButton: {fileID: 1882416428171655661}
|
||||||
|
diceRectTransform: {fileID: 4547155689416384467}
|
||||||
|
diceVal: 0
|
||||||
|
|||||||
@ -8492,7 +8492,7 @@ MonoBehaviour:
|
|||||||
isDebugPlayerTest: 0
|
isDebugPlayerTest: 0
|
||||||
diceRollHandler: {fileID: 1013177415}
|
diceRollHandler: {fileID: 1013177415}
|
||||||
diceValue: 0
|
diceValue: 0
|
||||||
botDiceRollDelay: 0.25
|
diceRollDelay: 0.7
|
||||||
maxDiceSixRollCounter: 2
|
maxDiceSixRollCounter: 2
|
||||||
totalStepsForCharacter: 57
|
totalStepsForCharacter: 57
|
||||||
currentPlayerTurnMaxTime: 4
|
currentPlayerTurnMaxTime: 4
|
||||||
|
|||||||
@ -4,6 +4,8 @@ using System.Linq;
|
|||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Threading;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public enum BotMove
|
public enum BotMove
|
||||||
{
|
{
|
||||||
@ -25,10 +27,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
[SerializeField] DiceRollHandler diceRollHandler;
|
[SerializeField] DiceRollHandler diceRollHandler;
|
||||||
|
|
||||||
[SerializeField] private int diceValue = 0;
|
[SerializeField] private int diceValue = 0;
|
||||||
[SerializeField] private float botDiceRollDelay = 0.25f;
|
[SerializeField] private float diceRollDelayForBot = 0.5f;
|
||||||
|
[SerializeField] private float diceRollDelayForUser = 0.5f;
|
||||||
[SerializeField] private int maxDiceSixRollCounter = 2;
|
[SerializeField] private int maxDiceSixRollCounter = 2;
|
||||||
[SerializeField] private int totalStepsForCharacter = 57;
|
[SerializeField] private int totalStepsForCharacter = 57;
|
||||||
[SerializeField] private int currentPlayerTurnMaxTime = 5;
|
[SerializeField] private int currentPlayerTurnMaxTime = 5;
|
||||||
|
[SerializeField] private int currentPlayerSelectionMaxTime = 5;
|
||||||
|
|
||||||
[SerializeField] private TextMeshProUGUI diceText;
|
[SerializeField] private TextMeshProUGUI diceText;
|
||||||
|
|
||||||
@ -42,7 +46,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
[SerializeField] private PlayerGameData[] playerGameDatas;
|
[SerializeField] private PlayerGameData[] playerGameDatas;
|
||||||
[SerializeField] private PlayerBaseHandler playerBaseHandler;
|
[SerializeField] private PlayerBaseHandler playerBaseHandler;
|
||||||
|
|
||||||
public PlayerType CurrentPlayerTypeTurn => currentPlayerTypeTurn;
|
|
||||||
public PlayerBaseHandler PlayerBaseHandler => playerBaseHandler;
|
public PlayerBaseHandler PlayerBaseHandler => playerBaseHandler;
|
||||||
|
|
||||||
private PlayerType currentPlayerTypeTurn;
|
private PlayerType currentPlayerTypeTurn;
|
||||||
@ -169,7 +172,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void HandleDiceRollWithDelay()
|
private void HandleDiceRollWithDelay()
|
||||||
{
|
{
|
||||||
Invoke(nameof(RollDiceForBot), botDiceRollDelay);
|
Invoke(nameof(RollDiceForBot), diceRollDelayForBot);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitBotRuntimeData()
|
private void InitBotRuntimeData()
|
||||||
@ -240,12 +243,22 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
playerBaseHandler.ShowSelectedPlayerBase(currentPlayerTypeTurn, false);
|
playerBaseHandler.ShowSelectedPlayerBase(currentPlayerTypeTurn, false);
|
||||||
currentPlayerTypeTurn = playerType;
|
currentPlayerTypeTurn = playerType;
|
||||||
playerBaseHandler.ShowSelectedPlayerBase(currentPlayerTypeTurn, true);
|
playerBaseHandler.ShowSelectedPlayerBase(currentPlayerTypeTurn, true);
|
||||||
diceRollHandler.DiceView.SetDiceButtonInteraction(true);
|
|
||||||
|
|
||||||
UpdateTurnTimer();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateTurnTimer()
|
private void UpdateDiceView()
|
||||||
|
{
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(true);
|
||||||
|
diceRollHandler.DiceView.ShowDefaultSprite();
|
||||||
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateDiceViewForBot()
|
||||||
|
{
|
||||||
|
UpdateDiceView();
|
||||||
|
HandleDiceRollWithDelay();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateResponseTimerForUser(int currentPlayerMaxTime, Action onComplete)
|
||||||
{
|
{
|
||||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot)
|
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot)
|
||||||
{
|
{
|
||||||
@ -260,18 +273,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
else
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
|
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerTurnMaxTime);
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime);
|
||||||
|
|
||||||
if (currentPlayerTurnTimer == null)
|
if (currentPlayerTurnTimer == null)
|
||||||
currentPlayerTurnTimer = new TimerSystem();
|
currentPlayerTurnTimer = new TimerSystem();
|
||||||
|
|
||||||
currentPlayerTurnTimer.Init(currentPlayerTurnMaxTime, onComplete: () =>
|
currentPlayerTurnTimer.Init(currentPlayerMaxTime, onComplete: () =>
|
||||||
{
|
{
|
||||||
Debug.Log($"currentPlayerTurnTimer: HandleDiceViewForUser");
|
Debug.Log($"currentPlayerTurnTimer: HandleDiceViewForUser");
|
||||||
RollDiceForUser();
|
onComplete?.Invoke();
|
||||||
}, inProgress: (remTime) =>
|
}, inProgress: (remTime) =>
|
||||||
{
|
{
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerTurnMaxTime - (int)remTime);
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime - (int)remTime);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,6 +309,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitCurrentGamePlayerInfo()
|
public void InitCurrentGamePlayerInfo()
|
||||||
{
|
{
|
||||||
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
||||||
|
UpdateDiceView();
|
||||||
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -337,11 +351,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EnablePlayerSelectionStates(bool state)
|
public void SetPlayerSelectionStates(bool state, Predicate<PlayerState> skipPredicate = null)
|
||||||
{
|
{
|
||||||
foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
|
foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
|
||||||
{
|
{
|
||||||
if (playerPawn.Value.GetPlayerState() == PlayerState.InFinishingPath) continue;
|
if (skipPredicate != null && skipPredicate.Invoke(playerPawn.Value.GetPlayerState()))
|
||||||
|
{
|
||||||
|
playerPawn.Value.SetPlayerSelectionState(false);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
playerPawn.Value.SetPlayerSelectionState(state);
|
playerPawn.Value.SetPlayerSelectionState(state);
|
||||||
}
|
}
|
||||||
@ -411,10 +430,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
Debug.Log($"SelectPawnFromBotBase: availPlayers.Count(): {availPlayersToMove.Count()}, CanRollDiceAgain: {CanRollDiceAgain}");
|
Debug.Log($"SelectPawnFromBotBase: availPlayers.Count(): {availPlayersToMove.Count()}, CanRollDiceAgain: {CanRollDiceAgain}");
|
||||||
|
|
||||||
|
InitActivePlayers();
|
||||||
|
#if UNITY_EDITOR
|
||||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0)
|
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0)
|
||||||
{
|
{
|
||||||
UpdateActivePlayersAndSetDisplay(true);
|
SetDisplayCountForAllAvailPlayers(true);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (CanRollDiceAgain) // got a 6 roll value
|
if (CanRollDiceAgain) // got a 6 roll value
|
||||||
{
|
{
|
||||||
@ -573,19 +595,23 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private bool HasNoPlayersTravelling() => Mathf.Abs(availPlayersToMove.Count - playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInFinishingPath) < 1;
|
private bool HasNoPlayersTravelling() => Mathf.Abs(availPlayersToMove.Count - playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInFinishingPath) < 1;
|
||||||
|
|
||||||
|
private bool IsUsersTurn() => gameModeHandler.CurrentGameModeType != GameModeType.Bot ||
|
||||||
|
!botTypesInGame.Contains(currentPlayerTypeTurn);
|
||||||
|
|
||||||
public void OnDiceRolled(int rolledVal)
|
public void OnDiceRolled(int rolledVal)
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(false);
|
SetCanRollDiceForUser(false);
|
||||||
diceRollHandler.DiceView.SetDiceButtonInteraction(false);
|
|
||||||
|
|
||||||
// add core dice logic here
|
// add core dice logic here
|
||||||
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
||||||
diceRolledValue = rolledVal;
|
diceRolledValue = rolledVal;
|
||||||
diceText.text = $"{diceRolledValue}";
|
diceText.text = $"{diceRolledValue}";
|
||||||
|
|
||||||
if (!CanRollDiceAgain)
|
if (!CanRollDiceAgain) // remove this check for showing arrow logic
|
||||||
{
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
SetDisplayCountForAllAvailPlayers(true);
|
SetDisplayCountForAllAvailPlayers(true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||||
@ -596,8 +622,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
diceSixRollCounter++;
|
diceSixRollCounter++;
|
||||||
|
|
||||||
if (botTypesInGame != null && !botTypesInGame.Contains(currentPlayerTypeTurn))
|
if (IsUsersTurn())
|
||||||
{
|
{
|
||||||
|
Debug.Log($"availPlayersToMove.Count < 1: {availPlayersToMove.Count < 1} || HasNoPlayersTravelling(): {HasNoPlayersTravelling()}");
|
||||||
if (availPlayersToMove.Count < 1 || HasNoPlayersTravelling())
|
if (availPlayersToMove.Count < 1 || HasNoPlayersTravelling())
|
||||||
{
|
{
|
||||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
||||||
@ -617,24 +644,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
pointerMeshRend.material = selectMat;
|
pointerMeshRend.material = selectMat;
|
||||||
#endif
|
#endif
|
||||||
foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
|
|
||||||
if (playerPawn.Value.GetPlayerState() == PlayerState.InFinishingPath)
|
|
||||||
playerPawn.Value.SetPlayerSelectionState(false);
|
|
||||||
|
|
||||||
Debug.Log($"### AreAllPawnsInFinishingPath");
|
Debug.Log($"### AreAllPawnsInFinishingPath");
|
||||||
if (AreAllPawnsInFinishingPath())
|
if (AreAllPawnsInFinishingPath())
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(gameModeHandler.CurrentGameModeType != GameModeType.Bot || !botTypesInGame.Contains(currentPlayerTypeTurn));
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"### EnablePlayerSelectionStates");
|
SetPlayerSelectionStates(true, (state) => state == PlayerState.InFinishingPath || state == PlayerState.HasFinished);
|
||||||
|
|
||||||
EnablePlayerSelectionStates(true);
|
|
||||||
// pointerMeshRend.materials[0] = selectMat;
|
|
||||||
}
|
}
|
||||||
else // if there are any other pawns that are in safe or moving state
|
else
|
||||||
{
|
{
|
||||||
Debug.Log($"before CustomAvailablePlayers: {availPlayersToMove.Count}");
|
Debug.Log($"before CustomAvailablePlayers: {availPlayersToMove.Count}");
|
||||||
List<int> indexesToRemove = new List<int>();
|
List<int> indexesToRemove = new List<int>();
|
||||||
@ -654,7 +675,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
indexesToRemove.Add(i);
|
indexesToRemove.Add(i);
|
||||||
availPlayersToMove[i].SetPlayerSelectionState(false);
|
availPlayersToMove[i].SetPlayerSelectionState(false);
|
||||||
|
#if UNITY_EDITOR
|
||||||
availPlayersToMove[i].ShowPlayerCountCanvas(false);
|
availPlayersToMove[i].ShowPlayerCountCanvas(false);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
@ -666,21 +689,36 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
for (int idx = indexesToRemove.Count - 1; idx >= 0; idx--)
|
for (int idx = indexesToRemove.Count - 1; idx >= 0; idx--)
|
||||||
availPlayersToMove.RemoveAt(idx);
|
availPlayersToMove.RemoveAt(idx);
|
||||||
|
|
||||||
|
// TODO :: Show the selectable characters indicator here
|
||||||
Debug.Log($"CustomAvailablePlayers: {availPlayersToMove.Count}");
|
Debug.Log($"CustomAvailablePlayers: {availPlayersToMove.Count}");
|
||||||
canSwitchPlayer = availPlayersToMove.Count < 1;
|
canSwitchPlayer = availPlayersToMove.Count < 1;
|
||||||
CanRollDiceAgain = false;
|
CanRollDiceAgain = false;
|
||||||
|
|
||||||
if (botTypesInGame != null && !botTypesInGame.Contains(currentPlayerTypeTurn) &&
|
if (IsUsersTurn() && availPlayersToMove.Count > 0)
|
||||||
availPlayersToMove.Count > 0)
|
|
||||||
{
|
{
|
||||||
if (CanMoveSoloPlayer())
|
if (CanMoveSoloPlayer())
|
||||||
{
|
{
|
||||||
EnablePlayerSelectionStates(false);
|
SetPlayerSelectionStates(false);
|
||||||
OnPawnSelected(availPlayersToMove[0]);
|
OnPawnSelected(availPlayersToMove[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
||||||
|
|
||||||
|
Action onComplete = null;
|
||||||
|
if (CanRollDiceAgain && availPlayersToMove.Count < 1 && playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
||||||
|
{
|
||||||
|
onComplete = () => OnPawnSelected(playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values
|
||||||
|
.FirstOrDefault(pawn => pawn.GetPlayerState() == PlayerState.InHome));
|
||||||
|
}
|
||||||
|
else if (availPlayersToMove.Count > 0)
|
||||||
|
{
|
||||||
|
onComplete = () => availPlayersToMove.OrderByDescending(pawn => pawn.StepsTaken).FirstOrDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => onComplete?.Invoke());
|
||||||
|
|
||||||
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,12 +737,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateActivePlayersAndSetDisplay(bool state)
|
|
||||||
{
|
|
||||||
InitActivePlayers();
|
|
||||||
SetDisplayCountForAllAvailPlayers(state);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitActivePlayers()
|
private void InitActivePlayers()
|
||||||
{
|
{
|
||||||
availPlayersToMove = new List<PlayerPawn>();
|
availPlayersToMove = new List<PlayerPawn>();
|
||||||
@ -792,23 +824,28 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void OnPawnSelected(PlayerPawn selectedPawn)
|
public void OnPawnSelected(PlayerPawn selectedPawn)
|
||||||
{
|
{
|
||||||
EnablePlayerSelectionStates(false);
|
// TODO :: Hide the selectable characters indicator here
|
||||||
|
SetPlayerSelectionStates(false);
|
||||||
|
|
||||||
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
||||||
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
selectedPawn.ShowPlayerCountCanvas(false);
|
||||||
|
#endif
|
||||||
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
||||||
{
|
{
|
||||||
Tile targetTile = TilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
Tile targetTile = TilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
||||||
|
|
||||||
selectedPawn.ShowPlayerCountCanvas(false);
|
|
||||||
selectedPawn.MoveToTile(
|
selectedPawn.MoveToTile(
|
||||||
TilesManager.GetAndInitPositionInsideSafeZone(selectedPawn, targetTile, currentPlayerTypeTurn),
|
TilesManager.GetAndInitPositionInsideSafeZone(selectedPawn, targetTile, currentPlayerTypeTurn),
|
||||||
onComplete: () =>
|
onComplete: () =>
|
||||||
{
|
{
|
||||||
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
||||||
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
||||||
|
#if UNITY_EDITOR
|
||||||
ShowUpdatedPlayerCountOnTile(selectedPawn);
|
ShowUpdatedPlayerCountOnTile(selectedPawn);
|
||||||
|
#endif
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -817,7 +854,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (selectedPawn.IsBotPlayer)
|
if (selectedPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot();
|
||||||
else
|
else
|
||||||
UpdateTurnTimer();
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
|
||||||
}, playerGameData.startIndex);
|
}, playerGameData.startIndex);
|
||||||
|
|
||||||
@ -828,12 +865,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Tile currentSittingTile = TilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
Tile currentSittingTile = TilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
||||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
if (currentSittingTile.HasPawnsAvailable)
|
if (currentSittingTile.HasPawnsAvailable)
|
||||||
{
|
{
|
||||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||||
foreach (var pawn in playerPawns)
|
foreach (var pawn in playerPawns)
|
||||||
ShowUpdatedPlayerCountOnTile(pawn);
|
ShowUpdatedPlayerCountOnTile(pawn);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
ApplyFinishingPathLogic(selectedPawn);
|
ApplyFinishingPathLogic(selectedPawn);
|
||||||
}
|
}
|
||||||
@ -866,22 +905,26 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
pawn.MoveToCustomTilePosition(currentSittingSafeTile.CenterPlacementPosition);
|
pawn.MoveToCustomTilePosition(currentSittingSafeTile.CenterPlacementPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
if (currentSittingSafeTile.ContainsPlayerType(currentPlayerTypeTurn))
|
if (currentSittingSafeTile.ContainsPlayerType(currentPlayerTypeTurn))
|
||||||
{
|
{
|
||||||
var playerPawns = currentSittingSafeTile.GetPlayerPawns(currentPlayerTypeTurn);
|
var playerPawns = currentSittingSafeTile.GetPlayerPawns(currentPlayerTypeTurn);
|
||||||
foreach (var pawn in playerPawns)
|
foreach (var pawn in playerPawns)
|
||||||
ShowUpdatedPlayerCountOnTile(pawn);
|
ShowUpdatedPlayerCountOnTile(pawn);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||||
|
#if UNITY_EDITOR
|
||||||
if (currentSittingTile.HasPawnsAvailable)
|
if (currentSittingTile.HasPawnsAvailable)
|
||||||
{
|
{
|
||||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||||
foreach (var pawn in playerPawns)
|
foreach (var pawn in playerPawns)
|
||||||
ShowUpdatedPlayerCountOnTile(pawn);
|
ShowUpdatedPlayerCountOnTile(pawn);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
||||||
@ -896,7 +939,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
||||||
|
|
||||||
playerPawn.ShowPlayerCountCanvas(false);
|
|
||||||
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -916,7 +958,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
Debug.Log($"before SwitchPlayer availPlayers: {availPlayersToMove.Count}, playerPawn: {playerPawn}");
|
Debug.Log($"before SwitchPlayer availPlayers: {availPlayersToMove.Count}, playerPawn: {playerPawn}");
|
||||||
|
|
||||||
UpdateActivePlayersAndSetDisplay(false);
|
InitActivePlayers();
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
SetDisplayCountForAllAvailPlayers(false);
|
||||||
|
#endif
|
||||||
Debug.Log($"after SwitchPlayer availPlayers: {availPlayersToMove.Count}, playerPawn: {playerPawn}");
|
Debug.Log($"after SwitchPlayer availPlayers: {availPlayersToMove.Count}, playerPawn: {playerPawn}");
|
||||||
Debug.Log($"after allPlayerTypes.Count: {allPlayerTypes.Count}");
|
Debug.Log($"after allPlayerTypes.Count: {allPlayerTypes.Count}");
|
||||||
|
|
||||||
@ -939,12 +984,26 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
soundManager.PlayGameSoundClip(SoundType.Turn);
|
soundManager.PlayGameSoundClip(SoundType.Turn);
|
||||||
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
||||||
|
|
||||||
|
Debug.Log($"IsUsersTurn: {IsUsersTurn()}");
|
||||||
|
if (IsUsersTurn())
|
||||||
|
{
|
||||||
|
Invoke(nameof(UpdateDiceView), diceRollDelayForUser);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Invoke(nameof(UpdateDiceViewForBot), diceRollDelayForBot);
|
||||||
|
|
||||||
diceSixRollCounter = 0;
|
diceSixRollCounter = 0;
|
||||||
diceText.text = $"{0}";
|
diceText.text = $"{0}";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateTurnTimer();
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
|
||||||
|
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||||
|
{
|
||||||
|
Debug.Log($"Invoking RollDiceForBot");
|
||||||
|
HandleDiceRollWithDelay();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
||||||
@ -955,34 +1014,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
pointerMeshRend.material = turnMat;
|
pointerMeshRend.material = turnMat;
|
||||||
// pointerMeshRend.materials[0] = turnMat;
|
// pointerMeshRend.materials[0] = turnMat;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Debug.Log($"botTypesInGame.Contains(currentPlayerTypeTurn): {botTypesInGame.Contains(currentPlayerTypeTurn)}");
|
|
||||||
|
|
||||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
|
||||||
{
|
|
||||||
Debug.Log($"Invoking RollDiceForBot");
|
|
||||||
HandleDiceRollWithDelay();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
|
||||||
private void SetCurrentSelectedPointer()
|
|
||||||
{
|
|
||||||
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
|
||||||
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public void SetDisplayCountForAllAvailPlayers(bool state)
|
|
||||||
{
|
|
||||||
if (state)
|
|
||||||
{
|
|
||||||
availPlayersToMove.ForEach(pawn => ShowUpdatedPlayerCountOnTile(pawn));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
availPlayersToMove.ForEach(pawn => pawn.ShowPlayerCountCanvas(false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||||
@ -1002,7 +1033,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||||
playerPawn.ShowPlayerCountCanvas(false);
|
#if UNITY_EDITOR
|
||||||
|
playerPawn.ShowPlayerCountCanvas(false); // TODO :: Check if call can be removed
|
||||||
|
#endif
|
||||||
|
|
||||||
playerPawn.MoveToTile(
|
playerPawn.MoveToTile(
|
||||||
targetPosition,
|
targetPosition,
|
||||||
@ -1038,7 +1071,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
||||||
|
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!nextTile.IsSafeZone)
|
if (!nextTile.IsSafeZone)
|
||||||
{
|
{
|
||||||
@ -1069,12 +1106,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
if (!playerPawn.IsBotPlayer)
|
if (!playerPawn.IsBotPlayer)
|
||||||
{
|
{
|
||||||
UpdateTurnTimer();
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
|
#if UNITY_EDITOR
|
||||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
@ -1098,8 +1139,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void CheckForGamePause(Action onComplete)
|
public void CheckForGamePause(Action onComplete)
|
||||||
{
|
{
|
||||||
Debug.Log($"CheckForGamePause: {GameManager.CurrentGameState == GameState.IsPaused}");
|
Debug.Log($"CheckForGamePause: {GameManager.CurrentGameState == GameState.IsPaused}");
|
||||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && !botTypesInGame.Contains(currentPlayerTypeTurn)
|
if ((botTypesInGame == null || !botTypesInGame.Contains(currentPlayerTypeTurn)) &&
|
||||||
&& GameManager.CurrentGameState == GameState.IsPaused)
|
GameManager.CurrentGameState == GameState.IsPaused)
|
||||||
{
|
{
|
||||||
OnGameResumed = onComplete;
|
OnGameResumed = onComplete;
|
||||||
}
|
}
|
||||||
@ -1180,8 +1221,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateTurnTimer();
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1195,7 +1238,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
|
{
|
||||||
|
#if UNITY_EDITOR
|
||||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
@ -1210,6 +1257,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
private void ShowUpdatedPlayerCountOnTile(PlayerPawn playerPawn)
|
private void ShowUpdatedPlayerCountOnTile(PlayerPawn playerPawn)
|
||||||
{
|
{
|
||||||
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
||||||
@ -1230,9 +1278,28 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
Debug.Log($"ShowUpdatedPlayerCountOnTile: {count}");
|
Debug.Log($"ShowUpdatedPlayerCountOnTile: {count}");
|
||||||
|
|
||||||
playerPawn.PlayerCountCanvas.SetPlayerCount(count);
|
playerPawn.PlayerIndicatorCanvas.SetPlayerCount(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void SetCurrentSelectedPointer()
|
||||||
|
{
|
||||||
|
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
||||||
|
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetDisplayCountForAllAvailPlayers(bool state)
|
||||||
|
{
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
availPlayersToMove.ForEach(pawn => ShowUpdatedPlayerCountOnTile(pawn));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
availPlayersToMove.ForEach(pawn => pawn.ShowPlayerCountCanvas(false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public void ResetTileDatasForPlayers()
|
public void ResetTileDatasForPlayers()
|
||||||
{
|
{
|
||||||
foreach (PlayerData data in playerDatas)
|
foreach (PlayerData data in playerDatas)
|
||||||
@ -1255,6 +1322,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
ResetGameRestartData();
|
ResetGameRestartData();
|
||||||
|
|
||||||
|
currentPlayerTurnTimer.KillTimer();
|
||||||
|
currentPlayerTurnTimer = null;
|
||||||
OnGameResumed = null;
|
OnGameResumed = null;
|
||||||
playerDatas = null;
|
playerDatas = null;
|
||||||
allPlayerTypes = null;
|
allPlayerTypes = null;
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public enum PlayerState
|
public enum PlayerState
|
||||||
{
|
{
|
||||||
@ -21,12 +22,12 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
{
|
{
|
||||||
[SerializeField] private PlayerState playerState;
|
[SerializeField] private PlayerState playerState;
|
||||||
[SerializeField] private Animator animator;
|
[SerializeField] private Animator animator;
|
||||||
[SerializeField] private PlayerCountCanvas playerCountCanvas;
|
[SerializeField] private PlayerIndicatorCanvas playerIndicatorCanvas;
|
||||||
|
|
||||||
private PlayerBase playerBase;
|
private PlayerBase playerBase;
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public PlayerCountCanvas PlayerCountCanvas => playerCountCanvas;
|
public PlayerIndicatorCanvas PlayerIndicatorCanvas => playerIndicatorCanvas;
|
||||||
|
|
||||||
public int PlayerId { get; private set; }
|
public int PlayerId { get; private set; }
|
||||||
public int StepsTaken { get; private set; }
|
public int StepsTaken { get; private set; }
|
||||||
@ -43,6 +44,8 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
public void SetPlayerSelectionState(bool state)
|
public void SetPlayerSelectionState(bool state)
|
||||||
{
|
{
|
||||||
CanSelectPlayer = state;
|
CanSelectPlayer = state;
|
||||||
|
Debug.Log($"### SetPlayerSelectionState: {name} :: {state}, ");
|
||||||
|
ShowPlayerSelCanvas(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex)
|
public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex)
|
||||||
@ -61,7 +64,7 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
|
|
||||||
// Rotate Player
|
// Rotate Player
|
||||||
TilesManager tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
TilesManager tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
SetGameplayManager();
|
||||||
|
|
||||||
Vector3 lookDirection = Vector3.zero;
|
Vector3 lookDirection = Vector3.zero;
|
||||||
|
|
||||||
@ -121,7 +124,7 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
transform.position = transformData.position;
|
transform.position = transformData.position;
|
||||||
transform.rotation = transformData.rotation;
|
transform.rotation = transformData.rotation;
|
||||||
SetPlayerState(PlayerState.InHome);
|
SetPlayerState(PlayerState.InHome);
|
||||||
ShowPlayerCountCanvas(false);
|
ShowPlayerSelCanvas(false);
|
||||||
StepsTaken = 0;
|
StepsTaken = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +159,13 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
|
|
||||||
public void ShowPlayerCountCanvas(bool show)
|
public void ShowPlayerCountCanvas(bool show)
|
||||||
{
|
{
|
||||||
playerCountCanvas.gameObject.SetActive(show);
|
// add the player count canvas to the object and show from here.
|
||||||
|
// playerIndicatorCanvas.gameObject.SetActive(show);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ShowPlayerSelCanvas(bool show)
|
||||||
|
{
|
||||||
|
playerIndicatorCanvas.gameObject.SetActive(show);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetData()
|
public void ResetData()
|
||||||
@ -164,8 +173,7 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
SetPlayerState(PlayerState.InHome);
|
SetPlayerState(PlayerState.InHome);
|
||||||
StepsTaken = 0;
|
StepsTaken = 0;
|
||||||
PlayerId = 0;
|
PlayerId = 0;
|
||||||
if (playerCountCanvas.gameObject.activeInHierarchy)
|
if (playerIndicatorCanvas.gameObject.activeInHierarchy)
|
||||||
ShowPlayerCountCanvas(false);
|
ShowPlayerSelCanvas(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,13 +55,11 @@ public class GameHUDS : ScreenBase
|
|||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType playerType, int remSec)
|
public void UpdatePlayerTurnText(PlayerType playerType, int remSec)
|
||||||
{
|
{
|
||||||
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
|
||||||
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)} ({remSec})";
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)} ({remSec})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBotTurnText(PlayerType playerType)
|
public void UpdateBotTurnText(PlayerType playerType)
|
||||||
{
|
{
|
||||||
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
|
||||||
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)}";
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ using TMPro;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class PlayerCountCanvas : MonoBehaviour
|
public class PlayerIndicatorCanvas : MonoBehaviour
|
||||||
{
|
{
|
||||||
Transform cam;
|
Transform cam;
|
||||||
[SerializeField] private TMP_Text playerCountText;
|
[SerializeField] private TMP_Text playerCountText;
|
||||||
@ -21,18 +21,22 @@ public class PlayerCountCanvas : MonoBehaviour
|
|||||||
indicatorBtn.onClick.RemoveListener(() => OnClickPlayer());
|
indicatorBtn.onClick.RemoveListener(() => OnClickPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
cam = GameObject.FindGameObjectWithTag("MainCamera").transform;
|
cam = GameObject.FindGameObjectWithTag("MainCamera").transform;
|
||||||
}
|
}
|
||||||
void LateUpdate()
|
|
||||||
|
private void LateUpdate()
|
||||||
{
|
{
|
||||||
transform.LookAt(cam.forward + transform.position);
|
transform.LookAt(cam.forward + transform.position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if UNITY_EDITOR
|
||||||
public void SetPlayerCount(int count)
|
public void SetPlayerCount(int count)
|
||||||
{
|
{
|
||||||
playerCountText.text = count.ToString();
|
playerCountText.text = count.ToString();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
public void OnClickPlayer()
|
public void OnClickPlayer()
|
||||||
{
|
{
|
||||||
Loading…
x
Reference in New Issue
Block a user