You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

210 lines
7.0 KiB

using IVDataFormat;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using UnityEngine;
public class GameMgr : MonoBehaviour
{
#region Scene
[SerializeField]
private Camera camUI;
#endregion Scene
// 게임 처음 시작시(게임씬 로드) 초기화.
IEnumerator Start()
{
CoverCamera.SetCamera(camUI);
CoverCamera.Hold();
{
// 로컬라이징이 필요한 UI 초기화.
EnhanceMgr.SLocalize(true);
BagMgr.SLocalize(true);
TreasureMgr.SLocalize(true);
SkillMgr.SLocalize(true);
PetMgr.SLocalize(true);
DungeonMgr.SLocalize(true);
GachaMgr.SLocalize(true);
CustomizeMgr.SLocalize(true);
ShopMgr.SLocalize(true);
PassMgr.SLocalize(true);
yield return null;
StageMgr.SLocalize(true);
SettingMgr.SLocalize(true);
MailMgr.SLocalize(true);
NoticeMgr.SLocalize(true);
ChatMgr.SLocalize(true);
AdBuffMgr.SLocalize(true);
GameUIMgr.SLocalize(true);
ProfileMgr.SLocalize(true);
GoodsInfo.SLocalize(true);
QuestMgr.SLocalize(true);
MissionMgr.SLocalize();
PvpMgr.SLocalize(true);
GuardianMgr.SLocalize(true);
MaskMgr.SLocalize(true);
SleepModeMgr.SLocalize(true);
yield return null;
GameUIMgr.SSetPlayerName();
GameUIMgr.SSetPlayerTitle(DataHandler.PlayData.playerTitle);
GameUIMgr.SSetPlayerIcon(DataHandler.PlayData.playerIcon);
GameUIMgr.SSetPlayerLv();
BattleMgr.SInit(camUI);
yield return null;
BattleMgr.SResetSkillPreset();
ChatMgr.SInitializeChat();
AdBuffMgr.InitRemainBuff();
yield return null;
SoundMgr.SPlayBgm(BGM.stage);
SingleMgr.SetPlay(true);
GameUIMgr.SFadeInFullBack(0.5f);
yield return null;
BattleMgr.SInitCostume();
while (BattleMgr.I_InitCos > 0)
{
yield return null;
}
yield return null;
BattleMgr.SSetPet(DataHandler.PlayData.usePetPreset);
BattleMgr.SSetGuardian();
BattleMgr.SInitStage();
yield return null;
MateMgr.Instance.Init();
yield return null;
}
CoverCamera.Release();
PassMgr.SSetBadge(true);
MailMgr.SSetBadgeAndRecieveAllButton();
QuestMgr.SSetBadge();
if (SettingMgr.SGetTest())
GameUIMgr.SOpenPopup2Button("현재 테스트모드 사용중 입니다. \n 오프라인 최대 보상을 받으시겠습니까?", () => OpenOffline(86400));
else
OpenOffline(SingleMgr.I_OfflineTime);
DataHandler.isUpdateNotice();
}
void OnDestroy()
{
ChatMgr.SFinalizeChat();
}
private void OnApplicationPause(bool pause)
{
if (!pause)
{
ChatMgr.SConnectChat();
}
}
// 오프라인 보상 계산.
private void OpenOffline(int itime)
{
SingleMgr.I_OfflineTime = 0;
if (itime < DataHandler.Const.offlineTimeStage)
return;
int iofflinetime = Mathf.Min(itime, DataHandler.Const.offlineTimeMax);
int iclearcnt = iofflinetime / DataHandler.Const.offlineTimeStage;
int iofflinereward = DataHandler.Const.offlineReward;
//BigInteger bichestrateadd = (BigInteger)BuffMgr.Instance.GetChestDropRate() + dConst.RateMax;
//BigInteger bipetboxrateadd = (BigInteger)BuffMgr.Instance.GetPetBoxDropRate() + dConst.RateMax;
List<nGoods> goods = new List<nGoods>();
dArea area = DataHandler.GetArea(DataHandler.PlayData.clearStage);
// 골드 보상.
BigInteger bigold = area.gold;
// 최고 스테이지 보상(버프 포함).
bigold = bigold * (BigInteger)BuffMgr.Instance.GetGoldDropRate() / dConst.RateMax;
// 오프라인 시간에 따른 보상.
bigold = bigold * iclearcnt * iofflinereward / dConst.RateMax;
if (bigold >= 0L)
goods.Add(new nGoods(cGoods.TCurrency, cGoods.CGold, bigold));
DataHandler.AddGold(bigold);
// 경험치 보상.
BigInteger biexp = area.exp;
biexp = biexp * (BigInteger)BuffMgr.Instance.GetExpDropRate() / dConst.RateMax;
biexp = biexp * iclearcnt * iofflinereward / dConst.RateMax;
if (biexp >= 0L)
goods.Add(new nGoods(cGoods.TExp, 0, biexp));
DataHandler.AddPlayerExp(biexp);
// 드롭 아이템 보상.
//dAreaReward[] rewards = area.rewards;
//for (int i = 0; i < rewards.Length; i++)
//{
// BigInteger biitem = rewards[i].rewardProp * rewards[i].rewardCnt;
// biitem = biitem * iclearcnt * iofflinereward / dConst.RateMax;
// // 상자 획득.
// if (rewards[i].rewardType == cGoods.TBox)
// {
// // 장비 상자.
// if (rewards[i].rewardId < cGoods.CBoxPetStart)
// biitem = biitem * bichestrateadd / dConst.RateMax;
// // 펫 상자.
// else if (rewards[i].rewardId < cGoods.CBoxDiary)
// biitem = biitem * bipetboxrateadd / dConst.RateMax;
// biitem /= dConst.RateMax;
// // 획득한 경우.
// if (biitem > 0L)
// {
// goods.Add(new nGoods(rewards[i].rewardType, rewards[i].rewardId, biitem));
// DataHandler.AddBox(rewards[i].rewardId, (int)biitem);
// }
// }
// //// 이벤트 아이템.
// //else if (rewards[i].rewardType == cGoods.TEvent)
// //{
// //}
//}
if (DataHandler.GetSysEventTrade().id != 0)
{
int tradeEventItemCount = (int)((float)iclearcnt / 2 * 1);
if (tradeEventItemCount > 0)
{
goods.Add(new nGoods(cGoods.TEventTrade, 1, tradeEventItemCount));
DataHandler.GetPlayEventTrade().item += tradeEventItemCount;
}
}
if (DataHandler.GetSysEventRaise().id != 0)
{
int raiseEventItemCount = (int)((float)iclearcnt / 10 * 1);
if (raiseEventItemCount > 0)
{
goods.Add(new nGoods(cGoods.TEventRaise, 1, raiseEventItemCount));
DataHandler.GetPlayEventRaise().item += raiseEventItemCount;
}
}
if (DataHandler.GetSysEventRoulette().id != 0)
{
int rouletteEventItemCount = (int)((float)iclearcnt / 10 * 1);
if (rouletteEventItemCount > 0)
{
goods.Add(new nGoods(cGoods.TEventRoulette, 1, rouletteEventItemCount));
DataHandler.GetPlayEventRoulette().item += rouletteEventItemCount;
}
}
GameUIMgr.SOpenPopupOffline(itime, goods);
}
}