Compare commits
19 Commits
f5629aa283
...
318a34e192
| Author | SHA1 | Date | |
|---|---|---|---|
| 318a34e192 | |||
| 1897a36a88 | |||
| 7dc4cb5478 | |||
| f1e88fe0f3 | |||
| d07951dabf | |||
| 57787ecc4e | |||
| 4530c474e9 | |||
| 273c86d5b9 | |||
| 77edc7197e | |||
| f12bd32c55 | |||
| 6b5dd5d0f0 | |||
| 76659bc964 | |||
| ffabbf808f | |||
| 2a348436d3 | |||
| e069dd4755 | |||
| 4bec2bc8fa | |||
| 9d6d2599e1 | |||
| d1836cf10c | |||
| afb05e4116 |
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:
|
||||
|
||||
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:
|
||||
@ -25,7 +25,7 @@ public class BotModeData
|
||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
private GameManager gameManager;
|
||||
private PVPModeData pvpModeData;
|
||||
private BotModeData botModeData;
|
||||
|
||||
@ -41,6 +41,7 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void InitializeData()
|
||||
{
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
@ -69,6 +70,8 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void OnGameRestarted()
|
||||
{
|
||||
gameManager.OnGameStateChanged(GameState.InGame);
|
||||
gameplayManager.ResetGameRestartData();
|
||||
switch (CurrentGameModeType)
|
||||
{
|
||||
case GameModeType.PVP:
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
using TMPro;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public enum BotMove
|
||||
{
|
||||
@ -16,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;
|
||||
|
||||
@ -46,6 +52,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
private TilesManager tilesManager;
|
||||
private UIManager uIManager;
|
||||
private GameManager gameManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int diceRolledValue;
|
||||
|
||||
@ -79,12 +86,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
uIManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||
gameModeHandler = InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>();
|
||||
}
|
||||
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
||||
{
|
||||
allPlayerTypes = new List<PlayerType>(types);
|
||||
playerDatas.Clear();
|
||||
playerDatas = new List<PlayerData>();
|
||||
|
||||
TotalPlayersInGame = types.Count;
|
||||
|
||||
@ -119,7 +127,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
if (botTypesInGame.Contains(playerType))
|
||||
{
|
||||
allPlayerTypes.Add(playerType);
|
||||
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{playerType}" });
|
||||
playerDatas.Add(new PlayerData { playerType = playerType, playerName = $"{playerType}" });
|
||||
}
|
||||
else if (selectedPlayerData.playerType == playerType)
|
||||
{
|
||||
@ -128,9 +136,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var type in allPlayerTypes)
|
||||
Debug.Log($"allPlayerTypes ::: {type}");
|
||||
|
||||
tilesManager.InitTilesData();
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
@ -205,10 +210,12 @@ 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>();
|
||||
@ -268,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();
|
||||
@ -303,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;
|
||||
|
||||
@ -316,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
|
||||
@ -331,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)
|
||||
@ -365,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;
|
||||
@ -417,8 +412,23 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
}
|
||||
|
||||
if (pawn != null)
|
||||
{
|
||||
Debug.Log($"AI playerPawn :: {pawn.name} :: SelectedPawn: {pawn.name}");
|
||||
OnPawnSelected(pawn);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckForMaxDiceRollAttempt())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CanRollDiceAgain)
|
||||
HandleDiceRoll();
|
||||
else
|
||||
SwitchPlayer();
|
||||
}
|
||||
|
||||
void InitPawnBasedOnState(BotMove botMove)
|
||||
{
|
||||
@ -448,6 +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);
|
||||
@ -474,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;
|
||||
}
|
||||
@ -488,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}");
|
||||
@ -518,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}");
|
||||
@ -529,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()
|
||||
@ -575,7 +600,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
playerPawn.SetPlayerState(playerState);
|
||||
}
|
||||
|
||||
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
||||
private void CheckDiceRollForBot()
|
||||
{
|
||||
if (CanRollDiceAgain)
|
||||
{
|
||||
@ -585,37 +610,39 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private void HandleDiceRoll()
|
||||
{
|
||||
// diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||
if (isDebugTest)
|
||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal), diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||
else
|
||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||
}
|
||||
|
||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||
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);
|
||||
|
||||
@ -623,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);
|
||||
}
|
||||
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
Tile currentSittingTile = tilesManager.RetrieveFinishingTileBasedOnIndex(selectedPawn.PlayerType, selectedPawn.CurrentTileIndex);
|
||||
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||
|
||||
if (currentSittingTile.HasPawnsAvailable)
|
||||
{
|
||||
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
||||
ApplyFinishingPathLogic(playerPawn);
|
||||
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||
foreach (var pawn in playerPawns)
|
||||
ShowUpdatedPlayerCountOnTile(pawn);
|
||||
}
|
||||
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
||||
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
}
|
||||
else if (selectedPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||
{
|
||||
tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex).ResetPlayerPawn(selectedPawn);
|
||||
ApplyFinishingPathLogic(selectedPawn);
|
||||
}
|
||||
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);
|
||||
// }
|
||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn);
|
||||
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||
{
|
||||
var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType);
|
||||
|
||||
if (safeTile.PlayerTypesCount == 1)
|
||||
{
|
||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||
|
||||
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -680,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);
|
||||
}
|
||||
|
||||
@ -706,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)
|
||||
{
|
||||
@ -721,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;
|
||||
@ -737,30 +782,43 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
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);
|
||||
@ -778,7 +836,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
|
||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.ShowPlayerCountCanvas(false);
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
targetPosition,
|
||||
@ -811,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)
|
||||
{
|
||||
@ -830,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++;
|
||||
@ -841,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;
|
||||
@ -932,9 +991,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
|
||||
|
||||
DisplayPlayerCountOnTile(playerPawn, false);
|
||||
playerPawn.MoveToTile(
|
||||
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
|
||||
tilesManager.RetrieveFinishingTileBasedOnIndex(currentPlayerTypeTurn, index).transform.position,
|
||||
onComplete: () =>
|
||||
{
|
||||
diceRolledValue--;
|
||||
@ -952,45 +1010,43 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
}
|
||||
else
|
||||
{
|
||||
DisplayPlayerCountOnTile(playerPawn, true);
|
||||
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))
|
||||
{
|
||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
allPlayerTypes.Remove(playerTypeToRemove);
|
||||
playerDatas.FirstOrDefault(data => data.playerType == playerTypeToRemove).ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
}
|
||||
|
||||
if (allPlayerTypes.Count == 1)
|
||||
{
|
||||
// Game is over
|
||||
var lastUnfinishingPlayerType = allPlayerTypes[0];
|
||||
allPlayerTypes.RemoveAt(0);
|
||||
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||
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);
|
||||
}
|
||||
@ -998,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();
|
||||
}
|
||||
}
|
||||
@ -1016,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)
|
||||
@ -1033,18 +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;
|
||||
botTypesInGame = null;
|
||||
allPlayerTypes = null;
|
||||
|
||||
botRuntimeMovementData = null;
|
||||
playerGameDatasDict = null;
|
||||
playerDatas = null;
|
||||
availPlayers = null;
|
||||
|
||||
botTypesInGame = null;
|
||||
botRuntimeMovementData = null;
|
||||
}
|
||||
|
||||
public void ResetGameRestartData()
|
||||
{
|
||||
currentPlayerTurnIndex = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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;
|
||||
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);
|
||||
}
|
||||
|
||||
@ -145,8 +169,6 @@ public class PlayerPawn : MonoBehaviour
|
||||
|
||||
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);
|
||||
|
||||
if (inputManager.GameplayManager.IsDebugTest)
|
||||
OnUserDiceRollComplete(GetDiceTestVal());
|
||||
// diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
else
|
||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
||||
}
|
||||
|
||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||
{
|
||||
diceView.Roll(onComplete: (val) => onComplete?.Invoke(val), true);
|
||||
diceView.Roll(onComplete: onComplete, true);
|
||||
}
|
||||
|
||||
public void HandleDiceViewForBot(Action<int> onComplete, int val)
|
||||
|
||||
@ -10,6 +10,7 @@ public enum GameState
|
||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private UIManager uiManager;
|
||||
private TilesManager tilesManager;
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameState GameState
|
||||
@ -25,6 +26,7 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
|
||||
OnGameStateChanged(GameState.InMenu);
|
||||
@ -33,10 +35,12 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
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:
|
||||
|
||||
@ -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()
|
||||
{
|
||||
@ -32,13 +32,14 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
|
||||
public void InitTilesData()
|
||||
{
|
||||
finishingTileDataPairs = new Dictionary<PlayerType, List<Tile>>();
|
||||
foreach (var tileData in tileDatas)
|
||||
{
|
||||
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
||||
{
|
||||
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>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -52,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();
|
||||
}
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ public class ScreenBase : UIBase, IUIBase
|
||||
|
||||
public ScreenType ScreenType => screenType;
|
||||
|
||||
private ScreenManager screenManager;
|
||||
protected ScreenManager screenManager;
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@ -12,7 +13,26 @@ public class GameOverPopup : PopupBase
|
||||
[SerializeField] private TextMeshProUGUI[] texts;
|
||||
|
||||
private GameModeHandler gameModeHandler;
|
||||
private ScreenManager screenManager;
|
||||
|
||||
public void InitData(List<PlayerData> playerData)
|
||||
{
|
||||
for (int idx = 0; idx < texts.Length; idx++)
|
||||
{
|
||||
if (idx >= playerData.Count)
|
||||
{
|
||||
texts[idx].gameObject.SetActive(false);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (playerData[idx].ranking == 1)
|
||||
{
|
||||
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].playerName} Wins";
|
||||
continue;
|
||||
}
|
||||
|
||||
texts[playerData[idx].ranking - 1].text = $"{playerData[idx].ranking}. {playerData[idx].playerName}";
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
@ -42,22 +62,5 @@ public class GameOverPopup : PopupBase
|
||||
public void OnMainMenuClicked()
|
||||
{
|
||||
HidePopup();
|
||||
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
}
|
||||
|
||||
public void InitData(List<PlayerData> playerDatas)
|
||||
{
|
||||
for (int i = 0; i < playerDatas.Count; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
texts[i].text = $"{playerDatas[i].playerName} Wins";
|
||||
continue;
|
||||
}
|
||||
|
||||
texts[i].text = $"{(i + 1)}. {playerDatas[i].playerName}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,6 +39,7 @@ public class PvPModePopup : PopupBase
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private GameManager gameManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
@ -151,6 +152,9 @@ public class PvPModePopup : PopupBase
|
||||
|
||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList(), playerNameMap.Values.ToList());
|
||||
|
||||
gameManager = gameManager == null ? InterfaceManager.Instance.GetInterfaceInstance<GameManager>() : gameManager;
|
||||
gameManager.OnGameStateChanged(GameState.InGame);
|
||||
}
|
||||
|
||||
private void OnClick_SwitchButton()
|
||||
|
||||
@ -1,8 +1,44 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameOverScreen : ScreenBase
|
||||
{
|
||||
[SerializeField] private Button playAgainBtn;
|
||||
[SerializeField] private Button mainMenuBtn;
|
||||
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
||||
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
playAgainBtn.onClick.RemoveAllListeners();
|
||||
mainMenuBtn.onClick.RemoveAllListeners();
|
||||
}
|
||||
|
||||
public void OnPlayAgainClicked()
|
||||
{
|
||||
HideScreen();
|
||||
}
|
||||
|
||||
private void HideScreen()
|
||||
{
|
||||
screenManager.HideScreen(screenType);
|
||||
}
|
||||
|
||||
public void OnMainMenuClicked()
|
||||
{
|
||||
HideScreen();
|
||||
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
screenManager.ShowScreen(ScreenType.MainMenuScreen);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user