Refactored FindPossibleTileData function.
This commit is contained in:
parent
4530c474e9
commit
57787ecc4e
@ -24,6 +24,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
[SerializeField] private int diceValue = 0;
|
||||
[SerializeField] private int maxDiceSixRollCounter = 2;
|
||||
[SerializeField] private int totalStepsForCharacter = 57;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI diceText;
|
||||
|
||||
@ -463,16 +464,24 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private void FindPossibleTileData(PlayerPawn playerPawn, out int possibleSteps, out Tile possibleTileData)
|
||||
{
|
||||
possibleSteps = playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId].StepsTaken + diceRolledValue;
|
||||
int lastStepGenTileIdx = playerGameDatasDict[playerPawn.PlayerType].endIndex;
|
||||
int lastStepGenTile = totalStepsForCharacter - tilesManager.GetFinishingTileDataLength(playerPawn.PlayerType);//playerGameDatasDict[playerPawn.PlayerType].endIndex;
|
||||
int possibleTileIndex = playerPawn.CurrentTileIndex + diceRolledValue;
|
||||
|
||||
int totalStepsInGeneralPath = tilesManager.GetGeneralTilesLength() - 1; // including the first safe zone
|
||||
int lastTileIndex = tilesManager.GetGeneralTilesLength() - 1;
|
||||
int index = possibleSteps > totalStepsInGeneralPath ? possibleTileIndex - lastStepGenTileIdx - 1
|
||||
: possibleTileIndex > lastTileIndex ? possibleTileIndex - lastTileIndex - 1 : possibleTileIndex;
|
||||
bool canGoingInsideFinishingPath = IsGoingInsideFinishingPath(playerPawn, out possibleSteps);
|
||||
|
||||
possibleTileData = possibleSteps > totalStepsInGeneralPath ? tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, index) : tilesManager.RetrieveTileBasedOnIndex(index);
|
||||
int index = canGoingInsideFinishingPath ? possibleSteps - lastStepGenTile - 1
|
||||
: possibleTileIndex > lastTileIndex ? possibleTileIndex - lastTileIndex - 1 : possibleTileIndex; // case for addressing the scenario when going through the last index of general tiles.
|
||||
|
||||
Debug.Log($"possibleTileIndex: {possibleTileIndex}, lastStepGenTileIdx: {lastStepGenTile}");
|
||||
Debug.Log($"index: {index}");
|
||||
possibleTileData = canGoingInsideFinishingPath ? tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, index) : tilesManager.RetrieveTileBasedOnIndex(index);
|
||||
}
|
||||
|
||||
public bool IsGoingInsideFinishingPath(PlayerPawn playerPawn, out int possibleSteps)
|
||||
{
|
||||
possibleSteps = playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId].StepsTaken + diceRolledValue;
|
||||
return possibleSteps > tilesManager.GetGeneralTilesLength() - 1;
|
||||
}
|
||||
|
||||
public void OnDiceRolled(int rolledVal)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user