feat: 로비 화면의 사용자 포션 아이템 갯수 매핑 로직 추가
This commit is contained in:
@@ -2602,6 +2602,8 @@ MonoBehaviour:
|
|||||||
wave: {fileID: 4021099301320444836}
|
wave: {fileID: 4021099301320444836}
|
||||||
playTime: {fileID: 708268260796241340}
|
playTime: {fileID: 708268260796241340}
|
||||||
score: {fileID: 8600056355742485418}
|
score: {fileID: 8600056355742485418}
|
||||||
|
hpPotionCount: {fileID: 3161548932776254936}
|
||||||
|
mpPotionCount: {fileID: 1423836256582408442}
|
||||||
emptyHeartAlert: {fileID: 5022332146818450050}
|
emptyHeartAlert: {fileID: 5022332146818450050}
|
||||||
--- !u!1 &3818176463653432039
|
--- !u!1 &3818176463653432039
|
||||||
GameObject:
|
GameObject:
|
||||||
@@ -5376,13 +5378,13 @@ MonoBehaviour:
|
|||||||
m_text: "\uD558\uD2B8\uAC00 \uBD80\uC871\uD569\uB2C8\uB2E4"
|
m_text: "\uD558\uD2B8\uAC00 \uBD80\uC871\uD569\uB2C8\uB2E4"
|
||||||
m_isRightToLeft: 0
|
m_isRightToLeft: 0
|
||||||
m_fontAsset: {fileID: 11400000, guid: 3116464c7616674448f2fb05b50bf91b, type: 2}
|
m_fontAsset: {fileID: 11400000, guid: 3116464c7616674448f2fb05b50bf91b, type: 2}
|
||||||
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
m_sharedMaterial: {fileID: -5364670637895760327, guid: 3116464c7616674448f2fb05b50bf91b, type: 2}
|
||||||
m_fontSharedMaterials: []
|
m_fontSharedMaterials: []
|
||||||
m_fontMaterial: {fileID: 0}
|
m_fontMaterial: {fileID: 0}
|
||||||
m_fontMaterials: []
|
m_fontMaterials: []
|
||||||
m_fontColor32:
|
m_fontColor32:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
rgba: 4294967295
|
rgba: 4278190080
|
||||||
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
|
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_enableVertexGradient: 0
|
m_enableVertexGradient: 0
|
||||||
m_colorMode: 3
|
m_colorMode: 3
|
||||||
|
|||||||
@@ -0,0 +1,93 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BackEnd;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TON
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 뒤끝 서버 사용자 소모 아이템 데이터 관리 담당 클래스
|
||||||
|
/// </summary>
|
||||||
|
public class BackendItemDataManager
|
||||||
|
{
|
||||||
|
// 테이블 이름 상수
|
||||||
|
private const string USER_ITEM_TABLE = "USER_ITEM_DATA";
|
||||||
|
|
||||||
|
public void LoadMyItemData(System.Action<UserItemData> onComplete)
|
||||||
|
{
|
||||||
|
UserItemData userItemData = new UserItemData();
|
||||||
|
|
||||||
|
Backend.PlayerData.GetMyData(USER_ITEM_TABLE, callback =>
|
||||||
|
{
|
||||||
|
if (callback.IsSuccess() == false)
|
||||||
|
{
|
||||||
|
Debug.Log("데이터 읽기 중에 문제가 발생했습니다 : " + callback.ToString());
|
||||||
|
onComplete?.Invoke(userItemData); // 에러 상황에서 기본 객체 반환
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 불러오기에는 성공했으나 데이터가 존재하지 않는 경우
|
||||||
|
if (callback.IsSuccess() && callback.FlattenRows().Count <= 0)
|
||||||
|
{
|
||||||
|
Debug.Log("데이터가 존재하지 않습니다");
|
||||||
|
InsertInitData(() =>
|
||||||
|
{
|
||||||
|
// 초기 데이터 삽입 후 다시 데이터를 불러옴
|
||||||
|
LoadDataAfterInsert(onComplete);
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1개 이상 데이터를 불러온 경우
|
||||||
|
if (callback.FlattenRows().Count > 0)
|
||||||
|
{
|
||||||
|
userItemData.hpPotion = int.Parse(callback.FlattenRows()[0]["hp_potion"].ToString());
|
||||||
|
userItemData.mpPotion = int.Parse(callback.FlattenRows()[0]["mp_potion"].ToString());
|
||||||
|
onComplete?.Invoke(userItemData); // 성공 시 데이터 반환
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 데이터 삽입 후 다시 불러오는 메소드
|
||||||
|
private void LoadDataAfterInsert(System.Action<UserItemData> onComplete)
|
||||||
|
{
|
||||||
|
Backend.PlayerData.GetMyData(USER_ITEM_TABLE, callback =>
|
||||||
|
{
|
||||||
|
UserItemData userItemData = new UserItemData();
|
||||||
|
|
||||||
|
if (callback.IsSuccess() && callback.FlattenRows().Count > 0)
|
||||||
|
{
|
||||||
|
userItemData.hpPotion = int.Parse(callback.FlattenRows()[0]["hp_potion"].ToString());
|
||||||
|
userItemData.mpPotion = int.Parse(callback.FlattenRows()[0]["mp_potion"].ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
onComplete?.Invoke(userItemData);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 캐릭터 초기 생성 시 row 삽입
|
||||||
|
/// </summary>
|
||||||
|
public void InsertInitData(System.Action onComplete = null)
|
||||||
|
{
|
||||||
|
Param param = new Param();
|
||||||
|
param.Add("hp_potion", 5);
|
||||||
|
param.Add("mp_potion", 5);
|
||||||
|
|
||||||
|
Backend.PlayerData.InsertData(USER_ITEM_TABLE, param, callback =>
|
||||||
|
{
|
||||||
|
if (callback.IsSuccess())
|
||||||
|
{
|
||||||
|
Debug.Log("초기 데이터 삽입 성공");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("초기 데이터 삽입 실패: " + callback.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
onComplete?.Invoke();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b1502b07ba467a2408412ceb984db71c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,6 +12,7 @@ namespace TON
|
|||||||
public PlayerData player { get; private set; }
|
public PlayerData player { get; private set; }
|
||||||
public int goldAmount { get; private set; }
|
public int goldAmount { get; private set; }
|
||||||
public int fishAmount { get; private set; }
|
public int fishAmount { get; private set; }
|
||||||
|
public UserItemData userItem { get; private set; } = new UserItemData();
|
||||||
|
|
||||||
public int defensiveIntention { get; private set; } = 200; // 방어력 변수 (조정 가능)
|
public int defensiveIntention { get; private set; } = 200; // 방어력 변수 (조정 가능)
|
||||||
|
|
||||||
@@ -19,13 +20,16 @@ namespace TON
|
|||||||
[SerializeField] private int attackGrowthFactor = 50; // 공격력 성장 변수 (조정 가능)
|
[SerializeField] private int attackGrowthFactor = 50; // 공격력 성장 변수 (조정 가능)
|
||||||
|
|
||||||
private BackendCashDataManager cashDataManager;
|
private BackendCashDataManager cashDataManager;
|
||||||
|
private BackendItemDataManager itemDataManager;
|
||||||
|
|
||||||
public void Initalize()
|
public void Initalize()
|
||||||
{
|
{
|
||||||
cashDataManager = new BackendCashDataManager();
|
cashDataManager = new BackendCashDataManager();
|
||||||
|
itemDataManager = new BackendItemDataManager();
|
||||||
|
|
||||||
LoadPlayerData();
|
LoadPlayerData();
|
||||||
LoadPlayerCashData();
|
LoadPlayerCashData();
|
||||||
|
LoadPlayerItemData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadPlayerData()
|
private void LoadPlayerData()
|
||||||
@@ -54,6 +58,16 @@ namespace TON
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void LoadPlayerItemData()
|
||||||
|
{
|
||||||
|
itemDataManager.LoadMyItemData(userItemData =>
|
||||||
|
{
|
||||||
|
userItem.hpPotion = userItemData.hpPotion;
|
||||||
|
userItem.mpPotion = userItemData.mpPotion;
|
||||||
|
Debug.Log($"로드된 hp포션: {userItemData.hpPotion}, mp포션: {userItemData.mpPotion}");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public void AddGold(int amount)
|
public void AddGold(int amount)
|
||||||
{
|
{
|
||||||
goldAmount += amount;
|
goldAmount += amount;
|
||||||
@@ -104,18 +118,6 @@ namespace TON
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 플레이어가 사망했을때 호출
|
|
||||||
public void PlayerDeadEvent()
|
|
||||||
{
|
|
||||||
Invoke(nameof(ShowGameEndUI), 0.5f);
|
|
||||||
|
|
||||||
}
|
|
||||||
private void ShowGameEndUI()
|
|
||||||
{
|
|
||||||
UIManager.Show<GameWinUI>(UIList.GameWinUI);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 공격력과 방어력 업데이트
|
// 공격력과 방어력 업데이트
|
||||||
private void UpdateStats(int currentLevel)
|
private void UpdateStats(int currentLevel)
|
||||||
{
|
{
|
||||||
@@ -176,5 +178,16 @@ namespace TON
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 플레이어가 사망했을때 호출
|
||||||
|
public void PlayerDeadEvent()
|
||||||
|
{
|
||||||
|
Invoke(nameof(ShowGameEndUI), 0.5f);
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ShowGameEndUI()
|
||||||
|
{
|
||||||
|
UIManager.Show<GameWinUI>(UIList.GameWinUI);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
19
Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs
Normal file
19
Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace TON
|
||||||
|
{
|
||||||
|
[System.Serializable]
|
||||||
|
public class UserItemData
|
||||||
|
{
|
||||||
|
public int hpPotion;
|
||||||
|
public int mpPotion;
|
||||||
|
|
||||||
|
public UserItemData()
|
||||||
|
{
|
||||||
|
hpPotion = 0;
|
||||||
|
mpPotion = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: fb32053a6a7bb30498bb2155fcbffd1a
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
@@ -23,14 +24,20 @@ namespace TON
|
|||||||
[SerializeField] private TextMeshProUGUI playTime;
|
[SerializeField] private TextMeshProUGUI playTime;
|
||||||
[SerializeField] private TextMeshProUGUI score;
|
[SerializeField] private TextMeshProUGUI score;
|
||||||
|
|
||||||
|
// 보유 포션 수량
|
||||||
|
[SerializeField] private TextMeshProUGUI hpPotionCount;
|
||||||
|
[SerializeField] private TextMeshProUGUI mpPotionCount;
|
||||||
|
|
||||||
public GameObject emptyHeartAlert;
|
public GameObject emptyHeartAlert;
|
||||||
|
|
||||||
private void OnEnable()
|
private void OnEnable()
|
||||||
{
|
{
|
||||||
SetCharacterData();
|
SetCharacterData();
|
||||||
|
SetUserItemData();
|
||||||
SetUserRankData();
|
SetUserRankData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 사용자 최고 기록 데이터 세팅
|
||||||
private void SetUserRankData()
|
private void SetUserRankData()
|
||||||
{
|
{
|
||||||
ClearData TOP_RECORD = StageManager.Singleton.TOP_RECORD;
|
ClearData TOP_RECORD = StageManager.Singleton.TOP_RECORD;
|
||||||
@@ -57,6 +64,7 @@ namespace TON
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 캐릭터 기본 스탯 표시
|
||||||
private void SetCharacterData()
|
private void SetCharacterData()
|
||||||
{
|
{
|
||||||
PlayerData player = PlayerDataManager.Singleton.player;
|
PlayerData player = PlayerDataManager.Singleton.player;
|
||||||
@@ -73,6 +81,15 @@ namespace TON
|
|||||||
characterCritical.text = $"{player.critical}";
|
characterCritical.text = $"{player.critical}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 사용자 보유 포션 수량 세팅
|
||||||
|
private void SetUserItemData()
|
||||||
|
{
|
||||||
|
UserItemData userItem = PlayerDataManager.Singleton.userItem;
|
||||||
|
|
||||||
|
hpPotionCount.text = $"{userItem.hpPotion}";
|
||||||
|
mpPotionCount.text = $"{userItem.mpPotion}";
|
||||||
|
}
|
||||||
|
|
||||||
public void OnClickStagePlayButton()
|
public void OnClickStagePlayButton()
|
||||||
{
|
{
|
||||||
PlayerPrefs.SetString("StageId", "STG004");
|
PlayerPrefs.SetString("StageId", "STG004");
|
||||||
|
|||||||
Reference in New Issue
Block a user