feat: 스테이지 클리어 정보에 따라 slide 데이터 세팅 구조 적용
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace TON
|
||||
@@ -24,7 +25,8 @@ namespace TON
|
||||
|
||||
public List<string> stageList = new List<string> { "STG001", "STG002", "STG003", "STG004" };
|
||||
|
||||
public LobbyUI_StagePage stagePagePrefab;
|
||||
public List<LobbyUI_StagePage> stagePages = new List<LobbyUI_StagePage>();
|
||||
public GameObject stagePagePrefab;
|
||||
public Transform stagePageGroup;
|
||||
|
||||
private void Start()
|
||||
@@ -50,22 +52,38 @@ namespace TON
|
||||
|
||||
private void SetStageData()
|
||||
{
|
||||
stageList.ForEach(stageId =>
|
||||
if (stagePages.Count > 0)
|
||||
{
|
||||
LobbyUI_StagePage stagePage = Instantiate(stagePagePrefab, stagePageGroup);
|
||||
stagePage.Initalize(stageId);
|
||||
});
|
||||
foreach (var stagePage in stagePages)
|
||||
{
|
||||
Destroy(stagePage.gameObject);
|
||||
}
|
||||
stagePages.Clear();
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < stageList.Count; i++)
|
||||
{
|
||||
string stageId = stageList[i];
|
||||
GameObject stagePageObject = Instantiate(stagePagePrefab, stagePageGroup);
|
||||
LobbyUI_StagePage stagePage = stagePageObject.GetComponent<LobbyUI_StagePage>();
|
||||
stagePageObject.SetActive(true);
|
||||
stagePage.Initalize(stageId, i);
|
||||
stagePages.Add(stagePage);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClickChangeStageButton()
|
||||
{
|
||||
// TODO: 스테이지 입장 popupUI 비활성화
|
||||
stagePages.ForEach(page => page.GetComponent<LobbyUI_StagePage>().OnClickStageChangeButton());
|
||||
}
|
||||
|
||||
public void OnClickStageButton()
|
||||
{
|
||||
// TODO: 스테이지 선택 UI 활성화
|
||||
|
||||
GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
|
||||
Debug.Log("OnClickStageButton:: " + currentSelectedGameObject.GetComponent<LobbyUI_StagePage>().stageId);
|
||||
}
|
||||
|
||||
public void OnClickStagePlayButton()
|
||||
|
||||
@@ -11,40 +11,90 @@ namespace TON
|
||||
{
|
||||
public Button stageEntryButton;
|
||||
public GameObject stageImage;
|
||||
public GameObject starPoint;
|
||||
public Transform starGroup;
|
||||
public StageStar starPrefab;
|
||||
|
||||
public GameObject stageEntryUI;
|
||||
public GameObject lockState;
|
||||
|
||||
private string stageId;
|
||||
|
||||
public StageClearData stageClearData;
|
||||
|
||||
public void Initalize(string stageId)
|
||||
|
||||
public string stageId;
|
||||
private SerializableDictionary<string, StageClearData> bestStageClearDict = new SerializableDictionary<string, StageClearData>();
|
||||
|
||||
public void Initalize(string stageId, int index)
|
||||
{
|
||||
this.stageId = stageId;
|
||||
|
||||
if (stageId == "STG001")
|
||||
{
|
||||
lockState.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
SerializableDictionary<string, StageClearData> bestStageClearDict = StageManager.Singleton.bestStageClearDict;
|
||||
stageClearData = bestStageClearDict.GetValueOrDefault(stageId, null);
|
||||
SetStageImage();
|
||||
Debug.Log($"LobbyUI_StagePage stageId: {stageId}");
|
||||
|
||||
// 스테이지 슬롯에 스테이지 클리어 정보가 있는 경우
|
||||
if (stageClearData != null) // 스테이지 슬롯에 별점이 지정된 경우
|
||||
bestStageClearDict = StageManager.Singleton.bestStageClearDict;
|
||||
stageClearData = bestStageClearDict.GetValueOrDefault(stageId, null);
|
||||
|
||||
SetStageImage();
|
||||
SetStageEntryInfo(index);
|
||||
}
|
||||
|
||||
private void SetStageEntryInfo(int index)
|
||||
{
|
||||
if (stageClearData != null)
|
||||
{
|
||||
// for (int i = 0; i < starCount; i++)
|
||||
// {
|
||||
// starPoint.transform.GetChild(i).gameObject.SetActive(true);
|
||||
// }
|
||||
// 스테이지 슬롯에 스테이지 클리어 정보가 있는 경우
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
StageStar stageStar = Instantiate(starPrefab, starGroup);
|
||||
stageStar.gameObject.SetActive(true);
|
||||
if (i < stageClearData.starRating)
|
||||
{
|
||||
stageStar.SetStar(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
stageStar.SetStar(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 이전 스테이지가 클리어되지 않아 진입할 수 없는 경우
|
||||
stageEntryButton.interactable = false;
|
||||
Debug.Log($"StageClearData is null");
|
||||
// 스테이지 슬롯에 스테이지 클리어 정보가 없고 첫번째 스테이지가 아닌 경우
|
||||
if (index != 0)
|
||||
{
|
||||
StageClearData prevStageClearData = bestStageClearDict.GetValueOrDefault($"STG00{index - 1}", null);
|
||||
// 직전 스테이지의 클리어 결과가 있고 별점이 1개 이상인 경우
|
||||
if (prevStageClearData != null && prevStageClearData.starRating > 0)
|
||||
{
|
||||
lockState.SetActive(false);
|
||||
stageEntryButton.interactable = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultStarPoint();
|
||||
// 이전 스테이지를 클리어하지 않은 경우
|
||||
stageEntryButton.interactable = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetDefaultStarPoint();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void SetDefaultStarPoint()
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
StageStar stageStar = Instantiate(starPrefab, starGroup);
|
||||
stageStar.gameObject.SetActive(true);
|
||||
Instantiate(starPrefab, starGroup.transform).SetStar(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,5 +109,10 @@ namespace TON
|
||||
{
|
||||
stageEntryUI.SetActive(true);
|
||||
}
|
||||
|
||||
public void OnClickStageChangeButton()
|
||||
{
|
||||
stageEntryUI.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user