스테이지 -> 로비, 스탯 저장

This commit is contained in:
Ino 2025-06-28 09:28:41 +09:00
parent a934e89e1b
commit 029901437d
12 changed files with 270 additions and 39 deletions

View File

@ -87,10 +87,3 @@ messageinfo 엄청 느린 버그
보스몬스터 좀 더 보완
다른 게임 참조해서 인게임 다듬어 보자.
스킬 등 인게임 부족한 부분 보완하자.

View File

@ -277,6 +277,8 @@ handlers.ServerSave_AllData = function(args)
var error = Get_Error(args.Token);
if(error < 0) return {error:error};
log.info(args.AllData);
server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Permission: "Public", Data: {"UserInfo": JSON.stringify(args.AllData)} });
return {
@ -284,6 +286,120 @@ handlers.ServerSave_AllData = function(args)
}
}
/////////////////////////////////// 서버 처리
function Get_JsonUserData()
{
return JSON.parse(server.GetUserReadOnlyData({ PlayFabId: currentPlayerId }).Data.UserInfo.Value);
}
function Set_JsonUserData(urod)
{
server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Permission: "Public", Data: {"UserInfo": JSON.stringify(urod)} });
}
function Add_MissionCount(purpose, conditionvalue, count, setValue) {
if (count <= 0) return;
var table = Get_MissionTable(); // 전체 미션 테이블
var matchingMissions = [];
// 조건에 맞는 미션만 추림
for (var i = 0; i < table.length; i++) {
if (table[i].e_MissionConditionType == purpose)
{
matchingMissions.push(table[i]);
log.info(purpose + " : " + table[i].e_MissionConditionType + ", " + table[i].n_MissionGroupId + ", " + table[i].n_MissionIndex);
}
}
// 조건에 맞는 미션들만 처리
for (var i = 0; i < matchingMissions.length; i++) {
var mission = matchingMissions[i];
// 조건 값 확인
if (mission.n_MissionConditionValue === 0 || conditionvalue === mission.n_MissionConditionValue) {
var key1 = Get_Key(mission.n_MissionGroupId);
var key2 = Get_Key(mission.n_MissionIndex);
if (!Mission[key1]) Mission[key1] = {};
if (!Mission[key1][key2]) Mission[key1][key2] = [0, 0]; // 예: [목표값, 현재값]
if (setValue)
Mission[key1][key2][1] = count;
else
Mission[key1][key2][1] += count;
}
}
}
function Get_Exp(lv) {
var base = (lv * 10) + 21 + (lv * 50);
var exp = Math.pow(base, 1.05 + Math.sqrt(lv * 0.0000000001));
return Math.max(Math.floor(exp), 0);
}
handlers.Save_StageResult = function(args) {
var error = Get_Error(args.Token);
if (error < 0) return { error: error };
var urod = Get_JsonUserData();
// 경험치 처리
urod.PC.Exp += args.Exp;
while (urod.PC.Exp >= Get_Exp(urod.PC.Lv + 1)) {
urod.PC.Lv++;
}
// 아이템 처리 (args.Item은 JS object 형태로 전달됨)
var items = args.Item; // ex: { "1001": 3, "1002": 1 }
for (var key in items) {
var itemId = key;
var itemCount = items[key];
if (!urod.Item[itemId]) urod.Item[itemId] = [0, 0, 0];
urod.Item[itemId][0] += itemCount;
urod.Item[itemId][1] += itemCount;
}
Set_JsonUserData(urod);
return {
error: 0
};
}
handlers.Save_PC_Stat = function(args)
{
var error = Get_Error(args.Token);
if (error < 0) return { error: error };
if (!args.UsePoint || args.UsePoint.length !== 4) {
return { error: 2 }; // invalid input
}
for (var i = 0; i < 4; i++) {
if (args.UsePoint[i] < 0)
return { error: 3 }; // no negative values allowed
}
var urod = Get_JsonUserData();
var usedPoint = urod.PC.Stat.reduce((a, b) => a + b, 0);
var totalPoint = (urod.PC.Lv - 1) * 5;
var remainPoint = totalPoint - usedPoint;
var curUsePoint = args.UsePoint.reduce((a, b) => a + b, 0);
if (curUsePoint <= remainPoint) {
for (var i = 0; i < 4; i++) {
urod.PC.Stat[i] += args.UsePoint[i];
}
Add_MissionCount("HERO_STAT_UPGRADE_ACC", 0, curUsePoint, false);
Set_JsonUserData(urod);
return { error: 0 };
} else {
return { error: 1 }; // not enough points
}
};
/////////////////////////////////// 서버 처리
handlers.Write_UnityInApp = function(args)
{
server.UpdateUserReadOnlyData({ PlayFabId: currentPlayerId, Permission: "Public", Data: {"UserInfo": JSON.stringify(args.AllData)} });
@ -873,6 +989,11 @@ handlers.GetOtherData = function(args)
function Get_Inventory()
{
return server.GetUserInventory({ PlayFabId: currentPlayerId });
@ -905,6 +1026,11 @@ function Get_ShopTable()
var titleData = server.GetTitleInternalData({ Keys: ["ShopTable"] });
return JSON.parse(titleData.Data.ShopTable);
}
function Get_MissionTable()
{
var titleData = server.GetTitleInternalData({ Keys: ["MissionTable"] });
return JSON.parse(titleData.Data.MissionTable);
}
function Get_PlayOCoupons()
{
var poc = JSON.parse(server.GetTitleInternalData("PlayO").Data.PlayO);

File diff suppressed because one or more lines are too long

Binary file not shown.

View File

@ -427,6 +427,8 @@ public class MobActor : Actor
var exp = m_MonsterAppearData.n_DropExp;
exp += (uint)(exp * (pcstat.Get_Stat(eStat.EXP_Multiplier) + pcstat.Get_Stat(eStat.Battle_EXP_Multiplier)));
sdata.PC.Add_Exp(exp);
DropItemInfo.Ins.m_StageDropData.GetExp += exp;
DropItemInfo.Ins.m_StageDropData.GetExp.RandomizeCryptoKey();
// 아이템 드랍
var rndBag = table_randombag.Ins.Get_DataList(m_MonsterAppearData.n_DropReward);

View File

@ -1,5 +1,6 @@
using CodeStage.AntiCheat.ObscuredTypes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DropItem : ProjectileBase
@ -121,6 +122,7 @@ public class DropItem : ProjectileBase
m_itemamount = Random.Range(mingold, maxgold);
}
sdata.Add_Item(m_itemid, _itemamount);
DropItemInfo.Ins.m_StageDropData.Add_Item(_itemid, m_itemamount);
}
InGameInfo.Ins.Show_Effect("Effect_GetCoin", transform.position);

View File

@ -1,6 +1,7 @@
using CodeStage.AntiCheat.ObscuredTypes;
using System.Collections.Generic;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine;
using UnityEngine.ResourceManagement.AsyncOperations;
public class DropItemInfo : MonoBehaviourSingletonTemplate<DropItemInfo>
{
@ -13,6 +14,8 @@ public class DropItemInfo : MonoBehaviourSingletonTemplate<DropItemInfo>
};
List<DropItem> list_dropitems = new List<DropItem>();
public StageDropData m_StageDropData = new StageDropData();
private void Start()
{
Make_DropItem(-1, 2);
@ -21,6 +24,8 @@ public class DropItemInfo : MonoBehaviourSingletonTemplate<DropItemInfo>
public void AllOff()
{
m_StageDropData.Init();
foreach (var item in dic_dropitem)
for (int i = 0; i < item.Value.Count; i++)
item.Value[i].gameObject.SetActive(false);
@ -107,3 +112,24 @@ public class DropItemInfo : MonoBehaviourSingletonTemplate<DropItemInfo>
return nearestItem;
}
}
public class StageDropData
{
public ObscuredUInt GetExp;
Dictionary<int, ObscuredInt> Item = new Dictionary<int, ObscuredInt>();
public void Init()
{
GetExp = 0;
GetExp.RandomizeCryptoKey();
Item.Clear();
}
public void Add_Item(int itemid, int count)
{
if (!Item.ContainsKey(itemid)) Item.Add(itemid, 0);
Item[itemid] += count;
Item[itemid].RandomizeCryptoKey();
}
public Dictionary<int, ObscuredInt> Get_Item() { return Item; }
}

View File

@ -45,26 +45,23 @@ public class ServerInfo : MyCoroutine
void Update()
{
ServerTime = ServerTime.AddSeconds(Time.unscaledDeltaTime);
m_relogintime += Time.unscaledDeltaTime;
if (m_relogintime > 43200f) // 12시간
{
m_relogintime = 0f;
Login(null, () =>
{
m_relogintime = 43000f; // 실패 시, 200초 뒤에 다시 시도
});
}
// 인터넷 연결 체크
if (Application.internetReachability == NetworkReachability.NotReachable)
{
return;
}
if (ServerTimeUpdate)
{
ServerTime = ServerTime.AddSeconds(Time.unscaledDeltaTime);
m_relogintime += Time.unscaledDeltaTime;
if (m_relogintime > 43200f) // 12시간
{
m_relogintime = 0f;
Login(null, () =>
{
m_relogintime = 43000f; // 실패 시, 200초 뒤에 다시 시도
});
}
m_serverTimeRefresh += Time.unscaledDeltaTime;
if (m_serverTimeRefresh > 300f) // 5분
{
@ -751,7 +748,85 @@ public class ServerInfo : MyCoroutine
public bool IsNewUser() { return string.IsNullOrEmpty(UserName); }
#region
#region
public void Save_StageResult(Action _act = null)
{
NetWait.Ins.Set(true);
Dictionary<string, int> items = new Dictionary<string, int>();
var dropitem = DropItemInfo.Ins.m_StageDropData.Get_Item();
foreach (var item in dropitem)
items.Add(item.Key.ToString(), item.Value.GetDecrypted());
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest
{
FunctionName = "Save_StageResult",
GeneratePlayStreamEvent = true,
FunctionParameter = new
{
Token = m_LoginInfo.EntityToken.EntityToken,
Exp = DropItemInfo.Ins.m_StageDropData.GetExp.GetDecrypted(),
Item = items
}
},
result =>
{
if (result.Error == null)
{
NetWait.Ins.Set(false);
var error = MyErrorCheck(result.FunctionResult.ToString());
switch (error)
{
case 0: _act?.Invoke(); break;
//case 1: ToastUI.Ins.Set(999900001); break;
//default: ToastUI.Ins.Set(999900002); break;
}
}
else
Set_Coroutine(() => { Save_StageResult(_act); }, 2f);
},
fail =>
{
Set_Coroutine(() => { Save_StageResult(_act); }, 2f);
});
}
public void Save_PC_Stat(List<int> usepoint, Action _act)
{
NetWait.Ins.Set(true);
PlayFabClientAPI.ExecuteCloudScript(new ExecuteCloudScriptRequest
{
FunctionName = "Save_PC_Stat",
GeneratePlayStreamEvent = true,
FunctionParameter = new
{
Token = m_LoginInfo.EntityToken.EntityToken,
UsePoint = usepoint,
}
},
result =>
{
if (result.Error == null)
{
NetWait.Ins.Set(false);
var error = MyErrorCheck(result.FunctionResult.ToString());
switch (error)
{
case 0: _act?.Invoke(); break;
case 1: ToastUI.Ins.Set(999900001); break;
default: ToastUI.Ins.Set(999900002); break;
}
}
else
Set_Coroutine(() => { Save_PC_Stat(usepoint, _act); }, 2f);
},
fail =>
{
Set_Coroutine(() => { Save_PC_Stat(usepoint, _act); }, 2f);
});
}
#endregion
#region
public void Get_MailList(bool _netwait, Action<SC_Mail> _act)
{
if (NewGameUI.isIns) NewGameUI.Ins.gos_noti[0].SetActive(false);

View File

@ -178,8 +178,11 @@ public class btn_gacha : MonoBehaviour
sdata.Add_MissionCount(ePurpose.GACHA_EQUIP_ACC, 0, m_Count);
}
ObtainItemUI.Ins.Set(items);
NewGameUI.Ins.m_GachaUI.Set_Money();
NewGameUI.Ins.m_GachaUI.m_gachaBase.Set_UI();
ServerInfo.Ins.Write(() =>
{
ObtainItemUI.Ins.Set(items);
NewGameUI.Ins.m_GachaUI.Set_Money();
NewGameUI.Ins.m_GachaUI.m_gachaBase.Set_UI();
});
}
}

View File

@ -125,7 +125,10 @@ public class NewGameUI : MonoBehaviourSingletonTemplate<NewGameUI>
else if (InGameInfo.Ins.IsGameMode(eGameMode.Dungeon))
DungeonInfo.Ins.Stop_Dungeon(null);
else
{
ServerInfo.Ins.Save_StageResult();
InGameInfo.Ins.Return_To_Lobby();
}
TestMapUIMgr.Ins.Set_TestBtns(false);
break;

View File

@ -70,14 +70,21 @@ public class PCInfoStatMgrUI : uScrollViewMgr
public void OnClick_Save()
{
var sdata = ServerInfo.Ins.m_ServerData;
foreach (var item in dic_SaveStat)
var lst = new List<int> { dic_SaveStat[eStat.STR], dic_SaveStat[eStat.DEX], dic_SaveStat[eStat.INT], dic_SaveStat[eStat.LUK] };
if (lst.Sum() > 0)
{
sdata.PC.Add_StatPoint(item.Key, item.Value);
sdata.Add_MissionCount(ePurpose.HERO_STAT_UPGRADE_ACC, 0, item.Value);
ServerInfo.Ins.Save_PC_Stat(lst, () =>
{
var sdata = ServerInfo.Ins.m_ServerData;
foreach (var item in dic_SaveStat)
{
sdata.PC.Add_StatPoint(item.Key, item.Value);
sdata.Add_MissionCount(ePurpose.HERO_STAT_UPGRADE_ACC, 0, item.Value);
}
Set_UI();
MyValue.Get_ActorStatInfoorNull(eRole.PC);
});
}
Set_UI();
MyValue.Get_ActorStatInfoorNull(eRole.PC);
}
public void OnClick_Reset()

View File

@ -1,6 +1,5 @@
using TMPro;
using UnityEngine.UI;
using static InvBaseItem;
/// <summary>
/// 초월 정보 (전 레벨 -> 다음 레벨)
@ -12,11 +11,6 @@ public class PCLimit_Center : PCLimit_StatInfo
BreakingLimitTableData m_CurData, m_NextData;
private void Awake()
{
ServerInfo.Ins.m_ServerData.PC.Add_Exp(3000);
}
public void Set()
{
var sdata = ServerInfo.Ins.m_ServerData;