Compare commits
No commits in common. "384356dc51a8ea74c8d972b68c24c78596711f7b" and "874e44a7f7343ddc19f9be4e378bcb5b1a2bb532" have entirely different histories.
384356dc51
...
874e44a7f7
@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DG.Tweening;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -81,7 +80,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
InterfaceManager.Instance?.RegisterInterface<GameplayManager>(this);
|
InterfaceManager.Instance?.RegisterInterface<GameplayManager>(this);
|
||||||
DOTween.useSafeMode = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
@ -236,7 +234,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
Debug.Log($"Switching player");
|
Debug.Log($"Switching player");
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
SetCanRollDiceForUser(currentPlayerTypeTurn, true);
|
CanRollDice = true;
|
||||||
}
|
}
|
||||||
// else if (botTypesInGame.Contains(currentPlayerTypeTurn) && CanRollDiceAgain)
|
// else if (botTypesInGame.Contains(currentPlayerTypeTurn) && CanRollDiceAgain)
|
||||||
// {
|
// {
|
||||||
@ -312,7 +310,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: state: {playerPawn.GetPlayerState()}, possibleLandingIndex: {possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex}");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: state: {playerPawn.GetPlayerState()}, possibleLandingIndex: {possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex}");
|
||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: possibleTileData.IsSafeZone: {possibleTileData.IsSafeZone}");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: possibleTileData.IsSafeZone: {possibleTileData.IsSafeZone}");
|
||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: possibleTileData.PlayerPawn: {possibleTileData.HasPawnsAvailable}");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: possibleTileData.PlayerPawn: {possibleTileData.PlayerPawn}");
|
||||||
|
|
||||||
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||||
{
|
{
|
||||||
@ -333,7 +331,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: safeMove");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: safeMove");
|
||||||
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.SafeMove;
|
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.SafeMove;
|
||||||
}
|
}
|
||||||
else if (possibleTileData.HasPawnsAvailable)
|
else if (possibleTileData.PlayerPawn != null)
|
||||||
{
|
{
|
||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: attackMove");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: attackMove");
|
||||||
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.AttackMove;
|
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.AttackMove;
|
||||||
@ -416,7 +414,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void OnDiceRolled(int rolledVal)
|
public void OnDiceRolled(int rolledVal)
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(currentPlayerTypeTurn, false);
|
CanRollDice = 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}");
|
||||||
@ -439,7 +437,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"### AreAllPawnsInFinishingPath");
|
Debug.Log($"### AreAllPawnsInFinishingPath");
|
||||||
if (AreAllPawnsInFinishingPath())
|
if (AreAllPawnsInFinishingPath())
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(currentPlayerTypeTurn, true);
|
CanRollDice = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -552,7 +550,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
||||||
|
|
||||||
SetCanRollDiceForUser(playerPawn.PlayerType, true);
|
CanRollDice = true;
|
||||||
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
||||||
if (playerPawn.IsBotPlayer)
|
if (playerPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot(playerPawn);
|
CheckDiceRollForBot(playerPawn);
|
||||||
@ -561,14 +559,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath
|
||||||
|
|| playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||||
{
|
{
|
||||||
ApplyFinishingPathLogic(playerPawn);
|
int finishingPathIndex = GetNextFinishingTileIndex(playerPawn);
|
||||||
}
|
int targetIdx = finishingPathIndex + diceRolledValue > tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 ?
|
||||||
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
||||||
{
|
|
||||||
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
||||||
ApplyFinishingPathLogic(playerPawn);
|
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
||||||
}
|
}
|
||||||
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
||||||
{
|
{
|
||||||
@ -597,24 +596,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentSittingTile.ResetPlayerPawn(playerPawn);
|
currentSittingTile.ResetPlayerPawn();
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ApplyFinishingPathLogic(PlayerPawn playerPawn)
|
|
||||||
{
|
|
||||||
int finishingPathIndex = GetNextFinishingTileIndex(playerPawn);
|
|
||||||
int targetIdx = finishingPathIndex + diceRolledValue > tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 ?
|
|
||||||
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
|
||||||
|
|
||||||
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
|
||||||
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public int GetNextGeneralTileIndex(PlayerPawn playerPawn)
|
public int GetNextGeneralTileIndex(PlayerPawn playerPawn)
|
||||||
{
|
{
|
||||||
return playerPawn.CurrentTileIndex == tilesManager.GetGeneralTilesLength() - 1 ? 0 : playerPawn.CurrentTileIndex + 1;
|
return playerPawn.CurrentTileIndex == tilesManager.GetGeneralTilesLength() - 1 ? 0 : playerPawn.CurrentTileIndex + 1;
|
||||||
@ -722,45 +710,25 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
||||||
if (!nextTile.IsSafeZone)
|
if (!nextTile.IsSafeZone)
|
||||||
{
|
{
|
||||||
Debug.Log($"nextTile.HasPawnsAvailable: {nextTile.HasPawnsAvailable}");
|
Debug.Log($"nextTile.PlayerPawn: {nextTile.PlayerPawn}, {nextTile.transform.name}");
|
||||||
if (nextTile.HasPawnsAvailable && playerPawn.PlayerType != nextTile.CurrentHoldingPlayerType)
|
if (nextTile.PlayerPawn != null && playerPawn.PlayerType != nextTile.PlayerPawn.PlayerType)
|
||||||
{
|
{
|
||||||
Debug.Log($"nextTile.PlayerPawn: {nextTile.CurrentHoldingPlayerType}, {nextTile.transform.name}");
|
|
||||||
Debug.Log($"nextTile.TotalPawnsInTile: {nextTile.TotalPawnsInTile}");
|
|
||||||
// play animation for moving back to base.
|
// play animation for moving back to base.
|
||||||
// TODO :: Send existing pawn back to base.
|
// TODO :: Send existing pawn back to base.
|
||||||
// means there's already a pawn there, move him back to the base.
|
// means there's already a pawn there, move him back to the base.
|
||||||
int counter = nextTile.TotalPawnsInTile;
|
var playerBasePos = playerBaseHandler.GetPlayerBase(nextTile.PlayerPawn.PlayerType)
|
||||||
for (int i = counter; i > 0; i--)
|
.GetBasePlacementDataPosition(nextTile.PlayerPawn.PlayerId - 1);
|
||||||
{
|
Debug.Log($"playerBasePos: {playerBasePos}");
|
||||||
var pawn = nextTile.GetPlayerPawn();
|
|
||||||
Debug.Log($"pawn: {pawn}");
|
|
||||||
Debug.Log($"playerBase: {playerBaseHandler}");
|
|
||||||
|
|
||||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType)
|
playerGameDatasDict[nextTile.PlayerPawn.PlayerType].totalPawnsInHome++;
|
||||||
.GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
nextTile.PlayerPawn.MoveBackToHome(playerBasePos);
|
||||||
Debug.Log($"playerBasePos: {playerBasePos}");
|
|
||||||
|
|
||||||
playerGameDatasDict[pawn.PlayerType].totalPawnsInHome++;
|
|
||||||
pawn.MoveBackToHome(playerBasePos);
|
|
||||||
}
|
|
||||||
|
|
||||||
CanRollDiceAgain = true;
|
|
||||||
|
|
||||||
if (playerPawn.IsBotPlayer)
|
|
||||||
CheckDiceRollForBot(playerPawn);
|
|
||||||
else
|
|
||||||
SetCanRollDiceForUser(playerPawn.PlayerType, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchPlayer(playerPawn);
|
SwitchPlayer(playerPawn);
|
||||||
if (!CanRollDiceAgain)
|
CanRollDice = true;
|
||||||
{
|
|
||||||
SetCanRollDiceForUser(playerPawn.PlayerType, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
@ -851,16 +819,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
||||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
||||||
|
|
||||||
Debug.Log($"totalPawnsFinished: {playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished}, playerPawnsDict.Count: {playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count}");
|
|
||||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count)
|
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count)
|
||||||
{
|
{
|
||||||
CanRollDiceAgain = false;
|
CanRollDiceAgain = false;
|
||||||
|
|
||||||
|
SwitchPlayer();
|
||||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||||
|
|
||||||
SwitchPlayer();
|
|
||||||
|
|
||||||
Debug.Log($"PlayerTypes: {allPlayerTypes.Count}");
|
Debug.Log($"PlayerTypes: {allPlayerTypes.Count}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -875,16 +841,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCanRollDiceForUser(playerPawn.PlayerType, true);
|
CanRollDice = true;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCanRollDiceForUser(PlayerType playerType, bool state)
|
|
||||||
{
|
|
||||||
if (botTypesInGame.Contains(playerType)) return;
|
|
||||||
|
|
||||||
CanRollDice = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,6 @@ public class PlayerBase : MonoBehaviour
|
|||||||
|
|
||||||
public Transform GetBasePlacementDataPosition(int idx)
|
public Transform GetBasePlacementDataPosition(int idx)
|
||||||
{
|
{
|
||||||
Debug.Log($"Index: {idx}, basePlacementDatas[idx]: {basePlacementDatas[idx]}");
|
|
||||||
return basePlacementDatas[idx].placementTransform;
|
return basePlacementDatas[idx].placementTransform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,30 +27,18 @@ public class Tile : MonoBehaviour
|
|||||||
|
|
||||||
protected int lastOccupiedIndex = 0;
|
protected int lastOccupiedIndex = 0;
|
||||||
|
|
||||||
private List<PlayerPawn> PlayerPawns = new List<PlayerPawn>(); // Change implementation
|
public PlayerPawn PlayerPawn // Change implementation
|
||||||
|
|
||||||
public bool HasPawnsAvailable => PlayerPawns.Count > 0;
|
|
||||||
public PlayerType CurrentHoldingPlayerType => PlayerPawns[0].PlayerType;
|
|
||||||
public int TotalPawnsInTile => PlayerPawns.Count;
|
|
||||||
|
|
||||||
public PlayerPawn GetPlayerPawn()
|
|
||||||
{
|
{
|
||||||
var pawn = PlayerPawns[0];
|
get; private set;
|
||||||
PlayerPawns.RemoveAt(0);
|
|
||||||
return pawn;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void InitPlayerPawn(PlayerPawn playerPawn, PlayerType playerType)
|
public virtual void InitPlayerPawn(PlayerPawn playerPawn, PlayerType playerType)
|
||||||
{
|
{
|
||||||
PlayerPawns.Add(playerPawn);
|
PlayerPawn = playerPawn;
|
||||||
Debug.Log($"Adding new PlayerPawn {playerPawn.name}, playerType: {playerType} to {name}");
|
|
||||||
Debug.Log($"Adding new PlayerPawn {PlayerPawns.Count} {name}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetPlayerPawn(PlayerPawn movingPawn)
|
public void ResetPlayerPawn()
|
||||||
{
|
{
|
||||||
PlayerPawns.Remove(movingPawn);
|
PlayerPawn = null;
|
||||||
Debug.Log($"Resetting new PlayerPawn {movingPawn.name} {name}");
|
|
||||||
Debug.Log($"Resetting new PlayerPawn {PlayerPawns.Count} {name}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user