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