Ludo-3D/Assets/Scripts/Input/DiceRollHandler.cs
Ashby Issac 9eef3eb04c Merge branch 'Gameplay/ashby-gameplay' into Gameplay/main-gameplay
# Conflicts:
#	Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs
#	Assets/Scripts/Gameplay/GameplayManager.cs
#	Assets/Scripts/Input/DiceRollHandler.cs
2026-01-30 12:57:17 +05:30

45 lines
1.3 KiB
C#

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