룰렛 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}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,18 +26,6 @@ namespace TON
 | 
			
		||||
        private int accumulatedWeight;  // 가중치 계산을 위한 변수
 | 
			
		||||
        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()
 | 
			
		||||
        {
 | 
			
		||||
@@ -45,8 +33,6 @@ namespace TON
 | 
			
		||||
            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,33 +1,31 @@
 | 
			
		||||
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;
 | 
			
		||||
        [SerializeField] private Button buttonSpin;
 | 
			
		||||
        
 | 
			
		||||
        // TODO : Roulette 변수 선언
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        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