|
|
|
|
@ -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,7 +208,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO :: Call based on 2P/3P/4P
|
|
|
|
|
public void InitCurrentGamePlayerInfo()
|
|
|
|
|
{
|
|
|
|
|
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
|
|
|
|
@ -309,12 +308,6 @@ 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;
|
|
|
|
|
|
|
|
|
|
@ -322,7 +315,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
|
|
|
|
|
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0)
|
|
|
|
|
{
|
|
|
|
|
InitActivePlayers();
|
|
|
|
|
UpdateActivePlayersAndSetDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (availPlayers.Count() < 1 && CanRollDiceAgain) // got a 6 roll value
|
|
|
|
|
@ -525,7 +518,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
|
|
|
|
|
InitActivePlayers();
|
|
|
|
|
UpdateActivePlayersAndSetDisplay();
|
|
|
|
|
|
|
|
|
|
int customAvailPlayers = availPlayers.Count();
|
|
|
|
|
Debug.Log($"before CustomAvailablePlayers: {customAvailPlayers}");
|
|
|
|
|
@ -567,17 +560,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void InitActivePlayers()
|
|
|
|
|
private void UpdateActivePlayersAndSetDisplay()
|
|
|
|
|
{
|
|
|
|
|
availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values.Select(pawn => pawn)
|
|
|
|
|
.Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone ||
|
|
|
|
|
pawn.GetPlayerState() == PlayerState.Moving ||
|
|
|
|
|
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var player in availPlayers) // TODO :: Move from here
|
|
|
|
|
{
|
|
|
|
|
DisplayPlayerCountOnTile(player, true);
|
|
|
|
|
}
|
|
|
|
|
SetDisplayCountForAllAvailPlayers(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private bool AreAllPawnsInFinishingPath()
|
|
|
|
|
@ -624,32 +614,32 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void OnPawnSelected(PlayerPawn playerPawn)
|
|
|
|
|
public void OnPawnSelected(PlayerPawn selectedPawn)
|
|
|
|
|
{
|
|
|
|
|
EnablePlayerSelectionStates(false);
|
|
|
|
|
|
|
|
|
|
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
|
|
|
|
Debug.Log($"playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}");
|
|
|
|
|
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (playerPawn.GetPlayerState() == PlayerState.InHome)
|
|
|
|
|
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
|
|
|
|
{
|
|
|
|
|
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
|
|
|
|
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, false);
|
|
|
|
|
playerPawn.MoveToTile(
|
|
|
|
|
GetAndInitPositionInsideSafeZone(playerPawn, targetTile),
|
|
|
|
|
selectedPawn.ShowPlayerCountCanvas(false);
|
|
|
|
|
selectedPawn.MoveToTile(
|
|
|
|
|
GetAndInitPositionInsideSafeZone(selectedPawn, targetTile),
|
|
|
|
|
onComplete: () =>
|
|
|
|
|
{
|
|
|
|
|
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
|
|
|
|
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, true);
|
|
|
|
|
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(selectedPawn);
|
|
|
|
|
if (CheckForMaxDiceRollAttempt())
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (playerPawn.IsBotPlayer)
|
|
|
|
|
if (selectedPawn.IsBotPlayer)
|
|
|
|
|
CheckDiceRollForBot();
|
|
|
|
|
else
|
|
|
|
|
SetCanRollDiceForUser(true);
|
|
|
|
|
@ -658,53 +648,71 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
|
|
|
|
else if (selectedPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
|
|
|
|
{
|
|
|
|
|
ApplyFinishingPathLogic(playerPawn);
|
|
|
|
|
}
|
|
|
|
|
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
|
|
|
|
Tile currentSittingTile = tilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
|
|
|
|
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
|
|
|
|
|
|
|
|
|
if (currentSittingTile.HasPawnsAvailable)
|
|
|
|
|
{
|
|
|
|
|
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
|
|
|
|
ApplyFinishingPathLogic(playerPawn);
|
|
|
|
|
var playerPawns = currentSittingTile.GetPlayerPawns();
|
|
|
|
|
foreach (var pawn in playerPawns)
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(pawn);
|
|
|
|
|
}
|
|
|
|
|
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
|
|
|
|
|
|
|
|
|
ApplyFinishingPathLogic(selectedPawn);
|
|
|
|
|
}
|
|
|
|
|
else if (selectedPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
|
|
|
|
{
|
|
|
|
|
tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex).ResetPlayerPawn(selectedPawn);
|
|
|
|
|
ApplyFinishingPathLogic(selectedPawn);
|
|
|
|
|
}
|
|
|
|
|
else if (selectedPawn.GetPlayerState() == PlayerState.InSafeZone || selectedPawn.GetPlayerState() == PlayerState.Moving)
|
|
|
|
|
{
|
|
|
|
|
// move based on the dice value
|
|
|
|
|
Debug.Log($"Tile Index :: currentTileIndex: {playerPawn.CurrentTileIndex}");
|
|
|
|
|
int nextTileIdx = GetNextGeneralTileIndex(playerPawn);
|
|
|
|
|
int targetIdx = playerPawn.CurrentTileIndex + diceRolledValue;
|
|
|
|
|
Debug.Log($"Tile Index :: currentTileIndex: {selectedPawn.CurrentTileIndex}");
|
|
|
|
|
int nextTileIdx = GetNextGeneralTileIndex(selectedPawn);
|
|
|
|
|
int targetIdx = selectedPawn.CurrentTileIndex + diceRolledValue;
|
|
|
|
|
|
|
|
|
|
if (nextTileIdx == 0)
|
|
|
|
|
targetIdx = (targetIdx - playerPawn.CurrentTileIndex) - 1;
|
|
|
|
|
targetIdx = (targetIdx - selectedPawn.CurrentTileIndex) - 1;
|
|
|
|
|
|
|
|
|
|
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
|
|
|
|
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex);
|
|
|
|
|
if (currentSittingTile.IsSafeZone)
|
|
|
|
|
{
|
|
|
|
|
SafeTile safeTile = (SafeTile)currentSittingTile;
|
|
|
|
|
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);
|
|
|
|
|
// }
|
|
|
|
|
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn);
|
|
|
|
|
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
|
|
|
|
{
|
|
|
|
|
var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType);
|
|
|
|
|
|
|
|
|
|
if (safeTile.PlayerTypesCount == 1)
|
|
|
|
|
{
|
|
|
|
|
PlayerType playerType = safeTile.GetFirstPlayerType();
|
|
|
|
|
|
|
|
|
|
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
|
|
|
|
foreach (var pawn in playerPawns)
|
|
|
|
|
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
|
|
|
|
{
|
|
|
|
|
foreach (var pawn in playerPawns)
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(pawn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
currentSittingTile.ResetPlayerPawn(playerPawn);
|
|
|
|
|
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
|
|
|
|
if (currentSittingTile.HasPawnsAvailable)
|
|
|
|
|
{
|
|
|
|
|
var playerPawns = currentSittingTile.GetPlayerPawns();
|
|
|
|
|
foreach (var pawn in playerPawns)
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(pawn);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
|
|
|
|
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -715,7 +723,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
|
|
|
|
|
|
|
|
|
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, false);
|
|
|
|
|
|
|
|
|
|
playerPawn.ShowPlayerCountCanvas(false);
|
|
|
|
|
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -742,9 +751,8 @@ 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);
|
|
|
|
|
|
|
|
|
|
@ -772,8 +780,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
diceSixRollCounter = 0;
|
|
|
|
|
diceText.text = $"{0}";
|
|
|
|
|
|
|
|
|
|
InitActivePlayers();
|
|
|
|
|
SetDisplayCountForAllAvailPlayers(true);
|
|
|
|
|
UpdateActivePlayersAndSetDisplay();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
|
|
|
|
@ -800,9 +807,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
|
|
|
|
|
public void SetDisplayCountForAllAvailPlayers(bool state)
|
|
|
|
|
{
|
|
|
|
|
foreach (var pawn in availPlayers)
|
|
|
|
|
if (state)
|
|
|
|
|
{
|
|
|
|
|
DisplayPlayerCountOnTile(pawn, state);
|
|
|
|
|
availPlayers.ForEach(pawn => ShowUpdatedPlayerCountOnTile(pawn));
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
availPlayers.ForEach(pawn => pawn.ShowPlayerCountCanvas(false));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -823,7 +834,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug.Log($"tile targetPosition: {targetPosition}");
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, false);
|
|
|
|
|
playerPawn.ShowPlayerCountCanvas(false);
|
|
|
|
|
|
|
|
|
|
playerPawn.MoveToTile(
|
|
|
|
|
targetPosition,
|
|
|
|
|
@ -856,7 +867,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
|
|
|
|
|
|
|
|
|
if (CanRollDiceAgain)
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, true);
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
|
|
|
|
|
|
|
|
|
if (!nextTile.IsSafeZone)
|
|
|
|
|
{
|
|
|
|
|
@ -875,8 +886,7 @@ 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++;
|
|
|
|
|
@ -886,7 +896,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
if (CheckForMaxDiceRollAttempt())
|
|
|
|
|
{
|
|
|
|
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, true);
|
|
|
|
|
// UpdatePlayerCountOnTile(playerPawn, true);
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
@ -897,7 +907,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
|
|
|
|
DisplayPlayerCountOnTile(playerPawn, true);
|
|
|
|
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
|
|
|
|
|
|
|
|
|
if (CheckForMaxDiceRollAttempt())
|
|
|
|
|
{
|
|
|
|
|
@ -998,9 +1008,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++;
|
|
|
|
|
|
|
|
|
|
@ -1042,11 +1052,16 @@ 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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -1060,14 +1075,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DisplayPlayerCountOnTile(PlayerPawn playerPawn, bool show)
|
|
|
|
|
private void ShowUpdatedPlayerCountOnTile(PlayerPawn playerPawn)
|
|
|
|
|
{
|
|
|
|
|
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
|
|
|
|
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
|
|
|
|
: tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
|
|
|
|
|
|
|
|
|
playerPawn.ShowPlayerCountCanvas(show);
|
|
|
|
|
if (!show) return;
|
|
|
|
|
playerPawn.ShowPlayerCountCanvas(true);
|
|
|
|
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
if (tile.IsSafeZone)
|
|
|
|
|
@ -1079,6 +1093,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|
|
|
|
count = tile.TotalPawnsInTile;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Debug.Log($"ShowUpdatedPlayerCountOnTile: {count}");
|
|
|
|
|
|
|
|
|
|
playerPawn.PlayerCountCanvas.SetPlayerCount(count);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|