Ludo-3D/Assets/Scripts/Input/DiceRollHandler.cs

45 lines
1.3 KiB
C#
Raw Normal View History

using System;
2026-01-21 20:27:45 +05:30
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DiceRollHandler : MonoBehaviour
2026-01-21 20:27:45 +05:30
{
[SerializeField] private DiceView diceView;
[SerializeField] private int diceTestValue = 0;
2026-01-21 20:27:45 +05:30
private InputManager inputManager;
private void OnMouseDown()
{
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
// RollDiceOnClick();
2026-01-21 20:27:45 +05:30
}
private void Update()
{
inputManager = inputManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<InputManager>() : inputManager;
}
public void OnUserDiceRollComplete(int rolledVal)
2026-01-21 20:27:45 +05:30
{
SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance<SoundManager>();
soundManager?.PlayGameSoundClip(SoundType.Dice);
inputManager.SetDiceRollValue(rolledVal);
}
public void HandleDiceViewForUser()
{
if (!inputManager.GameplayManager.CanRollDiceForUser) return;
2026-01-30 12:54:43 +05:30
diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false);
2026-01-21 20:27:45 +05:30
}
public void HandleDiceViewForBot(Action<int> onComplete)
{
2026-01-30 12:54:43 +05:30
diceView.Roll(onComplete: (val) => onComplete?.Invoke(val), true);
}
2026-01-21 20:27:45 +05:30
}