Merge branch 'UI/ashby-ui' into UI/main-ui
# Conflicts: # Assets/Scripts/UI/Pages/PopUp/PvPModePopup.cs
This commit is contained in:
commit
253b5affc3
@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class DiceView : MonoBehaviour, IBase, IBootLoader
|
||||
public class DiceView : MonoBehaviour, IBase
|
||||
{
|
||||
private Rigidbody rb;
|
||||
private bool rolling;
|
||||
@ -15,21 +16,22 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader
|
||||
[SerializeField] private float liftForce = 0.1f;
|
||||
|
||||
|
||||
private Action<int> onRollingComplete = null;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
rb = GetComponent<Rigidbody>();
|
||||
rb.useGravity = false;
|
||||
}
|
||||
public void Initialize()
|
||||
{
|
||||
InterfaceManager.Instance?.RegisterInterface<DiceView>(this);
|
||||
transform.localPosition = new Vector3(0, 20, 0);
|
||||
}
|
||||
|
||||
public void Roll()
|
||||
|
||||
public void Roll(Action<int> onComplete)
|
||||
{
|
||||
if (!rolling)
|
||||
{
|
||||
onRollingComplete = onComplete;
|
||||
StartCoroutine(RollRoutine());
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator RollRoutine()
|
||||
@ -37,26 +39,26 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader
|
||||
rolling = true;
|
||||
|
||||
// MICRO DELAY → breaks physics sync between dice
|
||||
yield return new WaitForSeconds(Random.Range(0.01f, 0.06f));
|
||||
yield return new WaitForSeconds(UnityEngine.Random.Range(0.01f, 0.06f));
|
||||
|
||||
rb.useGravity = true;
|
||||
|
||||
// PER-DICE FORCE MULTIPLIER
|
||||
float spinMultiplier = Random.Range(0.8f, 1.25f);
|
||||
float spinMultiplier = UnityEngine.Random.Range(0.8f, 1.25f);
|
||||
|
||||
// RANDOM TORQUE
|
||||
rb.AddTorque(
|
||||
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
UnityEngine.Random.Range(-baseSpinForce, baseSpinForce) * spinMultiplier,
|
||||
ForceMode.Impulse
|
||||
);
|
||||
|
||||
// RANDOM SIDE FORCE
|
||||
Vector3 sideDir = new Vector3(
|
||||
Random.Range(-1f, 1f),
|
||||
UnityEngine.Random.Range(-1f, 1f),
|
||||
0f,
|
||||
Random.Range(-1f, 1f)
|
||||
UnityEngine.Random.Range(-1f, 1f)
|
||||
).normalized;
|
||||
|
||||
rb.AddForce(sideDir * sideForce, ForceMode.Impulse);
|
||||
@ -71,6 +73,8 @@ public class DiceView : MonoBehaviour, IBase, IBootLoader
|
||||
//TODO: Use the dice value as needed
|
||||
Debug.Log($"Dice rolled: {value}");
|
||||
|
||||
onRollingComplete?.Invoke(value);
|
||||
|
||||
ResetDice();
|
||||
}
|
||||
|
||||
|
||||
@ -237,6 +237,18 @@ PrefabInstance:
|
||||
propertyPath: m_Layer
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3}
|
||||
propertyPath: liftForce
|
||||
value: 0.25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3}
|
||||
propertyPath: sideForce
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804238606659730488, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3}
|
||||
propertyPath: baseSpinForce
|
||||
value: 2000
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1804238606659730489, guid: 7a038d77e6ef54ce4b627bc5bf3ed17d, type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 0
|
||||
|
||||
@ -4046,6 +4046,37 @@ Transform:
|
||||
m_Father: {fileID: 491039299}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 180, z: 0}
|
||||
--- !u!1 &429754880
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 429754881}
|
||||
m_Layer: 0
|
||||
m_Name: GameMode
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &429754881
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 429754880}
|
||||
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: 1332468941}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &433034049
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -7795,7 +7826,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
diceRollHandler: {fileID: 1013177415}
|
||||
diceValue: 6
|
||||
diceValue: 0
|
||||
diceText: {fileID: 953941044}
|
||||
pointerDebug: {fileID: 102349503}
|
||||
pointerMeshRend: {fileID: 102349501}
|
||||
@ -10520,7 +10551,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
diceView: {fileID: 1619592888}
|
||||
diceTestValue: 6
|
||||
diceTestValue: 0
|
||||
--- !u!4 &1039618837 stripped
|
||||
Transform:
|
||||
m_CorrespondingSourceObject: {fileID: 5672526856521419272, guid: 4dc45edb05c8f4268aebcd5e9cbac783, type: 3}
|
||||
@ -13896,6 +13927,7 @@ Transform:
|
||||
- {fileID: 1954289400}
|
||||
- {fileID: 896127050}
|
||||
- {fileID: 1013177414}
|
||||
- {fileID: 429754881}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -22049,10 +22081,10 @@ RectTransform:
|
||||
m_Father: {fileID: 5608193482000915565}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 439.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &5608193481682591349
|
||||
GameObject:
|
||||
@ -23753,7 +23785,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
m_IsActive: 0
|
||||
--- !u!222 &5608193481910428234
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -24810,10 +24842,10 @@ RectTransform:
|
||||
m_Father: {fileID: 5608193482000915565}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 170.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &5608193482091674333
|
||||
GameObject:
|
||||
@ -25052,9 +25084,9 @@ RectTransform:
|
||||
m_Father: {fileID: 5608193481540211365}
|
||||
m_RootOrder: 1
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 487.5, y: -150}
|
||||
m_SizeDelta: {x: 250, y: 250}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &5608193482123643061
|
||||
@ -26731,7 +26763,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &5608193482405246783
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -29762,9 +29794,9 @@ RectTransform:
|
||||
m_Father: {fileID: 5608193481540211365}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 162.5, y: -150}
|
||||
m_SizeDelta: {x: 250, y: 250}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &5608193482885172033
|
||||
@ -32611,10 +32643,10 @@ RectTransform:
|
||||
m_Father: {fileID: 5608193482000915565}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 708.5, y: -62.5}
|
||||
m_SizeDelta: {x: 249, y: 76}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &5608193483470603110
|
||||
CanvasRenderer:
|
||||
|
||||
40
Assets/Scripts/Gameplay/GameModeHandler.cs
Normal file
40
Assets/Scripts/Gameplay/GameModeHandler.cs
Normal file
@ -0,0 +1,40 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public enum GameModeType
|
||||
{
|
||||
PVP,
|
||||
Bot,
|
||||
}
|
||||
|
||||
public class GameModeHandler : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
|
||||
public GameModeType GameModeType
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
InterfaceManager.Instance.RegisterInterface<GameModeHandler>(this);
|
||||
}
|
||||
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
}
|
||||
|
||||
public void InitPVPModeData(List<PlayerType> types)
|
||||
{
|
||||
GameModeType = GameModeType.PVP;
|
||||
gameplayManager.InitPlayerTypesForPVP(types);
|
||||
}
|
||||
|
||||
public void InitBotModeData(PlayerType selectedPlayer, int botCount)
|
||||
{
|
||||
GameModeType = GameModeType.Bot;
|
||||
gameplayManager.InitPlayerTypesForBotMatch(selectedPlayer, botCount);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Gameplay/GameModeHandler.cs.meta
Normal file
11
Assets/Scripts/Gameplay/GameModeHandler.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d8a94cfc31bb45f9a403db0c1f4c116
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@ -80,7 +80,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
private List<PlayerPawn> availPlayers = new List<PlayerPawn>();
|
||||
private bool canSwitchPlayer = false;
|
||||
|
||||
public bool CanRollDice
|
||||
public bool CanRollDiceForUser
|
||||
{
|
||||
get; private set;
|
||||
}
|
||||
@ -96,20 +96,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
tilesManager = InterfaceManager.Instance.GetInterfaceInstance<TilesManager>();
|
||||
|
||||
CanRollDice = true;
|
||||
CanRollDiceForUser = true;
|
||||
|
||||
// initialize the player list from UI.
|
||||
|
||||
// InitPlayerTypesForLAN(null);
|
||||
InitPlayerTypesForBotMatch(PlayerType.Player1, 3);
|
||||
}
|
||||
|
||||
// TODO :: Call when the UI selection is made and game starts
|
||||
public void InitPlayerTypesForLAN(List<PlayerType> types)
|
||||
public void InitPlayerTypesForPVP(List<PlayerType> types)
|
||||
{
|
||||
// TODO :: 2P, 3P, 4P
|
||||
allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player2, PlayerType.Player3, PlayerType.Player4 };
|
||||
// allPlayerTypes = new List<PlayerType> { PlayerType.Player1, PlayerType.Player3 };
|
||||
allPlayerTypes = new List<PlayerType>(types);
|
||||
|
||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||
InitCurrentGamePlayerInfo();
|
||||
@ -232,7 +228,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
|
||||
public void OnDiceInteracted()
|
||||
{
|
||||
diceRollHandler.HandleDiceView();
|
||||
diceRollHandler.HandleDiceViewForUser();
|
||||
}
|
||||
|
||||
public void RollDiceForPlayer(int rolledVal)
|
||||
@ -264,12 +260,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
return false;
|
||||
}
|
||||
|
||||
private void RollDiceForBot()
|
||||
private void RollDiceForBot(int rolledVal)
|
||||
{
|
||||
Debug.Log($"CallTest: RollDiceForBot");
|
||||
|
||||
// OnDiceRolled(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||
OnDiceRolled(diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue);
|
||||
OnDiceRolled(rolledVal);
|
||||
|
||||
SelectPawnFromBotBase();
|
||||
|
||||
@ -549,7 +545,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
private void CheckDiceRollForBot(PlayerPawn playerPawn)
|
||||
{
|
||||
if (CanRollDiceAgain)
|
||||
RollDiceForBot();
|
||||
{
|
||||
HandleDiceRoll();
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleDiceRoll()
|
||||
{
|
||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||
}
|
||||
|
||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
||||
@ -693,7 +696,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
if (botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||
{
|
||||
Debug.Log($"Invoking RollDiceForBot");
|
||||
Invoke(nameof(RollDiceForBot), 1f);
|
||||
Invoke(nameof(HandleDiceRoll), 1f);
|
||||
}
|
||||
}
|
||||
|
||||
@ -945,6 +948,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
// if (botTypesInGame.Contains(playerType)) return;
|
||||
|
||||
CanRollDice = state;
|
||||
CanRollDiceForUser = state;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
@ -12,32 +13,32 @@ public class DiceRollHandler : MonoBehaviour
|
||||
private void OnMouseDown()
|
||||
{
|
||||
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
||||
if (!inputManager.GameplayManager.CanRollDice) return;
|
||||
|
||||
RollDiceOnClick();
|
||||
// RollDiceOnClick();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
||||
if (!inputManager.GameplayManager.CanRollDice) return;
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.Space))
|
||||
RollDiceOnClick();
|
||||
}
|
||||
|
||||
private void RollDiceOnClick()
|
||||
public void OnUserDiceRollComplete(int rolledVal)
|
||||
{
|
||||
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
||||
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
||||
|
||||
int currentRolledVal = // Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
|
||||
diceTestValue != 0 ? diceTestValue : Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1);
|
||||
inputManager.SetDiceRollValue(currentRolledVal);
|
||||
inputManager.SetDiceRollValue(rolledVal);
|
||||
}
|
||||
|
||||
public void HandleDiceView()
|
||||
public void HandleDiceViewForUser()
|
||||
{
|
||||
diceView.Roll();
|
||||
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
||||
|
||||
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal));
|
||||
}
|
||||
|
||||
public void HandleDiceViewForBot(Action<int> onComplete)
|
||||
{
|
||||
diceView.Roll(onComplete: onComplete);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,7 +5,6 @@ using UnityEngine;
|
||||
public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
{
|
||||
private GameplayManager gameplayManager;
|
||||
private PopupManager popupManager;
|
||||
private ScreenManager screenManager;
|
||||
|
||||
public void Initialize()
|
||||
@ -16,8 +15,6 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
public void InitializeData()
|
||||
{
|
||||
gameplayManager = InterfaceManager.Instance.GetInterfaceInstance<GameplayManager>();
|
||||
popupManager = InterfaceManager.Instance.GetInterfaceInstance<PopupManager>();
|
||||
|
||||
}
|
||||
|
||||
public void OnDiceViewInteracted()
|
||||
@ -38,7 +35,7 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||
}
|
||||
|
||||
public void OnPlayButtonClicked()
|
||||
public void UpdateSelectedPlayerCount(int playersCount)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@ -20,16 +20,18 @@ public class PvAIModePopup : PopupBase
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private SoundManager soundManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
public int SelectedPlayerCount => selectedPlayerCount;
|
||||
private PlayerType playerType;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
twoPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(2));
|
||||
threePlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(3));
|
||||
fourPlayerBtn.onClick.AddListener(() => OnPlayerCountSelected(4));
|
||||
playBtn.onClick.AddListener(OnClick_playBtn);
|
||||
closeBtn.onClick.AddListener(OnClick_closeBtn);
|
||||
playBtn.onClick.AddListener(OnClick_PlayButton);
|
||||
closeBtn.onClick.AddListener(OnClick_CloseButton);
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
@ -45,9 +47,9 @@ public class PvAIModePopup : PopupBase
|
||||
selectedPlayerCount = count;
|
||||
}
|
||||
|
||||
private void OnClick_playBtn()
|
||||
private void OnClick_PlayButton()
|
||||
{
|
||||
playerName = playerNameInput.text;
|
||||
playerName = string.IsNullOrWhiteSpace(playerNameInput.text) ? Ludo_3D_Constants.Player1_Name : playerNameInput.text;
|
||||
|
||||
soundManager = soundManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>() : soundManager;
|
||||
soundManager?.PlayGameSoundClip(SoundType.ButtonClick);
|
||||
@ -57,10 +59,11 @@ public class PvAIModePopup : PopupBase
|
||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||
Debug.Log($"Player 1: {playerName}");
|
||||
|
||||
|
||||
gameModeHandler = gameModeHandler == null ? InterfaceManager.Instance.GetInterfaceInstance<GameModeHandler>() : gameModeHandler;
|
||||
gameModeHandler.InitBotModeData(playerType, selectedPlayerCount - 1);
|
||||
}
|
||||
|
||||
private void OnClick_closeBtn()
|
||||
private void OnClick_CloseButton()
|
||||
{
|
||||
screenManager = screenManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<ScreenManager>() : screenManager;
|
||||
screenManager.ShowScreen(ScreenType.MenuScreen);
|
||||
|
||||
@ -36,8 +36,9 @@ public class PvPModePopup : PopupBase
|
||||
[SerializeField] private TMP_Text playerFourPlaceholder;
|
||||
|
||||
private ScreenManager screenManager;
|
||||
private GameManager gameManager;
|
||||
private SoundManager soundManager;
|
||||
private GameModeHandler gameModeHandler;
|
||||
|
||||
private int selectedPlayerCount;
|
||||
public int SelectedPlayerCount => selectedPlayerCount;
|
||||
|
||||
@ -139,10 +140,33 @@ public class PvPModePopup : PopupBase
|
||||
Debug.Log($"Starting PVP Mode with {selectedPlayerCount} players:");
|
||||
Debug.Log($"Player 1: {playerOneName}");
|
||||
Debug.Log($"Player 2: {playerTwoName}");
|
||||
|
||||
if (selectedPlayerCount >= 3)
|
||||
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.InitPVPModeData(playerTypes);
|
||||
}
|
||||
|
||||
private void OnClick_SwitchBtn()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user