Merge branch 'main' into feature/main-ui

This commit is contained in:
Ashby Issac 2026-01-23 15:36:05 +05:30
commit bcc42f8321
19 changed files with 1396 additions and 792 deletions

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class PlayerBaseData
{
public PlayerTypes playerType;
public PlayerBase playerBase;
}
public class PlayerBaseHandler : MonoBehaviour
{
[SerializeField] private PlayerBase[] playerBases;
public void InitPlayerTypes(List<PlayerTypes> playerTypes)
{
foreach (PlayerBase playerBase in playerBases)
{
if (playerTypes.Contains(playerBase.GetPlayerType()))
{
playerBase.InitPlayerIds();
playerBase.gameObject.SetActive(true);
}
else
{
playerBase.gameObject.SetActive(false);
}
}
}
public void GetPlayerBase()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 647207b7c72d24ccaaebc10900c23d2b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 7993275380040288456} m_GameObject: {fileID: 7993275380040288456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59} m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59}
m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -110,3 +110,4 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: da493b8dbb3aa475abf11f31549b9293, type: 3} m_Script: {fileID: 11500000, guid: da493b8dbb3aa475abf11f31549b9293, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
playerState: 0

View File

@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 7993275380040288456} m_GameObject: {fileID: 7993275380040288456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59} m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59}
m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 7993275380040288456} m_GameObject: {fileID: 7993275380040288456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59} m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59}
m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

@ -29,7 +29,7 @@ Transform:
m_GameObject: {fileID: 7993275380040288456} m_GameObject: {fileID: 7993275380040288456}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59} m_LocalPosition: {x: 18.7, y: 3.76, z: -10.59}
m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

@ -1,6 +1,6 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &340880580 --- !u!1 &141183527
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -8,30 +8,158 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 340880581} - component: {fileID: 141183528}
m_Layer: 0 m_Layer: 0
m_Name: GameObject m_Name: Placement (1)
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!4 &340880581 --- !u!4 &141183528
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 340880580} m_GameObject: {fileID: 141183527}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.09, y: 0, z: -1.01} m_LocalPosition: {x: -1.06, y: 0, z: -1.03}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1216908670}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &165064736
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 165064737}
m_Layer: 0
m_Name: Placement (4)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &165064737
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 165064736}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.89, y: 0, z: -0.92}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1216908670}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &172566720
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 172566721}
m_Layer: 0
m_Name: Placement (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &172566721
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172566720}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.88, y: 0, z: 1.12}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1216908670}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1216908669
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1216908670}
m_Layer: 0
m_Name: Placements
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1216908670
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1216908669}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 141183528}
- {fileID: 172566721}
- {fileID: 1619171259}
- {fileID: 165064737}
m_Father: {fileID: 2960581183699728426}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1221159069
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1221159070}
m_Layer: 0
m_Name: CenteredPoint
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1221159070
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1221159069}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 2960581183699728426} m_Father: {fileID: 2960581183699728426}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &489080435 --- !u!1 &1619171258
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -39,91 +167,29 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 489080436} - component: {fileID: 1619171259}
m_Layer: 0 m_Layer: 0
m_Name: GameObject (1) m_Name: Placement (3)
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 1
--- !u!4 &489080436 --- !u!4 &1619171259
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0} m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 489080435} m_GameObject: {fileID: 1619171258}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.11, y: 0, z: 1.2} m_LocalPosition: {x: -1.09, y: 0, z: 1.26}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 2960581183699728426} m_Father: {fileID: 1216908670}
m_RootOrder: 2 m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &575231063
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 575231064}
m_Layer: 0
m_Name: GameObject (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &575231064
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 575231063}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.89, y: 0, z: -1.05}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 2960581183699728426}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1493812672
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1493812673}
m_Layer: 0
m_Name: GameObject (2)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1493812673
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1493812672}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.8, y: 0, z: 0.97}
m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 2960581183699728426}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2960581183699728427 --- !u!1 &2960581183699728427
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -133,9 +199,9 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 2960581183699728426} - component: {fileID: 2960581183699728426}
- component: {fileID: 2960581183699728421} - component: {fileID: 5376650559335035371}
m_Layer: 0 m_Layer: 0
m_Name: Tile (1) m_Name: SafeTile
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -153,14 +219,12 @@ Transform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 340880581} - {fileID: 1221159070}
- {fileID: 1493812673} - {fileID: 1216908670}
- {fileID: 489080436}
- {fileID: 575231064}
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2960581183699728421 --- !u!114 &5376650559335035371
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -169,7 +233,13 @@ MonoBehaviour:
m_GameObject: {fileID: 2960581183699728427} m_GameObject: {fileID: 2960581183699728427}
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 0 m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be69a8cfb3b2940308cbac570565e629, type: 3} m_Script: {fileID: 11500000, guid: 114033ff484fb492290f3118615ad4d8, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isSafeZone: 0 isSafeZone: 1
centerPlacementPoint: {fileID: 1221159070}
placementPoints:
- {fileID: 141183528}
- {fileID: 172566721}
- {fileID: 1619171259}
- {fileID: 165064737}

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 13346690e7c8b414cb171f800c32ec57
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,47 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &2960581183699728427
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2960581183699728426}
- component: {fileID: 2960581183699728421}
m_Layer: 0
m_Name: Tile
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2960581183699728426
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2960581183699728427}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 18.83, y: 0, z: -3.42}
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 &2960581183699728421
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2960581183699728427}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: be69a8cfb3b2940308cbac570565e629, type: 3}
m_Name:
m_EditorClassIdentifier:
isSafeZone: 0

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,4 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -14,11 +15,11 @@ public enum PlayerTypes
public class PlayerGameData public class PlayerGameData
{ {
public PlayerTypes playerType; public PlayerTypes playerType;
public GameObject playerCornerEntity;
public int startIndex; public int startIndex;
public int endIndex; public int endIndex;
public Transform playersParent; public Transform playersParent;
public List<PlayerPawn> playerPawns; public List<PlayerPawn> playerPawnsDict;
public int totalPawnsFinished = 0;
} }
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
@ -29,8 +30,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
[SerializeField] private Material selectMat; [SerializeField] private Material selectMat;
[SerializeField] private PlayerGameData[] playerGameDatas; [SerializeField] private PlayerGameData[] playerGameDatas;
[SerializeField] private PlayerBaseHandler playerBaseHandler;
private PlayerTypes currentPlayerTurn; private PlayerTypes currentPlayerTypeTurn;
private int currentPlayerTurnIndex = 0; private int currentPlayerTurnIndex = 0;
private List<PlayerTypes> playerTypes = new List<PlayerTypes>(); private List<PlayerTypes> playerTypes = new List<PlayerTypes>();
@ -47,7 +49,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
get; private set; get; private set;
} }
private bool HasRolledSix = false; private bool CanRollDiceAgain = false; // used for when you get a 6 or when you reach the finish point
public void Initialize() public void Initialize()
{ {
@ -59,39 +61,38 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>(); tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
CanRollDice = true; CanRollDice = true;
InitCurrentGamePlayerInfo( playerTypes = new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 };
new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 });
playerBaseHandler.InitPlayerTypes(playerTypes);
InitCurrentGamePlayerInfo();
} }
// TODO :: Call based on 2P/3P/4P // TODO :: Call based on 2P/3P/4P
public void InitCurrentGamePlayerInfo(List<PlayerTypes> playerTypes) public void InitCurrentGamePlayerInfo()
{ {
this.playerTypes = playerTypes; currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex];
currentPlayerTurn = playerTypes[currentPlayerTurnIndex];
// initialize the board based on the player types // initialize the board based on the player types
foreach (PlayerGameData playerGameData in playerGameDatas) foreach (PlayerGameData playerGameData in playerGameDatas)
{ {
if (!playerTypes.Contains(playerGameData.playerType)) if (!playerTypes.Contains(playerGameData.playerType))
{ continue;
playerGameData.playerCornerEntity.SetActive(false);
}
else
{
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
playerGameDatasDict[playerGameData.playerType].playerPawns = new List<PlayerPawn>(); playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
foreach (Transform playerPawnChild in playerGameData.playersParent) playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new List<PlayerPawn>();
{
playerGameDatasDict[playerGameData.playerType].playerPawns.Add(playerPawnChild.GetComponent<PlayerPawn>()); foreach (Transform playerPawnChild in playerGameData.playersParent)
} {
if (!playerPawnChild.gameObject.activeInHierarchy) continue;
playerGameDatasDict[playerGameData.playerType].playerPawnsDict.Add(playerPawnChild.GetComponent<PlayerPawn>());
} }
} }
} }
public void EnablePlayerSelectionStates(bool state) public void EnablePlayerSelectionStates(bool state)
{ {
foreach (PlayerPawn playerPawn in playerGameDatasDict[currentPlayerTurn].playerPawns) foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
{ {
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) continue; if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) continue;
@ -104,7 +105,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
CanRollDice = false; CanRollDice = false;
// add core dice logic here // add core dice logic here
Debug.Log($"LUDO :: rolledVal: {rolledVal}"); Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
diceRolledValue = rolledVal; diceRolledValue = rolledVal;
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls) if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
@ -113,7 +114,23 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
// also play a simple animation before selecting // also play a simple animation before selecting
EnablePlayerSelectionStates(true); EnablePlayerSelectionStates(true);
HasRolledSix = true; CanRollDiceAgain = true;
bool AreAllPawnsInFinishingPath = false;
foreach (var pawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
{
if (pawn.GetPlayerState() == PlayerState.InFinishingPath && pawn.GetPlayerState() != PlayerState.HasFinished)
{
AreAllPawnsInFinishingPath = true;
continue;
}
AreAllPawnsInFinishingPath = false;
break;
}
if (AreAllPawnsInFinishingPath)
CanRollDice = true;
pointerMeshRend.material = selectMat; pointerMeshRend.material = selectMat;
// pointerMeshRend.materials[0] = selectMat; // pointerMeshRend.materials[0] = selectMat;
@ -121,33 +138,41 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
else // if there are any other pawns that are in safe or moving state else // if there are any other pawns that are in safe or moving state
{ {
// for player's logic // for player's logic
IEnumerable<PlayerPawn> availPlayers = playerGameDatasDict[currentPlayerTurn].playerPawns.Select(pawn => pawn) IEnumerable<PlayerPawn> availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Select(pawn => pawn)
.Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone || .Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone ||
pawn.GetPlayerState() == PlayerState.Moving || pawn.GetPlayerState() == PlayerState.Moving ||
pawn.GetPlayerState() == PlayerState.InFinishingPath); pawn.GetPlayerState() == PlayerState.InFinishingPath);
int customAvailPlayers = availPlayers.Count();
foreach (PlayerPawn playerPawn in availPlayers) foreach (PlayerPawn playerPawn in availPlayers)
{ {
Debug.Log($"## playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}"); Debug.Log($"## playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}");
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
{ {
// TODO :: if rolled dice value <= rem tiles to complete in finishing path if (diceRolledValue <= tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - (playerPawn.CurrentTileIndex + 1))
// TODO :: playerPawn.SetPlayerSelectionState(true); {
// if (diceRolledValue < 6 - playerPawn.CurrentTileIndex) // TODO :: Change hardcoded value playerPawn.SetPlayerSelectionState(true);
} }
else else
{ {
playerPawn.SetPlayerSelectionState(true); customAvailPlayers--;
}
continue;
} }
playerPawn.SetPlayerSelectionState(true);
} }
if (availPlayers.Count() < 1) // if (availPlayers.Count() < 1)
Debug.Log($"CustomAvailablePlayers: {customAvailPlayers}");
if (customAvailPlayers < 1)
{ {
SwitchPlayer(); SwitchPlayer();
CanRollDice = true; CanRollDice = true;
} }
HasRolledSix = false; CanRollDiceAgain = false;
} }
} }
@ -155,12 +180,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
{ {
EnablePlayerSelectionStates(false); EnablePlayerSelectionStates(false);
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTurn]; PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
if (playerPawn.GetPlayerState() == PlayerState.InHome) if (playerPawn.GetPlayerState() == PlayerState.InHome)
{ {
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
playerPawn.MoveToTile( playerPawn.MoveToTile(
tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex).transform.position, GetAndInitPositionInsideSafeZone(playerPawn, targetTile),
onComplete: () => onComplete: () =>
{ {
CanRollDice = true; CanRollDice = true;
@ -169,90 +196,260 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
return; return;
} }
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath
|| playerPawn.GetPlayerState() == PlayerState.InFinishingPath) || playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
{
int finishingPathIndex = GetNextFinishingTileIndex(playerPawn);
int targetIdx = finishingPathIndex + diceRolledValue > tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 ?
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
Debug.Log($"TargetIdx: {targetIdx}");
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
}
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
{ {
// move based on the dice value // move based on the dice value
Debug.Log($"Tile Index :: currentTileIndex: {playerPawn.CurrentTileIndex}");
int nextTileIdx = GetNextGeneralTileIndex(playerPawn);
int targetIdx = playerPawn.CurrentTileIndex + diceRolledValue;
MoveThroughTiles(playerPawn, playerPawn.CurrentTileIndex + 1, targetIndex: playerPawn.CurrentTileIndex + diceRolledValue); if (nextTileIdx == 0)
targetIdx = targetIdx - playerPawn.CurrentTileIndex;
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
if (currentSittingTile.IsSafeZone)
{
SafeTile safeTile = (SafeTile)currentSittingTile;
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn);
if (safeTile.PlayerTypesCount == 1)
{
PlayerTypes playerType = safeTile.GetFirstPlayerType();
var playerPawns = safeTile.GetPlayerPawns(playerType);
foreach (var pawn in playerPawns)
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
}
}
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
} }
} }
private void SwitchPlayer() private int GetNextGeneralTileIndex(PlayerPawn playerPawn)
{ {
if (!HasRolledSix) return playerPawn.CurrentTileIndex == tilesManager.GetGeneralTilesLength() - 1 ? 0 : playerPawn.CurrentTileIndex + 1;
}
private int GetNextFinishingTileIndex(PlayerPawn playerPawn)
{
return playerPawn.CurrentTileIndex > tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 ? 0 : playerPawn.CurrentTileIndex + 1;
}
private void SwitchPlayer(PlayerPawn playerPawn = null)
{
if (!CanRollDiceAgain)
{ {
if (currentPlayerTurn == playerTypes[playerTypes.Count - 1]) Debug.Log($"currentPlayerTurn: {currentPlayerTypeTurn}");
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
if (playerTypes.Count == 1)
{
Debug.LogError($"GAME IS OVER");
return;
}
if (currentPlayerTypeTurn == playerTypes[playerTypes.Count - 1])
{ {
currentPlayerTurnIndex = 0; currentPlayerTurnIndex = 0;
currentPlayerTurn = playerTypes[currentPlayerTurnIndex]; currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex];
} }
else else
{ {
currentPlayerTurnIndex++; currentPlayerTurnIndex++;
currentPlayerTurn = playerTypes[currentPlayerTurnIndex]; currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex];
Debug.Log($"currentPlayerTurn: {currentPlayerTurn}");
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
} }
} }
var tempPos = playerGameDatasDict[currentPlayerTurn].playerCornerEntity.transform.position; // var tempPos = playerGameDatasDict[currentPlayerTypeTurn].playerCornerEntity.transform.position;
pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z); // pointerDebug.position = new Vector3(tempPos.x, 3f, tempPos.z);
pointerMeshRend.material = turnMat; pointerMeshRend.material = turnMat;
// pointerMeshRend.materials[0] = turnMat; // pointerMeshRend.materials[0] = turnMat;
if (playerPawn)
playerPawn.SetPlayerState(tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).IsSafeZone ? PlayerState.InSafeZone : PlayerState.Moving);
} }
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex) private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
{ {
Tile tile = tilesManager.RetrieveTileBasedOnIndex(index); Tile nextTile = tilesManager.RetrieveTileBasedOnIndex(index);
Vector3 targetPosition = nextTile.CenterPlacementPosition;
Debug.Log($"Tile Index :: nextIndex: {index}, targetIndex: {targetIndex}, nextTileName: {nextTile.name}");
if (index == targetIndex) // if the target index is the safe zone only then apply the logic for rearranging pawns
{
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(targetIndex);
if (targetTile.IsSafeZone)
{
targetPosition = GetAndInitPositionInsideSafeZone(playerPawn, targetTile);
}
}
Debug.Log($"tile targetPosition: {targetPosition}");
playerPawn.MoveToTile( playerPawn.MoveToTile(
tilesManager.RetrieveTileBasedOnIndex(index).transform.position, targetPosition,
onComplete: () => onComplete: () =>
{ {
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || index == playerGameDatasDict[currentPlayerTurn].endIndex) diceRolledValue--;
Debug.Log($"DiceRolledValue: {diceRolledValue}");
if (diceRolledValue > 0)
{ {
// MoveThroughTiles(playerPawn, index, targetIndex); int nextTileIndex = GetNextGeneralTileIndex(playerPawn);
Debug.Log($"IsMovingThroughFinishingPath({currentPlayerTurn}): {index + 1} :: {playerGameDatasDict[currentPlayerTurn].endIndex}"); Debug.Log($"currentTileIndex: {playerPawn.CurrentTileIndex}, nextTileIndex: {nextTileIndex}, targetIndex: {targetIndex}");
MoveThroughFinishingPath(playerPawn, 0, targetIndex - index);
} if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || index == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
else if (index + 1 <= targetIndex) {
{ // MoveThroughTiles(playerPawn, index, targetIndex);
MoveThroughTiles(playerPawn, index + 1, targetIndex); Debug.Log($"TargetIdx: {targetIndex - index}");
MoveThroughFinishingPath(playerPawn, 0, targetIndex - index);
}
else if (nextTileIndex <= targetIndex)
{
if (nextTileIndex == 0)
targetIndex = (targetIndex - playerPawn.CurrentTileIndex) - 1;
MoveThroughTiles(playerPawn, nextTileIndex, targetIndex);
}
} }
else else
{ {
if (tile.PlayerPawn != null) // TODO :: Improve this logic, use a collection
if (!nextTile.IsSafeZone)
{ {
// send this pawn back to base if (nextTile.PlayerPawn != null)
{
// TODO :: Send existing pawn back to base.
// means there's already a pawn there, move him back to the base.
}
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
} }
tile.InitPlayerPawn(playerPawn); SwitchPlayer(playerPawn);
SwitchPlayer(); CanRollDice = true;
} }
}, },
index); index);
}
CanRollDice = true; private Vector3 GetAndInitPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile)
playerPawn.SetPlayerState(tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).IsSafeZone ? PlayerState.InSafeZone : PlayerState.Moving); {
Vector3 targetPosition;
SafeTile targetSafeTile = (SafeTile)targetTile;
Debug.Log($"targetSafeTile.PlayerTypesCount: {targetSafeTile.PlayerTypesCount}");
if (targetSafeTile.PlayerTypesCount == 1)
{
Debug.Log($"targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn): {targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn)}");
if (!targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn)) // means it is a new player type, the second one
{
PlayerTypes initialPlayerType = targetSafeTile.GetFirstPlayerType();
// rearrange already existing player from center position to it's saved transform
var playerPawns = targetSafeTile.GetPlayerPawns(initialPlayerType);
foreach (var pawn in playerPawns)
{
var placementPoint = targetSafeTile.GetPlacementPoint(initialPlayerType);
pawn.MoveToCustomTilePosition(placementPoint.position);
}
targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
targetPosition = targetSafeTile.GetPlacementPoint(currentPlayerTypeTurn).position;
}
else
{
targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
targetPosition = targetTile.CenterPlacementPosition;
}
}
else
{
// TODO :: Check the data if it's consistent
Debug.Log($"targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn): {targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn)}");
if (!targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn))
{
Debug.Log($"targetSafeTile.PlayerTypesCount: {targetSafeTile.PlayerTypesCount}");
if (targetSafeTile.PlayerTypesCount < 1) // he is the only player that is being added to the safe zone
{
targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
targetPosition = targetTile.CenterPlacementPosition;
}
else
{
targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
targetPosition = targetSafeTile.GetPlacementPoint(currentPlayerTypeTurn).position;
}
}
else
{
targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
targetPosition = targetSafeTile.GetPlacementPoint(currentPlayerTypeTurn).position;
}
}
return targetPosition;
} }
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex) private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
{ {
playerPawn.SetPlayerState(PlayerState.InFinishingPath); playerPawn.SetPlayerState(PlayerState.InFinishingPath);
playerPawn.MoveToTile( playerPawn.MoveToTile(
tilesManager.RetrievePositionForFinishingTile(currentPlayerTurn, index).position, tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
onComplete: () => onComplete: () =>
{ {
Debug.Log($"index: {index}, targetIndex: {targetIndex}"); diceRolledValue--;
if (index + 1 < targetIndex)
Debug.Log($"DiceRolledValue: {diceRolledValue}");
if (diceRolledValue > 0)
{ {
// MoveThroughTiles(playerPawn, index, targetIndex); int tileIndex = GetNextFinishingTileIndex(playerPawn);
MoveThroughFinishingPath(playerPawn, index + 1, targetIndex); Debug.Log($"tileIndex: {tileIndex}, targetIndex: {targetIndex}");
if (tileIndex <= targetIndex)
{
// MoveThroughTiles(playerPawn, index, targetIndex);
MoveThroughFinishingPath(playerPawn, tileIndex, targetIndex);
}
} }
else else
{ {
SwitchPlayer(); if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
{
playerPawn.SetPlayerState(PlayerState.HasFinished);
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count)
{
CanRollDiceAgain = false;
SwitchPlayer();
if (playerTypes.Contains(currentPlayerTypeTurn))
playerTypes.Remove(currentPlayerTypeTurn);
Debug.Log($"PlayerTypes: {playerTypes.Count}");
}
else
{
CanRollDiceAgain = true;
}
}
else
{
SwitchPlayer();
}
CanRollDice = true;
} }
}, },
index); index);

View File

@ -1,15 +1,30 @@
using UnityEngine; using UnityEngine;
[System.Serializable]
public class BasePlacementData
{
public int playerBaseId;
public Transform placementTransform;
}
public class PlayerBase : MonoBehaviour public class PlayerBase : MonoBehaviour
{ {
void Start() [SerializeField] private PlayerTypes playerType;
{ [SerializeField] private BasePlacementData[] basePlacementDatas;
[SerializeField] private PlayerPawn[] playerPawns;
public PlayerTypes GetPlayerType() => playerType;
public void InitPlayerIds()
{
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
{
playerPawns[idx].InitId(basePlacementDatas[idx].playerBaseId);
}
} }
// Update is called once per frame public BasePlacementData GetBasePlacementData(int idx)
void Update()
{ {
return basePlacementDatas[idx];
} }
} }

View File

@ -21,6 +21,16 @@ public class PlayerPawn : MonoBehaviour
get; private set; get; private set;
} }
public int PlayerId
{
get; private set;
}
public int BaseId
{
get; private set;
}
private GameplayManager gameplayManager; private GameplayManager gameplayManager;
public void SetPlayerSelectionState(bool state) public void SetPlayerSelectionState(bool state)
@ -32,9 +42,9 @@ public class PlayerPawn : MonoBehaviour
} }
} }
public void CheckCurrentTileIndex(int maxTiles) public void SetCurrentTileIndex(int tileIndex)
{ {
CurrentTileIndex = CurrentTileIndex == maxTiles ? 0 : CurrentTileIndex; CurrentTileIndex = tileIndex;
} }
public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex) public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex)
@ -43,6 +53,11 @@ public class PlayerPawn : MonoBehaviour
transform.DOMove(startingPoint, 0.1f).onComplete = () => onComplete?.Invoke(); transform.DOMove(startingPoint, 0.1f).onComplete = () => onComplete?.Invoke();
} }
public void MoveToCustomTilePosition(Vector3 targetPoint)
{
transform.DOMove(targetPoint, 0.1f);
}
// when he is defeated // when he is defeated
public void MoveBackToHome() public void MoveBackToHome()
{ {
@ -68,4 +83,9 @@ public class PlayerPawn : MonoBehaviour
{ {
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>(); gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
} }
public void InitId(int id)
{
PlayerId = id;
}
} }

View File

@ -4,6 +4,8 @@ using UnityEngine;
public class DiceRoller : MonoBehaviour public class DiceRoller : MonoBehaviour
{ {
[SerializeField] private int diceTestValue = 0;
private InputManager inputManager; private InputManager inputManager;
private void OnMouseDown() private void OnMouseDown()
@ -14,9 +16,18 @@ public class DiceRoller : MonoBehaviour
OnDiceRolled(); OnDiceRolled();
} }
private void Update()
{
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
if (!inputManager.GameplayManager.CanRollDice) return;
if (Input.GetKeyDown(KeyCode.Space))
OnDiceRolled();
}
private void OnDiceRolled() private void OnDiceRolled()
{ {
int currentRolledVal = Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1); int currentRolledVal = diceTestValue != 0 ? diceTestValue : Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
inputManager.SetDiceRollValue(currentRolledVal); inputManager.SetDiceRollValue(currentRolledVal);
} }
} }

View File

@ -0,0 +1,89 @@
using UnityEngine;
using System.Linq;
using System.Collections.Generic;
public class SafeTile : Tile
{
[SerializeField] private Transform centerPlacementPoint;
[SerializeField] private Transform[] placementPoints;
protected Queue<Transform> placementQueue = new Queue<Transform>();
protected Dictionary<PlayerTypes, PlayerTileData> playerTypesDict = new Dictionary<PlayerTypes, PlayerTileData>();
public int PlayerTypesCount => playerTypesDict.Count;
public bool HasMoreThanOnePlayerType => playerTypesDict.Count > 1;
public List<PlayerPawn> GetPlayerPawns(PlayerTypes playerType) => playerTypesDict[playerType].playerPawns.Values.ToList();
public bool ContainsPlayerType(PlayerTypes playerType) => playerTypesDict.ContainsKey(playerType);
private void Awake()
{
foreach (var placement in placementPoints)
{
placementQueue.Enqueue(placement);
}
}
public override void InitPlayerPawn(PlayerPawn playerPawn, PlayerTypes playerType)
{
// PlayerPawn = playerPawn;
if (!playerTypesDict.ContainsKey(playerType))
{
playerTypesDict.Add(
playerType,
new PlayerTileData { playerCount = 1,
playerPawns = new Dictionary<int, PlayerPawn>()
});
playerTypesDict[playerType].playerPawns.Add(playerPawn.PlayerId, playerPawn);
playerTypesDict[playerType].commonPlacementTransform = placementQueue.Dequeue();
Debug.Log($"targetSafeTile. Adding player {playerType} {playerTypesDict[playerType].playerCount} tileName: {name}");
}
else
{
playerTypesDict[playerType].playerCount++;
Debug.Log($"targetSafeTile. Adding player {playerType} {playerTypesDict[playerType].playerCount}, tileName: {name}");
playerTypesDict[playerType].playerPawns.Add(playerPawn.PlayerId, playerPawn);
}
}
public void UpdateSafeZonePlayerData(PlayerTypes playerType, PlayerPawn playerPawn)
{
if (playerTypesDict.ContainsKey(playerType))
{
if (playerTypesDict[playerType].playerCount > 0)
{
Debug.Log($"targetSafeTile. Removing player {playerType} {playerTypesDict[playerType].playerCount}, tileName: {name}");
playerTypesDict[playerType].playerCount--;
Debug.Log($"targetSafeTile. Removing player {playerType} after: {playerTypesDict[playerType].playerCount}");
playerTypesDict[playerType].playerPawns.Remove(playerPawn.PlayerId);
if (playerTypesDict[playerType].playerCount == 0)
{
placementQueue.Enqueue(playerTypesDict[playerType].commonPlacementTransform);
playerTypesDict.Remove(playerType);
Debug.Log($"targetSafeTile. Removing player {playerType}");
lastOccupiedIndex--;
}
}
}
}
public PlayerTypes GetFirstPlayerType() => playerTypesDict.Keys.FirstOrDefault();
public int GetPlayerPawnsCountInTile(PlayerTypes playerType)
{
return playerTypesDict[playerType].playerPawns.Count;
}
public PlayerPawn IterateAndGetPlayerPawn(PlayerTypes playerType, int index)
{
return playerTypesDict[playerType].playerPawns[index + 1];
}
public Transform GetPlacementPoint(PlayerTypes playerType)
{
return playerTypesDict[playerType].commonPlacementTransform;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 114033ff484fb492290f3118615ad4d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,16 +1,37 @@
using UnityEngine; using UnityEngine;
using System.Collections.Generic;
[System.Serializable]
public class PlayerPlacementData
{
public PlayerPawn pawn;
}
[System.Serializable]
public class PlayerTileData
{
public int playerCount;
public Transform commonPlacementTransform;
public Dictionary<int, PlayerPawn> playerPawns;
}
public class Tile : MonoBehaviour public class Tile : MonoBehaviour
{ {
[SerializeField] private bool isSafeZone = false; [SerializeField] protected bool isSafeZone = false;
public PlayerPawn PlayerPawn
public bool IsSafeZone => isSafeZone;
public Vector3 CenterPlacementPosition => transform.position;
protected int lastOccupiedIndex = 0;
public PlayerPawn PlayerPawn // Change implementation
{ {
get; private set; get; private set;
} }
public bool IsSafeZone => isSafeZone; public virtual void InitPlayerPawn(PlayerPawn playerPawn, PlayerTypes playerType)
public void InitPlayerPawn(PlayerPawn playerPawn)
{ {
PlayerPawn = playerPawn; PlayerPawn = playerPawn;
} }

View File

@ -17,10 +17,6 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
[SerializeField] private TileData[] tileDatas; [SerializeField] private TileData[] tileDatas;
private GameplayManager gameplayManager; private GameplayManager gameplayManager;
public int FinishingTileDataLength
{
get; private set;
}
private Dictionary<PlayerTypes, List<Transform>> finishingTileDataPairs = new Dictionary<PlayerTypes, List<Transform>>(); private Dictionary<PlayerTypes, List<Transform>> finishingTileDataPairs = new Dictionary<PlayerTypes, List<Transform>>();
@ -42,16 +38,23 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
finishingTileDataPairs[tileData.playerType].Add(child); finishingTileDataPairs[tileData.playerType].Add(child);
} }
} }
// FinishingTileDataLength = finishingTileDataPairs.FirstOrDefault().Value.Count;
} }
public int GetFinishingTileDataLength(PlayerTypes playerType) => finishingTileDataPairs[playerType].Count;
public int GetGeneralTilesLength() => generalTiles.Length; public int GetGeneralTilesLength() => generalTiles.Length;
public Tile RetrieveTileBasedOnIndex(int index) public Tile RetrieveTileBasedOnIndex(int index)
{ {
Debug.Log($"RetrieveTileBasedOnIndex: Index: {index}");
return index == generalTiles.Length ? generalTiles[0] : generalTiles[index]; Tile tile = index == generalTiles.Length ? generalTiles[0] : generalTiles[index];
// if (tile.IsSafeZone)
// {
// return (SafeTile)tile;
// }
return tile;
} }
public Transform RetrievePositionForFinishingTile(PlayerTypes playerType, int index) public Transform RetrievePositionForFinishingTile(PlayerTypes playerType, int index)