Game over flow changes.
This commit is contained in:
parent
41c2fdbee5
commit
e57be039ff
@ -22667,6 +22667,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 5608193481571390226}
|
- component: {fileID: 5608193481571390226}
|
||||||
|
- component: {fileID: 5608193481571390228}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: GameOverPopup
|
m_Name: GameOverPopup
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -22674,6 +22675,31 @@ GameObject:
|
|||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
|
--- !u!114 &5608193481571390228
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5608193481571390227}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 178d988f5211b4ef5b8c2df230b708d4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
popupScaleContent: {fileID: 5608193481571390226}
|
||||||
|
zoomDuration: 0.5
|
||||||
|
popupType: 5
|
||||||
|
popupScalerType: 1
|
||||||
|
canvasGroup: {fileID: 0}
|
||||||
|
fadeDuration: 0
|
||||||
|
playAgainBtn: {fileID: 5608193482985030359}
|
||||||
|
mainMenuBtn: {fileID: 5608193483181475110}
|
||||||
|
texts:
|
||||||
|
- {fileID: 5608193483287721217}
|
||||||
|
- {fileID: 28556636}
|
||||||
|
- {fileID: 300136906}
|
||||||
|
- {fileID: 1260155923}
|
||||||
--- !u!1 &5608193481588389864
|
--- !u!1 &5608193481588389864
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -26175,7 +26201,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!222 &5608193482973815122
|
--- !u!222 &5608193482973815122
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27386,7 +27412,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!222 &5608193483354237948
|
--- !u!222 &5608193483354237948
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27538,7 +27564,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 0
|
||||||
--- !u!222 &5608193483406443892
|
--- !u!222 &5608193483406443892
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -7,11 +8,28 @@ public enum GameModeType
|
|||||||
Bot,
|
Bot,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PVPModeData
|
||||||
|
{
|
||||||
|
public List<PlayerType> types;
|
||||||
|
public List<string> names;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class BotModeData
|
||||||
|
{
|
||||||
|
public PlayerData playerData;
|
||||||
|
public int botCount;
|
||||||
|
}
|
||||||
|
|
||||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public GameModeType GameModeType
|
private PVPModeData pvpModeData;
|
||||||
|
private BotModeData botModeData;
|
||||||
|
|
||||||
|
public GameModeType CurrentGameModeType
|
||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
@ -26,15 +44,39 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPVPModeData(List<PlayerType> types)
|
public void InitPVPModeData(List<PlayerType> types, List<string> names)
|
||||||
{
|
{
|
||||||
GameModeType = GameModeType.PVP;
|
pvpModeData = new PVPModeData
|
||||||
gameplayManager.InitPlayerTypesForPVP(types);
|
{
|
||||||
|
types = types, names = names
|
||||||
|
};
|
||||||
|
|
||||||
|
CurrentGameModeType = GameModeType.PVP;
|
||||||
|
gameplayManager.InitPlayerTypesForPVP(types, names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
public void InitBotModeData(PlayerData playerData, int botCount)
|
||||||
{
|
{
|
||||||
GameModeType = GameModeType.Bot;
|
botModeData = new BotModeData
|
||||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
{
|
||||||
|
playerData = playerData,
|
||||||
|
botCount = botCount
|
||||||
|
};
|
||||||
|
|
||||||
|
CurrentGameModeType = GameModeType.Bot;
|
||||||
|
gameplayManager.InitPlayerTypesForBotMatch(playerData, botCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnGameRestarted()
|
||||||
|
{
|
||||||
|
switch (CurrentGameModeType)
|
||||||
|
{
|
||||||
|
case GameModeType.PVP:
|
||||||
|
InitPVPModeData(pvpModeData.types, pvpModeData.names);
|
||||||
|
break;
|
||||||
|
case GameModeType.Bot:
|
||||||
|
InitBotModeData(botModeData.playerData, botModeData.botCount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,33 +5,6 @@ using DG.Tweening;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public enum PlayerType
|
|
||||||
{
|
|
||||||
Player1 = 0,
|
|
||||||
Player2 = 1,
|
|
||||||
Player3 = 2,
|
|
||||||
Player4 = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public class PlayerGameData
|
|
||||||
{
|
|
||||||
public PlayerType playerType;
|
|
||||||
public int startIndex;
|
|
||||||
public int endIndex;
|
|
||||||
public Transform playersParent;
|
|
||||||
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
|
||||||
public int totalPawnsInHome = 0;
|
|
||||||
public int totalPawnsFinished = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public enum MatchType
|
|
||||||
{
|
|
||||||
PVP,
|
|
||||||
Bot
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BotMove
|
public enum BotMove
|
||||||
{
|
{
|
||||||
FinishingPathMove = 0,
|
FinishingPathMove = 0,
|
||||||
@ -59,18 +32,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private PlayerType currentPlayerTypeTurn;
|
private PlayerType currentPlayerTypeTurn;
|
||||||
private int currentPlayerTurnIndex = 0;
|
private int currentPlayerTurnIndex = 0;
|
||||||
|
|
||||||
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
||||||
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
||||||
private List<PlayerType> playerRankings = new List<PlayerType>();
|
|
||||||
|
private List<PlayerData> playerDatas = new List<PlayerData>();
|
||||||
|
|
||||||
|
|
||||||
// private Dictionary<PlayerTypes, > playerPawnsDict = new Dictionary<PlayerTypes, List<PlayerPawn>>();
|
|
||||||
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||||
|
|
||||||
// botRuntimeMovementData: where can the bot move if a particular dice value is thrown, and based on the value set the bot move for each using a predictive approach and select based on the the priority
|
|
||||||
private Dictionary<PlayerType, Dictionary<int, BotMove>> botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
private Dictionary<PlayerType, Dictionary<int, BotMove>> botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||||
|
|
||||||
private TilesManager tilesManager;
|
private TilesManager tilesManager;
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
private int diceRolledValue;
|
private int diceRolledValue;
|
||||||
|
|
||||||
@ -84,6 +57,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int TotalPlayersInGame
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlayerData> PlayerDatas => playerDatas;
|
||||||
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
@ -95,16 +75,24 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
|
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||||
// InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
|
||||||
// InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO :: Call when the UI selection is made and game starts
|
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
||||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
|
||||||
{
|
{
|
||||||
// TODO :: 2P, 3P, 4P
|
|
||||||
allPlayerTypes = new List<PlayerType>(types);
|
allPlayerTypes = new List<PlayerType>(types);
|
||||||
|
playerDatas.Clear();
|
||||||
|
|
||||||
|
TotalPlayersInGame = types.Count;
|
||||||
|
|
||||||
|
for (int i=0; i<types.Count; i++)
|
||||||
|
{
|
||||||
|
playerDatas.Add(new PlayerData
|
||||||
|
{
|
||||||
|
playerType = types[i],
|
||||||
|
playerName = names[i],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
@ -112,22 +100,37 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||||
{
|
{
|
||||||
|
playerDatas.Clear();
|
||||||
botTypesInGame.Clear();
|
botTypesInGame.Clear();
|
||||||
allPlayerTypes.Clear();
|
allPlayerTypes.Clear();
|
||||||
AssignBotTypes(selectedPlayerType, botCount);
|
|
||||||
|
|
||||||
|
TotalPlayersInGame = botCount + 1;
|
||||||
|
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
||||||
|
|
||||||
allPlayerTypes.Add(selectedPlayerType);
|
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
||||||
allPlayerTypes.AddRange(botTypesInGame);
|
{
|
||||||
|
if (botTypesInGame.Contains(playerType))
|
||||||
|
{
|
||||||
|
allPlayerTypes.Add(playerType);
|
||||||
|
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{playerType}" });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
allPlayerTypes.Add(selectedPlayerData.playerType);
|
||||||
|
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{selectedPlayerData.playerName}" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
InitBotRuntimeData();
|
InitBotRuntimeData();
|
||||||
AssignPlayerAndBotStates(selectedPlayerType);
|
AssignPlayerAndBotStates(selectedPlayerData.playerType);
|
||||||
|
|
||||||
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
SetCanRollDiceForUser(!botTypesInGame.Contains(allPlayerTypes[0]));
|
||||||
|
if (botTypesInGame.Contains(allPlayerTypes[0]))
|
||||||
|
Invoke(nameof(HandleDiceRoll), 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitBotRuntimeData()
|
private void InitBotRuntimeData()
|
||||||
@ -199,6 +202,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||||
|
|
||||||
// initialize the board based on the player types
|
// initialize the board based on the player types
|
||||||
|
playerGameDatasDict.Clear();
|
||||||
|
|
||||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||||
{
|
{
|
||||||
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
||||||
@ -571,8 +576,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void HandleDiceRoll()
|
private void HandleDiceRoll()
|
||||||
{
|
{
|
||||||
// diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||||
@ -950,17 +955,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||||
{
|
{
|
||||||
playerRankings.Add(currentPlayerTypeTurn);
|
|
||||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||||
|
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allPlayerTypes.Count == 1)
|
if (allPlayerTypes.Count == 1)
|
||||||
{
|
{
|
||||||
// Game is over
|
// Game is over
|
||||||
playerRankings.Add(allPlayerTypes[0]);
|
allPlayerTypes.RemoveAt(0);
|
||||||
allPlayerTypes.Remove(0);
|
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||||
|
|
||||||
// Show Game Over panel
|
// Show Game Over panel
|
||||||
|
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1019,5 +1025,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetData()
|
||||||
|
{
|
||||||
|
playerDatas = null;
|
||||||
|
botTypesInGame = null;
|
||||||
|
allPlayerTypes = null;
|
||||||
|
|
||||||
|
botRuntimeMovementData = null;
|
||||||
|
playerGameDatasDict = null;
|
||||||
|
playerDatas = null;
|
||||||
|
availPlayers = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class PlayerBase : MonoBehaviour
|
|||||||
{
|
{
|
||||||
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
||||||
{
|
{
|
||||||
playerPawns[idx].Init(basePlacementDatas[idx].playerBaseId, playerType);
|
playerPawns[idx].Init(basePlacementDatas[idx], playerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
Assets/Scripts/Gameplay/Player/PlayerGameData.cs
Normal file
30
Assets/Scripts/Gameplay/Player/PlayerGameData.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public enum PlayerType
|
||||||
|
{
|
||||||
|
Player1 = 0,
|
||||||
|
Player2 = 1,
|
||||||
|
Player3 = 2,
|
||||||
|
Player4 = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PlayerGameData
|
||||||
|
{
|
||||||
|
public PlayerType playerType;
|
||||||
|
public int startIndex;
|
||||||
|
public int endIndex;
|
||||||
|
public Transform playersParent;
|
||||||
|
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
||||||
|
public int totalPawnsInHome = 0;
|
||||||
|
public int totalPawnsFinished = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PlayerData
|
||||||
|
{
|
||||||
|
public PlayerType playerType;
|
||||||
|
public string playerName;
|
||||||
|
public int ranking = 0;
|
||||||
|
}
|
||||||
11
Assets/Scripts/Gameplay/Player/PlayerGameData.cs.meta
Normal file
11
Assets/Scripts/Gameplay/Player/PlayerGameData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9f4a588284ad4839bff99f31d6d402c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -135,10 +135,12 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(int id, PlayerType playerType)
|
public void Init(BasePlacementData basePlacementData, PlayerType playerType)
|
||||||
{
|
{
|
||||||
PlayerId = id;
|
PlayerId = basePlacementData.playerBaseId;
|
||||||
PlayerType = playerType;
|
PlayerType = playerType;
|
||||||
|
|
||||||
|
MoveBackToHome(basePlacementData.placementTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowPlayerCountCanvas(bool show)
|
public void ShowPlayerCountCanvas(bool show)
|
||||||
|
|||||||
@ -34,8 +34,8 @@ public class DiceRollHandler : MonoBehaviour
|
|||||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||||
|
|
||||||
OnUserDiceRollComplete(GetDiceTestVal());
|
// OnUserDiceRollComplete(GetDiceTestVal());
|
||||||
// diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||||
|
|||||||
@ -4,11 +4,13 @@ public enum GameState
|
|||||||
{
|
{
|
||||||
InMenu,
|
InMenu,
|
||||||
InGame,
|
InGame,
|
||||||
|
GameOver,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private UIManager uiManager;
|
private UIManager uiManager;
|
||||||
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public GameState GameState
|
public GameState GameState
|
||||||
{
|
{
|
||||||
@ -23,21 +25,26 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||||
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
|
||||||
GameState = GameState.InMenu;
|
OnGameStateChanged(GameState.InMenu);
|
||||||
OnGameStateChanged(GameState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGameStateChanged(GameState gameState)
|
public void OnGameStateChanged(GameState gameState)
|
||||||
{
|
{
|
||||||
|
GameState = gameState;
|
||||||
switch (gameState)
|
switch (gameState)
|
||||||
{
|
{
|
||||||
case GameState.InMenu:
|
case GameState.InMenu:
|
||||||
|
gameplayManager.ResetData();
|
||||||
uiManager.OnInMenuScreen();
|
uiManager.OnInMenuScreen();
|
||||||
break;
|
break;
|
||||||
case GameState.InGame:
|
case GameState.InGame:
|
||||||
uiManager.OnInGameScreen();
|
uiManager.OnInGameScreen();
|
||||||
break;
|
break;
|
||||||
|
case GameState.GameOver:
|
||||||
|
uiManager.OnGameOver();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,6 +6,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
|
private PopupManager popupManager;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
@ -15,6 +16,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDiceViewInteracted()
|
public void OnDiceViewInteracted()
|
||||||
@ -35,8 +37,9 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSelectedPlayerCount(int playersCount)
|
public void OnGameOver()
|
||||||
{
|
{
|
||||||
|
popupManager.GetPopup<GameOverPopup>(PopupType.GameOverPopup).InitData(gameplayManager.PlayerDatas);
|
||||||
|
popupManager.ShowPopup(PopupType.GameOverPopup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,8 @@ public enum PopupType
|
|||||||
PvAIModePopup,
|
PvAIModePopup,
|
||||||
OptionsPopup,
|
OptionsPopup,
|
||||||
InstructionsPopup,
|
InstructionsPopup,
|
||||||
PauseMenuPopup
|
PauseMenuPopup,
|
||||||
|
GameOverPopup
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PopupScalerType
|
public enum PopupScalerType
|
||||||
|
|||||||
65
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
65
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class GameOverPopup : PopupBase
|
||||||
|
{
|
||||||
|
[SerializeField] private Button playAgainBtn;
|
||||||
|
[SerializeField] private Button mainMenuBtn;
|
||||||
|
|
||||||
|
[SerializeField] private TextMeshProUGUI[] texts;
|
||||||
|
|
||||||
|
private GameModeHandler gameModeHandler;
|
||||||
|
private ScreenManager screenManager;
|
||||||
|
private PopupManager popupManager;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
||||||
|
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
playAgainBtn.onClick.RemoveAllListeners();
|
||||||
|
mainMenuBtn.onClick.RemoveAllListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPlayAgainClicked()
|
||||||
|
{
|
||||||
|
HidePopup();
|
||||||
|
|
||||||
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
|
gameModeHandler.OnGameRestarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HidePopup()
|
||||||
|
{
|
||||||
|
popupManager = popupManager == null ? InterfaceManager.Instance.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||||
|
popupManager.HidePopup(popupType);
|
||||||
|
}
|
||||||
|
|
||||||
|
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}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs.meta
Normal file
11
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 178d988f5211b4ef5b8c2df230b708d4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -33,6 +33,7 @@ public class PvAIModePopup : PopupBase
|
|||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private GameModeHandler gameModeHandler;
|
private GameModeHandler gameModeHandler;
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
private int selectedPlayerCount;
|
private int selectedPlayerCount;
|
||||||
private PlayerType playerType;
|
private PlayerType playerType;
|
||||||
@ -58,6 +59,7 @@ public class PvAIModePopup : PopupBase
|
|||||||
private void Start()
|
private void Start()
|
||||||
{
|
{
|
||||||
OnPlayerCountSelected(2, twoPlayerBtn);
|
OnPlayerCountSelected(2, twoPlayerBtn);
|
||||||
|
OnColorSelected(PlayerType.Player1, redBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
@ -105,7 +107,10 @@ public class PvAIModePopup : PopupBase
|
|||||||
popupManager.HidePopup(popupType);
|
popupManager.HidePopup(popupType);
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
|
gameModeHandler.InitBotModeData(new PlayerData{ playerType = playerType, playerName = playerName }, selectedPlayerCount - 1);
|
||||||
|
|
||||||
|
gameManager = gameManager == null ? InterfaceManager.Instance.GetInterfaceInstance<GameManager>() : gameManager;
|
||||||
|
gameManager.OnGameStateChanged(GameState.InGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_CloseButton()
|
private void OnClick_CloseButton()
|
||||||
|
|||||||
@ -150,7 +150,7 @@ public class PvPModePopup : PopupBase
|
|||||||
popupManager.HidePopup(popupType);
|
popupManager.HidePopup(popupType);
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList());
|
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList(), playerNameMap.Values.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_SwitchButton()
|
private void OnClick_SwitchButton()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user