Compare commits
No commits in common. "b002f8e021bcfe1e230eb02e606f491f3a71454e" and "f2d9a7f7cce373db0ceafbd5da63138487b8641b" have entirely different histories.
b002f8e021
...
f2d9a7f7cc
@ -22667,7 +22667,6 @@ 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
|
||||||
@ -22675,31 +22674,6 @@ 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
|
||||||
@ -26201,7 +26175,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 &5608193482973815122
|
--- !u!222 &5608193482973815122
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27412,7 +27386,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 &5608193483354237948
|
--- !u!222 &5608193483354237948
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27564,7 +27538,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 &5608193483406443892
|
--- !u!222 &5608193483406443892
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -8,28 +7,11 @@ 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;
|
||||||
|
|
||||||
private PVPModeData pvpModeData;
|
public GameModeType GameModeType
|
||||||
private BotModeData botModeData;
|
|
||||||
|
|
||||||
public GameModeType CurrentGameModeType
|
|
||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
@ -44,39 +26,15 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPVPModeData(List<PlayerType> types, List<string> names)
|
public void InitPVPModeData(List<PlayerType> types)
|
||||||
{
|
{
|
||||||
pvpModeData = new PVPModeData
|
GameModeType = GameModeType.PVP;
|
||||||
{
|
gameplayManager.InitPlayerTypesForPVP(types);
|
||||||
types = types, names = names
|
|
||||||
};
|
|
||||||
|
|
||||||
CurrentGameModeType = GameModeType.PVP;
|
|
||||||
gameplayManager.InitPlayerTypesForPVP(types, names);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitBotModeData(PlayerData playerData, int botCount)
|
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
||||||
{
|
{
|
||||||
botModeData = new BotModeData
|
GameModeType = GameModeType.Bot;
|
||||||
{
|
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,6 +5,33 @@ 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,
|
||||||
@ -32,18 +59,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;
|
||||||
|
|
||||||
@ -57,13 +84,6 @@ 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()
|
||||||
@ -75,24 +95,16 @@ 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})
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
// TODO :: Call when the UI selection is made and game starts
|
||||||
|
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();
|
||||||
@ -100,37 +112,22 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||||
{
|
{
|
||||||
playerDatas.Clear();
|
|
||||||
botTypesInGame.Clear();
|
botTypesInGame.Clear();
|
||||||
allPlayerTypes.Clear();
|
allPlayerTypes.Clear();
|
||||||
|
AssignBotTypes(selectedPlayerType, botCount);
|
||||||
|
|
||||||
TotalPlayersInGame = botCount + 1;
|
|
||||||
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
|
||||||
|
|
||||||
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
allPlayerTypes.Add(selectedPlayerType);
|
||||||
{
|
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(selectedPlayerData.playerType);
|
AssignPlayerAndBotStates(selectedPlayerType);
|
||||||
|
|
||||||
SetCanRollDiceForUser(!botTypesInGame.Contains(allPlayerTypes[0]));
|
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
||||||
if (botTypesInGame.Contains(allPlayerTypes[0]))
|
|
||||||
Invoke(nameof(HandleDiceRoll), 1f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitBotRuntimeData()
|
private void InitBotRuntimeData()
|
||||||
@ -202,8 +199,6 @@ 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))
|
||||||
@ -576,8 +571,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)
|
||||||
@ -955,18 +950,17 @@ 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
|
||||||
allPlayerTypes.RemoveAt(0);
|
playerRankings.Add(allPlayerTypes[0]);
|
||||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
allPlayerTypes.Remove(0);
|
||||||
|
|
||||||
// Show Game Over panel
|
// Show Game Over panel
|
||||||
gameManager.OnGameStateChanged(GameState.GameOver);
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1025,15 +1019,5 @@ 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], playerType);
|
playerPawns[idx].Init(basePlacementDatas[idx].playerBaseId, playerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,30 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: e9f4a588284ad4839bff99f31d6d402c
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -135,12 +135,10 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(BasePlacementData basePlacementData, PlayerType playerType)
|
public void Init(int id, PlayerType playerType)
|
||||||
{
|
{
|
||||||
PlayerId = basePlacementData.playerBaseId;
|
PlayerId = id;
|
||||||
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,13 +4,11 @@ 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
|
||||||
{
|
{
|
||||||
@ -25,26 +23,21 @@ 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>();
|
|
||||||
|
|
||||||
OnGameStateChanged(GameState.InMenu);
|
GameState = 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,7 +6,6 @@ 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()
|
||||||
{
|
{
|
||||||
@ -16,7 +15,6 @@ 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()
|
||||||
@ -37,9 +35,8 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGameOver()
|
public void UpdateSelectedPlayerCount(int playersCount)
|
||||||
{
|
{
|
||||||
popupManager.GetPopup<GameOverPopup>(PopupType.GameOverPopup).InitData(gameplayManager.PlayerDatas);
|
|
||||||
popupManager.ShowPopup(PopupType.GameOverPopup);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,8 +9,7 @@ public enum PopupType
|
|||||||
PvAIModePopup,
|
PvAIModePopup,
|
||||||
OptionsPopup,
|
OptionsPopup,
|
||||||
InstructionsPopup,
|
InstructionsPopup,
|
||||||
PauseMenuPopup,
|
PauseMenuPopup
|
||||||
GameOverPopup
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PopupScalerType
|
public enum PopupScalerType
|
||||||
|
|||||||
@ -1,65 +0,0 @@
|
|||||||
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}";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,11 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 178d988f5211b4ef5b8c2df230b708d4
|
|
||||||
MonoImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
defaultReferences: []
|
|
||||||
executionOrder: 0
|
|
||||||
icon: {instanceID: 0}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -33,7 +33,6 @@ 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;
|
||||||
@ -59,7 +58,6 @@ 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()
|
||||||
@ -107,10 +105,7 @@ 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(new PlayerData{ playerType = playerType, playerName = playerName }, selectedPlayerCount - 1);
|
gameModeHandler.InitBotModeData(playerType, 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(), playerNameMap.Values.ToList());
|
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_SwitchButton()
|
private void OnClick_SwitchButton()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user