2026-01-30 11:30:40 +05:30
|
|
|
using System;
|
2026-01-21 20:27:45 +05:30
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2026-01-30 09:35:31 +05:30
|
|
|
public class DiceRollHandler : MonoBehaviour
|
2026-01-21 20:27:45 +05:30
|
|
|
{
|
2026-01-30 09:35:31 +05:30
|
|
|
[SerializeField] private DiceView diceView;
|
2026-01-22 20:50:41 +05:30
|
|
|
[SerializeField] private int diceTestValue = 0;
|
|
|
|
|
|
2026-01-21 20:27:45 +05:30
|
|
|
private InputManager inputManager;
|
2026-01-30 19:04:14 +05:30
|
|
|
|
2026-01-21 20:27:45 +05:30
|
|
|
private void OnMouseDown()
|
|
|
|
|
{
|
|
|
|
|
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
|
|
|
|
|
2026-01-30 11:30:40 +05:30
|
|
|
// RollDiceOnClick();
|
2026-01-21 20:27:45 +05:30
|
|
|
}
|
|
|
|
|
|
2026-01-22 20:50:41 +05:30
|
|
|
private void Update()
|
|
|
|
|
{
|
|
|
|
|
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-30 11:30:40 +05:30
|
|
|
public void OnUserDiceRollComplete(int rolledVal)
|
2026-01-21 20:27:45 +05:30
|
|
|
{
|
2026-01-30 11:30:40 +05:30
|
|
|
inputManager.SetDiceRollValue(rolledVal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void HandleDiceViewForUser()
|
|
|
|
|
{
|
|
|
|
|
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
|
|
|
|
|
|
2026-01-30 19:04:14 +05:30
|
|
|
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
|
|
|
|
|
soundManager?.PlayGameSoundClip(SoundType.Dice);
|
|
|
|
|
|
2026-01-31 20:33:50 +05:30
|
|
|
if (inputManager.GameplayManager.IsDebugTest)
|
|
|
|
|
OnUserDiceRollComplete(GetDiceTestVal());
|
|
|
|
|
else
|
|
|
|
|
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
|
2026-01-21 20:27:45 +05:30
|
|
|
}
|
2026-01-30 09:35:31 +05:30
|
|
|
|
2026-01-30 11:30:40 +05:30
|
|
|
public void HandleDiceViewForBot(Action<int> onComplete)
|
2026-01-30 09:35:31 +05:30
|
|
|
{
|
2026-01-31 20:33:50 +05:30
|
|
|
diceView.Roll(onComplete: onComplete, true);
|
2026-01-30 09:35:31 +05:30
|
|
|
}
|
2026-01-30 19:04:14 +05:30
|
|
|
|
|
|
|
|
public void HandleDiceViewForBot(Action<int> onComplete, int val)
|
|
|
|
|
{
|
|
|
|
|
onComplete?.Invoke(val);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int GetDiceTestVal() => diceTestValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceTestValue;
|
2026-01-21 20:27:45 +05:30
|
|
|
}
|