Compare commits

..

No commits in common. "141eef7aef3767f8b7c7dc6d68f0e8a347a22faa" and "c9ec236fabb67c5c47be514a721fcf8993ebf192" have entirely different histories.

19 changed files with 771 additions and 1375 deletions

View File

@ -1,36 +0,0 @@
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

@ -1,11 +0,0 @@
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: 1, y: 1, z: 1} m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}
@ -110,4 +110,3 @@ 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: 1, y: 1, z: 1} m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844}
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: 1, y: 1, z: 1} m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844}
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: 1, y: 1, z: 1} m_LocalScale: {x: 2.1844, y: 2.1844, z: 2.1844}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 0} m_Father: {fileID: 0}

View File

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

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 &141183527 --- !u!1 &340880580
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -8,30 +8,30 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 141183528} - component: {fileID: 340880581}
m_Layer: 0 m_Layer: 0
m_Name: Placement (1) m_Name: GameObject
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 &141183528 --- !u!4 &340880581
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: 141183527} m_GameObject: {fileID: 340880580}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.06, y: 0, z: -1.03} m_LocalPosition: {x: -1.09, y: 0, z: -1.01}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 1216908670} 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 &165064736 --- !u!1 &489080435
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -39,30 +39,61 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 165064737} - component: {fileID: 489080436}
m_Layer: 0 m_Layer: 0
m_Name: Placement (4) m_Name: GameObject (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 &165064737 --- !u!4 &489080436
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: 165064736} m_GameObject: {fileID: 489080435}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.89, y: 0, z: -0.92} m_LocalPosition: {x: -1.11, y: 0, z: 1.2}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 1216908670} m_Father: {fileID: 2960581183699728426}
m_RootOrder: 2
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_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &172566720 --- !u!1 &1493812672
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -70,125 +101,28 @@ GameObject:
m_PrefabAsset: {fileID: 0} m_PrefabAsset: {fileID: 0}
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 172566721} - component: {fileID: 1493812673}
m_Layer: 0 m_Layer: 0
m_Name: Placement (2) m_Name: GameObject (2)
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 &172566721 --- !u!4 &1493812673
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: 172566720} m_GameObject: {fileID: 1493812672}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.88, y: 0, z: 1.12} m_LocalPosition: {x: 0.8, y: 0, z: 0.97}
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 0.5, y: 0.5, z: 0.5}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 1
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: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1619171258
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1619171259}
m_Layer: 0
m_Name: Placement (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1619171259
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1619171258}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -1.09, y: 0, z: 1.26}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1216908670}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2960581183699728427 --- !u!1 &2960581183699728427
GameObject: GameObject:
@ -199,9 +133,9 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 2960581183699728426} - component: {fileID: 2960581183699728426}
- component: {fileID: 5376650559335035371} - component: {fileID: 2960581183699728421}
m_Layer: 0 m_Layer: 0
m_Name: SafeTile m_Name: Tile (1)
m_TagString: Untagged m_TagString: Untagged
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
@ -219,12 +153,14 @@ 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: 1221159070} - {fileID: 340880581}
- {fileID: 1216908670} - {fileID: 1493812673}
- {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 &5376650559335035371 --- !u!114 &2960581183699728421
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0} m_CorrespondingSourceObject: {fileID: 0}
@ -233,13 +169,7 @@ 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: 114033ff484fb492290f3118615ad4d8, type: 3} m_Script: {fileID: 11500000, guid: be69a8cfb3b2940308cbac570565e629, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
isSafeZone: 1 isSafeZone: 0
centerPlacementPoint: {fileID: 1221159070}
placementPoints:
- {fileID: 141183528}
- {fileID: 172566721}
- {fileID: 1619171259}
- {fileID: 165064737}

View File

@ -1,47 +0,0 @@
%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,4 +1,3 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine; using UnityEngine;
@ -15,11 +14,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> playerPawnsDict; public List<PlayerPawn> playerPawns;
public int totalPawnsFinished = 0;
} }
public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
@ -30,9 +29,8 @@ 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 currentPlayerTypeTurn; private PlayerTypes currentPlayerTurn;
private int currentPlayerTurnIndex = 0; private int currentPlayerTurnIndex = 0;
private List<PlayerTypes> playerTypes = new List<PlayerTypes>(); private List<PlayerTypes> playerTypes = new List<PlayerTypes>();
@ -49,7 +47,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
get; private set; get; private set;
} }
private bool CanRollDiceAgain = false; // used for when you get a 6 or when you reach the finish point private bool HasRolledSix = false;
public void Initialize() public void Initialize()
{ {
@ -61,38 +59,39 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>(); tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
CanRollDice = true; CanRollDice = true;
playerTypes = new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 }; InitCurrentGamePlayerInfo(
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() public void InitCurrentGamePlayerInfo(List<PlayerTypes> playerTypes)
{ {
currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex]; this.playerTypes = playerTypes;
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.Add(playerGameData.playerType, playerGameData);
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new List<PlayerPawn>();
playerGameDatasDict[playerGameData.playerType].playerPawns = new List<PlayerPawn>();
foreach (Transform playerPawnChild in playerGameData.playersParent) foreach (Transform playerPawnChild in playerGameData.playersParent)
{ {
if (!playerPawnChild.gameObject.activeInHierarchy) continue; playerGameDatasDict[playerGameData.playerType].playerPawns.Add(playerPawnChild.GetComponent<PlayerPawn>());
}
playerGameDatasDict[playerGameData.playerType].playerPawnsDict.Add(playerPawnChild.GetComponent<PlayerPawn>());
} }
} }
} }
public void EnablePlayerSelectionStates(bool state) public void EnablePlayerSelectionStates(bool state)
{ {
foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict) foreach (PlayerPawn playerPawn in playerGameDatasDict[currentPlayerTurn].playerPawns)
{ {
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) continue; if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) continue;
@ -105,7 +104,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
CanRollDice = false; CanRollDice = false;
// add core dice logic here // add core dice logic here
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}"); Debug.Log($"LUDO :: rolledVal: {rolledVal}");
diceRolledValue = rolledVal; diceRolledValue = rolledVal;
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls) if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
@ -114,23 +113,7 @@ 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);
CanRollDiceAgain = true; HasRolledSix = 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;
@ -138,41 +121,33 @@ 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[currentPlayerTypeTurn].playerPawnsDict.Select(pawn => pawn) IEnumerable<PlayerPawn> availPlayers = playerGameDatasDict[currentPlayerTurn].playerPawns.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)
{ {
if (diceRolledValue <= tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - (playerPawn.CurrentTileIndex + 1)) // TODO :: if rolled dice value <= rem tiles to complete in finishing path
{ // TODO :: playerPawn.SetPlayerSelectionState(true);
playerPawn.SetPlayerSelectionState(true); // if (diceRolledValue < 6 - playerPawn.CurrentTileIndex) // TODO :: Change hardcoded value
} }
else else
{ {
customAvailPlayers--;
}
continue;
}
playerPawn.SetPlayerSelectionState(true); playerPawn.SetPlayerSelectionState(true);
} }
}
// if (availPlayers.Count() < 1) if (availPlayers.Count() < 1)
Debug.Log($"CustomAvailablePlayers: {customAvailPlayers}");
if (customAvailPlayers < 1)
{ {
SwitchPlayer(); SwitchPlayer();
CanRollDice = true; CanRollDice = true;
} }
CanRollDiceAgain = false; HasRolledSix = false;
} }
} }
@ -180,14 +155,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
{ {
EnablePlayerSelectionStates(false); EnablePlayerSelectionStates(false);
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn]; PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTurn];
if (playerPawn.GetPlayerState() == PlayerState.InHome) if (playerPawn.GetPlayerState() == PlayerState.InHome)
{ {
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
playerPawn.MoveToTile( playerPawn.MoveToTile(
GetAndInitPositionInsideSafeZone(playerPawn, targetTile), tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex).transform.position,
onComplete: () => onComplete: () =>
{ {
CanRollDice = true; CanRollDice = true;
@ -196,261 +169,91 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
return; return;
} }
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving
|| playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex) || playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
{
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;
if (nextTileIdx == 0) MoveThroughTiles(playerPawn, playerPawn.CurrentTileIndex + 1, targetIndex: playerPawn.CurrentTileIndex + diceRolledValue);
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)
{ {
return playerPawn.CurrentTileIndex == tilesManager.GetGeneralTilesLength() - 1 ? 0 : playerPawn.CurrentTileIndex + 1; if (!HasRolledSix)
}
private int GetNextFinishingTileIndex(PlayerPawn playerPawn)
{ {
return playerPawn.CurrentTileIndex > tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 ? 0 : playerPawn.CurrentTileIndex + 1; if (currentPlayerTurn == playerTypes[playerTypes.Count - 1])
}
private void SwitchPlayer(PlayerPawn playerPawn = null)
{
if (!CanRollDiceAgain)
{
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;
currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex]; currentPlayerTurn = playerTypes[currentPlayerTurnIndex];
} }
else else
{ {
currentPlayerTurnIndex++; currentPlayerTurnIndex++;
currentPlayerTypeTurn = playerTypes[currentPlayerTurnIndex]; currentPlayerTurn = playerTypes[currentPlayerTurnIndex];
Debug.Log($"currentPlayerTurn: {currentPlayerTurn}");
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
} }
} }
// var tempPos = playerGameDatasDict[currentPlayerTypeTurn].playerCornerEntity.transform.position; var tempPos = playerGameDatasDict[currentPlayerTurn].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 nextTile = tilesManager.RetrieveTileBasedOnIndex(index); Tile tile = 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(
targetPosition, tilesManager.RetrieveTileBasedOnIndex(index).transform.position,
onComplete: () => onComplete: () =>
{ {
diceRolledValue--; if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || index == playerGameDatasDict[currentPlayerTurn].endIndex)
Debug.Log($"DiceRolledValue: {diceRolledValue}");
if (diceRolledValue > 0)
{
int nextTileIndex = GetNextGeneralTileIndex(playerPawn);
Debug.Log($"currentTileIndex: {playerPawn.CurrentTileIndex}, nextTileIndex: {nextTileIndex}, targetIndex: {targetIndex}");
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath || index == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
{ {
// MoveThroughTiles(playerPawn, index, targetIndex); // MoveThroughTiles(playerPawn, index, targetIndex);
Debug.Log($"TargetIdx: {targetIndex - index}"); Debug.Log($"IsMovingThroughFinishingPath({currentPlayerTurn}): {index + 1} :: {playerGameDatasDict[currentPlayerTurn].endIndex}");
MoveThroughFinishingPath(playerPawn, 0, targetIndex - index); MoveThroughFinishingPath(playerPawn, 0, targetIndex - index);
} }
else if (nextTileIndex <= targetIndex) else if (index + 1 <= targetIndex)
{ {
if (nextTileIndex == 0) MoveThroughTiles(playerPawn, index + 1, targetIndex);
targetIndex = (targetIndex - playerPawn.CurrentTileIndex) - 1;
MoveThroughTiles(playerPawn, nextTileIndex, targetIndex);
}
} }
else else
{ {
// TODO :: Improve this logic, use a collection if (tile.PlayerPawn != null)
if (!nextTile.IsSafeZone)
{ {
if (nextTile.PlayerPawn != null) // send this pawn back to base
{
// 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();
SwitchPlayer(playerPawn);
CanRollDice = true;
} }
}, },
index); index);
}
private Vector3 GetAndInitPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile) CanRollDice = true;
{ 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(currentPlayerTypeTurn, index).position, tilesManager.RetrievePositionForFinishingTile(currentPlayerTurn, index).position,
onComplete: () => onComplete: () =>
{ {
diceRolledValue--; Debug.Log($"index: {index}, targetIndex: {targetIndex}");
if (index + 1 < targetIndex)
Debug.Log($"DiceRolledValue: {diceRolledValue}");
if (diceRolledValue > 0)
{
int tileIndex = GetNextFinishingTileIndex(playerPawn);
Debug.Log($"tileIndex: {tileIndex}, targetIndex: {targetIndex}");
if (tileIndex <= targetIndex)
{ {
// MoveThroughTiles(playerPawn, index, targetIndex); // MoveThroughTiles(playerPawn, index, targetIndex);
MoveThroughFinishingPath(playerPawn, tileIndex, targetIndex); MoveThroughFinishingPath(playerPawn, index + 1, targetIndex);
}
}
else
{
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 else
{ {
SwitchPlayer(); SwitchPlayer();
} }
CanRollDice = true;
}
}, },
index); index);
} }

View File

@ -1,30 +1,15 @@
using UnityEngine; using UnityEngine;
[System.Serializable]
public class BasePlacementData
{
public int playerBaseId;
public Transform placementTransform;
}
public class PlayerBase : MonoBehaviour public class PlayerBase : MonoBehaviour
{ {
[SerializeField] private PlayerTypes playerType; void Start()
[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);
}
} }
public BasePlacementData GetBasePlacementData(int idx) // Update is called once per frame
void Update()
{ {
return basePlacementDatas[idx];
} }
} }

View File

@ -21,16 +21,6 @@ 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)
@ -42,9 +32,9 @@ public class PlayerPawn : MonoBehaviour
} }
} }
public void SetCurrentTileIndex(int tileIndex) public void CheckCurrentTileIndex(int maxTiles)
{ {
CurrentTileIndex = tileIndex; CurrentTileIndex = CurrentTileIndex == maxTiles ? 0 : CurrentTileIndex;
} }
public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex) public void MoveToTile(Vector3 startingPoint, Action onComplete, int tileIndex)
@ -53,11 +43,6 @@ 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()
{ {
@ -83,9 +68,4 @@ 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,8 +4,6 @@ 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()
@ -16,18 +14,9 @@ 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 = diceTestValue != 0 ? diceTestValue : Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1); int currentRolledVal = Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
inputManager.SetDiceRollValue(currentRolledVal); inputManager.SetDiceRollValue(currentRolledVal);
} }
} }

View File

@ -1,89 +0,0 @@
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

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

View File

@ -1,37 +1,16 @@
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] protected bool isSafeZone = false; [SerializeField] private 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 virtual void InitPlayerPawn(PlayerPawn playerPawn, PlayerTypes playerType) public bool IsSafeZone => isSafeZone;
public void InitPlayerPawn(PlayerPawn playerPawn)
{ {
PlayerPawn = playerPawn; PlayerPawn = playerPawn;
} }

View File

@ -17,6 +17,10 @@ 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>>();
@ -38,23 +42,16 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
finishingTileDataPairs[tileData.playerType].Add(child); finishingTileDataPairs[tileData.playerType].Add(child);
} }
} }
}
public int GetFinishingTileDataLength(PlayerTypes playerType) => finishingTileDataPairs[playerType].Count; // FinishingTileDataLength = finishingTileDataPairs.FirstOrDefault().Value.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}");
Tile tile = index == generalTiles.Length ? generalTiles[0] : generalTiles[index]; return 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)