diff --git a/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.LobbyUI.prefab b/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.LobbyUI.prefab
index e1cdbd9d..8985e6c2 100644
--- a/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.LobbyUI.prefab
+++ b/Gameton-06/Assets/Gameton/Resources/UI/Prefabs/UI.LobbyUI.prefab
@@ -2602,6 +2602,8 @@ MonoBehaviour:
wave: {fileID: 4021099301320444836}
playTime: {fileID: 708268260796241340}
score: {fileID: 8600056355742485418}
+ hpPotionCount: {fileID: 3161548932776254936}
+ mpPotionCount: {fileID: 1423836256582408442}
emptyHeartAlert: {fileID: 5022332146818450050}
--- !u!1 &3818176463653432039
GameObject:
@@ -5376,13 +5378,13 @@ MonoBehaviour:
m_text: "\uD558\uD2B8\uAC00 \uBD80\uC871\uD569\uB2C8\uB2E4"
m_isRightToLeft: 0
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_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
- rgba: 4294967295
+ rgba: 4278190080
m_fontColor: {r: 0, g: 0, b: 0, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
diff --git a/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs
new file mode 100644
index 00000000..e8acb149
--- /dev/null
+++ b/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs
@@ -0,0 +1,93 @@
+using System.Collections;
+using System.Collections.Generic;
+using BackEnd;
+using UnityEngine;
+
+namespace TON
+{
+ ///
+ /// 뒤끝 서버 사용자 소모 아이템 데이터 관리 담당 클래스
+ ///
+ public class BackendItemDataManager
+ {
+ // 테이블 이름 상수
+ private const string USER_ITEM_TABLE = "USER_ITEM_DATA";
+
+ public void LoadMyItemData(System.Action 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 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);
+ });
+ }
+
+ ///
+ /// 캐릭터 초기 생성 시 row 삽입
+ ///
+ 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();
+ });
+ }
+
+ }
+}
diff --git a/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs.meta b/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs.meta
new file mode 100644
index 00000000..0f2494c5
--- /dev/null
+++ b/Gameton-06/Assets/Gameton/Scripts/Backend/BackendItemDataManager.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: b1502b07ba467a2408412ceb984db71c
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs b/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs
index ce746422..37ce2969 100644
--- a/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs
+++ b/Gameton-06/Assets/Gameton/Scripts/Character/PlayerDataManager.cs
@@ -12,6 +12,7 @@ namespace TON
public PlayerData player { get; private set; }
public int goldAmount { get; private set; }
public int fishAmount { get; private set; }
+ public UserItemData userItem { get; private set; } = new UserItemData();
public int defensiveIntention { get; private set; } = 200; // 방어력 변수 (조정 가능)
@@ -19,13 +20,16 @@ namespace TON
[SerializeField] private int attackGrowthFactor = 50; // 공격력 성장 변수 (조정 가능)
private BackendCashDataManager cashDataManager;
+ private BackendItemDataManager itemDataManager;
public void Initalize()
{
cashDataManager = new BackendCashDataManager();
+ itemDataManager = new BackendItemDataManager();
LoadPlayerData();
LoadPlayerCashData();
+ LoadPlayerItemData();
}
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)
{
goldAmount += amount;
@@ -104,18 +118,6 @@ namespace TON
});
}
- // 플레이어가 사망했을때 호출
- public void PlayerDeadEvent()
- {
- Invoke(nameof(ShowGameEndUI), 0.5f);
-
- }
- private void ShowGameEndUI()
- {
- UIManager.Show(UIList.GameWinUI);
- }
-
-
// 공격력과 방어력 업데이트
private void UpdateStats(int currentLevel)
{
@@ -176,5 +178,16 @@ namespace TON
}
}
+ // 플레이어가 사망했을때 호출
+ public void PlayerDeadEvent()
+ {
+ Invoke(nameof(ShowGameEndUI), 0.5f);
+
+ }
+ private void ShowGameEndUI()
+ {
+ UIManager.Show(UIList.GameWinUI);
+ }
+
}
}
diff --git a/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs b/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs
new file mode 100644
index 00000000..1f408e13
--- /dev/null
+++ b/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs
@@ -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;
+ }
+ }
+}
diff --git a/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs.meta b/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs.meta
new file mode 100644
index 00000000..b1e4014d
--- /dev/null
+++ b/Gameton-06/Assets/Gameton/Scripts/GameData/UserItemData.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: fb32053a6a7bb30498bb2155fcbffd1a
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Gameton-06/Assets/Gameton/Scripts/UI/LobbyUI.cs b/Gameton-06/Assets/Gameton/Scripts/UI/LobbyUI.cs
index b0b9fb54..f1eb513d 100644
--- a/Gameton-06/Assets/Gameton/Scripts/UI/LobbyUI.cs
+++ b/Gameton-06/Assets/Gameton/Scripts/UI/LobbyUI.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections;
using System.Collections.Generic;
using TMPro;
@@ -23,14 +24,20 @@ namespace TON
[SerializeField] private TextMeshProUGUI playTime;
[SerializeField] private TextMeshProUGUI score;
+ // 보유 포션 수량
+ [SerializeField] private TextMeshProUGUI hpPotionCount;
+ [SerializeField] private TextMeshProUGUI mpPotionCount;
+
public GameObject emptyHeartAlert;
private void OnEnable()
{
SetCharacterData();
+ SetUserItemData();
SetUserRankData();
}
+ // 사용자 최고 기록 데이터 세팅
private void SetUserRankData()
{
ClearData TOP_RECORD = StageManager.Singleton.TOP_RECORD;
@@ -57,6 +64,7 @@ namespace TON
}
}
+ // 캐릭터 기본 스탯 표시
private void SetCharacterData()
{
PlayerData player = PlayerDataManager.Singleton.player;
@@ -73,6 +81,15 @@ namespace TON
characterCritical.text = $"{player.critical}";
}
+ // 사용자 보유 포션 수량 세팅
+ private void SetUserItemData()
+ {
+ UserItemData userItem = PlayerDataManager.Singleton.userItem;
+
+ hpPotionCount.text = $"{userItem.hpPotion}";
+ mpPotionCount.text = $"{userItem.mpPotion}";
+ }
+
public void OnClickStagePlayButton()
{
PlayerPrefs.SetString("StageId", "STG004");