룰렛 mvp 패턴 적용 중...
This commit is contained in:
@@ -6297,7 +6297,7 @@ MonoBehaviour:
|
||||
weight: 0
|
||||
- icon: {fileID: 21300000, guid: 50787c1045972c64690b9a12c89b24e1, type: 3}
|
||||
description: 2
|
||||
chance: 15
|
||||
chance: 14
|
||||
index: 0
|
||||
weight: 0
|
||||
- icon: {fileID: 21300000, guid: 50787c1045972c64690b9a12c89b24e1, type: 3}
|
||||
|
||||
@@ -27,26 +27,12 @@ namespace TON
|
||||
private bool isSpinning = false; // 현재 회전중인지
|
||||
private int selectedIndex = 0; // 룰렛에서 선택된 아이템
|
||||
|
||||
private RoulettePresenter _presenter;
|
||||
|
||||
public void Bind(RouletteItemPresenter presenter)
|
||||
{
|
||||
// presenter.Gold.Subscribe()
|
||||
}
|
||||
|
||||
public class RouletteItemPresenter
|
||||
{
|
||||
public ReactiveProperty<int> Gold { get; set; }
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
pieceAngle = 360 / roulettePieceData.Length;
|
||||
halfPieceAngle = pieceAngle * 0.5f;
|
||||
halfPieceAngleWithPaddings = halfPieceAngle - (halfPieceAngle * 0.25f);
|
||||
|
||||
_presenter = new RoulettePresenter();
|
||||
|
||||
SpawnPiecesAndLines();
|
||||
CalculateWeightsAndIndices();
|
||||
}
|
||||
|
||||
@@ -19,5 +19,12 @@ namespace TON
|
||||
|
||||
[HideInInspector] public int index; // 아이템 순번
|
||||
[HideInInspector] public int weight; // 가중치
|
||||
|
||||
public RoulettePieceData(string Description, int Chance)
|
||||
{
|
||||
// icon = null; // 기본 아이콘은 null
|
||||
description = Description; // 기본 설명
|
||||
chance = Chance; // 기본 확률
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,8 @@ namespace TON
|
||||
public class RoulettePresenter
|
||||
{
|
||||
private PlayerDataManager playerDataManager;
|
||||
private List<RoulettePieceData> roulettePieceData = new();
|
||||
private List<RoulettePieceData> roulettePieceModels = new();
|
||||
public ReactiveCollection<RoulettePresenter> RoulettePieces { get; } = new();
|
||||
|
||||
public RoulettePresenter()
|
||||
{
|
||||
@@ -22,11 +23,16 @@ namespace TON
|
||||
|
||||
// Todo : UI 바인딩
|
||||
|
||||
roulettePieceData.Add(new RoulettePieceData());
|
||||
roulettePieceModels.Add(new RoulettePieceData("10", 1));
|
||||
roulettePieceModels.Add(new RoulettePieceData("2", 14));
|
||||
roulettePieceModels.Add(new RoulettePieceData("25", 1));
|
||||
roulettePieceModels.Add(new RoulettePieceData("400", 72));
|
||||
roulettePieceModels.Add(new RoulettePieceData("50", 1));
|
||||
roulettePieceModels.Add(new RoulettePieceData("1000", 11));
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
foreach (var item in roulettePieceModels)
|
||||
{
|
||||
roulettePieceData[i].description = 10.ToString();
|
||||
RoulettePieces.Add(new RoulettePresenter(this, item));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
using System.Collections;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
{
|
||||
// View
|
||||
// View <> Presenter <> Model
|
||||
public class RouletteSpin : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Roulette roulette;
|
||||
@@ -15,19 +17,15 @@ namespace TON
|
||||
|
||||
private RoulettePresenter roulettePresenter;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// Presenter 초기화
|
||||
roulettePresenter = new RoulettePresenter();
|
||||
// TODO : UI와 Presenter 바인딩
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// // 싱글톤으로 PlayerDataManager 접근
|
||||
// playerDataManager = PlayerDataManager.Singleton;
|
||||
//
|
||||
// if (playerDataManager == null)
|
||||
// {
|
||||
// Debug.LogError("PlayerDataManager가 초기화되지 않았습니다.");
|
||||
// }
|
||||
|
||||
// TODO : Presenter 초기화
|
||||
// TODO : UI와 Presenter 바인딩
|
||||
|
||||
buttonSpin.onClick.AddListener(()=>
|
||||
{
|
||||
buttonSpin.interactable = false;
|
||||
@@ -42,4 +40,26 @@ namespace TON
|
||||
roulettePresenter.InsertRouletteResult(selectedData);
|
||||
}
|
||||
}
|
||||
|
||||
// Presenter
|
||||
public class RouletteItemPresenter
|
||||
{
|
||||
public ReactiveProperty<string> Description { get; set; }
|
||||
public ReactiveProperty<int> Chance { get; set; }
|
||||
|
||||
public ReactiveCommand BuyCommand { get; set; }
|
||||
|
||||
private RoulettePieceData _model;
|
||||
|
||||
public RouletteItemPresenter(RoulettePresenter roulettePresenter, RoulettePieceData model)
|
||||
{
|
||||
_model = model;
|
||||
|
||||
Description = new ReactiveProperty<string>(model.description);
|
||||
Chance = new ReactiveProperty<int>(model.chance);
|
||||
|
||||
BuyCommand = new ReactiveCommand();
|
||||
BuyCommand.Subscribe(_ => roulettePresenter.InsertRouletteResult(this));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user