Game over flow changes.
This commit is contained in:
parent
41c2fdbee5
commit
e57be039ff
@ -22667,6 +22667,7 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 5608193481571390226}
|
||||
- component: {fileID: 5608193481571390228}
|
||||
m_Layer: 5
|
||||
m_Name: GameOverPopup
|
||||
m_TagString: Untagged
|
||||
@ -22674,6 +22675,31 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
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
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -26175,7 +26201,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!222 &5608193482973815122
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -27386,7 +27412,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!222 &5608193483354237948
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -27538,7 +27564,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!222 &5608193483406443892
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
@ -7,11 +8,28 @@ public enum GameModeType
|
||||
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
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameModeType GameModeType
|
||||
private PVPModeData pvpModeData;
|
||||
private BotModeData botModeData;
|
||||
|
||||
public GameModeType CurrentGameModeType
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
@ -26,15 +44,39 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitPVPModeData(List<PlayerType> types)
|
||||
public void InitPVPModeData(List<PlayerType> types, List<string> names)
|
||||
{
|
||||
GameModeType = GameModeType.PVP;
|
||||
gameplayManager.InitPlayerTypesForPVP(types);
|
||||
pvpModeData = new PVPModeData
|
||||
{
|
||||
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;
|
||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
||||
botModeData = new BotModeData
|
||||
{
|
||||
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 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
|
||||
{
|
||||
FinishingPathMove = 0,
|
||||
@ -59,18 +32,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private PlayerType currentPlayerTypeTurn;
|
||||
private int currentPlayerTurnIndex = 0;
|
||||
|
||||
private List<PlayerType> allPlayerTypes = 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>();
|
||||
|
||||
// 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 TilesManager tilesManager;
|
||||
private GameManager gameManager;
|
||||
|
||||
private int diceRolledValue;
|
||||
|
||||
@ -84,6 +57,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public int TotalPlayersInGame
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public List<PlayerData> PlayerDatas => playerDatas;
|
||||
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
||||
|
||||
public void Initialize()
|
||||
@ -95,16 +75,24 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
|
||||
// InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
||||
// InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2})
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
}
|
||||
|
||||
// TODO :: Call when the UI selection is made and game starts
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
||||
{
|
||||
// TODO :: 2P, 3P, 4P
|
||||
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);
|
||||
InitCurrentGamePlayerInfo();
|
||||
@ -112,22 +100,37 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||
{
|
||||
playerDatas.Clear();
|
||||
botTypesInGame.Clear();
|
||||
allPlayerTypes.Clear();
|
||||
AssignBotTypes(selectedPlayerType, botCount);
|
||||
|
||||
TotalPlayersInGame = botCount + 1;
|
||||
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
||||
|
||||
allPlayerTypes.Add(selectedPlayerType);
|
||||
allPlayerTypes.AddRange(botTypesInGame);
|
||||
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
||||
{
|
||||
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);
|
||||
InitCurrentGamePlayerInfo();
|
||||
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()
|
||||
@ -199,6 +202,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||
|
||||
// initialize the board based on the player types
|
||||
playerGameDatasDict.Clear();
|
||||
|
||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||
{
|
||||
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
||||
@ -571,8 +576,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private void HandleDiceRoll()
|
||||
{
|
||||
// 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));
|
||||
// diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal), diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||
}
|
||||
|
||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||
@ -950,17 +955,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||
{
|
||||
playerRankings.Add(currentPlayerTypeTurn);
|
||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
}
|
||||
|
||||
if (allPlayerTypes.Count == 1)
|
||||
{
|
||||
// Game is over
|
||||
playerRankings.Add(allPlayerTypes[0]);
|
||||
allPlayerTypes.Remove(0);
|
||||
allPlayerTypes.RemoveAt(0);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
|
||||
// Show Game Over panel
|
||||
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -1019,5 +1025,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
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++)
|
||||
{
|
||||
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>();
|
||||
}
|
||||
|
||||
public void Init(int id, PlayerType playerType)
|
||||
public void Init(BasePlacementData basePlacementData, PlayerType playerType)
|
||||
{
|
||||
PlayerId = id;
|
||||
PlayerId = basePlacementData.playerBaseId;
|
||||
PlayerType = playerType;
|
||||
|
||||
MoveBackToHome(basePlacementData.placementTransform);
|
||||
}
|
||||
|
||||
public void ShowPlayerCountCanvas(bool show)
|
||||
|
||||
@ -34,8 +34,8 @@ public class DiceRollHandler : MonoBehaviour
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||
|
||||
OnUserDiceRollComplete(GetDiceTestVal());
|
||||
// diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
// OnUserDiceRollComplete(GetDiceTestVal());
|
||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
}
|
||||
|
||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||
|
||||
@ -4,11 +4,13 @@ public enum GameState
|
||||
{
|
||||
InMenu,
|
||||
InGame,
|
||||
GameOver,
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private UIManager uiManager;
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameState GameState
|
||||
{
|
||||
@ -23,21 +25,26 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
|
||||
GameState = GameState.InMenu;
|
||||
OnGameStateChanged(GameState);
|
||||
OnGameStateChanged(GameState.InMenu);
|
||||
}
|
||||
|
||||
public void OnGameStateChanged(GameState gameState)
|
||||
{
|
||||
GameState = gameState;
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.InMenu:
|
||||
gameplayManager.ResetData();
|
||||
uiManager.OnInMenuScreen();
|
||||
break;
|
||||
case GameState.InGame:
|
||||
uiManager.OnInGameScreen();
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
uiManager.OnGameOver();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
private ScreenManager screenManager;
|
||||
private PopupManager popupManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@ -15,6 +16,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
||||
}
|
||||
|
||||
public void OnDiceViewInteracted()
|
||||
@ -35,8 +37,9 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
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,
|
||||
OptionsPopup,
|
||||
InstructionsPopup,
|
||||
PauseMenuPopup
|
||||
PauseMenuPopup,
|
||||
GameOverPopup
|
||||
}
|
||||
|
||||
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 SoundManager soundManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
private GameManager gameManager;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
private PlayerType playerType;
|
||||
@ -58,6 +59,7 @@ public class PvAIModePopup : PopupBase
|
||||
private void Start()
|
||||
{
|
||||
OnPlayerCountSelected(2, twoPlayerBtn);
|
||||
OnColorSelected(PlayerType.Player1, redBtn);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -105,7 +107,10 @@ public class PvAIModePopup : PopupBase
|
||||
popupManager.HidePopup(popupType);
|
||||
|
||||
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()
|
||||
|
||||
@ -150,7 +150,7 @@ public class PvPModePopup : PopupBase
|
||||
popupManager.HidePopup(popupType);
|
||||
|
||||
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()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user