Compare commits
7 Commits
d20503fd9b
...
0aa1f18801
| Author | SHA1 | Date | |
|---|---|---|---|
| 0aa1f18801 | |||
| 1113352c7c | |||
| b002f8e021 | |||
| e57be039ff | |||
| f2d9a7f7cc | |||
| 41c2fdbee5 | |||
| 6e74d05851 |
@ -582,7 +582,7 @@ MonoBehaviour:
|
|||||||
m_SelectOnRight: {fileID: 0}
|
m_SelectOnRight: {fileID: 0}
|
||||||
m_Transition: 1
|
m_Transition: 1
|
||||||
m_Colors:
|
m_Colors:
|
||||||
m_NormalColor: {r: 0.2264151, g: 0.2264151, b: 0.2264151, a: 0.78431374}
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 0.78431374}
|
||||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0.88235295}
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 0.88235295}
|
||||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
m_SelectedColor: {r: 1, g: 1, b: 1, a: 1}
|
m_SelectedColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
|||||||
@ -122,6 +122,17 @@ NavMeshSettings:
|
|||||||
debug:
|
debug:
|
||||||
m_Flags: 0
|
m_Flags: 0
|
||||||
m_NavMeshData: {fileID: 0}
|
m_NavMeshData: {fileID: 0}
|
||||||
|
--- !u!114 &16179158 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 8065952316906327149, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2049814614}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &28556634
|
--- !u!1 &28556634
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -2500,6 +2511,17 @@ MeshFilter:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 224854105}
|
m_GameObject: {fileID: 224854105}
|
||||||
m_Mesh: {fileID: 4300004, guid: 25e0b84f10949354b96b98b3742acdde, type: 3}
|
m_Mesh: {fileID: 4300004, guid: 25e0b84f10949354b96b98b3742acdde, type: 3}
|
||||||
|
--- !u!114 &232996781 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 8065952317181319405, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2049814614}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &241691679
|
--- !u!1 &241691679
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -4213,6 +4235,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 429754881}
|
- component: {fileID: 429754881}
|
||||||
|
- component: {fileID: 429754882}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: GameMode
|
m_Name: GameMode
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -4235,6 +4258,18 @@ Transform:
|
|||||||
m_Father: {fileID: 1332468941}
|
m_Father: {fileID: 1332468941}
|
||||||
m_RootOrder: 3
|
m_RootOrder: 3
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &429754882
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 429754880}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2d8a94cfc31bb45f9a403db0c1f4c116, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &433034049
|
--- !u!1 &433034049
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -8166,6 +8201,17 @@ Transform:
|
|||||||
m_Father: {fileID: 2090077059}
|
m_Father: {fileID: 2090077059}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!114 &876481615 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 8065952316677608095, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2049814614}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &884011400
|
--- !u!1 &884011400
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -10449,7 +10495,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 7
|
value: 5
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
- target: {fileID: 4851974414659941541, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
propertyPath: m_AnchorMax.x
|
propertyPath: m_AnchorMax.x
|
||||||
@ -10523,6 +10569,38 @@ PrefabInstance:
|
|||||||
propertyPath: m_LocalEulerAnglesHint.z
|
propertyPath: m_LocalEulerAnglesHint.z
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnNormalColor.a
|
||||||
|
value: 0.78431374
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnNormalColor.b
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnNormalColor.g
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnNormalColor.r
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnSelectedColor.a
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnSelectedColor.b
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnSelectedColor.g
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 4851974414659941542, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
|
propertyPath: playerBtnSelectedColor.r
|
||||||
|
value: 1
|
||||||
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8050308181185231130, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
- target: {fileID: 8050308181185231130, guid: b04f48863fc6c4f75821857086cea347, type: 3}
|
||||||
propertyPath: m_AnchorMax.y
|
propertyPath: m_AnchorMax.y
|
||||||
value: 1
|
value: 1
|
||||||
@ -14721,6 +14799,7 @@ MonoBehaviour:
|
|||||||
- {fileID: 247469677}
|
- {fileID: 247469677}
|
||||||
- {fileID: 875086323}
|
- {fileID: 875086323}
|
||||||
- {fileID: 896127049}
|
- {fileID: 896127049}
|
||||||
|
- {fileID: 429754880}
|
||||||
- {fileID: 1954289399}
|
- {fileID: 1954289399}
|
||||||
- {fileID: 1107252688}
|
- {fileID: 1107252688}
|
||||||
- {fileID: 1406544794}
|
- {fileID: 1406544794}
|
||||||
@ -18202,6 +18281,17 @@ Transform:
|
|||||||
m_Father: {fileID: 491039299}
|
m_Father: {fileID: 491039299}
|
||||||
m_RootOrder: 1
|
m_RootOrder: 1
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||||
|
--- !u!114 &1811366701 stripped
|
||||||
|
MonoBehaviour:
|
||||||
|
m_CorrespondingSourceObject: {fileID: 8065952316882128052, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
m_PrefabInstance: {fileID: 2049814614}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 0}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 2da0c512f12947e489f739169773d7ca, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1820161969
|
--- !u!1 &1820161969
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -20298,6 +20388,26 @@ PrefabInstance:
|
|||||||
m_Modification:
|
m_Modification:
|
||||||
m_TransformParent: {fileID: 5608193481910428232}
|
m_TransformParent: {fileID: 5608193481910428232}
|
||||||
m_Modifications:
|
m_Modifications:
|
||||||
|
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
propertyPath: inputFields.Array.size
|
||||||
|
value: 4
|
||||||
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
propertyPath: inputFields.Array.data[0]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 876481615}
|
||||||
|
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
propertyPath: inputFields.Array.data[1]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 1811366701}
|
||||||
|
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
propertyPath: inputFields.Array.data[2]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 232996781}
|
||||||
|
- target: {fileID: 8065952316435045037, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
|
propertyPath: inputFields.Array.data[3]
|
||||||
|
value:
|
||||||
|
objectReference: {fileID: 16179158}
|
||||||
- target: {fileID: 8065952316435045038, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
- target: {fileID: 8065952316435045038, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
propertyPath: m_Name
|
propertyPath: m_Name
|
||||||
value: Player V Player Popup
|
value: Player V Player Popup
|
||||||
@ -20316,7 +20426,7 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
propertyPath: m_RootOrder
|
propertyPath: m_RootOrder
|
||||||
value: 6
|
value: 4
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
- target: {fileID: 8065952316435045039, guid: 4fd2ca927610f4ed9a93f6bb3ec71a1d, type: 3}
|
||||||
propertyPath: m_AnchorMax.x
|
propertyPath: m_AnchorMax.x
|
||||||
@ -22557,6 +22667,7 @@ GameObject:
|
|||||||
serializedVersion: 6
|
serializedVersion: 6
|
||||||
m_Component:
|
m_Component:
|
||||||
- component: {fileID: 5608193481571390226}
|
- component: {fileID: 5608193481571390226}
|
||||||
|
- component: {fileID: 5608193481571390228}
|
||||||
m_Layer: 5
|
m_Layer: 5
|
||||||
m_Name: GameOverPopup
|
m_Name: GameOverPopup
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@ -22564,6 +22675,31 @@ GameObject:
|
|||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 1
|
m_IsActive: 1
|
||||||
|
--- !u!114 &5608193481571390228
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 5608193481571390227}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 178d988f5211b4ef5b8c2df230b708d4, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
popupScaleContent: {fileID: 5608193481571390226}
|
||||||
|
zoomDuration: 0.5
|
||||||
|
popupType: 5
|
||||||
|
popupScalerType: 1
|
||||||
|
canvasGroup: {fileID: 0}
|
||||||
|
fadeDuration: 0
|
||||||
|
playAgainBtn: {fileID: 5608193482985030359}
|
||||||
|
mainMenuBtn: {fileID: 5608193483181475110}
|
||||||
|
texts:
|
||||||
|
- {fileID: 5608193483287721217}
|
||||||
|
- {fileID: 28556636}
|
||||||
|
- {fileID: 300136906}
|
||||||
|
- {fileID: 1260155923}
|
||||||
--- !u!1 &5608193481588389864
|
--- !u!1 &5608193481588389864
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -26065,7 +26201,7 @@ GameObject:
|
|||||||
m_Icon: {fileID: 0}
|
m_Icon: {fileID: 0}
|
||||||
m_NavMeshLayer: 0
|
m_NavMeshLayer: 0
|
||||||
m_StaticEditorFlags: 0
|
m_StaticEditorFlags: 0
|
||||||
m_IsActive: 0
|
m_IsActive: 1
|
||||||
--- !u!222 &5608193482973815122
|
--- !u!222 &5608193482973815122
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27276,7 +27412,7 @@ GameObject:
|
|||||||
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: 0
|
||||||
--- !u!222 &5608193483354237948
|
--- !u!222 &5608193483354237948
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@ -27428,7 +27564,7 @@ GameObject:
|
|||||||
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: 0
|
||||||
--- !u!222 &5608193483406443892
|
--- !u!222 &5608193483406443892
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
@ -7,11 +8,28 @@ public enum GameModeType
|
|||||||
Bot,
|
Bot,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class PVPModeData
|
||||||
|
{
|
||||||
|
public List<PlayerType> types;
|
||||||
|
public List<string> names;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class BotModeData
|
||||||
|
{
|
||||||
|
public PlayerData playerData;
|
||||||
|
public int botCount;
|
||||||
|
}
|
||||||
|
|
||||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public GameModeType GameModeType
|
private PVPModeData pvpModeData;
|
||||||
|
private BotModeData botModeData;
|
||||||
|
|
||||||
|
public GameModeType CurrentGameModeType
|
||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
@ -26,15 +44,39 @@ public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPVPModeData(List<PlayerType> types)
|
public void InitPVPModeData(List<PlayerType> types, List<string> names)
|
||||||
{
|
{
|
||||||
GameModeType = GameModeType.PVP;
|
pvpModeData = new PVPModeData
|
||||||
gameplayManager.InitPlayerTypesForPVP(types);
|
{
|
||||||
|
types = types, names = names
|
||||||
|
};
|
||||||
|
|
||||||
|
CurrentGameModeType = GameModeType.PVP;
|
||||||
|
gameplayManager.InitPlayerTypesForPVP(types, names);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
public void InitBotModeData(PlayerData playerData, int botCount)
|
||||||
{
|
{
|
||||||
GameModeType = GameModeType.Bot;
|
botModeData = new BotModeData
|
||||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
{
|
||||||
|
playerData = playerData,
|
||||||
|
botCount = botCount
|
||||||
|
};
|
||||||
|
|
||||||
|
CurrentGameModeType = GameModeType.Bot;
|
||||||
|
gameplayManager.InitPlayerTypesForBotMatch(playerData, botCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnGameRestarted()
|
||||||
|
{
|
||||||
|
switch (CurrentGameModeType)
|
||||||
|
{
|
||||||
|
case GameModeType.PVP:
|
||||||
|
InitPVPModeData(pvpModeData.types, pvpModeData.names);
|
||||||
|
break;
|
||||||
|
case GameModeType.Bot:
|
||||||
|
InitBotModeData(botModeData.playerData, botModeData.botCount);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,33 +5,6 @@ using DG.Tweening;
|
|||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public enum PlayerType
|
|
||||||
{
|
|
||||||
Player1 = 0,
|
|
||||||
Player2 = 1,
|
|
||||||
Player3 = 2,
|
|
||||||
Player4 = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public class PlayerGameData
|
|
||||||
{
|
|
||||||
public PlayerType playerType;
|
|
||||||
public int startIndex;
|
|
||||||
public int endIndex;
|
|
||||||
public Transform playersParent;
|
|
||||||
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
|
||||||
public int totalPawnsInHome = 0;
|
|
||||||
public int totalPawnsFinished = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public enum MatchType
|
|
||||||
{
|
|
||||||
PVP,
|
|
||||||
Bot
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum BotMove
|
public enum BotMove
|
||||||
{
|
{
|
||||||
FinishingPathMove = 0,
|
FinishingPathMove = 0,
|
||||||
@ -59,18 +32,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private PlayerType currentPlayerTypeTurn;
|
private PlayerType currentPlayerTypeTurn;
|
||||||
private int currentPlayerTurnIndex = 0;
|
private int currentPlayerTurnIndex = 0;
|
||||||
|
|
||||||
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
private List<PlayerType> allPlayerTypes = new List<PlayerType>();
|
||||||
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
private List<PlayerType> botTypesInGame = new List<PlayerType>();
|
||||||
private List<PlayerType> playerRankings = new List<PlayerType>();
|
|
||||||
|
private List<PlayerData> playerDatas = new List<PlayerData>();
|
||||||
|
|
||||||
|
|
||||||
// private Dictionary<PlayerTypes, > playerPawnsDict = new Dictionary<PlayerTypes, List<PlayerPawn>>();
|
|
||||||
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
private Dictionary<PlayerType, PlayerGameData> playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||||
|
|
||||||
// botRuntimeMovementData: where can the bot move if a particular dice value is thrown, and based on the value set the bot move for each using a predictive approach and select based on the the priority
|
|
||||||
private Dictionary<PlayerType, Dictionary<int, BotMove>> botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
private Dictionary<PlayerType, Dictionary<int, BotMove>> botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||||
|
|
||||||
private TilesManager tilesManager;
|
private TilesManager tilesManager;
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
private int diceRolledValue;
|
private int diceRolledValue;
|
||||||
|
|
||||||
@ -84,6 +57,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
get; private set;
|
get; private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int TotalPlayersInGame
|
||||||
|
{
|
||||||
|
get; private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<PlayerData> PlayerDatas => playerDatas;
|
||||||
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
@ -95,16 +75,26 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||||
|
gameManager = InterfaceManager.Instance.GetInterfaceInstance<GameManager>();
|
||||||
// InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
|
||||||
InitPlayerTypesForPVP(new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO :: Call when the UI selection is made and game starts
|
public void InitPlayerTypesForPVP(List<PlayerType> types, List<string> names)
|
||||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
|
||||||
{
|
{
|
||||||
// TODO :: 2P, 3P, 4P
|
|
||||||
allPlayerTypes = new List<PlayerType>(types);
|
allPlayerTypes = new List<PlayerType>(types);
|
||||||
|
playerDatas.Clear();
|
||||||
|
|
||||||
|
TotalPlayersInGame = types.Count;
|
||||||
|
|
||||||
|
for (int i=0; i<types.Count; i++)
|
||||||
|
{
|
||||||
|
playerDatas.Add(new PlayerData
|
||||||
|
{
|
||||||
|
playerType = types[i],
|
||||||
|
playerName = names[i],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
tilesManager.InitTilesData();
|
||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
@ -112,26 +102,46 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForBotMatch(PlayerType selectedPlayerType, int botCount)
|
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||||
{
|
{
|
||||||
botTypesInGame.Clear();
|
playerDatas = new List<PlayerData>();
|
||||||
allPlayerTypes.Clear();
|
botTypesInGame = new List<PlayerType>();
|
||||||
AssignBotTypes(selectedPlayerType, botCount);
|
allPlayerTypes = new List<PlayerType>();
|
||||||
|
|
||||||
allPlayerTypes.Add(selectedPlayerType);
|
TotalPlayersInGame = botCount + 1;
|
||||||
allPlayerTypes.AddRange(botTypesInGame);
|
AssignBotTypes(selectedPlayerData.playerType, botCount);
|
||||||
|
|
||||||
|
foreach (PlayerType playerType in Enum.GetValues(typeof(PlayerType)))
|
||||||
|
{
|
||||||
|
if (botTypesInGame.Contains(playerType))
|
||||||
|
{
|
||||||
|
allPlayerTypes.Add(playerType);
|
||||||
|
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{playerType}" });
|
||||||
|
}
|
||||||
|
else if (selectedPlayerData.playerType == playerType)
|
||||||
|
{
|
||||||
|
allPlayerTypes.Add(selectedPlayerData.playerType);
|
||||||
|
playerDatas.Add(new PlayerData { playerType = selectedPlayerData.playerType, playerName = $"{selectedPlayerData.playerName}" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var type in allPlayerTypes)
|
||||||
|
Debug.Log($"allPlayerTypes ::: {type}");
|
||||||
|
|
||||||
|
tilesManager.InitTilesData();
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
InitBotRuntimeData();
|
InitBotRuntimeData();
|
||||||
AssignPlayerAndBotStates(selectedPlayerType);
|
AssignPlayerAndBotStates(selectedPlayerData.playerType);
|
||||||
|
|
||||||
SetCanRollDiceForUser(!botTypesInGame.Contains(selectedPlayerType));
|
SetCanRollDiceForUser(!botTypesInGame.Contains(allPlayerTypes[0]));
|
||||||
|
if (botTypesInGame.Contains(allPlayerTypes[0]))
|
||||||
|
Invoke(nameof(HandleDiceRoll), 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitBotRuntimeData()
|
private void InitBotRuntimeData()
|
||||||
{
|
{
|
||||||
botRuntimeMovementData.Clear();
|
botRuntimeMovementData = new Dictionary<PlayerType, Dictionary<int, BotMove>>();
|
||||||
|
|
||||||
foreach (var botType in botTypesInGame)
|
foreach (var botType in botTypesInGame)
|
||||||
{
|
{
|
||||||
@ -198,12 +208,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||||
|
|
||||||
// initialize the board based on the player types
|
// initialize the board based on the player types
|
||||||
|
playerGameDatasDict = new Dictionary<PlayerType, PlayerGameData>();
|
||||||
|
|
||||||
foreach (PlayerGameData playerGameData in playerGameDatas)
|
foreach (PlayerGameData playerGameData in playerGameDatas)
|
||||||
{
|
{
|
||||||
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
if (!allPlayerTypes.Contains(playerGameData.playerType))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Debug.Log($"playerGameData.playerType: {playerGameData.playerType}");
|
Debug.Log($"playerGameData.playerType: {playerGameData.playerType}");
|
||||||
|
|
||||||
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
playerGameDatasDict.Add(playerGameData.playerType, playerGameData);
|
||||||
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new Dictionary<int, PlayerPawn>();
|
playerGameDatasDict[playerGameData.playerType].playerPawnsDict = new Dictionary<int, PlayerPawn>();
|
||||||
|
|
||||||
@ -440,7 +453,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
Debug.Log($"Tile Index :: LUDO :: rolledVal: {rolledVal} :: {currentPlayerTypeTurn}");
|
||||||
diceRolledValue = rolledVal;
|
diceRolledValue = rolledVal;
|
||||||
diceText.text = $"{diceRolledValue}";
|
diceText.text = $"{diceRolledValue}";
|
||||||
availPlayers.Clear();
|
availPlayers = new List<PlayerPawn>();
|
||||||
|
|
||||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||||
{
|
{
|
||||||
@ -913,6 +926,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
|
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
|
||||||
{
|
{
|
||||||
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
|
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
|
||||||
|
|
||||||
|
DisplayPlayerCountOnTile(playerPawn, false);
|
||||||
playerPawn.MoveToTile(
|
playerPawn.MoveToTile(
|
||||||
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
|
tilesManager.RetrievePositionForFinishingTile(currentPlayerTypeTurn, index).position,
|
||||||
onComplete: () =>
|
onComplete: () =>
|
||||||
@ -932,6 +947,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
DisplayPlayerCountOnTile(playerPawn, true);
|
||||||
Debug.Log($"CurrentTileIndex: {playerPawn.CurrentTileIndex} == lastIndex: {tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1}");
|
Debug.Log($"CurrentTileIndex: {playerPawn.CurrentTileIndex} == lastIndex: {tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1}");
|
||||||
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
||||||
{
|
{
|
||||||
@ -945,17 +961,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
if (allPlayerTypes.Contains(currentPlayerTypeTurn))
|
||||||
{
|
{
|
||||||
playerRankings.Add(currentPlayerTypeTurn);
|
|
||||||
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
allPlayerTypes.Remove(currentPlayerTypeTurn);
|
||||||
|
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (allPlayerTypes.Count == 1)
|
if (allPlayerTypes.Count == 1)
|
||||||
{
|
{
|
||||||
// Game is over
|
// Game is over
|
||||||
playerRankings.Add(allPlayerTypes[0]);
|
allPlayerTypes.RemoveAt(0);
|
||||||
allPlayerTypes.Remove(0);
|
playerDatas[(int)currentPlayerTypeTurn].ranking = TotalPlayersInGame - allPlayerTypes.Count;
|
||||||
|
|
||||||
// Show Game Over panel
|
// Show Game Over panel
|
||||||
|
gameManager.OnGameStateChanged(GameState.GameOver);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -975,6 +992,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// activate here
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -1013,5 +1031,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
playerPawn.GetComponentInChildren<PlayerCountCanvas>().SetPlayerCount(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetData()
|
||||||
|
{
|
||||||
|
playerDatas = null;
|
||||||
|
botTypesInGame = null;
|
||||||
|
allPlayerTypes = null;
|
||||||
|
|
||||||
|
botRuntimeMovementData = null;
|
||||||
|
playerGameDatasDict = null;
|
||||||
|
playerDatas = null;
|
||||||
|
availPlayers = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,7 +24,7 @@ public class PlayerBase : MonoBehaviour
|
|||||||
{
|
{
|
||||||
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
for (int idx = 0; idx < basePlacementDatas.Length; idx++)
|
||||||
{
|
{
|
||||||
playerPawns[idx].Init(basePlacementDatas[idx].playerBaseId, playerType);
|
playerPawns[idx].Init(basePlacementDatas[idx], playerType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
30
Assets/Scripts/Gameplay/Player/PlayerGameData.cs
Normal file
30
Assets/Scripts/Gameplay/Player/PlayerGameData.cs
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public enum PlayerType
|
||||||
|
{
|
||||||
|
Player1 = 0,
|
||||||
|
Player2 = 1,
|
||||||
|
Player3 = 2,
|
||||||
|
Player4 = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PlayerGameData
|
||||||
|
{
|
||||||
|
public PlayerType playerType;
|
||||||
|
public int startIndex;
|
||||||
|
public int endIndex;
|
||||||
|
public Transform playersParent;
|
||||||
|
public Dictionary<int, PlayerPawn> playerPawnsDict;
|
||||||
|
public int totalPawnsInHome = 0;
|
||||||
|
public int totalPawnsFinished = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class PlayerData
|
||||||
|
{
|
||||||
|
public PlayerType playerType;
|
||||||
|
public string playerName;
|
||||||
|
public int ranking = 0;
|
||||||
|
}
|
||||||
11
Assets/Scripts/Gameplay/Player/PlayerGameData.cs.meta
Normal file
11
Assets/Scripts/Gameplay/Player/PlayerGameData.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e9f4a588284ad4839bff99f31d6d402c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -135,10 +135,12 @@ public class PlayerPawn : MonoBehaviour
|
|||||||
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = gameplayManager ?? InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(int id, PlayerType playerType)
|
public void Init(BasePlacementData basePlacementData, PlayerType playerType)
|
||||||
{
|
{
|
||||||
PlayerId = id;
|
PlayerId = basePlacementData.playerBaseId;
|
||||||
PlayerType = playerType;
|
PlayerType = playerType;
|
||||||
|
|
||||||
|
MoveBackToHome(basePlacementData.placementTransform);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ShowPlayerCountCanvas(bool show)
|
public void ShowPlayerCountCanvas(bool show)
|
||||||
|
|||||||
@ -4,11 +4,13 @@ public enum GameState
|
|||||||
{
|
{
|
||||||
InMenu,
|
InMenu,
|
||||||
InGame,
|
InGame,
|
||||||
|
GameOver,
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||||
{
|
{
|
||||||
private UIManager uiManager;
|
private UIManager uiManager;
|
||||||
|
private GameplayManager gameplayManager;
|
||||||
|
|
||||||
public GameState GameState
|
public GameState GameState
|
||||||
{
|
{
|
||||||
@ -23,21 +25,26 @@ public class GameManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
uiManager = InterfaceManager.Instance.GetInterfaceInstance<UIManager>();
|
||||||
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
|
||||||
GameState = GameState.InMenu;
|
OnGameStateChanged(GameState.InMenu);
|
||||||
OnGameStateChanged(GameState);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGameStateChanged(GameState gameState)
|
public void OnGameStateChanged(GameState gameState)
|
||||||
{
|
{
|
||||||
|
GameState = gameState;
|
||||||
switch (gameState)
|
switch (gameState)
|
||||||
{
|
{
|
||||||
case GameState.InMenu:
|
case GameState.InMenu:
|
||||||
|
gameplayManager.ResetData();
|
||||||
uiManager.OnInMenuScreen();
|
uiManager.OnInMenuScreen();
|
||||||
break;
|
break;
|
||||||
case GameState.InGame:
|
case GameState.InGame:
|
||||||
uiManager.OnInGameScreen();
|
uiManager.OnInGameScreen();
|
||||||
break;
|
break;
|
||||||
|
case GameState.GameOver:
|
||||||
|
uiManager.OnGameOver();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,10 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitTilesData()
|
||||||
|
{
|
||||||
foreach (var tileData in tileDatas)
|
foreach (var tileData in tileDatas)
|
||||||
{
|
{
|
||||||
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
if (gameplayManager.PlayerTypesCollection.Contains(tileData.playerType))
|
||||||
|
|||||||
@ -6,6 +6,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
private GameplayManager gameplayManager;
|
private GameplayManager gameplayManager;
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
|
private PopupManager popupManager;
|
||||||
|
|
||||||
public void Initialize()
|
public void Initialize()
|
||||||
{
|
{
|
||||||
@ -15,6 +16,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitializeData()
|
public void InitializeData()
|
||||||
{
|
{
|
||||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||||
|
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDiceViewInteracted()
|
public void OnDiceViewInteracted()
|
||||||
@ -35,8 +37,9 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateSelectedPlayerCount(int playersCount)
|
public void OnGameOver()
|
||||||
{
|
{
|
||||||
|
popupManager.GetPopup<GameOverPopup>(PopupType.GameOverPopup).InitData(gameplayManager.PlayerDatas);
|
||||||
|
popupManager.ShowPopup(PopupType.GameOverPopup);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,7 +9,8 @@ public enum PopupType
|
|||||||
PvAIModePopup,
|
PvAIModePopup,
|
||||||
OptionsPopup,
|
OptionsPopup,
|
||||||
InstructionsPopup,
|
InstructionsPopup,
|
||||||
PauseMenuPopup
|
PauseMenuPopup,
|
||||||
|
GameOverPopup
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum PopupScalerType
|
public enum PopupScalerType
|
||||||
|
|||||||
64
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
64
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class GameOverPopup : PopupBase
|
||||||
|
{
|
||||||
|
[SerializeField] private Button playAgainBtn;
|
||||||
|
[SerializeField] private Button mainMenuBtn;
|
||||||
|
|
||||||
|
[SerializeField] private TextMeshProUGUI[] texts;
|
||||||
|
|
||||||
|
private GameModeHandler gameModeHandler;
|
||||||
|
private ScreenManager screenManager;
|
||||||
|
|
||||||
|
private void OnEnable()
|
||||||
|
{
|
||||||
|
playAgainBtn.onClick.AddListener(OnPlayAgainClicked);
|
||||||
|
mainMenuBtn.onClick.AddListener(OnMainMenuClicked);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnDisable()
|
||||||
|
{
|
||||||
|
playAgainBtn.onClick.RemoveAllListeners();
|
||||||
|
mainMenuBtn.onClick.RemoveAllListeners();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPlayAgainClicked()
|
||||||
|
{
|
||||||
|
HidePopup();
|
||||||
|
|
||||||
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
|
gameModeHandler.OnGameRestarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HidePopup()
|
||||||
|
{
|
||||||
|
popupManager = popupManager == null ? InterfaceManager.Instance.GetInterfaceInstance<PopupManager>() : popupManager;
|
||||||
|
popupManager.HidePopup(popupType);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnMainMenuClicked()
|
||||||
|
{
|
||||||
|
HidePopup();
|
||||||
|
|
||||||
|
screenManager = screenManager == null ? InterfaceManager.Instance.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||||
|
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InitData(List<PlayerData> playerDatas)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < playerDatas.Count; i++)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
texts[i].text = $"{playerDatas[i].playerName} Wins";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
texts[i].text = $"{(i+1)}. {playerDatas[i].playerName}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs.meta
Normal file
11
Assets/Scripts/UI/Pages/PopUp/GameOverPopup.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 178d988f5211b4ef5b8c2df230b708d4
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -1,9 +1,13 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class PvAIModePopup : PopupBase
|
public class PvAIModePopup : PopupBase
|
||||||
{
|
{
|
||||||
|
[SerializeField] private Color playerBtnNormalColor;
|
||||||
|
[SerializeField] private Color playerBtnSelectedColor;
|
||||||
|
|
||||||
[Header("Bot Selection Buttons")]
|
[Header("Bot Selection Buttons")]
|
||||||
[SerializeField] private Button twoPlayerBtn;
|
[SerializeField] private Button twoPlayerBtn;
|
||||||
[SerializeField] private Button threePlayerBtn;
|
[SerializeField] private Button threePlayerBtn;
|
||||||
@ -29,24 +33,33 @@ public class PvAIModePopup : PopupBase
|
|||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
private GameModeHandler gameModeHandler;
|
private GameModeHandler gameModeHandler;
|
||||||
|
private GameManager gameManager;
|
||||||
|
|
||||||
private int selectedPlayerCount;
|
private int selectedPlayerCount;
|
||||||
private PlayerType playerType;
|
private PlayerType playerType;
|
||||||
|
|
||||||
|
private Button currPlayerCountBtn, prevPlayerCountBtn;
|
||||||
|
private Button currPlayerTypeBtn, prePlayerTypeBtn;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
|
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2, twoPlayerBtn));
|
||||||
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
|
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3, threePlayerBtn));
|
||||||
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
|
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4, fourPlayerBtn));
|
||||||
|
|
||||||
playBtn.onClick.AddListener(OnClick_PlayButton);
|
playBtn.onClick.AddListener(OnClick_PlayButton);
|
||||||
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
||||||
redBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player1));
|
|
||||||
blueBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player2));
|
|
||||||
greyBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player3));
|
|
||||||
greenBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player4));
|
|
||||||
|
|
||||||
redBtn.Select();
|
redBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player1, redBtn));
|
||||||
twoPlayerBtn.Select();
|
blueBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player2, blueBtn));
|
||||||
|
greyBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player3, greyBtn));
|
||||||
|
greenBtn.onClick.AddListener(() => OnColorSelected(PlayerType.Player4, greenBtn));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
OnPlayerCountSelected(2, twoPlayerBtn);
|
||||||
|
OnColorSelected(PlayerType.Player1, redBtn);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnDisable()
|
private void OnDisable()
|
||||||
@ -54,12 +67,29 @@ public class PvAIModePopup : PopupBase
|
|||||||
twoPlayerBtn.onClick.RemoveAllListeners();
|
twoPlayerBtn.onClick.RemoveAllListeners();
|
||||||
threePlayerBtn.onClick.RemoveAllListeners();
|
threePlayerBtn.onClick.RemoveAllListeners();
|
||||||
fourPlayerBtn.onClick.RemoveAllListeners();
|
fourPlayerBtn.onClick.RemoveAllListeners();
|
||||||
|
|
||||||
playBtn.onClick.RemoveAllListeners();
|
playBtn.onClick.RemoveAllListeners();
|
||||||
closeBtn.onClick.RemoveAllListeners();
|
closeBtn.onClick.RemoveAllListeners();
|
||||||
}
|
}
|
||||||
private void OnPlayerCountSelected(int count)
|
|
||||||
|
private void OnPlayerCountSelected(int count, Button button)
|
||||||
{
|
{
|
||||||
selectedPlayerCount = count;
|
selectedPlayerCount = count;
|
||||||
|
|
||||||
|
prevPlayerCountBtn = currPlayerCountBtn;
|
||||||
|
currPlayerCountBtn = button;
|
||||||
|
|
||||||
|
ColorBlock colorBlock;
|
||||||
|
if (prevPlayerCountBtn)
|
||||||
|
{
|
||||||
|
colorBlock = prevPlayerCountBtn.colors;
|
||||||
|
colorBlock.normalColor = playerBtnNormalColor;
|
||||||
|
prevPlayerCountBtn.colors = colorBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
colorBlock = currPlayerCountBtn.colors;
|
||||||
|
colorBlock.normalColor = playerBtnSelectedColor;
|
||||||
|
currPlayerCountBtn.colors = colorBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_PlayButton()
|
private void OnClick_PlayButton()
|
||||||
@ -74,8 +104,13 @@ public class PvAIModePopup : PopupBase
|
|||||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||||
Debug.Log($"Player 1: {playerName}");
|
Debug.Log($"Player 1: {playerName}");
|
||||||
|
|
||||||
|
popupManager.HidePopup(popupType);
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
|
gameModeHandler.InitBotModeData(new PlayerData{ playerType = playerType, playerName = playerName }, selectedPlayerCount - 1);
|
||||||
|
|
||||||
|
gameManager = gameManager == null ? InterfaceManager.Instance.GetInterfaceInstance<GameManager>() : gameManager;
|
||||||
|
gameManager.OnGameStateChanged(GameState.InGame);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_CloseButton()
|
private void OnClick_CloseButton()
|
||||||
@ -88,8 +123,23 @@ public class PvAIModePopup : PopupBase
|
|||||||
Hide();
|
Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnColorSelected(PlayerType type)
|
private void OnColorSelected(PlayerType type, Button button)
|
||||||
{
|
{
|
||||||
playerType = type;
|
playerType = type;
|
||||||
|
|
||||||
|
prePlayerTypeBtn = currPlayerTypeBtn;
|
||||||
|
currPlayerTypeBtn = button;
|
||||||
|
|
||||||
|
ColorBlock colorBlock;
|
||||||
|
if (prePlayerTypeBtn)
|
||||||
|
{
|
||||||
|
colorBlock = prePlayerTypeBtn.colors;
|
||||||
|
colorBlock.normalColor = playerBtnNormalColor;
|
||||||
|
prePlayerTypeBtn.colors = colorBlock;
|
||||||
|
}
|
||||||
|
|
||||||
|
colorBlock = currPlayerTypeBtn.colors;
|
||||||
|
colorBlock.normalColor = playerBtnSelectedColor;
|
||||||
|
currPlayerTypeBtn.colors = colorBlock;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
@ -19,12 +20,6 @@ public class PvPModePopup : PopupBase
|
|||||||
[SerializeField] private TMP_InputField playerThreeNameInput;
|
[SerializeField] private TMP_InputField playerThreeNameInput;
|
||||||
[SerializeField] private TMP_InputField playerFourNameInput;
|
[SerializeField] private TMP_InputField playerFourNameInput;
|
||||||
|
|
||||||
[Header("Player Names")]
|
|
||||||
private string playerOneName;
|
|
||||||
private string playerTwoName;
|
|
||||||
private string playerThreeName;
|
|
||||||
private string playerFourName;
|
|
||||||
|
|
||||||
[Header("References")]
|
[Header("References")]
|
||||||
[SerializeField] private GameObject playerNameInputParent1;
|
[SerializeField] private GameObject playerNameInputParent1;
|
||||||
[SerializeField] private GameObject playerNameInputParent2;
|
[SerializeField] private GameObject playerNameInputParent2;
|
||||||
@ -34,6 +29,13 @@ public class PvPModePopup : PopupBase
|
|||||||
[SerializeField] private TMP_Text playerTwoPlaceholder;
|
[SerializeField] private TMP_Text playerTwoPlaceholder;
|
||||||
[SerializeField] private TMP_Text playerThreePlaceholder;
|
[SerializeField] private TMP_Text playerThreePlaceholder;
|
||||||
[SerializeField] private TMP_Text playerFourPlaceholder;
|
[SerializeField] private TMP_Text playerFourPlaceholder;
|
||||||
|
[SerializeField] private List<TMP_InputField> inputFields = new List<TMP_InputField>();
|
||||||
|
|
||||||
|
[Header("Player Names")]
|
||||||
|
private string playerOneName;
|
||||||
|
private string playerTwoName;
|
||||||
|
private string playerThreeName;
|
||||||
|
private string playerFourName;
|
||||||
|
|
||||||
private ScreenManager screenManager;
|
private ScreenManager screenManager;
|
||||||
private SoundManager soundManager;
|
private SoundManager soundManager;
|
||||||
@ -43,19 +45,23 @@ public class PvPModePopup : PopupBase
|
|||||||
public int SelectedPlayerCount => selectedPlayerCount;
|
public int SelectedPlayerCount => selectedPlayerCount;
|
||||||
|
|
||||||
[Header("Horizontal Rows (P1–P4)")]
|
[Header("Horizontal Rows (P1–P4)")]
|
||||||
public List<GameObject> rows;
|
|
||||||
private int hiddenIndex = 0;
|
private int hiddenIndex = 0;
|
||||||
|
|
||||||
Dictionary<PlayerType, string> playerNameMap = new();
|
private List<int> hiddenIndexes = new List<int>();
|
||||||
|
private Dictionary<PlayerType, string> playerNameMap = new();
|
||||||
|
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
twoPlayerBtn.onClick.AddListener(OnClick_TwoPlayerBtn);
|
twoPlayerBtn.onClick.AddListener(OnClick_TwoPlayerBtn);
|
||||||
threePlayerBtn.onClick.AddListener(OnClick_ThreePlayerBtn);
|
threePlayerBtn.onClick.AddListener(OnClick_ThreePlayerBtn);
|
||||||
fourPlayerBtn.onClick.AddListener(OnClick_FourPlayerBtn);
|
fourPlayerBtn.onClick.AddListener(OnClick_FourPlayerBtn);
|
||||||
playBtn.onClick.AddListener(OnClick_PlayBtn);
|
|
||||||
closeBtn.onClick.AddListener(OnClick_CloseBtn);
|
playBtn.onClick.AddListener(OnClick_PlayButton);
|
||||||
switchBtn.onClick.AddListener(OnClick_SwitchBtn);
|
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
||||||
|
|
||||||
|
switchBtn.onClick.AddListener(OnClick_SwitchButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Start()
|
private void Start()
|
||||||
@ -68,33 +74,44 @@ public class PvPModePopup : PopupBase
|
|||||||
twoPlayerBtn.onClick.RemoveListener(OnClick_TwoPlayerBtn);
|
twoPlayerBtn.onClick.RemoveListener(OnClick_TwoPlayerBtn);
|
||||||
threePlayerBtn.onClick.RemoveListener(OnClick_ThreePlayerBtn);
|
threePlayerBtn.onClick.RemoveListener(OnClick_ThreePlayerBtn);
|
||||||
fourPlayerBtn.onClick.RemoveAllListeners();
|
fourPlayerBtn.onClick.RemoveAllListeners();
|
||||||
playBtn.onClick.RemoveListener(OnClick_PlayBtn);
|
|
||||||
closeBtn.onClick.RemoveListener(OnClick_CloseBtn);
|
playBtn.onClick.RemoveListener(OnClick_PlayButton);
|
||||||
switchBtn.onClick.RemoveListener(OnClick_SwitchBtn);
|
closeBtn.onClick.RemoveListener(OnClick_CloseButton);
|
||||||
|
|
||||||
|
switchBtn.onClick.RemoveListener(OnClick_SwitchButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_TwoPlayerBtn()
|
private void OnClick_TwoPlayerBtn()
|
||||||
{
|
{
|
||||||
switchBtn.gameObject.SetActive(true);
|
|
||||||
selectedPlayerCount = 2;
|
selectedPlayerCount = 2;
|
||||||
|
|
||||||
|
OnPlayerCountsSwitched();
|
||||||
|
|
||||||
|
switchBtn.gameObject.SetActive(true);
|
||||||
playerNameInputParent2.SetActive(false);
|
playerNameInputParent2.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_ThreePlayerBtn()
|
private void OnClick_ThreePlayerBtn()
|
||||||
{
|
{
|
||||||
switchBtn.gameObject.SetActive(true);
|
|
||||||
selectedPlayerCount = 3;
|
selectedPlayerCount = 3;
|
||||||
|
|
||||||
|
OnPlayerCountsSwitched();
|
||||||
|
|
||||||
|
switchBtn.gameObject.SetActive(true);
|
||||||
playerNameInputParent1.SetActive(true);
|
playerNameInputParent1.SetActive(true);
|
||||||
playerNameInputParent2.SetActive(true);
|
playerNameInputParent2.SetActive(true);
|
||||||
|
|
||||||
UpdateInputFieldsVisibility();
|
UpdateInputFieldsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_FourPlayerBtn()
|
private void OnClick_FourPlayerBtn()
|
||||||
{
|
{
|
||||||
switchBtn.gameObject.SetActive(false);
|
|
||||||
selectedPlayerCount = 4;
|
selectedPlayerCount = 4;
|
||||||
|
|
||||||
|
switchBtn.gameObject.SetActive(false);
|
||||||
playerNameInputParent1.SetActive(true);
|
playerNameInputParent1.SetActive(true);
|
||||||
playerNameInputParent2.SetActive(true);
|
playerNameInputParent2.SetActive(true);
|
||||||
|
|
||||||
UpdateInputFieldsVisibility();
|
UpdateInputFieldsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,84 +123,51 @@ public class PvPModePopup : PopupBase
|
|||||||
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
|
playerFourNameInput.transform.parent.gameObject.SetActive(selectedPlayerCount >= 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_PlayBtn()
|
private void OnClick_PlayButton()
|
||||||
{
|
{
|
||||||
int logicalIndex = 0;
|
playerNameMap.Clear();
|
||||||
|
for (int idx = 0; idx < inputFields.Count; idx++)
|
||||||
foreach (GameObject row in rows)
|
|
||||||
{
|
{
|
||||||
if (!row.activeSelf)
|
PlayerType playerType = (PlayerType)idx;
|
||||||
|
if (!inputFields[idx].transform.parent.gameObject.activeInHierarchy)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
TMP_InputField input = row.GetComponentInChildren<TMP_InputField>();
|
playerNameMap.Add(playerType, string.IsNullOrWhiteSpace(inputFields[idx].text) ? $"{playerType}" : inputFields[idx].text);
|
||||||
|
|
||||||
PlayerType playerType = (PlayerType)logicalIndex;
|
|
||||||
|
|
||||||
string playerName = string.IsNullOrWhiteSpace(input.text)
|
|
||||||
? playerType.ToString()
|
|
||||||
: input.text;
|
|
||||||
|
|
||||||
playerNameMap[playerType] = playerName;
|
|
||||||
logicalIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// playerOneName = string.IsNullOrWhiteSpace(playerOneNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerOneNameInput.text;
|
|
||||||
// playerTwoName = string.IsNullOrWhiteSpace(playerTwoNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerTwoNameInput.text;
|
|
||||||
// playerThreeName = string.IsNullOrWhiteSpace(playerThreeNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerThreeNameInput.text;
|
|
||||||
// playerFourName = string.IsNullOrWhiteSpace(playerFourNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerFourNameInput.text;
|
|
||||||
|
|
||||||
playerOneName = playerNameMap.GetValueOrDefault(PlayerType.Player1, Ludo_3D_Constants.Player1_Name);
|
playerOneName = playerNameMap.GetValueOrDefault(PlayerType.Player1, Ludo_3D_Constants.Player1_Name);
|
||||||
playerTwoName = playerNameMap.GetValueOrDefault(PlayerType.Player2, Ludo_3D_Constants.Player2_Name);
|
playerTwoName = playerNameMap.GetValueOrDefault(PlayerType.Player2, Ludo_3D_Constants.Player2_Name);
|
||||||
playerThreeName = playerNameMap.GetValueOrDefault(PlayerType.Player3, Ludo_3D_Constants.Player3_Name);
|
playerThreeName = playerNameMap.GetValueOrDefault(PlayerType.Player3, Ludo_3D_Constants.Player3_Name);
|
||||||
playerFourName = playerNameMap.GetValueOrDefault(PlayerType.Player4, Ludo_3D_Constants.Player4_Name);
|
playerFourName = playerNameMap.GetValueOrDefault(PlayerType.Player4, Ludo_3D_Constants.Player4_Name);
|
||||||
|
|
||||||
|
|
||||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||||
|
|
||||||
//TODO: Start PVP Game with the selected player count and names
|
|
||||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||||
Debug.Log($"Player 1: {playerOneName}");
|
|
||||||
Debug.Log($"Player 2: {playerTwoName}");
|
|
||||||
|
|
||||||
if (selectedPlayerCount >= 3)
|
popupManager.HidePopup(popupType);
|
||||||
Debug.Log($"Player 3: {playerThreeName}");
|
|
||||||
if (selectedPlayerCount == 4)
|
|
||||||
Debug.Log($"Player 4: {playerFourName}");
|
|
||||||
|
|
||||||
InitPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InitPlayers()
|
|
||||||
{
|
|
||||||
// update logic based on UpdateInputFieldsVisibility()
|
|
||||||
List<PlayerType> playerTypes = new List<PlayerType>();
|
|
||||||
if (playerOneNameInput.gameObject.activeInHierarchy)
|
|
||||||
playerTypes.Add(PlayerType.Player1);
|
|
||||||
|
|
||||||
if (playerTwoNameInput.gameObject.activeInHierarchy)
|
|
||||||
playerTypes.Add(PlayerType.Player2);
|
|
||||||
|
|
||||||
if (playerThreeNameInput.gameObject.activeInHierarchy)
|
|
||||||
playerTypes.Add(PlayerType.Player3);
|
|
||||||
|
|
||||||
if (playerFourNameInput.gameObject.activeInHierarchy)
|
|
||||||
playerTypes.Add(PlayerType.Player4);
|
|
||||||
|
|
||||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||||
gameModeHandler.InitPVPModeData(playerTypes);
|
gameModeHandler.InitPVPModeData(playerNameMap.Keys.ToList(), playerNameMap.Values.ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_SwitchBtn()
|
private void OnClick_SwitchButton()
|
||||||
{
|
{
|
||||||
|
hiddenIndexes.Clear();
|
||||||
if (SelectedPlayerCount == 2)
|
if (SelectedPlayerCount == 2)
|
||||||
{
|
{
|
||||||
if (playerNameInputParent1.activeSelf)
|
if (playerNameInputParent1.activeInHierarchy)
|
||||||
{
|
{
|
||||||
playerNameInputParent1.SetActive(false);
|
playerNameInputParent1.SetActive(false);
|
||||||
playerNameInputParent2.SetActive(true);
|
playerNameInputParent2.SetActive(true);
|
||||||
|
|
||||||
playerOnePlaceholder.text = "Player 1";
|
playerOnePlaceholder.text = "Player 1";
|
||||||
playerThreePlaceholder.text = "Player 2";
|
playerThreePlaceholder.text = "Player 2";
|
||||||
|
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player1);
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player3);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -191,30 +175,63 @@ public class PvPModePopup : PopupBase
|
|||||||
playerNameInputParent2.SetActive(false);
|
playerNameInputParent2.SetActive(false);
|
||||||
playerTwoPlaceholder.text = "Player 1";
|
playerTwoPlaceholder.text = "Player 1";
|
||||||
playerFourPlaceholder.text = "Player 2";
|
playerFourPlaceholder.text = "Player 2";
|
||||||
|
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player2);
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (SelectedPlayerCount == 3)
|
else if (SelectedPlayerCount == 3)
|
||||||
{
|
{
|
||||||
hiddenIndex = (hiddenIndex + 1) % rows.Count;
|
hiddenIndex = (hiddenIndex + 1) % inputFields.Count;
|
||||||
UpdateRows();
|
hiddenIndexes.Add(hiddenIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdateRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnPlayerCountsSwitched()
|
||||||
|
{
|
||||||
|
hiddenIndexes.Clear();
|
||||||
|
if (SelectedPlayerCount == 2)
|
||||||
|
{
|
||||||
|
if (playerNameInputParent1.activeInHierarchy)
|
||||||
|
{
|
||||||
|
playerOnePlaceholder.text = "Player 1";
|
||||||
|
playerThreePlaceholder.text = "Player 2";
|
||||||
|
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player2);
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player4);
|
||||||
|
}
|
||||||
|
else if (playerNameInputParent2.activeInHierarchy)
|
||||||
|
{
|
||||||
|
playerTwoPlaceholder.text = "Player 1";
|
||||||
|
playerFourPlaceholder.text = "Player 2";
|
||||||
|
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player1);
|
||||||
|
hiddenIndexes.Add((int)PlayerType.Player3);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (SelectedPlayerCount == 3)
|
||||||
|
{
|
||||||
|
hiddenIndex = (hiddenIndex + 1) % inputFields.Count;
|
||||||
|
hiddenIndexes.Add(hiddenIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateRows()
|
private void UpdateRows()
|
||||||
{
|
{
|
||||||
int visiblePlayerIndex = 1;
|
int visiblePlayerIndex = 1;
|
||||||
|
|
||||||
for (int i = 0; i < rows.Count; i++)
|
for (int i = 0; i < inputFields.Count; i++)
|
||||||
{
|
{
|
||||||
bool isHidden = (i == hiddenIndex);
|
bool isHidden = hiddenIndexes.Contains(i);
|
||||||
rows[i].SetActive(!isHidden);
|
inputFields[i].transform.parent.gameObject.SetActive(!isHidden);
|
||||||
|
|
||||||
if (!isHidden)
|
if (!isHidden)
|
||||||
{
|
{
|
||||||
TMP_InputField input =
|
TMP_Text placeholder = inputFields[i].placeholder as TMP_Text;
|
||||||
rows[i].GetComponentInChildren<TMP_InputField>();
|
|
||||||
|
|
||||||
TMP_Text placeholder = input.placeholder as TMP_Text;
|
|
||||||
if (placeholder != null)
|
if (placeholder != null)
|
||||||
{
|
{
|
||||||
placeholder.text = $"Player {visiblePlayerIndex}";
|
placeholder.text = $"Player {visiblePlayerIndex}";
|
||||||
@ -224,7 +241,7 @@ public class PvPModePopup : PopupBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnClick_CloseBtn()
|
private void OnClick_CloseButton()
|
||||||
{
|
{
|
||||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user