Compare commits
No commits in common. "f12bd32c554874c61ca27e2156c8e8c442f6c7cf" and "ffabbf808f156ec81e069fff53d6baa7f61a49f1" have entirely different histories.
f12bd32c55
...
ffabbf808f
@ -27,8 +27,6 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
|
|
||||||
public void Roll(Action<int> onComplete, bool isBot)
|
public void Roll(Action<int> onComplete, bool isBot)
|
||||||
{
|
{
|
||||||
Debug.Log($"Start rolling: {rolling}");
|
|
||||||
|
|
||||||
if (!rolling)
|
if (!rolling)
|
||||||
{
|
{
|
||||||
Debug.Log($"isBot: {isBot}");
|
Debug.Log($"isBot: {isBot}");
|
||||||
@ -76,8 +74,9 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
//TODO: Use the dice value as needed
|
//TODO: Use the dice value as needed
|
||||||
Debug.Log($"Dice rolled: {value}");
|
Debug.Log($"Dice rolled: {value}");
|
||||||
|
|
||||||
ResetDice();
|
|
||||||
onRollingComplete?.Invoke(value);
|
onRollingComplete?.Invoke(value);
|
||||||
|
|
||||||
|
ResetDice();
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetDiceValue()
|
int GetDiceValue()
|
||||||
@ -99,7 +98,7 @@ public class DiceView : MonoBehaviour, IBase
|
|||||||
transform.localPosition = new Vector3(0, 20, 0);
|
transform.localPosition = new Vector3(0, 20, 0);
|
||||||
rolling = false;
|
rolling = false;
|
||||||
|
|
||||||
// Invoke(nameof(ResetEvent), 0.1f);
|
Invoke(nameof(ResetEvent), 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetEvent()
|
private void ResetEvent()
|
||||||
|
|||||||
@ -215,7 +215,7 @@ Canvas:
|
|||||||
m_VertexColorAlwaysGammaSpace: 0
|
m_VertexColorAlwaysGammaSpace: 0
|
||||||
m_AdditionalShaderChannelsFlag: 25
|
m_AdditionalShaderChannelsFlag: 25
|
||||||
m_SortingLayerID: 0
|
m_SortingLayerID: 0
|
||||||
m_SortingOrder: 5
|
m_SortingOrder: 0
|
||||||
m_TargetDisplay: 0
|
m_TargetDisplay: 0
|
||||||
--- !u!114 &1334714064113256010
|
--- !u!114 &1334714064113256010
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
|
|||||||
@ -8460,10 +8460,8 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 0483b263e22fc433caab31141efbe319, type: 3}
|
m_Script: {fileID: 11500000, guid: 0483b263e22fc433caab31141efbe319, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
isDebugTest: 1
|
|
||||||
diceRollHandler: {fileID: 1013177415}
|
diceRollHandler: {fileID: 1013177415}
|
||||||
diceValue: 6
|
diceValue: 6
|
||||||
maxDiceSixRollCounter: 2
|
|
||||||
diceText: {fileID: 953941044}
|
diceText: {fileID: 953941044}
|
||||||
pointerDebug: {fileID: 102349503}
|
pointerDebug: {fileID: 102349503}
|
||||||
pointerMeshRend: {fileID: 102349501}
|
pointerMeshRend: {fileID: 102349501}
|
||||||
@ -11556,7 +11554,7 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
diceView: {fileID: 1619592888}
|
diceView: {fileID: 1619592888}
|
||||||
diceTestValue: 1
|
diceTestValue: 6
|
||||||
--- !u!4 &1039618837 stripped
|
--- !u!4 &1039618837 stripped
|
||||||
Transform:
|
Transform:
|
||||||
m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3}
|
m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3}
|
||||||
@ -23126,18 +23124,6 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4180996271043359930, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
|
|
||||||
propertyPath: m_LocalScale.x
|
|
||||||
value: 0.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4180996271043359930, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
|
|
||||||
propertyPath: m_LocalScale.y
|
|
||||||
value: 0.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
- target: {fileID: 4180996271043359930, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
|
|
||||||
propertyPath: m_LocalScale.z
|
|
||||||
value: 0.2
|
|
||||||
objectReference: {fileID: 0}
|
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: f7fae8d587c2e4afcbcd76b417afc521, type: 3}
|
||||||
--- !u!33 &4946864981684608825
|
--- !u!33 &4946864981684608825
|
||||||
@ -24580,7 +24566,7 @@ GameObject:
|
|||||||
- component: {fileID: 5608193481910428234}
|
- component: {fileID: 5608193481910428234}
|
||||||
- component: {fileID: 5608193481910428235}
|
- component: {fileID: 5608193481910428235}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: MainMenuScreen
|
m_Name: Main Menu
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -25328,7 +25314,7 @@ GameObject:
|
|||||||
- component: {fileID: 5608193482197189504}
|
- component: {fileID: 5608193482197189504}
|
||||||
- component: {fileID: 5608193482197189506}
|
- component: {fileID: 5608193482197189506}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: GameOverScreen
|
m_Name: Game Over
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -25348,8 +25334,6 @@ MonoBehaviour:
|
|||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
screenType: 2
|
screenType: 2
|
||||||
shouldFade: 0
|
shouldFade: 0
|
||||||
playAgainBtn: {fileID: 5608193482985030359}
|
|
||||||
mainMenuBtn: {fileID: 5608193483181475110}
|
|
||||||
--- !u!222 &5608193482210820768
|
--- !u!222 &5608193482210820768
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27088,7 +27072,7 @@ GameObject:
|
|||||||
- component: {fileID: 5608193482973815122}
|
- component: {fileID: 5608193482973815122}
|
||||||
- component: {fileID: 5608193482973815124}
|
- component: {fileID: 5608193482973815124}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: GameScreen
|
m_Name: Game
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -27171,7 +27155,7 @@ GameObject:
|
|||||||
- component: {fileID: 5608193482985030358}
|
- component: {fileID: 5608193482985030358}
|
||||||
- component: {fileID: 5608193482985030359}
|
- component: {fileID: 5608193482985030359}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: PlayAgainButton
|
m_Name: Retry Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
@ -27673,7 +27657,7 @@ GameObject:
|
|||||||
- component: {fileID: 5608193483181475113}
|
- component: {fileID: 5608193483181475113}
|
||||||
- component: {fileID: 5608193483181475110}
|
- component: {fileID: 5608193483181475110}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: MainMenuButton
|
m_Name: Home Button
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class BotModeData
|
|||||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
private GameManager gameManager;
|
|
||||||
private PVPModeData pvpModeData;
|
private PVPModeData pvpModeData;
|
||||||
private BotModeData botModeData;
|
private BotModeData botModeData;
|
||||||
|
|
||||||
@ -41,7 +41,6 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +69,6 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void OnGameRestarted()
|
public void OnGameRestarted()
|
||||||
{
|
{
|
||||||
gameManager.OnGameStateChanged(GameState.InGame);
|
|
||||||
gameplayManager.ResetGameRestartData();
|
|
||||||
switch (CurrentGameModeType)
|
switch (CurrentGameModeType)
|
||||||
{
|
{
|
||||||
case GameModeType.PVP:
|
case GameModeType.PVP:
|
||||||
|
|||||||
@ -16,14 +16,9 @@ public enum BotMove
|
|||||||
|
|
||||||
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
[SerializeField] private bool isDebugTest = false;
|
|
||||||
|
|
||||||
public bool IsDebugTest => isDebugTest;
|
|
||||||
|
|
||||||
[SerializeField] DiceRollHandler diceRollHandler;
|
[SerializeField] DiceRollHandler diceRollHandler;
|
||||||
|
|
||||||
[SerializeField] private int diceValue = 0;
|
[SerializeField] private int diceValue = 0;
|
||||||
[SerializeField] private int maxDiceSixRollCounter = 2;
|
|
||||||
|
|
||||||
[SerializeField] private TextMeshProUGUI diceText;
|
[SerializeField] private TextMeshProUGUI diceText;
|
||||||
|
|
||||||
@ -133,6 +128,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var type in allPlayerTypes)
|
||||||
|
Debug.Log($"allPlayerTypes ::: {type}");
|
||||||
|
|
||||||
tilesManager.InitTilesData();
|
tilesManager.InitTilesData();
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
@ -211,9 +209,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitCurrentGamePlayerInfo()
|
public void InitCurrentGamePlayerInfo()
|
||||||
{
|
{
|
||||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||||
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
|
||||||
|
|
||||||
SetCurrentSelectedPointer();
|
|
||||||
|
|
||||||
// initialize the board based on the player types
|
// initialize the board based on the player types
|
||||||
playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||||
@ -273,7 +268,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private bool CheckForMaxDiceRollAttempt()
|
private bool CheckForMaxDiceRollAttempt()
|
||||||
{
|
{
|
||||||
if (diceSixRollCounter > maxDiceSixRollCounter) // TODO :: Reset after test
|
if (diceSixRollCounter == 3)
|
||||||
{
|
{
|
||||||
CanRollDiceAgain = false;
|
CanRollDiceAgain = false;
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
@ -336,21 +331,27 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
// TODO :: Double check
|
// TODO :: Double check
|
||||||
foreach (var key in botPawnsDictForCurrentPlayer.Keys)
|
foreach (var key in botPawnsDictForCurrentPlayer.Keys)
|
||||||
{
|
{
|
||||||
Debug.Log($"b :: botPawnsDictForCurrentPlayer[key]: {key}, {botPawnsDictForCurrentPlayer[key]}");
|
Debug.Log($"b :: botPawnsDictForCurrentPlayer[key]: {botPawnsDictForCurrentPlayer[key]}");
|
||||||
// botPawnsDictForCurrentPlayer[key] = BotMove.NoMoves;
|
// botPawnsDictForCurrentPlayer[key] = BotMove.NoMoves;
|
||||||
|
Debug.Log($"a :: botPawnsDictForCurrentPlayer[key]: {botPawnsDictForCurrentPlayer[key]}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Debug.Log($"Before Iterating");
|
Debug.Log($"Before Iterating");
|
||||||
foreach (var playerPawn in availPlayers)
|
foreach (var playerPawn in availPlayers)
|
||||||
{
|
{
|
||||||
int possibleSteps = 0;
|
Debug.Log($"Iterating");
|
||||||
Tile possibleTileData = null;
|
var possibleLandingIndex = playerPawn.CurrentTileIndex + diceRolledValue;
|
||||||
|
|
||||||
if (playerPawn.GetPlayerState() != PlayerState.InFinishingPath)
|
int lastIndex = tilesManager.GetGeneralTilesLength() - 1;
|
||||||
FindPossibleTileData(playerPawn, out possibleSteps, out possibleTileData);
|
int index = possibleLandingIndex > lastIndex ? possibleLandingIndex - lastIndex - 1 : possibleLandingIndex;
|
||||||
|
Tile possibleTileData = tilesManager.RetrieveTileBasedOnIndex(index);
|
||||||
|
|
||||||
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleSteps > playerGameDatasDict[currentPlayerTypeTurn].endIndex) // TODO :: have a better second check
|
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.PlayerPawn: {possibleTileData.HasPawnsAvailable}");
|
||||||
|
|
||||||
|
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || possibleLandingIndex > playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||||
{
|
{
|
||||||
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: inFinishingPath :: canSelectPlayer: {playerPawn.CanSelectPlayer}");
|
Debug.Log($"AI playerPawn :: {playerPawn.name} :: {playerPawn.PlayerId} :: inFinishingPath :: canSelectPlayer: {playerPawn.CanSelectPlayer}");
|
||||||
if (playerPawn.CanSelectPlayer)
|
if (playerPawn.CanSelectPlayer)
|
||||||
@ -364,12 +365,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.NoMoves;
|
botPawnsDictForCurrentPlayer[playerPawn.PlayerId] = BotMove.NoMoves;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (possibleTileData != null && possibleTileData.IsSafeZone)
|
else if (possibleTileData.IsSafeZone)
|
||||||
{
|
{
|
||||||
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 != null && possibleTileData.HasPawnsAvailable && possibleTileData.CurrentHoldingPlayerType != playerPawn.PlayerType)
|
else if (possibleTileData.HasPawnsAvailable)
|
||||||
{
|
{
|
||||||
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,23 +417,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pawn != null)
|
Debug.Log($"AI playerPawn :: {pawn.name} :: SelectedPawn: {pawn.name}");
|
||||||
{
|
OnPawnSelected(pawn);
|
||||||
Debug.Log($"AI playerPawn :: {pawn.name} :: SelectedPawn: {pawn.name}");
|
|
||||||
OnPawnSelected(pawn);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (CheckForMaxDiceRollAttempt())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CanRollDiceAgain)
|
|
||||||
HandleDiceRoll();
|
|
||||||
else
|
|
||||||
SwitchPlayer();
|
|
||||||
}
|
|
||||||
|
|
||||||
void InitPawnBasedOnState(BotMove botMove)
|
void InitPawnBasedOnState(BotMove botMove)
|
||||||
{
|
{
|
||||||
@ -462,20 +448,6 @@ 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 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;
|
|
||||||
|
|
||||||
possibleTileData = possibleSteps > totalStepsInGeneralPath ? tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, index) : tilesManager.RetrieveTileBasedOnIndex(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnDiceRolled(int rolledVal)
|
public void OnDiceRolled(int rolledVal)
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(false);
|
SetCanRollDiceForUser(false);
|
||||||
@ -546,8 +518,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
availPlayers[i].SetPlayerSelectionState(true);
|
availPlayers[i].SetPlayerSelectionState(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int idx = indexesToRemove.Count - 1; idx >= 0; idx--)
|
foreach (int i in indexesToRemove) availPlayers.RemoveAt(i);
|
||||||
availPlayers.RemoveAt(idx);
|
|
||||||
|
|
||||||
// if (availPlayers.Count() < 1)
|
// if (availPlayers.Count() < 1)
|
||||||
Debug.Log($"CustomAvailablePlayers: {customAvailPlayers}");
|
Debug.Log($"CustomAvailablePlayers: {customAvailPlayers}");
|
||||||
@ -565,6 +536,11 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
pawn.GetPlayerState() == PlayerState.Moving ||
|
pawn.GetPlayerState() == PlayerState.Moving ||
|
||||||
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
||||||
|
|
||||||
|
Debug.Log($"#### UpdatePlayerState in InitActivePlayers ");
|
||||||
|
foreach (var pawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values)
|
||||||
|
{
|
||||||
|
Debug.Log($"pawn: {pawn.name}, state: {pawn.GetPlayerState()}");
|
||||||
|
}
|
||||||
foreach (var player in availPlayers) // TODO :: Move from here
|
foreach (var player in availPlayers) // TODO :: Move from here
|
||||||
{
|
{
|
||||||
DisplayPlayerCountOnTile(player, true);
|
DisplayPlayerCountOnTile(player, true);
|
||||||
@ -599,7 +575,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
playerPawn.SetPlayerState(playerState);
|
playerPawn.SetPlayerState(playerState);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CheckDiceRollForBot()
|
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
||||||
{
|
{
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
{
|
{
|
||||||
@ -609,10 +585,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void HandleDiceRoll()
|
private void HandleDiceRoll()
|
||||||
{
|
{
|
||||||
if (isDebugTest)
|
// diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal), diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal), diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||||
else
|
|
||||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||||
@ -641,7 +615,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (playerPawn.IsBotPlayer)
|
if (playerPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot(playerPawn);
|
||||||
else
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
|
|
||||||
@ -737,7 +711,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
InitActivePlayers();
|
InitActivePlayers();
|
||||||
|
|
||||||
Debug.Log($"after SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
Debug.Log($"after SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
||||||
SetDisplayCountForAllAvailPlayers(false);
|
foreach (var pawn in availPlayers)
|
||||||
|
{
|
||||||
|
DisplayPlayerCountOnTile(pawn, false);
|
||||||
|
}
|
||||||
|
|
||||||
if (allPlayerTypes.Count == 1)
|
if (allPlayerTypes.Count == 1)
|
||||||
{
|
{
|
||||||
@ -762,12 +739,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
diceText.text = $"{0}";
|
diceText.text = $"{0}";
|
||||||
|
|
||||||
InitActivePlayers();
|
InitActivePlayers();
|
||||||
SetDisplayCountForAllAvailPlayers(true);
|
foreach (var pawn in availPlayers)
|
||||||
|
{
|
||||||
|
DisplayPlayerCountOnTile(pawn, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||||
Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}");
|
Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}");
|
||||||
SetCurrentSelectedPointer();
|
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
||||||
|
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
||||||
|
|
||||||
pointerMeshRend.material = turnMat;
|
pointerMeshRend.material = turnMat;
|
||||||
// pointerMeshRend.materials[0] = turnMat;
|
// pointerMeshRend.materials[0] = turnMat;
|
||||||
@ -781,20 +762,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetCurrentSelectedPointer()
|
|
||||||
{
|
|
||||||
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
|
||||||
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetDisplayCountForAllAvailPlayers(bool state)
|
|
||||||
{
|
|
||||||
foreach (var pawn in availPlayers)
|
|
||||||
{
|
|
||||||
DisplayPlayerCountOnTile(pawn, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||||
{
|
{
|
||||||
Tile nextTile = tilesManager.RetrieveTileBasedOnIndex(index);
|
Tile nextTile = tilesManager.RetrieveTileBasedOnIndex(index);
|
||||||
@ -875,19 +842,17 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
if (!playerPawn.IsBotPlayer)
|
if (playerPawn.IsBotPlayer)
|
||||||
|
CheckDiceRollForBot(playerPawn);
|
||||||
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
|
||||||
|
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1010,9 +975,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (allPlayerTypes.Count == 1)
|
if (allPlayerTypes.Count == 1)
|
||||||
{
|
{
|
||||||
// Game is over
|
// Game is over
|
||||||
var lastFinishingPlayerType = allPlayerTypes[0];
|
|
||||||
allPlayerTypes.RemoveAt(0);
|
allPlayerTypes.RemoveAt(0);
|
||||||
playerDatas.FirstOrDefault(data => data.playerType == lastFinishingPlayerType).ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
playerDatas.FirstOrDefault(data => data.playerType == currentPlayerTypeTurn).ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||||
|
|
||||||
// Show Game Over panel
|
// Show Game Over panel
|
||||||
gameManager.OnGameStateChanged(GameState.GameOver);
|
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||||
@ -1028,7 +992,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
if (playerPawn.IsBotPlayer)
|
if (playerPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot(playerPawn);
|
||||||
else
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
@ -1060,6 +1024,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
||||||
: tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
: tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||||
|
|
||||||
|
Debug.Log($"Displaycount: {playerPawn.name} on tile: {tile.name}, show: {show}");
|
||||||
playerPawn.ShowPlayerCountCanvas(show);
|
playerPawn.ShowPlayerCountCanvas(show);
|
||||||
if (!show) return;
|
if (!show) return;
|
||||||
|
|
||||||
@ -1078,8 +1043,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void ResetData()
|
public void ResetData()
|
||||||
{
|
{
|
||||||
ResetGameRestartData();
|
|
||||||
|
|
||||||
playerDatas = null;
|
playerDatas = null;
|
||||||
botTypesInGame = null;
|
botTypesInGame = null;
|
||||||
allPlayerTypes = null;
|
allPlayerTypes = null;
|
||||||
@ -1089,9 +1052,4 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
playerDatas = null;
|
playerDatas = null;
|
||||||
availPlayers = null;
|
availPlayers = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetGameRestartData()
|
|
||||||
{
|
|
||||||
currentPlayerTurnIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -101,6 +101,7 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
|
|
||||||
public void MoveToCustomTilePosition(Vector3 targetPoint)
|
public void MoveToCustomTilePosition(Vector3 targetPoint)
|
||||||
{
|
{
|
||||||
|
StepsTaken++;
|
||||||
transform.DOMove(targetPoint, 1f);
|
transform.DOMove(targetPoint, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,15 +34,13 @@ public class DiceRollHandler : MonoBehaviour
|
|||||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||||
|
|
||||||
if (inputManager.GameplayManager.IsDebugTest)
|
OnUserDiceRollComplete(GetDiceTestVal());
|
||||||
OnUserDiceRollComplete(GetDiceTestVal());
|
// diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||||
else
|
|
||||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||||
{
|
{
|
||||||
diceView.Roll(onComplete: onComplete, true);
|
diceView.Roll(onComplete: (val) => onComplete?.Invoke(val), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleDiceViewForBot(Action<int> onComplete, int val)
|
public void HandleDiceViewForBot(Action<int> onComplete, int val)
|
||||||
|
|||||||
@ -10,7 +10,6 @@ public enum GameState
|
|||||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private UIManager uiManager;
|
private UIManager uiManager;
|
||||||
private TilesManager tilesManager;
|
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public GameState GameState
|
public GameState GameState
|
||||||
@ -26,7 +25,6 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
|
||||||
OnGameStateChanged(GameState.InMenu);
|
OnGameStateChanged(GameState.InMenu);
|
||||||
@ -39,7 +37,6 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
case GameState.InMenu:
|
case GameState.InMenu:
|
||||||
gameplayManager.ResetData();
|
gameplayManager.ResetData();
|
||||||
tilesManager.ResetData();
|
|
||||||
uiManager.OnInMenuScreen();
|
uiManager.OnInMenuScreen();
|
||||||
break;
|
break;
|
||||||
case GameState.InGame:
|
case GameState.InGame:
|
||||||
|
|||||||
@ -32,7 +32,6 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
|
|
||||||
public void InitTilesData()
|
public void InitTilesData()
|
||||||
{
|
{
|
||||||
finishingTileDataPairs = new Dictionary<PlayerType, List<Tile>>();
|
|
||||||
foreach (var tileData in tileDatas)
|
foreach (var tileData in tileDatas)
|
||||||
{
|
{
|
||||||
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
||||||
@ -53,6 +52,10 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
Debug.Log($"RetrieveTileBasedOnIndex: Index: {index}");
|
Debug.Log($"RetrieveTileBasedOnIndex: Index: {index}");
|
||||||
|
|
||||||
Tile tile = index == generalTiles.Length ? generalTiles[0] : generalTiles[index];
|
Tile tile = index == generalTiles.Length ? generalTiles[0] : generalTiles[index];
|
||||||
|
// if (tile.IsSafeZone)
|
||||||
|
// {
|
||||||
|
// return (SafeTile)tile;
|
||||||
|
// }
|
||||||
|
|
||||||
return tile;
|
return tile;
|
||||||
}
|
}
|
||||||
@ -62,8 +65,8 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
return finishingTileDataPairs[playerType][index];
|
return finishingTileDataPairs[playerType][index];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetData()
|
public Transform RetrievePositionForFinishingTile(PlayerType playerType, int index)
|
||||||
{
|
{
|
||||||
finishingTileDataPairs.Clear();
|
return finishingTileDataPairs[playerType][index].transform;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class ScreenBase : UIBase, IUIBase
|
|||||||
|
|
||||||
public ScreenType ScreenType => screenType;
|
public ScreenType ScreenType => screenType;
|
||||||
|
|
||||||
protected ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -13,26 +12,7 @@ public class GameOverPopup : PopupBase
|
|||||||
[SerializeField] private TextMeshProUGUI[] texts;
|
[SerializeField] private TextMeshProUGUI[] texts;
|
||||||
|
|
||||||
private GameModeHandler gameModeHandler;
|
private GameModeHandler gameModeHandler;
|
||||||
|
private ScreenManager screenManager;
|
||||||
public void InitData(List<PlayerData> playerData)
|
|
||||||
{
|
|
||||||
for (int idx = 0; idx < texts.Length; idx++)
|
|
||||||
{
|
|
||||||
if (idx >= playerData.Count)
|
|
||||||
{
|
|
||||||
texts[idx].gameObject.SetActive(false);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerData[idx].ranking == 1)
|
|
||||||
{
|
|
||||||
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].playerName} Wins";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].ranking}. {playerData[idx].playerName}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
@ -62,5 +42,33 @@ public class GameOverPopup : PopupBase
|
|||||||
public void OnMainMenuClicked()
|
public void OnMainMenuClicked()
|
||||||
{
|
{
|
||||||
HidePopup();
|
HidePopup();
|
||||||
|
|
||||||
|
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||||
|
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitData(List<PlayerData> playerDatas)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < playerDatas.Count; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
texts[i].text = $"{playerDatas[i].playerName} Wins";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
texts[i].text = $"{(i + 1)}. {playerDatas[i].playerName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var playerData in playerDatas)
|
||||||
|
{
|
||||||
|
if (playerData.ranking == 1)
|
||||||
|
{
|
||||||
|
texts[playerData.ranking - 1].text = $"{playerData.playerName} Wins";;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
texts[playerData.ranking - 1].text = $"{playerData.ranking}. {playerData.playerName}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,44 +1,8 @@
|
|||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class GameOverScreen : ScreenBase
|
public class GameOverScreen : ScreenBase
|
||||||
{
|
{
|
||||||
[SerializeField] private Button playAgainBtn;
|
|
||||||
[SerializeField] private Button mainMenuBtn;
|
|
||||||
|
|
||||||
private GameModeHandler gameModeHandler;
|
|
||||||
|
|
||||||
private void OnEnable()
|
|
||||||
{
|
|
||||||
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
|
||||||
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnDisable()
|
|
||||||
{
|
|
||||||
playAgainBtn.onClick.RemoveAllListeners();
|
|
||||||
mainMenuBtn.onClick.RemoveAllListeners();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnPlayAgainClicked()
|
|
||||||
{
|
|
||||||
HideScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HideScreen()
|
|
||||||
{
|
|
||||||
screenManager.HideScreen(screenType);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnMainMenuClicked()
|
|
||||||
{
|
|
||||||
HideScreen();
|
|
||||||
|
|
||||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
|
||||||
screenManager.ShowScreen(ScreenType.MainMenuScreen);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user