Compare commits
28 Commits
41c2fdbee5
...
318a34e192
| Author | SHA1 | Date | |
|---|---|---|---|
| 318a34e192 | |||
| 1897a36a88 | |||
| 7dc4cb5478 | |||
| f1e88fe0f3 | |||
| d07951dabf | |||
| 57787ecc4e | |||
| 4530c474e9 | |||
| 273c86d5b9 | |||
| 77edc7197e | |||
| f12bd32c55 | |||
| 6b5dd5d0f0 | |||
| 76659bc964 | |||
| ffabbf808f | |||
| 2a348436d3 | |||
| e069dd4755 | |||
| 4bec2bc8fa | |||
| 9d6d2599e1 | |||
| d1836cf10c | |||
| afb05e4116 | |||
| f5629aa283 | |||
| ca6561b418 | |||
| 0aa1f18801 | |||
| 2dd685a90a | |||
| 1113352c7c | |||
| b002f8e021 | |||
| e57be039ff | |||
| f2d9a7f7cc | |||
| 6e74d05851 |
BIN
Assets/Artifacts/Audio/Game Over BGM.wav
Normal file
BIN
Assets/Artifacts/Audio/Game Over BGM.wav
Normal file
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44a099190c52447f7a3254e3679ecfd8
|
||||
guid: 25dd9172f3ed8497bb638d649e5309f0
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
Binary file not shown.
48
Assets/Artifacts/Prefabs/Tiles/FinishingPathWaypoint.prefab
Normal file
48
Assets/Artifacts/Prefabs/Tiles/FinishingPathWaypoint.prefab
Normal file
@ -0,0 +1,48 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &8621343442563501342
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8621343442563501343}
|
||||
- component: {fileID: 8621343442563501340}
|
||||
m_Layer: 0
|
||||
m_Name: FinishingPathWaypoint
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8621343442563501343
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8621343442563501342}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.12, y: 0, z: -14.976}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &8621343442563501340
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8621343442563501342}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: be69a8cfb3b2940308cbac570565e629, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isSafeZone: 0
|
||||
centeredPoint: {fileID: 8621343442563501343}
|
||||
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9f6f4c66b5a34d7eb7286e772505389
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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()
|
||||
|
||||
@ -630,6 +630,7 @@ MonoBehaviour:
|
||||
playerState: 0
|
||||
animator: {fileID: 5526766409186502679}
|
||||
playerCountCanvasPrefab: {fileID: 9029553984926861784}
|
||||
playerCountCanvas: {fileID: 5728752331380905399}
|
||||
--- !u!1 &4818123989977612668
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1622,6 +1623,17 @@ RectTransform:
|
||||
m_CorrespondingSourceObject: {fileID: 953143927943285832, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 4537709141704337870}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &5728752331380905399 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 4537709141704337870}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9029553984926861784}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &9029553984926861784 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
|
||||
@ -630,6 +630,7 @@ MonoBehaviour:
|
||||
playerState: 0
|
||||
animator: {fileID: 5274388487207906813}
|
||||
playerCountCanvasPrefab: {fileID: 6862258105288866118}
|
||||
playerCountCanvas: {fileID: 7923051124467737897}
|
||||
--- !u!1 &5059623752267150313
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1671,3 +1672,14 @@ GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 2057554100330600784}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
--- !u!114 &7923051124467737897 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 2057554100330600784}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6862258105288866118}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
||||
@ -202,6 +202,7 @@ MonoBehaviour:
|
||||
playerState: 0
|
||||
animator: {fileID: 232863433340697214}
|
||||
playerCountCanvasPrefab: {fileID: 2911420982173280738}
|
||||
playerCountCanvas: {fileID: 1920934309388072333}
|
||||
--- !u!136 &1627116187348267135
|
||||
CapsuleCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1661,6 +1662,17 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
--- !u!114 &1920934309388072333 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 7769048123306772980}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2911420982173280738}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &2911420982173280738 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
|
||||
@ -1259,6 +1259,7 @@ MonoBehaviour:
|
||||
playerState: 0
|
||||
animator: {fileID: 7800412279828783518}
|
||||
playerCountCanvasPrefab: {fileID: 4593694095142779203}
|
||||
playerCountCanvas: {fileID: 941219433310479660}
|
||||
--- !u!1 &7074820051352815849
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1661,6 +1662,17 @@ PrefabInstance:
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
--- !u!114 &941219433310479660 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 8176763997504289913, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
m_PrefabInstance: {fileID: 8968445451050703189}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4593694095142779203}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 12325a6692b2349b5992ec00a2cf8162, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &4593694095142779203 stripped
|
||||
GameObject:
|
||||
m_CorrespondingSourceObject: {fileID: 4879164135252893718, guid: a925361762f504380a8aa4d7eb87b32c, type: 3}
|
||||
|
||||
@ -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:
|
||||
@ -239,7 +239,7 @@ MonoBehaviour:
|
||||
m_FallbackScreenDPI: 96
|
||||
m_DefaultSpriteDPI: 96
|
||||
m_DynamicPixelsPerUnit: 1
|
||||
m_PresetInfoIsWorld: 0
|
||||
m_PresetInfoIsWorld: 1
|
||||
--- !u!114 &2739169735767897497
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -347,8 +347,8 @@ MonoBehaviour:
|
||||
m_fontMaterials: []
|
||||
m_fontColor32:
|
||||
serializedVersion: 2
|
||||
rgba: 4282166768
|
||||
m_fontColor: {r: 0.9411765, g: 0.6784314, b: 0.23529412, a: 1}
|
||||
rgba: 4278190080
|
||||
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_enableVertexGradient: 0
|
||||
m_colorMode: 3
|
||||
m_fontColorGradient:
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
8
Assets/Scripts/Audio.meta
Normal file
8
Assets/Scripts/Audio.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e82d850a90884a54a07beff74d9a324
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/Scripts/Audio/MusicManager.cs
Normal file
65
Assets/Scripts/Audio/MusicManager.cs
Normal file
@ -0,0 +1,65 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum MusicType
|
||||
{
|
||||
HomeMusic,
|
||||
GameMusic,
|
||||
GameOverMusic
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class MusicData
|
||||
{
|
||||
public MusicType musicType;
|
||||
public int priority;
|
||||
public AudioClip musicClip;
|
||||
}
|
||||
|
||||
public class MusicManager : MonoBehaviour, IBootLoader, IBase, IDataLoader
|
||||
{
|
||||
[SerializeField] AudioSource audioSource;
|
||||
[SerializeField] private MusicData[] musicDatas;
|
||||
|
||||
public bool IsGamemusicOn
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
}
|
||||
|
||||
private Dictionary<MusicType, MusicData> musicDataDict = new Dictionary<MusicType, MusicData>();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
InterfaceManager.Instance?.RegisterInterface<MusicManager>(this);
|
||||
}
|
||||
|
||||
public void InitializeData()
|
||||
{
|
||||
audioSource.priority = 0;
|
||||
for (int idx = 0; idx < musicDatas.Length; idx++)
|
||||
{
|
||||
if (musicDataDict.ContainsKey(musicDatas[idx].musicType))
|
||||
musicDataDict[musicDatas[idx].musicType] = musicDatas[idx];
|
||||
else
|
||||
musicDataDict.Add(musicDatas[idx].musicType, musicDatas[idx]);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetGamemusic(bool state)
|
||||
{
|
||||
IsGamemusicOn = state;
|
||||
}
|
||||
|
||||
public void PlayMusicClip(MusicType musicType)
|
||||
{
|
||||
if (!enabled) return;
|
||||
|
||||
MusicData musicData = musicDataDict[musicType];
|
||||
|
||||
audioSource.priority = musicData.priority;
|
||||
audioSource.clip = musicData.musicClip;
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Audio/MusicManager.cs.meta
Normal file
11
Assets/Scripts/Audio/MusicManager.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f598c418041d4a9e89aa7a25efc1185
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -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;
|
||||
private GameManager gameManager;
|
||||
private PVPModeData pvpModeData;
|
||||
private BotModeData botModeData;
|
||||
|
||||
public GameModeType GameModeType
|
||||
public GameModeType CurrentGameModeType
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
@ -23,18 +41,45 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void InitializeData()
|
||||
{
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
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()
|
||||
{
|
||||
gameManager.OnGameStateChanged(GameState.InGame);
|
||||
gameplayManager.ResetGameRestartData();
|
||||
switch (CurrentGameModeType)
|
||||
{
|
||||
case GameModeType.PVP:
|
||||
InitPVPModeData(pvpModeData.types, pvpModeData.names);
|
||||
break;
|
||||
case GameModeType.Bot:
|
||||
InitBotModeData(botModeData.playerData, botModeData.botCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,36 +1,9 @@
|
||||
using TMPro;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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
|
||||
}
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum BotMove
|
||||
{
|
||||
@ -43,9 +16,15 @@ 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 int totalStepsForCharacter = 57;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI diceText;
|
||||
|
||||
@ -58,19 +37,22 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
[SerializeField] private PlayerBaseHandler playerBaseHandler;
|
||||
|
||||
private PlayerType currentPlayerTypeTurn;
|
||||
public PlayerType CurrentPlayerTypeTurn => 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 UIManager uIManager;
|
||||
private GameManager gameManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int diceRolledValue;
|
||||
|
||||
@ -84,6 +66,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 +84,28 @@ 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})
|
||||
uIManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
gameModeHandler = InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>();
|
||||
}
|
||||
|
||||
// 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 = new List<PlayerData>();
|
||||
|
||||
TotalPlayersInGame = types.Count;
|
||||
|
||||
for (int i=0; i<types.Count; i++)
|
||||
{
|
||||
playerDatas.Add(new PlayerData
|
||||
{
|
||||
playerType = types[i],
|
||||
playerName = names[i],
|
||||
});
|
||||
}
|
||||
|
||||
tilesManager.InitTilesData();
|
||||
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
@ -112,27 +113,43 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
||||
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||
{
|
||||
botTypesInGame.Clear();
|
||||
allPlayerTypes.Clear();
|
||||
AssignBotTypes(selectedPlayerType, botCount);
|
||||
playerDatas = new List<PlayerData>();
|
||||
botTypesInGame = new List<PlayerType>();
|
||||
allPlayerTypes = new List<PlayerType>();
|
||||
|
||||
|
||||
allPlayerTypes.Add(selectedPlayerType);
|
||||
allPlayerTypes.AddRange(botTypesInGame);
|
||||
TotalPlayersInGame = botCount + 1;
|
||||
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
||||
|
||||
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
||||
{
|
||||
if (botTypesInGame.Contains(playerType))
|
||||
{
|
||||
allPlayerTypes.Add(playerType);
|
||||
playerDatas.Add(new PlayerData { playerType = playerType, playerName = $"{playerType}" });
|
||||
}
|
||||
else if (selectedPlayerData.playerType == playerType)
|
||||
{
|
||||
allPlayerTypes.Add(selectedPlayerData.playerType);
|
||||
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{selectedPlayerData.playerName}" });
|
||||
}
|
||||
}
|
||||
|
||||
tilesManager.InitTilesData();
|
||||
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()
|
||||
{
|
||||
botRuntimeMovementData.Clear();
|
||||
botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||
|
||||
foreach (var botType in botTypesInGame)
|
||||
{
|
||||
@ -193,12 +210,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
// TODO :: Call based on 2P/3P/4P
|
||||
public void InitCurrentGamePlayerInfo()
|
||||
{
|
||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
||||
|
||||
SetCurrentSelectedPointer();
|
||||
|
||||
// initialize the board based on the player types
|
||||
playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||
|
||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||
{
|
||||
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
||||
@ -254,7 +275,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private bool CheckForMaxDiceRollAttempt()
|
||||
{
|
||||
if (diceSixRollCounter == 3)
|
||||
if (diceSixRollCounter > maxDiceSixRollCounter) // TODO :: Reset after test
|
||||
{
|
||||
CanRollDiceAgain = false;
|
||||
SwitchPlayer();
|
||||
@ -289,12 +310,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CallTest: SelectPawnFromBotBase: {currentPlayerTypeTurn}");
|
||||
var botPawnsDictForCurrentPlayer = botRuntimeMovementData[currentPlayerTypeTurn]; // set the data inside this dict
|
||||
|
||||
// check the data from the playerGameDataDict
|
||||
// change playerPawnsDict to list
|
||||
|
||||
// only select the pawns that are active
|
||||
// if no pawns have left the home select the first pawn inside the base should be selected
|
||||
|
||||
int savedPlayerId = -1;
|
||||
PlayerPawn pawn = null;
|
||||
|
||||
@ -302,7 +317,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0)
|
||||
{
|
||||
InitActivePlayers();
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
}
|
||||
|
||||
if (availPlayers.Count() < 1 && CanRollDiceAgain) // got a 6 roll value
|
||||
@ -317,27 +332,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)
|
||||
@ -351,12 +360,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;
|
||||
@ -403,8 +412,23 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"AI playerPawn :: {pawn.name} :: SelectedPawn: {pawn.name}");
|
||||
OnPawnSelected(pawn);
|
||||
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)
|
||||
{
|
||||
@ -434,6 +458,28 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
private void FindPossibleTileData(PlayerPawn playerPawn, out int possibleSteps, out Tile possibleTileData)
|
||||
{
|
||||
int lastStepGenTile = totalStepsForCharacter - tilesManager.GetFinishingTileDataLength(playerPawn.PlayerType);//playerGameDatasDict[playerPawn.PlayerType].endIndex;
|
||||
int possibleTileIndex = playerPawn.CurrentTileIndex + diceRolledValue;
|
||||
|
||||
int lastTileIndex = tilesManager.GetGeneralTilesLength() - 1;
|
||||
bool canGoingInsideFinishingPath = IsGoingInsideFinishingPath(playerPawn, out possibleSteps);
|
||||
|
||||
int index = canGoingInsideFinishingPath ? possibleSteps - lastStepGenTile - 1
|
||||
: possibleTileIndex > lastTileIndex ? possibleTileIndex - lastTileIndex - 1 : possibleTileIndex; // case for addressing the scenario when going through the last index of general tiles.
|
||||
|
||||
Debug.Log($"possibleTileIndex: {possibleTileIndex}, lastStepGenTileIdx: {lastStepGenTile}");
|
||||
Debug.Log($"index: {index}");
|
||||
possibleTileData = canGoingInsideFinishingPath ? tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, index) : tilesManager.RetrieveTileBasedOnIndex(index);
|
||||
}
|
||||
|
||||
public bool IsGoingInsideFinishingPath(PlayerPawn playerPawn, out int possibleSteps)
|
||||
{
|
||||
possibleSteps = playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId].StepsTaken + diceRolledValue;
|
||||
return possibleSteps > tilesManager.GetGeneralTilesLength() - 1;
|
||||
}
|
||||
|
||||
public void OnDiceRolled(int rolledVal)
|
||||
{
|
||||
SetCanRollDiceForUser(false);
|
||||
@ -442,7 +488,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
||||
diceRolledValue = rolledVal;
|
||||
diceText.text = $"{diceRolledValue}";
|
||||
availPlayers.Clear();
|
||||
availPlayers = new List<PlayerPawn>();
|
||||
|
||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||
{
|
||||
@ -460,7 +506,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"### AreAllPawnsInFinishingPath");
|
||||
if (AreAllPawnsInFinishingPath())
|
||||
{
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
SetCanRollDiceForUser(gameModeHandler.CurrentGameModeType != GameModeType.Bot || !botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
|
||||
return;
|
||||
}
|
||||
@ -474,7 +520,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else // if there are any other pawns that are in safe or moving state
|
||||
{
|
||||
// for player's logic
|
||||
InitActivePlayers();
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
|
||||
int customAvailPlayers = availPlayers.Count();
|
||||
Debug.Log($"before CustomAvailablePlayers: {customAvailPlayers}");
|
||||
@ -504,7 +550,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}");
|
||||
@ -515,22 +562,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
||||
}
|
||||
|
||||
private void InitActivePlayers()
|
||||
private void UpdateActivePlayersAndSetDisplay()
|
||||
{
|
||||
availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values.Select(pawn => pawn)
|
||||
.Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone ||
|
||||
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);
|
||||
}
|
||||
SetDisplayCountForAllAvailPlayers(true);
|
||||
}
|
||||
|
||||
private bool AreAllPawnsInFinishingPath()
|
||||
@ -561,7 +600,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
playerPawn.SetPlayerState(playerState);
|
||||
}
|
||||
|
||||
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
||||
private void CheckDiceRollForBot()
|
||||
{
|
||||
if (CanRollDiceAgain)
|
||||
{
|
||||
@ -571,37 +610,39 @@ 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);
|
||||
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)
|
||||
public void OnPawnSelected(PlayerPawn selectedPawn)
|
||||
{
|
||||
EnablePlayerSelectionStates(false);
|
||||
|
||||
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
||||
Debug.Log($"playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}");
|
||||
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
||||
|
||||
|
||||
if (playerPawn.GetPlayerState() == PlayerState.InHome)
|
||||
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
||||
{
|
||||
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
||||
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.MoveToTile(
|
||||
GetAndInitPositionInsideSafeZone(playerPawn, targetTile),
|
||||
selectedPawn.ShowPlayerCountCanvas(false);
|
||||
selectedPawn.MoveToTile(
|
||||
GetAndInitPositionInsideSafeZone(selectedPawn, targetTile),
|
||||
onComplete: () =>
|
||||
{
|
||||
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
||||
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
||||
ShowUpdatedPlayerCountOnTile(selectedPawn);
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (playerPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot(playerPawn);
|
||||
if (selectedPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot();
|
||||
else
|
||||
SetCanRollDiceForUser(true);
|
||||
|
||||
@ -609,53 +650,71 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
return;
|
||||
}
|
||||
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
||||
else if (selectedPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
||||
{
|
||||
ApplyFinishingPathLogic(playerPawn);
|
||||
Tile currentSittingTile = tilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||
|
||||
if (currentSittingTile.HasPawnsAvailable)
|
||||
{
|
||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
}
|
||||
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
else if (selectedPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
{
|
||||
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
||||
ApplyFinishingPathLogic(playerPawn);
|
||||
tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex).ResetPlayerPawn(selectedPawn);
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
}
|
||||
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
||||
else if (selectedPawn.GetPlayerState() == PlayerState.InSafeZone || selectedPawn.GetPlayerState() == PlayerState.Moving)
|
||||
{
|
||||
// move based on the dice value
|
||||
Debug.Log($"Tile Index :: currentTileIndex: {playerPawn.CurrentTileIndex}");
|
||||
int nextTileIdx = GetNextGeneralTileIndex(playerPawn);
|
||||
int targetIdx = playerPawn.CurrentTileIndex + diceRolledValue;
|
||||
Debug.Log($"Tile Index :: currentTileIndex: {selectedPawn.CurrentTileIndex}");
|
||||
int nextTileIdx = GetNextGeneralTileIndex(selectedPawn);
|
||||
int targetIdx = selectedPawn.CurrentTileIndex + diceRolledValue;
|
||||
|
||||
if (nextTileIdx == 0)
|
||||
targetIdx = (targetIdx - playerPawn.CurrentTileIndex) - 1;
|
||||
targetIdx = (targetIdx - selectedPawn.CurrentTileIndex) - 1;
|
||||
|
||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex);
|
||||
if (currentSittingTile.IsSafeZone)
|
||||
{
|
||||
SafeTile safeTile = (SafeTile)currentSittingTile;
|
||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn);
|
||||
// DisplayPlayerCountOnTile(playerPawn, false);
|
||||
// if (safeTile.PlayerTypesCount > 0)
|
||||
// {
|
||||
// var pawns = safeTile.GetPlayerPawns(playerPawn.PlayerType);
|
||||
// foreach (var pawn in pawns)
|
||||
// DisplayPlayerCountOnTile(pawn, true);
|
||||
// }
|
||||
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn);
|
||||
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||
{
|
||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||
var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType);
|
||||
|
||||
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
||||
foreach (var pawn in playerPawns)
|
||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
{
|
||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||
|
||||
foreach (var pawn in playerPawns)
|
||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||
}
|
||||
|
||||
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||
{
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
currentSittingTile.ResetPlayerPawn(playerPawn);
|
||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||
if (currentSittingTile.HasPawnsAvailable)
|
||||
{
|
||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
}
|
||||
|
||||
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
||||
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -666,6 +725,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
||||
|
||||
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
||||
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
||||
}
|
||||
|
||||
@ -692,14 +753,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
||||
|
||||
Debug.Log($"before SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
||||
if (availPlayers.Count < 1)
|
||||
InitActivePlayers();
|
||||
|
||||
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
Debug.Log($"after SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}");
|
||||
foreach (var pawn in availPlayers)
|
||||
{
|
||||
DisplayPlayerCountOnTile(pawn, false);
|
||||
}
|
||||
SetDisplayCountForAllAvailPlayers(false);
|
||||
|
||||
if (allPlayerTypes.Count == 1)
|
||||
{
|
||||
@ -707,6 +764,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
return;
|
||||
}
|
||||
|
||||
currentPlayerTurnIndex = allPlayerTypes.FindIndex(type => type == currentPlayerTypeTurn);
|
||||
|
||||
if (currentPlayerTypeTurn == allPlayerTypes[allPlayerTypes.Count - 1])
|
||||
{
|
||||
currentPlayerTurnIndex = 0;
|
||||
@ -718,33 +777,48 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||
}
|
||||
|
||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
||||
|
||||
diceSixRollCounter = 0;
|
||||
diceText.text = $"{0}";
|
||||
|
||||
InitActivePlayers();
|
||||
foreach (var pawn in availPlayers)
|
||||
{
|
||||
DisplayPlayerCountOnTile(pawn, true);
|
||||
}
|
||||
UpdateActivePlayersAndSetDisplay();
|
||||
}
|
||||
|
||||
SetCanRollDiceForUser(!botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
|
||||
Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}");
|
||||
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
||||
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
||||
SetCanRollDiceForUser(gameModeHandler.CurrentGameModeType != GameModeType.Bot || !botTypesInGame.Contains(currentPlayerTypeTurn));
|
||||
SetCurrentSelectedPointer();
|
||||
|
||||
pointerMeshRend.material = turnMat;
|
||||
// pointerMeshRend.materials[0] = turnMat;
|
||||
|
||||
Debug.Log($"botTypesInGame.Contains(currentPlayerTypeTurn): {botTypesInGame.Contains(currentPlayerTypeTurn)}");
|
||||
// Debug.Log($"botTypesInGame.Contains(currentPlayerTypeTurn): {botTypesInGame.Contains(currentPlayerTypeTurn)}");
|
||||
|
||||
if (botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||
{
|
||||
Debug.Log($"Invoking RollDiceForBot");
|
||||
Invoke(nameof(HandleDiceRoll), 1f);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetCurrentSelectedPointer()
|
||||
{
|
||||
var tempPos = playerBaseHandler.GetPlayerBase(currentPlayerTypeTurn).transform.position;
|
||||
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
|
||||
}
|
||||
|
||||
public void SetDisplayCountForAllAvailPlayers(bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
availPlayers.ForEach(pawn => ShowUpdatedPlayerCountOnTile(pawn));
|
||||
}
|
||||
else
|
||||
{
|
||||
availPlayers.ForEach(pawn => pawn.ShowPlayerCountCanvas(false));
|
||||
}
|
||||
}
|
||||
|
||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||
{
|
||||
Tile nextTile = tilesManager.RetrieveTileBasedOnIndex(index);
|
||||
@ -762,7 +836,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
|
||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
targetPosition,
|
||||
@ -795,7 +869,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
||||
|
||||
if (CanRollDiceAgain)
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
|
||||
if (!nextTile.IsSafeZone)
|
||||
{
|
||||
@ -814,8 +888,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"pawn: {pawn}");
|
||||
Debug.Log($"playerBase: {playerBaseHandler}");
|
||||
|
||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType)
|
||||
.GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType).GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
||||
Debug.Log($"playerBasePos: {playerBasePos}");
|
||||
|
||||
playerGameDatasDict[pawn.PlayerType].totalPawnsInHome++;
|
||||
@ -825,17 +898,19 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
// UpdatePlayerCountOnTile(playerPawn, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
CanRollDiceAgain = true;
|
||||
if (playerPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot(playerPawn);
|
||||
else
|
||||
if (!playerPawn.IsBotPlayer)
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
|
||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
@ -916,9 +991,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
|
||||
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(currentPlayerTypeTurn, index).transform.position,
|
||||
onComplete: () =>
|
||||
{
|
||||
diceRolledValue--;
|
||||
@ -936,44 +1010,43 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Debug.Log($"CurrentTileIndex: {playerPawn.CurrentTileIndex} == lastIndex: {tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1}");
|
||||
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
||||
{
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
||||
|
||||
Debug.Log($"totalPawnsFinished: {playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished}, playerPawnsDict.Count: {playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count}");
|
||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count)
|
||||
{
|
||||
CanRollDiceAgain = false;
|
||||
|
||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||
var playerTypeToRemove = currentPlayerTypeTurn;
|
||||
SwitchPlayer();
|
||||
|
||||
if (allPlayerTypes.Contains(playerTypeToRemove))
|
||||
{
|
||||
playerRankings.Add(currentPlayerTypeTurn);
|
||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||
allPlayerTypes.Remove(playerTypeToRemove);
|
||||
playerDatas.FirstOrDefault(data => data.playerType == playerTypeToRemove).ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
}
|
||||
|
||||
if (allPlayerTypes.Count == 1)
|
||||
{
|
||||
// Game is over
|
||||
playerRankings.Add(allPlayerTypes[0]);
|
||||
allPlayerTypes.Remove(0);
|
||||
var lastUnfinishingPlayerType = allPlayerTypes[0];
|
||||
allPlayerTypes.RemoveAt(0);
|
||||
playerDatas.FirstOrDefault(data => data.playerType == lastUnfinishingPlayerType).ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
|
||||
// Show Game Over panel
|
||||
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
SwitchPlayer();
|
||||
|
||||
Debug.Log($"PlayerTypes: {allPlayerTypes.Count}");
|
||||
}
|
||||
else
|
||||
{
|
||||
CanRollDiceAgain = true;
|
||||
if (playerPawn.IsBotPlayer)
|
||||
CheckDiceRollForBot(playerPawn);
|
||||
CheckDiceRollForBot();
|
||||
else
|
||||
SetCanRollDiceForUser(true);
|
||||
}
|
||||
@ -981,11 +1054,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else
|
||||
{
|
||||
// activate here
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(currentPlayerTypeTurn, playerPawn.CurrentTileIndex).InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CanRollDiceAgain)
|
||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||
|
||||
SwitchPlayer();
|
||||
}
|
||||
}
|
||||
@ -999,12 +1077,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||
}
|
||||
|
||||
private void DisplayPlayerCountOnTile(PlayerPawn playerPawn, bool show)
|
||||
private void ShowUpdatedPlayerCountOnTile(PlayerPawn playerPawn)
|
||||
{
|
||||
Tile tile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
Debug.Log($"Displaycount: {playerPawn.name} on tile: {tile.name}, show: {show}");
|
||||
playerPawn.ShowPlayerCountCanvas(show);
|
||||
if (!show) return;
|
||||
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
||||
: tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
|
||||
playerPawn.ShowPlayerCountCanvas(true);
|
||||
|
||||
int count = 0;
|
||||
if (tile.IsSafeZone)
|
||||
@ -1016,8 +1095,28 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
count = tile.TotalPawnsInTile;
|
||||
}
|
||||
|
||||
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
||||
Debug.Log($"ShowUpdatedPlayerCountOnTile: {count}");
|
||||
|
||||
playerPawn.PlayerCountCanvas.SetPlayerCount(count);
|
||||
}
|
||||
|
||||
public void ResetData()
|
||||
{
|
||||
ResetGameRestartData();
|
||||
|
||||
playerDatas = null;
|
||||
allPlayerTypes = null;
|
||||
|
||||
playerGameDatasDict = null;
|
||||
playerDatas = null;
|
||||
availPlayers = null;
|
||||
|
||||
botTypesInGame = null;
|
||||
botRuntimeMovementData = null;
|
||||
}
|
||||
|
||||
public void ResetGameRestartData()
|
||||
{
|
||||
currentPlayerTurnIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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:
|
||||
@ -21,7 +21,6 @@ public class PlayerPawn : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private PlayerState playerState;
|
||||
[SerializeField] private Animator animator;
|
||||
[SerializeField] private GameObject playerCountCanvasPrefab;
|
||||
[SerializeField] private PlayerCountCanvas playerCountCanvas;
|
||||
|
||||
public PlayerCountCanvas PlayerCountCanvas => playerCountCanvas;
|
||||
@ -90,10 +89,36 @@ public class PlayerPawn : MonoBehaviour
|
||||
TilesManager tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
|
||||
int nextTileIndex = gameplayManager.GetNextGeneralTileIndex(this);
|
||||
Vector3 lookDirection = tilesManager.RetrieveTileBasedOnIndex(nextTileIndex).transform.position - transform.position;
|
||||
Vector3 lookDirection = Vector3.zero;
|
||||
|
||||
if (playerState == PlayerState.InFinishingPath)
|
||||
{
|
||||
int nextIndex = CurrentTileIndex + 1;
|
||||
int maxIndex = tilesManager.GetFinishingTileDataLength(PlayerType) - 1;
|
||||
|
||||
if (nextIndex <= maxIndex)
|
||||
{
|
||||
lookDirection = tilesManager.RetrieveFinishingTileBasedOnIndex(PlayerType, nextIndex).transform.position - transform.position;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (gameplayManager.IsGoingInsideFinishingPath(this, out int possibleSteps))
|
||||
{
|
||||
lookDirection =tilesManager.RetrieveFinishingTileBasedOnIndex(PlayerType, 0).transform.position - transform.position;
|
||||
}
|
||||
else
|
||||
{
|
||||
int nextIndex = gameplayManager.GetNextGeneralTileIndex(this);
|
||||
lookDirection = tilesManager.RetrieveTileBasedOnIndex(nextIndex).transform.position - transform.position;
|
||||
}
|
||||
}
|
||||
|
||||
lookDirection.y = 0;
|
||||
transform.DOLookAt(transform.position + lookDirection, 0.2f);
|
||||
if (lookDirection != Vector3.zero)
|
||||
{
|
||||
transform.DOLookAt(transform.position + lookDirection, 0.2f);
|
||||
}
|
||||
|
||||
onComplete?.Invoke();
|
||||
};
|
||||
@ -101,7 +126,6 @@ public class PlayerPawn : MonoBehaviour
|
||||
|
||||
public void MoveToCustomTilePosition(Vector3 targetPoint)
|
||||
{
|
||||
StepsTaken++;
|
||||
transform.DOMove(targetPoint, 1f);
|
||||
}
|
||||
|
||||
@ -135,16 +159,16 @@ 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)
|
||||
{
|
||||
if (playerCountCanvasPrefab == null) return;
|
||||
|
||||
playerCountCanvasPrefab.SetActive(show);
|
||||
playerCountCanvas.gameObject.SetActive(show);
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,13 +34,15 @@ public class DiceRollHandler : MonoBehaviour
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||
|
||||
OnUserDiceRollComplete(GetDiceTestVal());
|
||||
// diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
if (inputManager.GameplayManager.IsDebugTest)
|
||||
OnUserDiceRollComplete(GetDiceTestVal());
|
||||
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)
|
||||
|
||||
@ -4,11 +4,14 @@ public enum GameState
|
||||
{
|
||||
InMenu,
|
||||
InGame,
|
||||
GameOver,
|
||||
}
|
||||
|
||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private UIManager uiManager;
|
||||
private TilesManager tilesManager;
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameState GameState
|
||||
{
|
||||
@ -23,21 +26,29 @@ 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>();
|
||||
|
||||
GameState = GameState.InMenu;
|
||||
OnGameStateChanged(GameState);
|
||||
OnGameStateChanged(GameState.InMenu);
|
||||
}
|
||||
|
||||
public void OnGameStateChanged(GameState gameState)
|
||||
{
|
||||
GameState = gameState;
|
||||
Debug.Log($"OnGameStateChanged: {gameState}");
|
||||
switch (gameState)
|
||||
{
|
||||
case GameState.InMenu:
|
||||
gameplayManager.ResetData();
|
||||
tilesManager.ResetData();
|
||||
uiManager.OnInMenuScreen();
|
||||
break;
|
||||
case GameState.InGame:
|
||||
uiManager.OnInGameScreen();
|
||||
break;
|
||||
case GameState.GameOver:
|
||||
uiManager.OnGameOver();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,6 @@ public class SafeTile : Tile
|
||||
placementQueue.Enqueue(playerTypesDict[playerType].commonPlacementTransform);
|
||||
playerTypesDict.Remove(playerType);
|
||||
Debug.Log($"targetSafeTile. tileName: {name} Removing player {playerType}");
|
||||
lastOccupiedIndex--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -25,10 +25,10 @@ public class Tile : MonoBehaviour
|
||||
|
||||
public Vector3 CenterPlacementPosition => centeredPoint.position;
|
||||
|
||||
protected int lastOccupiedIndex = 0;
|
||||
|
||||
private List<PlayerPawn> PlayerPawns = new List<PlayerPawn>(); // Change implementation
|
||||
|
||||
public List<PlayerPawn> GetPlayerPawns() => PlayerPawns;
|
||||
|
||||
public bool HasPawnsAvailable => PlayerPawns.Count > 0;
|
||||
public PlayerType CurrentHoldingPlayerType => PlayerPawns[0].PlayerType;
|
||||
public int TotalPawnsInTile => PlayerPawns.Count;
|
||||
|
||||
@ -18,7 +18,7 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
private Dictionary<PlayerType, List<Transform>> finishingTileDataPairs = new Dictionary<PlayerType, List<Transform>>();
|
||||
private Dictionary<PlayerType, List<Tile>> finishingTileDataPairs = new Dictionary<PlayerType, List<Tile>>();
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
@ -28,14 +28,18 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitTilesData()
|
||||
{
|
||||
finishingTileDataPairs = new Dictionary<PlayerType, List<Tile>>();
|
||||
foreach (var tileData in tileDatas)
|
||||
{
|
||||
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
||||
{
|
||||
finishingTileDataPairs.Add(tileData.playerType, new List<Transform>());
|
||||
finishingTileDataPairs.Add(tileData.playerType, new List<Tile>());
|
||||
foreach (Transform child in tileData.playerFinishingTileParent)
|
||||
finishingTileDataPairs[tileData.playerType].Add(child);
|
||||
finishingTileDataPairs[tileData.playerType].Add(child.GetComponent<Tile>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -49,16 +53,17 @@ 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;
|
||||
}
|
||||
|
||||
public Transform RetrievePositionForFinishingTile(PlayerType playerType, int index)
|
||||
public Tile RetrieveFinishingTileBasedOnIndex(PlayerType playerType, int index)
|
||||
{
|
||||
return finishingTileDataPairs[playerType][index];
|
||||
}
|
||||
|
||||
public void ResetData()
|
||||
{
|
||||
finishingTileDataPairs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
@ -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()
|
||||
@ -26,17 +28,27 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.HideAllScreens();
|
||||
screenManager.ShowScreen(ScreenType.MainMenuScreen);
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
}
|
||||
|
||||
public void OnInGameScreen()
|
||||
{
|
||||
screenManager.HideAllScreens();
|
||||
screenManager.ShowScreen(ScreenType.GameScreen);
|
||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||
}
|
||||
|
||||
public void UpdateSelectedPlayerCount(int playersCount)
|
||||
public void UpdatePlayerTurnText(PlayerType type)
|
||||
{
|
||||
|
||||
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdatePlayerTurnText(type);
|
||||
}
|
||||
|
||||
public void OnGameOver()
|
||||
{
|
||||
screenManager.HideAllScreens();
|
||||
screenManager.ShowScreen(ScreenType.GameOverScreen);
|
||||
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
|
||||
|
||||
@ -7,21 +7,24 @@ using UnityEngine;
|
||||
|
||||
public enum ScreenType
|
||||
{
|
||||
MainMenuScreen,
|
||||
GameScreen,
|
||||
GameOverScreen,
|
||||
LoadingScreen,
|
||||
LevelsScreen,
|
||||
InGameHUDScreen,
|
||||
MenuScreen,
|
||||
MenuScreen
|
||||
}
|
||||
|
||||
public class ScreenBase : UIBase, IUIBase
|
||||
{
|
||||
[SerializeField] protected ScreenType screenType;
|
||||
[SerializeField] protected bool shouldFade = false;
|
||||
|
||||
|
||||
|
||||
public ScreenType ScreenType => screenType;
|
||||
|
||||
private ScreenManager screenManager;
|
||||
protected ScreenManager screenManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
66
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
66
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
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;
|
||||
|
||||
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()
|
||||
{
|
||||
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.HidePopup(popupType);
|
||||
}
|
||||
|
||||
public void OnMainMenuClicked()
|
||||
{
|
||||
HidePopup();
|
||||
}
|
||||
}
|
||||
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()
|
||||
@ -103,9 +105,14 @@ public class PvAIModePopup : PopupBase
|
||||
Debug.Log($"Player 1: {playerName}");
|
||||
|
||||
popupManager.HidePopup(popupType);
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.HideScreen(ScreenType.MainMenuScreen);
|
||||
|
||||
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()
|
||||
@ -121,7 +128,7 @@ public class PvAIModePopup : PopupBase
|
||||
private void OnColorSelected(PlayerType type, Button button)
|
||||
{
|
||||
playerType = type;
|
||||
|
||||
|
||||
prePlayerTypeBtn = currPlayerTypeBtn;
|
||||
currPlayerTypeBtn = button;
|
||||
|
||||
|
||||
@ -39,6 +39,7 @@ public class PvPModePopup : PopupBase
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private GameManager gameManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
@ -150,7 +151,10 @@ 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());
|
||||
|
||||
gameManager = gameManager == null ? InterfaceManager.Instance.GetInterfaceInstance<GameManager>() : gameManager;
|
||||
gameManager.OnGameStateChanged(GameState.InGame);
|
||||
}
|
||||
|
||||
private void OnClick_SwitchButton()
|
||||
|
||||
@ -43,4 +43,27 @@ public class GameHUDS : ScreenBase
|
||||
uiManager = uiManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<UIManager>() : uiManager;
|
||||
uiManager.OnDiceViewInteracted();
|
||||
}
|
||||
|
||||
public void UpdatePlayerTurnText(PlayerType playerType)
|
||||
{
|
||||
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
||||
switch (playerType)
|
||||
{
|
||||
case PlayerType.Player1:
|
||||
playerTurnText.text = "Turn : Red";
|
||||
break;
|
||||
case PlayerType.Player2:
|
||||
playerTurnText.text = "Turn : Blue";
|
||||
break;
|
||||
case PlayerType.Player3:
|
||||
playerTurnText.text = "Turn : Grey";
|
||||
break;
|
||||
case PlayerType.Player4:
|
||||
playerTurnText.text = "Turn : Green";
|
||||
break;
|
||||
default:
|
||||
playerTurnText.text = "Turn";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
Assets/Scripts/UI/Pages/Screens/GameOverScreen.cs
Normal file
44
Assets/Scripts/UI/Pages/Screens/GameOverScreen.cs
Normal file
@ -0,0 +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);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/UI/Pages/Screens/GameOverScreen.cs.meta
Normal file
11
Assets/Scripts/UI/Pages/Screens/GameOverScreen.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 14661c82e227e4988a4ad90d300c6e40
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/UI/Pages/Screens/GameScreen.cs
Normal file
8
Assets/Scripts/UI/Pages/Screens/GameScreen.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GameScreen : ScreenBase
|
||||
{
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Pages/Screens/GameScreen.cs.meta
Normal file
11
Assets/Scripts/UI/Pages/Screens/GameScreen.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c92cd673ccb28491c89a3d28d8707e79
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/UI/Pages/Screens/MainMenuScreen.cs
Normal file
8
Assets/Scripts/UI/Pages/Screens/MainMenuScreen.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MainMenuScreen : ScreenBase
|
||||
{
|
||||
|
||||
}
|
||||
11
Assets/Scripts/UI/Pages/Screens/MainMenuScreen.cs.meta
Normal file
11
Assets/Scripts/UI/Pages/Screens/MainMenuScreen.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 81101c7d4c55a4f1e982f266e7298763
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
x
Reference in New Issue
Block a user