Bug fixes for safe mode edge cases.
This commit is contained in:
parent
45b5fe9dd5
commit
9b1c4f14b0
@ -1,6 +1,6 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &340880580
|
||||
--- !u!1 &141183527
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -8,7 +8,7 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 340880581}
|
||||
- component: {fileID: 141183528}
|
||||
m_Layer: 0
|
||||
m_Name: Placement (1)
|
||||
m_TagString: Untagged
|
||||
@ -16,22 +16,22 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &340880581
|
||||
--- !u!4 &141183528
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {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_LocalPosition: {x: -0.93, y: 0, z: -0.73}
|
||||
m_LocalScale: {x: 0.74999994, y: 0.74999994, z: 0.74999994}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_LocalPosition: {x: -1.06, y: 0, z: -1.03}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2960581183699728426}
|
||||
m_RootOrder: 1
|
||||
m_Father: {fileID: 1216908670}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &489080435
|
||||
--- !u!1 &165064736
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -39,38 +39,7 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 489080436}
|
||||
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 &489080436
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 489080435}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -0.93, y: 0, z: 0.97}
|
||||
m_LocalScale: {x: 0.74999994, y: 0.74999994, z: 0.74999994}
|
||||
m_ConstrainProportionsScale: 1
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2960581183699728426}
|
||||
m_RootOrder: 3
|
||||
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}
|
||||
- component: {fileID: 165064737}
|
||||
m_Layer: 0
|
||||
m_Name: Placement (4)
|
||||
m_TagString: Untagged
|
||||
@ -78,22 +47,22 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &575231064
|
||||
--- !u!4 &165064737
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 575231063}
|
||||
m_GameObject: {fileID: 165064736}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.8, y: 0, z: -0.73}
|
||||
m_LocalScale: {x: 0.74999994, y: 0.74999994, z: 0.74999994}
|
||||
m_ConstrainProportionsScale: 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: 2960581183699728426}
|
||||
m_RootOrder: 4
|
||||
m_Father: {fileID: 1216908670}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1493812672
|
||||
--- !u!1 &172566720
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -101,7 +70,7 @@ GameObject:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1493812673}
|
||||
- component: {fileID: 172566721}
|
||||
m_Layer: 0
|
||||
m_Name: Placement (2)
|
||||
m_TagString: Untagged
|
||||
@ -109,19 +78,116 @@ GameObject:
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1493812673
|
||||
--- !u!4 &172566721
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1493812672}
|
||||
m_GameObject: {fileID: 172566720}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0.8, y: 0, z: 0.97}
|
||||
m_LocalScale: {x: 0.74999994, y: 0.74999994, z: 0.74999994}
|
||||
m_ConstrainProportionsScale: 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_Father: {fileID: 2960581183699728426}
|
||||
m_RootOrder: 0
|
||||
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}
|
||||
--- !u!1 &2960581183699728427
|
||||
@ -133,9 +199,9 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2960581183699728426}
|
||||
- component: {fileID: 2960581183699728421}
|
||||
- component: {fileID: 5376650559335035371}
|
||||
m_Layer: 0
|
||||
m_Name: Tile (1)
|
||||
m_Name: SafeTile
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -153,15 +219,12 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 4090225931849457574}
|
||||
- {fileID: 340880581}
|
||||
- {fileID: 1493812673}
|
||||
- {fileID: 489080436}
|
||||
- {fileID: 575231064}
|
||||
- {fileID: 1221159070}
|
||||
- {fileID: 1216908670}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &2960581183699728421
|
||||
--- !u!114 &5376650559335035371
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -170,38 +233,13 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 2960581183699728427}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: be69a8cfb3b2940308cbac570565e629, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 114033ff484fb492290f3118615ad4d8, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
isSafeZone: 1
|
||||
--- !u!1 &7673046030148000875
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 4090225931849457574}
|
||||
m_Layer: 0
|
||||
m_Name: CenterPlacement
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &4090225931849457574
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7673046030148000875}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2960581183699728426}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
centerPlacementPoint: {fileID: 1221159070}
|
||||
placementPoints:
|
||||
- {fileID: 141183528}
|
||||
- {fileID: 172566721}
|
||||
- {fileID: 1619171259}
|
||||
- {fileID: 165064737}
|
||||
7
Assets/Prefabs/Tile/SafeTile.prefab.meta
Normal file
7
Assets/Prefabs/Tile/SafeTile.prefab.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 13346690e7c8b414cb171f800c32ec57
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
47
Assets/Prefabs/Tile/Tile.prefab
Normal file
47
Assets/Prefabs/Tile/Tile.prefab
Normal 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
@ -19,7 +19,7 @@ public class PlayerGameData
|
||||
public int startIndex;
|
||||
public int endIndex;
|
||||
public Transform playersParent;
|
||||
public List<PlayerPawn> playerPawns;
|
||||
public List<PlayerPawn> playerPawnsDict;
|
||||
public int totalPawnsFinished = 0;
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
CanRollDice = true;
|
||||
InitCurrentGamePlayerInfo(
|
||||
new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player3 });
|
||||
new List<PlayerTypes> { PlayerTypes.Player1, PlayerTypes.Player2, PlayerTypes.Player3, PlayerTypes.Player4 });
|
||||
}
|
||||
|
||||
// TODO :: Call based on 2P/3P/4P
|
||||
@ -81,13 +81,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else
|
||||
{
|
||||
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new List<PlayerPawn>();
|
||||
PlayerPawn playerPawn = null;
|
||||
int indexer = 0;
|
||||
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawns = new List<PlayerPawn>();
|
||||
foreach (Transform playerPawnChild in playerGameData.playersParent)
|
||||
{
|
||||
if (!playerPawnChild.gameObject.activeInHierarchy) continue;
|
||||
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawns.Add(playerPawnChild.GetComponent<PlayerPawn>());
|
||||
|
||||
playerPawn = playerPawnChild.GetComponent<PlayerPawn>();
|
||||
indexer++;
|
||||
playerPawn.InitId(indexer);
|
||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict.Add(playerPawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,7 +100,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void EnablePlayerSelectionStates(bool state)
|
||||
{
|
||||
foreach (PlayerPawn playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawns)
|
||||
foreach (var playerPawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
|
||||
{
|
||||
if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath) continue;
|
||||
|
||||
@ -120,7 +125,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
CanRollDiceAgain = true;
|
||||
|
||||
bool AreAllPawnsInFinishingPath = false;
|
||||
foreach (var pawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawns)
|
||||
foreach (var pawn in playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict)
|
||||
{
|
||||
if (pawn.GetPlayerState() == PlayerState.InFinishingPath && pawn.GetPlayerState() != PlayerState.HasFinished)
|
||||
{
|
||||
@ -141,7 +146,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
|
||||
IEnumerable<PlayerPawn> availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawns.Select(pawn => pawn)
|
||||
IEnumerable<PlayerPawn> availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Select(pawn => pawn)
|
||||
.Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone ||
|
||||
pawn.GetPlayerState() == PlayerState.Moving ||
|
||||
pawn.GetPlayerState() == PlayerState.InFinishingPath);
|
||||
@ -187,8 +192,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
if (playerPawn.GetPlayerState() == PlayerState.InHome)
|
||||
{
|
||||
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex).transform.position,
|
||||
GetPositionInsideSafeZone(playerPawn, targetTile),
|
||||
onComplete: () =>
|
||||
{
|
||||
CanRollDice = true;
|
||||
@ -220,7 +227,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
||||
if (currentSittingTile.IsSafeZone)
|
||||
{
|
||||
currentSittingTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn);
|
||||
((SafeTile)currentSittingTile).UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn);
|
||||
}
|
||||
|
||||
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
||||
@ -274,71 +281,32 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||
{
|
||||
Debug.Log($"Tile Index :: nextIndex: {index}, targetIndex: {targetIndex}");
|
||||
|
||||
Tile nextTile = tilesManager.RetrieveTileBasedOnIndex(index);
|
||||
Vector3 targetPosition = tilesManager.RetrieveTileBasedOnIndex(index).CenterPlacementPosition;
|
||||
Vector3 targetPosition = nextTile.CenterPlacementPosition;
|
||||
|
||||
if (index == targetIndex) // is next index the targetIndex
|
||||
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)
|
||||
{
|
||||
if (targetTile.PlayerTypesCount == 1)
|
||||
{
|
||||
if (!targetTile.ContainsPlayerType(currentPlayerTypeTurn)) // means it is a new player type, the second one
|
||||
{
|
||||
PlayerTypes initialPlayerType = targetTile.GetFirstPlayerType();
|
||||
var playerPawnsCount = targetTile.GetPlayerPawnsCountInTile(initialPlayerType);
|
||||
|
||||
// rearrange already existing player from center position to it's saved transform
|
||||
for (int idx = 0; idx < playerPawnsCount; idx++)
|
||||
{
|
||||
targetTile.IterateAndGetPlayerPawn(initialPlayerType, idx).MoveToTileSubPosition(targetTile.GetPlacementPoint(initialPlayerType).position);
|
||||
}
|
||||
|
||||
targetTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
targetPosition = targetTile.GetPlacementPoint(currentPlayerTypeTurn).position;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPosition = targetTile.CenterPlacementPosition;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO :: Check the data if it's consistent
|
||||
if (!targetTile.ContainsPlayerType(currentPlayerTypeTurn))
|
||||
{
|
||||
targetTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
targetPosition = targetTile.GetPlacementPoint(currentPlayerTypeTurn).position;
|
||||
}
|
||||
else
|
||||
{
|
||||
targetPosition = targetTile.GetPlacementPoint(currentPlayerTypeTurn).position;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO :: Introduce a swapping mechanism
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO :: Move code to onComplete callback
|
||||
if (targetTile.PlayerPawn != null) // TODO :: Improve this logic, use a collection
|
||||
{
|
||||
// TODO :: send this pawn back to base
|
||||
}
|
||||
targetPosition = GetPositionInsideSafeZone(playerPawn, targetTile);
|
||||
}
|
||||
}
|
||||
|
||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||
|
||||
playerPawn.MoveToTile(
|
||||
targetPosition,
|
||||
onComplete: () =>
|
||||
{
|
||||
diceRolledValue--;
|
||||
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)
|
||||
{
|
||||
@ -349,14 +317,29 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
else if (nextTileIndex <= targetIndex)
|
||||
{
|
||||
if (nextTileIndex == 0)
|
||||
targetIndex = targetIndex - playerPawn.CurrentTileIndex;
|
||||
targetIndex = (targetIndex - playerPawn.CurrentTileIndex) - 1;
|
||||
|
||||
MoveThroughTiles(playerPawn, nextTileIndex, targetIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
// TODO :: Improve this logic, use a collection
|
||||
if (!nextTile.IsSafeZone)
|
||||
{
|
||||
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);
|
||||
}
|
||||
// else
|
||||
// {
|
||||
// ((SafeTile)nextTile).InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||
// }
|
||||
|
||||
SwitchPlayer(playerPawn);
|
||||
CanRollDice = true;
|
||||
}
|
||||
@ -364,6 +347,74 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
index);
|
||||
}
|
||||
|
||||
private Vector3 GetPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile)
|
||||
{
|
||||
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
|
||||
{
|
||||
Debug.Log($"Logging data");
|
||||
PlayerTypes initialPlayerType = targetSafeTile.GetFirstPlayerType();
|
||||
Debug.Log($"initialPlayerType: {initialPlayerType}");
|
||||
int playerPawnsCount = targetSafeTile.GetPlayerPawnsCountInTile(initialPlayerType);
|
||||
Debug.Log($"playerPawnsCount: {playerPawnsCount}");
|
||||
|
||||
// rearrange already existing player from center position to it's saved transform
|
||||
var playerPawns = targetSafeTile.GetPlayerPawns(initialPlayerType);
|
||||
Debug.Log($"playerPawns: {playerPawns.Count}");
|
||||
foreach (var pawn in playerPawns)
|
||||
{
|
||||
Debug.Log($"Getting placement data");
|
||||
var placementPoint = targetSafeTile.GetPlacementPoint(initialPlayerType);
|
||||
Debug.Log($"PlacementPoint: {placementPoint.name}");
|
||||
pawn.MoveToTileSubPosition(placementPoint.position);
|
||||
}
|
||||
// for (int idx = 0; idx < playerPawnsCount; idx++)
|
||||
// {
|
||||
// targetSafeTile.IterateAndGetPlayerPawn(initialPlayerType, idx).MoveToTileSubPosition(targetSafeTile.GetPlacementPoint(initialPlayerType).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)
|
||||
{
|
||||
playerPawn.SetPlayerState(PlayerState.InFinishingPath);
|
||||
@ -391,7 +442,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
playerPawn.SetPlayerState(PlayerState.HasFinished);
|
||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
||||
|
||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawns.Count)
|
||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished == playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Count)
|
||||
{
|
||||
CanRollDiceAgain = false;
|
||||
|
||||
|
||||
@ -21,6 +21,11 @@ public class PlayerPawn : MonoBehaviour
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public int PlayerId
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public void SetPlayerSelectionState(bool state)
|
||||
@ -73,4 +78,9 @@ public class PlayerPawn : MonoBehaviour
|
||||
{
|
||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitId(int id)
|
||||
{
|
||||
PlayerId = id;
|
||||
}
|
||||
}
|
||||
|
||||
89
Assets/Scripts/Tile/SafeTile.cs
Normal file
89
Assets/Scripts/Tile/SafeTile.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Tile/SafeTile.cs.meta
Normal file
11
Assets/Scripts/Tile/SafeTile.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 114033ff484fb492290f3118615ad4d8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -1,106 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerPlacementData
|
||||
{
|
||||
public PlayerPawn pawn;
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class PlayerTileData
|
||||
{
|
||||
public int playerCount;
|
||||
public Transform placementTransform;
|
||||
public List<PlayerPawn> playerPawns;
|
||||
public Transform commonPlacementTransform;
|
||||
public Dictionary<int, PlayerPawn> playerPawns;
|
||||
}
|
||||
|
||||
public class Tile : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private bool isSafeZone = false;
|
||||
[SerializeField] private Transform centerPlacementPoint;
|
||||
[SerializeField] private Transform[] placementPoints;
|
||||
[SerializeField] protected bool isSafeZone = false;
|
||||
|
||||
private int lastOccupiedIndex = 0;
|
||||
public bool IsSafeZone => isSafeZone;
|
||||
|
||||
public Vector3 CenterPlacementPosition => transform.position;
|
||||
|
||||
protected int lastOccupiedIndex = 0;
|
||||
|
||||
public PlayerPawn PlayerPawn // Change implementation
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
private Queue<Transform> placementQueue = new Queue<Transform>();
|
||||
private Dictionary<PlayerTypes, PlayerTileData> playerTypesDict;
|
||||
|
||||
public int PlayerTypesCount => playerTypesDict.Count;
|
||||
public bool HasMoreThanOnePlayerType => playerTypesDict.Count > 1;
|
||||
public bool IsSafeZone => isSafeZone;
|
||||
|
||||
public Vector3 CenterPlacementPosition => centerPlacementPoint.position;
|
||||
|
||||
public bool ContainsPlayerType(PlayerTypes playerType) => playerTypesDict.ContainsKey(playerType);
|
||||
|
||||
public void Init(int playerTypesCount)
|
||||
{
|
||||
if (isSafeZone)
|
||||
{
|
||||
playerTypesDict = new Dictionary<PlayerTypes, PlayerTileData>();
|
||||
foreach (var placement in placementPoints)
|
||||
{
|
||||
placementQueue.Enqueue(placement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void InitPlayerPawn(PlayerPawn playerPawn, PlayerTypes playerType)
|
||||
public virtual void InitPlayerPawn(PlayerPawn playerPawn, PlayerTypes playerType)
|
||||
{
|
||||
PlayerPawn = playerPawn;
|
||||
if (isSafeZone)
|
||||
{
|
||||
if (!playerTypesDict.ContainsKey(playerType))
|
||||
{
|
||||
playerTypesDict.Add(
|
||||
playerType,
|
||||
new PlayerTileData { playerCount = 1, placementTransform = placementQueue.Dequeue(), // TODO :: Change indexing logic
|
||||
playerPawns = new List<PlayerPawn> { playerPawn }
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
playerTypesDict[playerType].playerCount++;
|
||||
playerTypesDict[playerType].playerPawns.Add(playerPawn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSafeZonePlayerData(PlayerTypes playerType)
|
||||
{
|
||||
if (!IsSafeZone) return;
|
||||
|
||||
if (playerTypesDict.ContainsKey(playerType))
|
||||
{
|
||||
if (playerTypesDict[playerType].playerCount > 0)
|
||||
{
|
||||
playerTypesDict[playerType].playerCount--;
|
||||
playerTypesDict[playerType].playerPawns.RemoveAt(playerTypesDict[playerType].playerPawns.Count - 1);
|
||||
if (playerTypesDict[playerType].playerCount == 0)
|
||||
{
|
||||
placementQueue.Enqueue(playerTypesDict[playerType].placementTransform);
|
||||
playerTypesDict.Remove(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];
|
||||
}
|
||||
|
||||
public Transform GetPlacementPoint(PlayerTypes playerType)
|
||||
{
|
||||
return playerTypesDict[playerType].placementTransform;
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,11 +38,6 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
finishingTileDataPairs[tileData.playerType].Add(child);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var tile in generalTiles)
|
||||
{
|
||||
tile.Init(gameplayManager.PlayerTypesCollection.Count);
|
||||
}
|
||||
}
|
||||
|
||||
public int GetFinishingTileDataLength(PlayerTypes playerType) => finishingTileDataPairs[playerType].Count;
|
||||
@ -52,7 +47,14 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
||||
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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user