Files
M-Gameton-06/Gameton-06/Assets/Gameton/Scripts/UI/RouletteSpin/RouletteSpin.cs
Mingu Kim 8cae00f132 룰렛에 mvp 패턴 추가중
- 룰렛 결과에 따른 재화 획득 기능 추가
2025-06-19 21:29:50 +09:00

50 lines
1.3 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace TON
{
public class RouletteSpin : MonoBehaviour
{
[SerializeField] private Roulette roulette;
[SerializeField] private Button buttonSpin;
private PlayerDataManager playerDataManager;
private void Awake()
{
// 싱글톤으로 PlayerDataManager 접근
playerDataManager = PlayerDataManager.Singleton;
if (playerDataManager == null)
{
Debug.LogError("PlayerDataManager가 초기화되지 않았습니다.");
}
buttonSpin.onClick.AddListener(()=>
{
buttonSpin.interactable = false;
roulette.Spin(EndOfSpin);
});
}
private void EndOfSpin(RoulettePieceData selectedData)
{
buttonSpin.interactable = true;
// 재화 획득 코드 추가
playerDataManager.AddGold(int.Parse(selectedData.description));
// UI 갱신 코드 추가
UIManager.Singleton.UpdateCashData();
Debug.Log($"{selectedData.index}:{selectedData.description}");
}
public class RoulettePresenter
{
}
}
}