Compare commits
No commits in common. "1897a36a88db033a3ab9e69e4f8d8eba2ab6adc9" and "f1e88fe0f35ff8aa6eec1dd824b17329c3bbb98f" have entirely different histories.
1897a36a88
...
f1e88fe0f3
@ -8464,7 +8464,6 @@ MonoBehaviour:
|
||||
diceRollHandler: {fileID: 1013177415}
|
||||
diceValue: 6
|
||||
maxDiceSixRollCounter: 2
|
||||
totalStepsForCharacter: 57
|
||||
diceText: {fileID: 953941044}
|
||||
pointerDebug: {fileID: 102349503}
|
||||
pointerMeshRend: {fileID: 102349501}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using TMPro;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum BotMove
|
||||
{
|
||||
@ -208,6 +208,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
// TODO :: Call based on 2P/3P/4P
|
||||
public void InitCurrentGamePlayerInfo()
|
||||
{
|
||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||
@ -308,6 +309,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CallTest: SelectPawnFromBotBase: {currentPlayerTypeTurn}");
|
||||
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
|
||||
|
||||
// check the data from the playerGameDataDict
|
||||
// change playerPawnsDict to list
|
||||
|
||||
// only select the pawns that are active
|
||||
// if no pawns have left the home select the first pawn inside the base should be selected
|
||||
|
||||
int savedPlayerId = -1;
|
||||
PlayerPawn pawn = null;
|
||||
|
||||
@ -315,7 +322,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0)
|
||||
{
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
InitActivePlayers();
|
||||
}
|
||||
|
||||
if (availPlayers.Count() < 1 && CanRollDiceAgain) // got a 6 roll value
|
||||
@ -518,7 +525,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else // if there are any other pawns that are in safe or moving state
|
||||
{
|
||||
// for player's logic
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
InitActivePlayers();
|
||||
|
||||
int customAvailPlayers = availPlayers.Count();
|
||||
Debug.Log($"before CustomAvailablePlayers: {customAvailPlayers}");
|
||||
@ -560,14 +567,17 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
||||
}
|
||||
|
||||
private void UpdateActivePlayersAndSetDisplay()
|
||||
private void InitActivePlayers()
|
||||
{
|
||||
availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values.Select(pawn => pawn)
|
||||
.Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone ||
|
||||
pawn.GetPlayerState() == PlayerState.Moving ||
|
||||
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
||||
|
||||
SetDisplayCountForAllAvailPlayers(true);
|
||||
foreach (var player in availPlayers) // TODO :: Move from here
|
||||
{
|
||||
DisplayPlayerCountOnTile(player, true);
|
||||
}
|
||||
}
|
||||
|
||||
private bool AreAllPawnsInFinishingPath()
|
||||
@ -614,32 +624,32 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||
}
|
||||
|
||||
public void OnPawnSelected(PlayerPawn selectedPawn)
|
||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||
{
|
||||
EnablePlayerSelectionStates(false);
|
||||
|
||||
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
||||
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
||||
Debug.Log($"playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}");
|
||||
|
||||
|
||||
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
||||
if (playerPawn.GetPlayerState() == PlayerState.InHome)
|
||||
{
|
||||
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
||||
|
||||
selectedPawn.ShowPlayerCountCanvas(false);
|
||||
selectedPawn.MoveToTile(
|
||||
GetAndInitPositionInsideSafeZone(selectedPawn, targetTile),
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.MoveToTile(
|
||||
GetAndInitPositionInsideSafeZone(playerPawn, targetTile),
|
||||
onComplete: () =>
|
||||
{
|
||||
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
||||
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
||||
ShowUpdatedPlayerCountOnTile(selectedPawn);
|
||||
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedPawn.IsBotPlayer)
|
||||
if (playerPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot();
|
||||
else
|
||||
SetCanRollDiceForUser(true);
|
||||
@ -648,71 +658,53 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
return;
|
||||
}
|
||||
else if (selectedPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
||||
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
||||
{
|
||||
Tile currentSittingTile = tilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||
|
||||
if (currentSittingTile.HasPawnsAvailable)
|
||||
{
|
||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
ApplyFinishingPathLogic(playerPawn);
|
||||
}
|
||||
else if (selectedPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
{
|
||||
tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex).ResetPlayerPawn(selectedPawn);
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
||||
ApplyFinishingPathLogic(playerPawn);
|
||||
}
|
||||
else if (selectedPawn.GetPlayerState() == PlayerState.InSafeZone || selectedPawn.GetPlayerState() == PlayerState.Moving)
|
||||
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
||||
{
|
||||
// move based on the dice value
|
||||
Debug.Log($"Tile Index :: currentTileIndex: {selectedPawn.CurrentTileIndex}");
|
||||
int nextTileIdx = GetNextGeneralTileIndex(selectedPawn);
|
||||
int targetIdx = selectedPawn.CurrentTileIndex + diceRolledValue;
|
||||
Debug.Log($"Tile Index :: currentTileIndex: {playerPawn.CurrentTileIndex}");
|
||||
int nextTileIdx = GetNextGeneralTileIndex(playerPawn);
|
||||
int targetIdx = playerPawn.CurrentTileIndex + diceRolledValue;
|
||||
|
||||
if (nextTileIdx == 0)
|
||||
targetIdx = (targetIdx - selectedPawn.CurrentTileIndex) - 1;
|
||||
targetIdx = (targetIdx - playerPawn.CurrentTileIndex) - 1;
|
||||
|
||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex);
|
||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
if (currentSittingTile.IsSafeZone)
|
||||
{
|
||||
SafeTile safeTile = (SafeTile)currentSittingTile;
|
||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn);
|
||||
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn);
|
||||
// DisplayPlayerCountOnTile(playerPawn, false);
|
||||
// if (safeTile.PlayerTypesCount > 0)
|
||||
// {
|
||||
// var pawns = safeTile.GetPlayerPawns(playerPawn.PlayerType);
|
||||
// foreach (var pawn in pawns)
|
||||
// DisplayPlayerCountOnTile(pawn, true);
|
||||
// }
|
||||
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
{
|
||||
var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType);
|
||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
{
|
||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||
|
||||
foreach (var pawn in playerPawns)
|
||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||
}
|
||||
|
||||
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||
{
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
||||
foreach (var pawn in playerPawns)
|
||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||
if (currentSittingTile.HasPawnsAvailable)
|
||||
{
|
||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
currentSittingTile.ResetPlayerPawn(playerPawn);
|
||||
}
|
||||
|
||||
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
||||
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -723,8 +715,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
||||
|
||||
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
||||
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
||||
}
|
||||
|
||||
@ -751,8 +742,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
||||
|
||||
Debug.Log($"before SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
||||
if (availPlayers.Count < 1)
|
||||
InitActivePlayers();
|
||||
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
Debug.Log($"after SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
||||
SetDisplayCountForAllAvailPlayers(false);
|
||||
|
||||
@ -780,7 +772,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
diceSixRollCounter = 0;
|
||||
diceText.text = $"{0}";
|
||||
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
InitActivePlayers();
|
||||
SetDisplayCountForAllAvailPlayers(true);
|
||||
}
|
||||
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
@ -807,14 +800,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void SetDisplayCountForAllAvailPlayers(bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
availPlayers.ForEach(pawn => ShowUpdatedPlayerCountOnTile(pawn));
|
||||
}
|
||||
else
|
||||
{
|
||||
availPlayers.ForEach(pawn => pawn.ShowPlayerCountCanvas(false));
|
||||
}
|
||||
foreach (var pawn in availPlayers)
|
||||
{
|
||||
DisplayPlayerCountOnTile(pawn, state);
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||
@ -834,7 +823,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
|
||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
targetPosition,
|
||||
@ -867,7 +856,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
||||
|
||||
if (CanRollDiceAgain)
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
|
||||
if (!nextTile.IsSafeZone)
|
||||
{
|
||||
@ -886,7 +875,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"pawn: {pawn}");
|
||||
Debug.Log($"playerBase: {playerBaseHandler}");
|
||||
|
||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType).GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType)
|
||||
.GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
||||
Debug.Log($"playerBasePos: {playerBasePos}");
|
||||
|
||||
playerGameDatasDict[pawn.PlayerType].totalPawnsInHome++;
|
||||
@ -896,7 +886,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
// UpdatePlayerCountOnTile(playerPawn, true);
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -907,7 +897,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
|
||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
@ -1008,9 +998,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
||||
{
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
||||
|
||||
@ -1052,16 +1042,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else
|
||||
{
|
||||
// activate here
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(currentPlayerTypeTurn, playerPawn.CurrentTileIndex).InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CanRollDiceAgain)
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
|
||||
SwitchPlayer();
|
||||
}
|
||||
}
|
||||
@ -1075,13 +1060,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||
}
|
||||
|
||||
private void ShowUpdatedPlayerCountOnTile(PlayerPawn playerPawn)
|
||||
private void DisplayPlayerCountOnTile(PlayerPawn playerPawn, bool show)
|
||||
{
|
||||
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
||||
: tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
|
||||
playerPawn.ShowPlayerCountCanvas(true);
|
||||
playerPawn.ShowPlayerCountCanvas(show);
|
||||
if (!show) return;
|
||||
|
||||
int count = 0;
|
||||
if (tile.IsSafeZone)
|
||||
@ -1093,8 +1079,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
count = tile.TotalPawnsInTile;
|
||||
}
|
||||
|
||||
Debug.Log($"ShowUpdatedPlayerCountOnTile: {count}");
|
||||
|
||||
playerPawn.PlayerCountCanvas.SetPlayerCount(count);
|
||||
}
|
||||
|
||||
|
||||
@ -21,6 +21,7 @@ public class PlayerPawn : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private PlayerState playerState;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private GameObject playerCountCanvasPrefab;
|
||||
[SerializeField] private PlayerCountCanvas playerCountCanvas;
|
||||
|
||||
public PlayerCountCanvas PlayerCountCanvas => playerCountCanvas;
|
||||
@ -169,6 +170,8 @@ public class PlayerPawn : MonoBehaviour
|
||||
|
||||
public void ShowPlayerCountCanvas(bool show)
|
||||
{
|
||||
playerCountCanvas.gameObject.SetActive(show);
|
||||
if (playerCountCanvasPrefab == null) return;
|
||||
|
||||
playerCountCanvasPrefab.SetActive(show);
|
||||
}
|
||||
}
|
||||
|
||||
@ -27,8 +27,6 @@ public class Tile : MonoBehaviour
|
||||
|
||||
private List<PlayerPawn> PlayerPawns = new List<PlayerPawn>(); // Change implementation
|
||||
|
||||
public List<PlayerPawn> GetPlayerPawns() => PlayerPawns;
|
||||
|
||||
public bool HasPawnsAvailable => PlayerPawns.Count > 0;
|
||||
public PlayerType CurrentHoldingPlayerType => PlayerPawns[0].PlayerType;
|
||||
public int TotalPawnsInTile => PlayerPawns.Count;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user