Compare commits

..

2 Commits

Author SHA1 Message Date
f1e88fe0f3 Added player rotation logic when entering finishing tiles
- refactor code (GetComponentInChildren -> ref from serialized object)
2026-02-02 16:37:43 +05:30
d07951dabf Refactored FindPossibleTileData function. 2026-02-02 16:07:27 +05:30
6 changed files with 93 additions and 10 deletions

View File

@ -630,6 +630,7 @@ MonoBehaviour:
playerState: 0
animator: {fileID: 5526766409186502679}
playerCountCanvasPrefab: {fileID: 9029553984926861784}
playerCountCanvas: {fileID: 5728752331380905399}
--- !u!1 &4818123989977612668
GameObject:
m_ObjectHideFlags: 0
@ -1622,6 +1623,17 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 953143927943285832, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 4537709141704337870}
m_PrefabAsset: {fileID: 0}
--- !u!114 &5728752331380905399 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 4537709141704337870}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 9029553984926861784}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &9029553984926861784 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}

View File

@ -630,6 +630,7 @@ MonoBehaviour:
playerState: 0
animator: {fileID: 5274388487207906813}
playerCountCanvasPrefab: {fileID: 6862258105288866118}
playerCountCanvas: {fileID: 7923051124467737897}
--- !u!1 &5059623752267150313
GameObject:
m_ObjectHideFlags: 0
@ -1671,3 +1672,14 @@ GameObject:
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 2057554100330600784}
m_PrefabAsset: {fileID: 0}
--- !u!114 &7923051124467737897 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 2057554100330600784}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6862258105288866118}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
m_Name:
m_EditorClassIdentifier:

View File

@ -202,6 +202,7 @@ MonoBehaviour:
playerState: 0
animator: {fileID: 232863433340697214}
playerCountCanvasPrefab: {fileID: 2911420982173280738}
playerCountCanvas: {fileID: 1920934309388072333}
--- !u!136 &1627116187348267135
CapsuleCollider:
m_ObjectHideFlags: 0
@ -1661,6 +1662,17 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
--- !u!114 &1920934309388072333 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 7769048123306772980}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2911420982173280738}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &2911420982173280738 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}

View File

@ -1259,6 +1259,7 @@ MonoBehaviour:
playerState: 0
animator: {fileID: 7800412279828783518}
playerCountCanvasPrefab: {fileID: 4593694095142779203}
playerCountCanvas: {fileID: 941219433310479660}
--- !u!1 &7074820051352815849
GameObject:
m_ObjectHideFlags: 0
@ -1661,6 +1662,17 @@ PrefabInstance:
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
--- !u!114 &941219433310479660 stripped
MonoBehaviour:
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
m_PrefabInstance: {fileID: 8968445451050703189}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4593694095142779203}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &4593694095142779203 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}

View File

@ -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;
@ -464,16 +465,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)
@ -1070,7 +1079,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
count = tile.TotalPawnsInTile;
}
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
playerPawn.PlayerCountCanvas.SetPlayerCount(count);
}
public void ResetData()

View File

@ -90,10 +90,36 @@ public class PlayerPawn : MonoBehaviour
TilesManager tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
int nextTileIndex = gameplayManager.GetNextGeneralTileIndex(this);
Vector3 lookDirection = tilesManager.RetrieveTileBasedOnIndex(nextTileIndex).transform.position - transform.position;
Vector3 lookDirection = Vector3.zero;
if (playerState == PlayerState.InFinishingPath)
{
int nextIndex = CurrentTileIndex + 1;
int maxIndex = tilesManager.GetFinishingTileDataLength(PlayerType) - 1;
if (nextIndex <= maxIndex)
{
lookDirection = tilesManager.RetrieveFinishingTileBasedOnIndex(PlayerType, nextIndex).transform.position - transform.position;
}
}
else
{
if (gameplayManager.IsGoingInsideFinishingPath(this, out int possibleSteps))
{
lookDirection =tilesManager.RetrieveFinishingTileBasedOnIndex(PlayerType, 0).transform.position - transform.position;
}
else
{
int nextIndex = gameplayManager.GetNextGeneralTileIndex(this);
lookDirection = tilesManager.RetrieveTileBasedOnIndex(nextIndex).transform.position - transform.position;
}
}
lookDirection.y = 0;
transform.DOLookAt(transform.position + lookDirection, 0.2f);
if (lookDirection != Vector3.zero)
{
transform.DOLookAt(transform.position + lookDirection, 0.2f);
}
onComplete?.Invoke();
};