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.
927 lines
38 KiB
927 lines
38 KiB
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using IVDataFormat;
|
|
using TMPro;
|
|
using System;
|
|
using EnhancedUI;
|
|
using System.Collections.Generic;
|
|
|
|
public class DungeonMgr : MonoSingleton<DungeonMgr>
|
|
{
|
|
public enum DungeonKind
|
|
{
|
|
DeepCave,
|
|
Atlantis,
|
|
ProtectTheMerchant,
|
|
DevelopTheJungle,
|
|
HuntEagle,
|
|
}
|
|
|
|
#region UI
|
|
[SerializeField]
|
|
private Canvas canvasUI;
|
|
[SerializeField]
|
|
TextMeshProUGUI txtMainT;
|
|
[SerializeField]
|
|
Button mainDungeonButton;
|
|
GameObject mainLock;
|
|
|
|
[SerializeField]
|
|
Canvas dungeonLeftPn;
|
|
GameObject leftCanvasUI;
|
|
|
|
GameObject leftPanel;
|
|
Image dungeonImage;
|
|
TextMeshProUGUI dungeonName;
|
|
[SerializeField]
|
|
GoodsItem[] rewardItem;
|
|
[SerializeField]
|
|
GameObject[] dungeonPanel;
|
|
GameObject[] objDungeonSelect = new GameObject[5];
|
|
GameObject[] objDungeonLock = new GameObject[5];
|
|
ButtonIV btnDungeonSkip;
|
|
[SerializeField] ButtonIV[] btnTabs;
|
|
[SerializeField] EScrController escrDungeonSelect;
|
|
Toggle autoProgressToggle;
|
|
#endregion
|
|
|
|
[SerializeField] bool autoProgress = false;
|
|
|
|
private int iLoading = 1;
|
|
private bool bReLocalize = true;
|
|
|
|
GameModData selectedMod;
|
|
private int SelectedTab = -1;
|
|
DungeonKind dungeonKind;
|
|
|
|
private int DungeonLevel = 1;
|
|
|
|
cDungeonPreset dungeonPreset => DataHandler.PlayDgPreset;
|
|
|
|
bool isUnlockDungeon = false;
|
|
|
|
#region Base
|
|
public static void SLocalize(bool bmain)
|
|
{
|
|
if (Instance != null)
|
|
Instance.Localize(bmain);
|
|
}
|
|
|
|
// 번역.
|
|
private void Localize(bool bmain)
|
|
{
|
|
if (bmain)
|
|
{
|
|
txtMainT.text = LocalizationText.GetText("dg_title");
|
|
}
|
|
else
|
|
{
|
|
bReLocalize = false;
|
|
canvasUI.transform.Find("txtT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("dungeon_title");
|
|
|
|
leftPanel = dungeonLeftPn.gameObject;
|
|
dungeonImage = leftPanel.transform.Find("DungeonImage").GetComponent<Image>();
|
|
dungeonName = dungeonImage.transform.Find("DungeonName").GetComponent<TextMeshProUGUI>();
|
|
|
|
for (int i = 0; i < dungeonPanel.Length; i++)
|
|
{
|
|
objDungeonSelect[i] = dungeonPanel[i].transform.Find("select").gameObject;
|
|
objDungeonLock[i] = dungeonPanel[i].transform.Find("DungeonLock").gameObject;
|
|
}
|
|
|
|
leftCanvasUI = dungeonLeftPn.gameObject;
|
|
leftCanvasUI.transform.Find("txtT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("dungeon_info");
|
|
btnDungeonSkip = leftCanvasUI.transform.Find("btnSkip").GetComponent<ButtonIV>();
|
|
|
|
autoProgressToggle = leftCanvasUI.transform.Find("txtCheckBox").transform.Find("CheckBox").GetComponent<Toggle>();
|
|
}
|
|
}
|
|
|
|
// 설정에서 언어 변경 시 처리.
|
|
public static void SReLocalize()
|
|
{
|
|
Instance.Localize(true);
|
|
Instance.bReLocalize = true;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
iLoading--;
|
|
}
|
|
|
|
public static bool SCloseMenu()
|
|
{
|
|
return Instance.CloseMenu();
|
|
}
|
|
|
|
private bool CloseMenu()
|
|
{
|
|
// 게임 시작 후 열린적 없음.
|
|
if (SelectedTab < 0) return false;
|
|
|
|
if (canvasUI.enabled)
|
|
{
|
|
CloseDungeon();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
#endregion Base
|
|
|
|
#region UI
|
|
public void MoveDungeon(eEventMoveType content)//다른 곳에서 던전 컨텐츠를 열어야 할 때.
|
|
{
|
|
switch (content)
|
|
{
|
|
case eEventMoveType.DgGold: dungeonKind = DungeonKind.DeepCave; break;
|
|
case eEventMoveType.DgStone: dungeonKind = DungeonKind.Atlantis; break;
|
|
case eEventMoveType.DgPet: dungeonKind = DungeonKind.ProtectTheMerchant; break;
|
|
case eEventMoveType.DgAwaken: dungeonKind = DungeonKind.DevelopTheJungle; break;
|
|
case eEventMoveType.DgRelic: dungeonKind = DungeonKind.HuntEagle; break;
|
|
}
|
|
|
|
OpenDungeon();
|
|
}
|
|
|
|
public void OpenDungeon() //던전 버튼으로 던전을 열 때. 최초 열 때는 골드던전이 활성화된다.
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(DeepCaveDungeonProperty.CodeName, out DeepCaveDungeonData deepCaveDungeonData);
|
|
GameModDataGroup.Instance.TryGetModData(AtlantisDungeonProperty.CodeName, out AtlantisDungeonData atlantisDungeonData);
|
|
GameModDataGroup.Instance.TryGetModData(ProtectTheMerchantDgProp.CodeName, out ProtectTheMerchantDgData protectTheMerchantDgData);
|
|
GameModDataGroup.Instance.TryGetModData(DevelopTheJungleDgProp.CodeName, out DevelopTheJungleDgData developTheJungleDgData);
|
|
GameModDataGroup.Instance.TryGetModData(HuntEagleDgProp.CodeName, out HuntEagleDgData huntEagleDgData);
|
|
|
|
if (mainLock.activeSelf)
|
|
{
|
|
GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(deepCaveDungeonData.OpenStage)); //펫 던전 해금될때 해금됨
|
|
return;
|
|
}
|
|
|
|
if (iLoading > 0) return;
|
|
|
|
iLoading++;
|
|
if (bReLocalize)
|
|
{
|
|
Localize(false);
|
|
}
|
|
|
|
canvasUI.enabled = true;
|
|
dungeonLeftPn.enabled = true;
|
|
|
|
GameUIMgr.SRightWindowClose();
|
|
GameUIMgr.SOpenLeftPanel(dggoldticket: true, dgenhanceticket: true, dgawakenticket: true, dgpetticket: true, dgrelicticket: true);
|
|
GameUIMgr.SSetMainUiOn(false);
|
|
|
|
objDungeonLock[0].SetActive(!DataHandler.IsClearStage(deepCaveDungeonData.OpenStage));
|
|
objDungeonLock[1].SetActive(!DataHandler.IsClearStage(atlantisDungeonData.OpenStage));
|
|
objDungeonLock[2].SetActive(!DataHandler.IsClearStage(protectTheMerchantDgData.OpenStage));
|
|
objDungeonLock[3].SetActive(!DataHandler.IsClearStage(developTheJungleDgData.OpenStage));
|
|
objDungeonLock[4].SetActive(!DataHandler.IsClearStage(huntEagleDgData.OpenStage));
|
|
|
|
switch (dungeonKind)
|
|
{
|
|
case DungeonKind.DeepCave: TabDeepCave(); break;
|
|
case DungeonKind.Atlantis: TabAtlantis(); break;
|
|
case DungeonKind.ProtectTheMerchant: TabProtectTheMerchant(); break;
|
|
case DungeonKind.DevelopTheJungle: TabDevelopTheJungle(); break;
|
|
case DungeonKind.HuntEagle: TabHuntEagle(); break;
|
|
default: TabDeepCave(); break;
|
|
};
|
|
|
|
iLoading--;
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
}
|
|
|
|
public void CloseDungeon()//던전을 닫을때
|
|
{
|
|
if (iLoading > 0) return;
|
|
iLoading++;
|
|
|
|
canvasUI.enabled = false;
|
|
dungeonLeftPn.enabled = false;
|
|
GameUIMgr.SRightWindowClose();
|
|
GameUIMgr.SCloseLeftPanel();
|
|
GameUIMgr.SSetMainUiOn(true);
|
|
|
|
SoundMgr.Instance.PlaySfx(SoundName.BtnPress);
|
|
|
|
iLoading--;
|
|
}
|
|
#endregion
|
|
|
|
public void IsUnlock()//메인창에서 던전이 해금되었는지의 여부를 분간한다. 해금되어있지 않으면 버튼색을 어둡게 하고 자물쇠를 건다.
|
|
{
|
|
if (isUnlockDungeon) return;
|
|
|
|
mainLock = mainDungeonButton.transform.Find("Image").gameObject;
|
|
|
|
if(GameModDataGroup.Instance.TryGetModData(DeepCaveDungeonProperty.CodeName, out DeepCaveDungeonData modData))
|
|
mainLock.SetActive(!DataHandler.IsClearStage(modData.OpenStage));
|
|
else
|
|
mainLock.SetActive(true);
|
|
|
|
ColorBlock colorBlock = mainDungeonButton.colors;
|
|
|
|
if (mainLock.activeSelf)
|
|
{
|
|
colorBlock.normalColor = new Color(0.5f, 0.5f, 0.5f);
|
|
colorBlock.highlightedColor = new Color(0.5f, 0.5f, 0.5f);
|
|
colorBlock.selectedColor = new Color(0.5f, 0.5f, 0.5f);
|
|
colorBlock.pressedColor = new Color(0.5f, 0.5f, 0.5f);
|
|
|
|
mainDungeonButton.colors = colorBlock;
|
|
}
|
|
else
|
|
{
|
|
isUnlockDungeon = true;
|
|
|
|
colorBlock.normalColor = new Color(1f, 1f, 1f);
|
|
colorBlock.highlightedColor = new Color(1f, 1f, 1f);
|
|
colorBlock.selectedColor = new Color(1f, 1f, 1f);
|
|
colorBlock.pressedColor = new Color(1f, 1f, 1f);
|
|
|
|
mainDungeonButton.colors = colorBlock;
|
|
}
|
|
}
|
|
|
|
#region Tab : 던전 항목의 각 탭을 클릭하면 던전의 종류와 레벨을 세팅하고 왼쪽에 있는 스크롤뷰의 정보를 갱신해준다.
|
|
public void TabDeepCave()
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(DeepCaveDungeonProperty.CodeName, out DeepCaveDungeonData modData);
|
|
|
|
selectedMod = modData;
|
|
SelectedTab = 0;
|
|
SetSelectTab(SelectedTab);
|
|
|
|
dungeonKind = DungeonKind.DeepCave;
|
|
|
|
DungeonLevel = (int)modData.Level;
|
|
selectDungeonLv = DungeonLevel;
|
|
|
|
SetSelectedDungeon(modData, SelectedTab, modData.AutoProgress, modData.GetRewardList(modData.Level));
|
|
|
|
btnDungeonSkip.interactable = modData.CanSkip(modData.Level);
|
|
getEnterCostItem = () => modData.EnterCostItem.ConvertTo(modData.EnterTicketCount);
|
|
onClickSkipConfirm = (useCount) =>
|
|
{
|
|
CoverCamera.Hold();
|
|
modData.TryGetReward(modData.Level - 1, (totalReward, result) =>
|
|
{
|
|
if (result)
|
|
{
|
|
GameUIMgr.SOpenPopupGoods(totalReward);
|
|
modData.EnterTicketCount -= useCount;
|
|
modData.TryCount += useCount;
|
|
modData.ClearCount += useCount;
|
|
|
|
GameUIMgr.RefreshDeepCaveDungeonTicket();
|
|
MissionMgr.SRefreshMission();
|
|
TabDeepCave();
|
|
}
|
|
CoverCamera.Release();
|
|
}, modData.GetRewardMultiplier(), (int)useCount);
|
|
};
|
|
}
|
|
|
|
public void TabAtlantis()
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(AtlantisDungeonProperty.CodeName, out AtlantisDungeonData modData);
|
|
|
|
if (objDungeonLock[1].activeSelf)
|
|
{
|
|
GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(modData.OpenStage));
|
|
return;
|
|
}
|
|
|
|
selectedMod = modData;
|
|
SelectedTab = 1;
|
|
SetSelectTab(SelectedTab);
|
|
|
|
dungeonKind = DungeonKind.Atlantis;
|
|
|
|
DungeonLevel = (int)modData.Level;
|
|
selectDungeonLv = DungeonLevel;
|
|
|
|
SetSelectedDungeon(modData, SelectedTab, modData.AutoProgress, modData.GetRewardList(modData.Level));
|
|
|
|
btnDungeonSkip.interactable = modData.CanSkip(modData.Level);
|
|
getEnterCostItem = () => modData.EnterCostItem.ConvertTo(modData.EnterTicketCount);
|
|
onClickSkipConfirm = (useCount) =>
|
|
{
|
|
CoverCamera.Hold();
|
|
modData.TryGetReward(modData.Level - 1, (totalReward, result) =>
|
|
{
|
|
if (result)
|
|
{
|
|
GameUIMgr.SOpenPopupGoods(totalReward);
|
|
modData.EnterTicketCount -= useCount;
|
|
modData.TryCount += useCount;
|
|
modData.ClearCount += useCount;
|
|
|
|
GameUIMgr.RefreshAtlantisDungeonTicket();
|
|
MissionMgr.SRefreshMission();
|
|
TabAtlantis();
|
|
}
|
|
CoverCamera.Release();
|
|
}, modData.GetRewardMultiplier(), (int)useCount);
|
|
};
|
|
}
|
|
|
|
public void TabProtectTheMerchant()
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(ProtectTheMerchantDgProp.CodeName, out ProtectTheMerchantDgData modData);
|
|
|
|
if (objDungeonLock[2].activeSelf)
|
|
{
|
|
GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(modData.OpenStage));
|
|
return;
|
|
}
|
|
|
|
selectedMod = modData;
|
|
SelectedTab = 2;
|
|
SetSelectTab(SelectedTab);
|
|
|
|
dungeonKind = DungeonKind.ProtectTheMerchant;
|
|
|
|
DungeonLevel = (int)modData.Level;
|
|
selectDungeonLv = DungeonLevel;
|
|
|
|
SetSelectedDungeon(modData, SelectedTab, modData.AutoProgress, modData.GetRewardList(modData.Level));
|
|
|
|
btnDungeonSkip.interactable = modData.CanSkip(modData.Level);
|
|
getEnterCostItem = () => modData.EnterCostItem.ConvertTo(modData.EnterTicketCount);
|
|
onClickSkipConfirm = (useCount) =>
|
|
{
|
|
CoverCamera.Hold();
|
|
modData.TryGetReward(modData.Level - 1, (totalReward, result) =>
|
|
{
|
|
if (result)
|
|
{
|
|
GameUIMgr.SOpenPopupGoods(totalReward);
|
|
modData.EnterTicketCount -= useCount;
|
|
modData.TryCount += useCount;
|
|
modData.ClearCount += useCount;
|
|
|
|
GameUIMgr.RefreshProtectTheMerchantDgTicket();
|
|
MissionMgr.SRefreshMission();
|
|
TabProtectTheMerchant();
|
|
}
|
|
CoverCamera.Release();
|
|
}, modData.GetRewardMultiplier(), (int)useCount);
|
|
};
|
|
}
|
|
|
|
public void TabDevelopTheJungle()
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(DevelopTheJungleDgProp.CodeName, out DevelopTheJungleDgData modData);
|
|
|
|
if (objDungeonLock[3].activeSelf)
|
|
{
|
|
GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(modData.OpenStage));
|
|
return;
|
|
}
|
|
|
|
selectedMod = modData;
|
|
SelectedTab = 3;
|
|
SetSelectTab(SelectedTab);
|
|
|
|
dungeonKind = DungeonKind.DevelopTheJungle;
|
|
|
|
DungeonLevel = (int)modData.Level;
|
|
selectDungeonLv = DungeonLevel;
|
|
|
|
SetSelectedDungeon(modData, SelectedTab, modData.AutoProgress, modData.GetRewardList(modData.Level));
|
|
|
|
btnDungeonSkip.interactable = modData.CanSkip(modData.Level);
|
|
getEnterCostItem = () => modData.EnterCostItem.ConvertTo(modData.EnterTicketCount);
|
|
onClickSkipConfirm = (useCount) =>
|
|
{
|
|
CoverCamera.Hold();
|
|
modData.TryGetReward(modData.Level - 1, (totalReward, result) =>
|
|
{
|
|
if (result)
|
|
{
|
|
GameUIMgr.SOpenPopupGoods(totalReward);
|
|
modData.EnterTicketCount -= useCount;
|
|
modData.TryCount += useCount;
|
|
modData.ClearCount += useCount;
|
|
|
|
GameUIMgr.RefreshDevelopTheJungleDgTicket();
|
|
MissionMgr.SRefreshMission();
|
|
TabDevelopTheJungle();
|
|
}
|
|
CoverCamera.Release();
|
|
}, modData.GetRewardMultiplier(), (int)useCount);
|
|
};
|
|
}
|
|
|
|
public void TabHuntEagle()
|
|
{
|
|
GameModDataGroup.Instance.TryGetModData(HuntEagleDgProp.CodeName, out HuntEagleDgData modData);
|
|
|
|
if (objDungeonLock[4].activeSelf)
|
|
{
|
|
GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(modData.OpenStage));
|
|
return;
|
|
}
|
|
|
|
selectedMod = modData;
|
|
SelectedTab = 4;
|
|
SetSelectTab(SelectedTab);
|
|
|
|
dungeonKind = DungeonKind.HuntEagle;
|
|
|
|
DungeonLevel = (int)modData.Level;
|
|
selectDungeonLv = DungeonLevel;
|
|
|
|
SetSelectedDungeon(modData, SelectedTab, modData.AutoProgress, modData.GetRewardList(modData.Level));
|
|
|
|
btnDungeonSkip.interactable = modData.CanSkip(modData.Level);
|
|
getEnterCostItem = () => modData.EnterCostItem.ConvertTo(modData.EnterTicketCount);
|
|
onClickSkipConfirm = (useCount) =>
|
|
{
|
|
CoverCamera.Hold();
|
|
modData.TryGetReward(modData.Level - 1, (totalReward, result) =>
|
|
{
|
|
if (result)
|
|
{
|
|
GameUIMgr.SOpenPopupGoods(totalReward);
|
|
modData.EnterTicketCount -= useCount;
|
|
modData.TryCount += useCount;
|
|
modData.ClearCount += useCount;
|
|
|
|
GameUIMgr.RefreshHuntEagleDgTicket();
|
|
MissionMgr.SRefreshMission();
|
|
TabHuntEagle();
|
|
}
|
|
CoverCamera.Release();
|
|
}, modData.GetRewardMultiplier(), (int)useCount);
|
|
};
|
|
}
|
|
|
|
private void SetSelectedDungeon(GameModData modData, int panelKey, bool isOnAutoProgress, IList<nGoods> rewards)
|
|
{
|
|
dungeonImage.sprite = AddressableMgr.GetDungeonPanel(panelKey);
|
|
dungeonName.text = LocalizationText.GetText(modData.NameKey);
|
|
autoProgressToggle.SetIsOnWithoutNotify(isOnAutoProgress);
|
|
SetRewardList(rewards);
|
|
|
|
var stages = new SmallList<int>();
|
|
for (int i = 0; i < modData.MaxLevel; i++)
|
|
{
|
|
stages.Add(i + 1);
|
|
}
|
|
|
|
escrDungeonSelect.LoadDatas(stages, modData);
|
|
AutoScrollAtLevel(selectDungeonLv);
|
|
}
|
|
|
|
ButtonIV prevSettedTabButton;
|
|
GameObject prevSettedTabSelectIndicator;
|
|
private void SetSelectTab(int idx)
|
|
{
|
|
if (prevSettedTabButton != null)
|
|
{
|
|
prevSettedTabButton.interactable = true;
|
|
prevSettedTabSelectIndicator.SetActive(false);
|
|
}
|
|
|
|
prevSettedTabButton = btnTabs[idx];
|
|
prevSettedTabSelectIndicator = objDungeonSelect[idx];
|
|
|
|
// 선택되어있는 항목 재선택을 막음(한 항목을 연속으로 터치하면 스크롤뷰 자동 옮기는 부분에서 문제가 발생함)
|
|
prevSettedTabButton.interactable = false;
|
|
prevSettedTabSelectIndicator.SetActive(true);
|
|
}
|
|
|
|
public void AutoScrollAtLevel(int targetLevel)
|
|
{
|
|
float scrollPosition = 0;
|
|
if (targetLevel >= 2)
|
|
scrollPosition = escrDungeonSelect.scroller.GetScrollPositionForCellViewIndex(targetLevel - 2, EnhancedUI.EnhancedScroller.EnhancedScroller.CellViewPositionEnum.Before);
|
|
|
|
escrDungeonSelect.scroller.SetScrollPositionImmediately(scrollPosition);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
}
|
|
#endregion
|
|
|
|
public void OpenPopupPreset(GameModData gMod, Action onStart = null)
|
|
{
|
|
int id = (int)gMod.ModID;
|
|
|
|
bool isDirty = false;
|
|
if (id >= DataHandler.PlayDgPreset.dgPetPreset.Length)
|
|
{
|
|
Array.Resize(ref DataHandler.PlayDgPreset.dgPetPreset, id + 1);
|
|
isDirty = true;
|
|
}
|
|
|
|
if (id >= DataHandler.PlayDgPreset.dgSkillPreset.Length)
|
|
{
|
|
Array.Resize(ref DataHandler.PlayDgPreset.dgSkillPreset, id + 1);
|
|
isDirty = true;
|
|
}
|
|
|
|
if (id >= DataHandler.PlayDgPreset.dgAwakenPreset.Length)
|
|
{
|
|
Array.Resize(ref DataHandler.PlayDgPreset.dgAwakenPreset, id + 1);
|
|
isDirty = true;
|
|
}
|
|
|
|
if(isDirty)
|
|
DataHandler.PlayDgPreset.Save();
|
|
|
|
GameUIMgr.SOpenPopupPreset(dungeonPreset.dgSkillPreset[id], dungeonPreset.dgPetPreset[id], dungeonPreset.dgAwakenPreset[id], () =>
|
|
{
|
|
onStart?.Invoke();
|
|
DungeonStart(gMod);
|
|
});
|
|
}
|
|
|
|
private void DungeonStart(GameModData gMod)//던전을 시작하면 프리셋이 던전 전용으로 맞춰진다. 그 다음 레벨을 세팅하고 던전을 비활성화하고 던전을 시작한다.
|
|
{
|
|
GameUIMgr.SPreservePreset(DataHandler.PlayData.usePreset, DataHandler.PlayData.usePetPreset, DataHandler.PlayAwaken.usePreset);
|
|
|
|
int skillpreset = GameUIMgr.SGetSkillPreset();
|
|
dungeonPreset.dgSkillPreset[gMod.ModID] = skillpreset;
|
|
if (skillpreset != DataHandler.PlayData.usePreset)
|
|
{
|
|
DataHandler.PlayData.usePreset = skillpreset;
|
|
SkillMgr.SResetPreset();
|
|
}
|
|
|
|
int petpreset = GameUIMgr.SGetPetPreset();
|
|
dungeonPreset.dgPetPreset[gMod.ModID] = petpreset;
|
|
if (petpreset != DataHandler.PlayData.usePetPreset)
|
|
{
|
|
DataHandler.PlayData.usePetPreset = petpreset;
|
|
BattleMgr.SSetPet(petpreset);
|
|
DataHandler.CalcPetEquipExtra(petpreset);
|
|
PetMgr.SResetPreset();
|
|
}
|
|
|
|
int awakenpreset = GameUIMgr.SGetAwakenPreset();
|
|
dungeonPreset.dgAwakenPreset[gMod.ModID] = awakenpreset;
|
|
if (awakenpreset != DataHandler.PlayAwaken.usePreset)
|
|
{
|
|
DataHandler.PlayAwaken.usePreset = awakenpreset;
|
|
EnhanceMgr.StartSetAwakenPreset();
|
|
EnhanceMgr.SResetAwakenPreset();
|
|
}
|
|
|
|
dungeonPreset.Save();
|
|
GameUIMgr.SCloseMenu();
|
|
GameUIMgr.SOnOffDungeonButton(false);
|
|
MissionMgr.SCloseMission();
|
|
|
|
BattleMgr.Instance.ClearRewardItemObjects();
|
|
BattleMgr.Instance.ChangeGameMod(gMod);
|
|
if (!autoProgress || canvasUI.isActiveAndEnabled)
|
|
{
|
|
CloseDungeon();
|
|
EnhanceMgr.CloseEnhance();
|
|
GuardianMgr.SGuardianWindowOff();
|
|
}
|
|
}
|
|
|
|
public void SetAutoProgress(bool onOff)
|
|
{
|
|
if(selectedMod is IAutoProgressable autoProgressable)
|
|
{
|
|
autoProgressable.AutoProgress = onOff;
|
|
}
|
|
}
|
|
|
|
int selectDungeonLv = 1;
|
|
public int GetSelectDgLv() => selectDungeonLv;
|
|
|
|
public void SetSelectDgLv(int level)
|
|
{
|
|
selectDungeonLv = level;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
}
|
|
|
|
//던전 목록 아래쪽의 보상 세팅
|
|
public void SetRewardList(IList<nGoods> rewards)
|
|
{
|
|
for (int i = 0; i < rewardItem.Length; i++)
|
|
{
|
|
if (i < rewards.Count)
|
|
{
|
|
var reward = rewards[i];
|
|
|
|
rewardItem[i].gameObject.SetActive(true);
|
|
rewardItem[i].SetGoods(reward.propertyType, reward.propertyId, rewards[i].propertyCount);
|
|
}
|
|
else
|
|
{
|
|
rewardItem[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
//던전 소탕을 할 때 사용되는 부분. 주로 소탕 횟수를 지정하는 버튼 기능(+ - Max Min)이 있다.
|
|
#region Skip
|
|
Func<nGoods> getEnterCostItem;
|
|
Action<uint> onClickSkipConfirm;
|
|
|
|
public void WindowTicketConsume()
|
|
{
|
|
if (iLoading > 0 || getEnterCostItem is null || onClickSkipConfirm is null) return;
|
|
|
|
uint useCount = 1;
|
|
var ticketToConsume = getEnterCostItem();
|
|
|
|
GameUIMgr.SOpenPopupItemUse(
|
|
ticketToConsume,
|
|
() => { useCount = Math.Max(useCount - 1, 1); GameUIMgr.SSetPopupItemUseCount((int)ticketToConsume.propertyCount, (int)useCount); },
|
|
() => { useCount = Math.Min(useCount + 1, (uint)ticketToConsume.propertyCount); GameUIMgr.SSetPopupItemUseCount((int)ticketToConsume.propertyCount, (int)useCount); },
|
|
() => { useCount = 1; GameUIMgr.SSetPopupItemUseCount((int)ticketToConsume.propertyCount, (int)useCount); },
|
|
() => { useCount = (uint)ticketToConsume.propertyCount; GameUIMgr.SSetPopupItemUseCount((int)ticketToConsume.propertyCount, (int)useCount); },
|
|
() => onClickSkipConfirm(useCount),
|
|
null,
|
|
FormatString.StringFormat(LocalizationText.GetText("dungeon_skip_level"), selectedMod.Level - 1),
|
|
LocalizationText.GetText("all_use"),
|
|
LocalizationText.GetText(Global.STR_CANCEL));
|
|
|
|
GameUIMgr.SSetPopupItemUseCount((int)ticketToConsume.propertyCount, (int)useCount);
|
|
}
|
|
#endregion
|
|
|
|
#if false
|
|
nDungeonTryInfo tryData = null;
|
|
int iSelectedCount = 0;
|
|
|
|
//던전이 성공했는지 실패했는지 혹은 소탕한건지를 저장해서 서버통신을 한다.
|
|
public void ADungeonTrySv(int lv, bool clear, bool isskip, int skipcnt, float ibonus)
|
|
{
|
|
CoverCamera.Hold();
|
|
int dgtype = (int)dungeonKind;
|
|
if (isskip == true) //소탕기능을 사용했다면 바로 서버와 통신한다.
|
|
{
|
|
tryData = new nDungeonTryInfo(lv, clear, isskip, skipcnt, dungeonPreset.dgSkillPreset[dgtype], dungeonPreset.dgPetPreset[dgtype], dungeonPreset.dgAwakenPreset[dgtype], ibonus);
|
|
}
|
|
else
|
|
{
|
|
switch (dungeonKind)//소탕기능을 사용하지 않았다면 종류별로 다르게 통신을 시도한다. 여기서는 통신에 사용할 데이터를 할당한다.
|
|
{
|
|
case DungeonKind.DeepCave:
|
|
case DungeonKind.Atlantis:
|
|
case DungeonKind.ProtectTheMerchant:
|
|
case DungeonKind.DevelopTheJungle:
|
|
case DungeonKind.HuntEagle:
|
|
tryData = new nDungeonTryInfo(lv, clear, isskip, skipcnt, dungeonPreset.dgSkillPreset[dgtype], dungeonPreset.dgPetPreset[dgtype], dungeonPreset.dgAwakenPreset[dgtype], ibonus);
|
|
break;
|
|
case DungeonKind.Train:
|
|
tryData = new nDungeonTryInfo(lv, clear, dungeonPreset.dgSkillPreset[dgtype], dungeonPreset.dgPetPreset[dgtype], dungeonPreset.dgAwakenPreset[dgtype]);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
switch (dungeonKind)//할당한 데이터를 통해 여기서 서버 통신을 시도한다.
|
|
{
|
|
case DungeonKind.DeepCave:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonGold), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
case DungeonKind.Atlantis:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonReinStone), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
case DungeonKind.ProtectTheMerchant:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonPet), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
case DungeonKind.DevelopTheJungle:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonAwakenStone), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
case DungeonKind.Train:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonAwaken), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
case DungeonKind.HuntEagle:
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.DungeonRelic), typeof(nDungeonResultReturn), ADungeonTrySucc, ADungeonTryFail, tryData, true);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
// 던전 성패 통신 성공.
|
|
private void ADungeonTrySucc(object result, object request)
|
|
{
|
|
nDungeonResultReturn data = result as nDungeonResultReturn;
|
|
if (data == null)
|
|
{
|
|
ADungeonTryFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
GuardianMgr.setActiveRobot(false);
|
|
|
|
if (tryData.clear)
|
|
{
|
|
if (!tryData.isSkip)//소탕하지 않았을때
|
|
{
|
|
switch (dungeonKind)
|
|
{
|
|
case DungeonKind.DeepCave:
|
|
BattleMgr.GetClearDungeonReward(DataHandler.GetDungeonTypeInfo(DungeonKind.DeepCave).diffs[DungeonLevel - 1].rewards);
|
|
DataHandler.PlayDgGold = data.playDgGold;
|
|
SetRewardList();
|
|
DungeonLevel++;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.Atlantis:
|
|
BattleMgr.GetClearDungeonReward(DataHandler.GetDungeonTypeInfo(DungeonKind.Atlantis).diffs[DungeonLevel - 1].rewards);
|
|
DataHandler.SetEnhanceStone(data.playCurrency.gearReinStone);
|
|
DataHandler.PlayDgReinStone = data.playDgReinStone;
|
|
SetRewardList();
|
|
DungeonLevel++;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.ProtectTheMerchant:
|
|
BattleMgr.GetClearDungeonReward(DataHandler.GetDungeonTypeInfo(DungeonKind.ProtectTheMerchant).diffs[DungeonLevel - 1].rewards);
|
|
DataHandler.SetPudding(data.playCurrency.pudding);
|
|
DataHandler.PlayDgPet = data.playDgPet;
|
|
SetRewardList();
|
|
DungeonLevel++;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.DevelopTheJungle:
|
|
BattleMgr.GetClearDungeonReward(DataHandler.GetDungeonTypeInfo(DungeonKind.DevelopTheJungle).diffs[DungeonLevel - 1].rewards);
|
|
DataHandler.SetAwakenStone(data.playCurrency.gearAwakenStone);
|
|
DataHandler.PlayDgAwakenStone = data.playDgAwakenStone;
|
|
SetRewardList();
|
|
DungeonLevel++;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.Train:
|
|
BattleMgr.Instance.ShowTrainDgSuccWindow();
|
|
DataHandler.PlayAwaken = data.playAwaken;
|
|
DataHandler.PlayDgAwaken = data.playDgAwaken;
|
|
if (DungeonLevel <= 6)
|
|
DataHandler.AwakenSlotUnlock(DungeonLevel);
|
|
EnhanceMgr.Instance.RecalculateRerollCost();
|
|
BuffMgr.Instance.ChangeAwakenDungeonStat(DungeonLevel);
|
|
EnhanceMgr.Instance.CalcMyInfoStat();
|
|
break;
|
|
case DungeonKind.HuntEagle:
|
|
BattleMgr.GetClearDungeonReward(DataHandler.GetDungeonTypeInfo(DungeonKind.HuntEagle).diffs[DungeonLevel - 1].rewards);
|
|
DataHandler.SetGoods(data.playCurrency, false);
|
|
DataHandler.PlayDgRelic = data.playDgRelic;
|
|
SetRewardList();
|
|
DungeonLevel++;
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (autoProgress && IsDungeonProgressOK(0) && dungeonKind != DungeonKind.Train)
|
|
{
|
|
//TODO: 자동진행
|
|
//DungeonStart();
|
|
}
|
|
else
|
|
{
|
|
//BattleMgr.Instance.ChangeBattleTypeNormal();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
int noreward = 0;
|
|
int norewardfront = 0;
|
|
for (int i = 0; i < DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards.Length; i++)
|
|
{
|
|
if (DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards[i].rewardCount == 0)
|
|
{
|
|
noreward++;
|
|
}
|
|
}
|
|
|
|
nGoods[] reward = new nGoods[DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards.Length - noreward];
|
|
|
|
for (int i = 0; i < DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards.Length; i++)
|
|
{
|
|
if (DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards[i].rewardCount != 0)
|
|
{
|
|
nReward rewarditem = DataHandler.GetDungeonTypeInfo(dungeonKind).diffs[DungeonLevel - 2].rewards[i];
|
|
//rewarditem.rewardCount *= iSelectedCount;
|
|
reward[i - norewardfront] = new nGoods(rewarditem);
|
|
}
|
|
else
|
|
{
|
|
norewardfront++;
|
|
}
|
|
}
|
|
|
|
switch (dungeonKind)
|
|
{
|
|
case DungeonKind.DeepCave:
|
|
BattleMgr.GetClearDungeonSkipReward(DataHandler.GetDungeonTypeInfo(DungeonKind.DeepCave).diffs[DungeonLevel - 2].rewards, iSelectedCount, tryData.bonus);
|
|
DataHandler.PlayDgGold = data.playDgGold;
|
|
reward[0].propertyCount = reward[0].propertyCount * (int)((tryData.bonus + 1.0f) * dConst.RateMaxFloat) / dConst.RateMaxBi * iSelectedCount;
|
|
GameUIMgr.SOpenPopupGoods(reward);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.Atlantis:
|
|
BattleMgr.GetClearDungeonSkipReward(DataHandler.GetDungeonTypeInfo(DungeonKind.Atlantis).diffs[DungeonLevel - 2].rewards, iSelectedCount);
|
|
DataHandler.SetEnhanceStone(data.playCurrency.gearReinStone);
|
|
DataHandler.PlayDgReinStone = data.playDgReinStone;
|
|
reward[0].propertyCount = reward[0].propertyCount * (int)((tryData.bonus + 1.0f) * dConst.RateMaxFloat) / dConst.RateMaxBi * iSelectedCount;
|
|
GameUIMgr.SOpenPopupGoods(reward);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.ProtectTheMerchant:
|
|
BattleMgr.GetClearDungeonSkipReward(DataHandler.GetDungeonTypeInfo(DungeonKind.ProtectTheMerchant).diffs[DungeonLevel - 2].rewards, iSelectedCount);
|
|
DataHandler.SetPudding(data.playCurrency.pudding);
|
|
DataHandler.PlayDgPet = data.playDgPet;
|
|
reward[0].propertyCount = reward[0].propertyCount * (int)((tryData.bonus + 1.0f) * dConst.RateMaxFloat) / dConst.RateMaxBi * iSelectedCount;
|
|
GameUIMgr.SOpenPopupGoods(reward);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.DevelopTheJungle:
|
|
BattleMgr.GetClearDungeonSkipReward(DataHandler.GetDungeonTypeInfo(DungeonKind.DevelopTheJungle).diffs[DungeonLevel - 2].rewards, iSelectedCount);
|
|
DataHandler.SetAwakenStone(data.playCurrency.gearAwakenStone);
|
|
DataHandler.PlayDgAwakenStone = data.playDgAwakenStone;
|
|
reward[0].propertyCount = reward[0].propertyCount * (int)((tryData.bonus + 1.0f) * dConst.RateMaxFloat) / dConst.RateMaxBi * iSelectedCount;
|
|
GameUIMgr.SOpenPopupGoods(reward);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
case DungeonKind.HuntEagle:
|
|
BattleMgr.GetClearDungeonSkipReward(DataHandler.GetDungeonTypeInfo(DungeonKind.HuntEagle).diffs[DungeonLevel - 2].rewards, iSelectedCount, tryData.bonus);
|
|
DataHandler.PlayDgRelic = data.playDgRelic;
|
|
reward[0].propertyCount = reward[0].propertyCount * (int)((tryData.bonus + 1.0f) * dConst.RateMaxFloat) / dConst.RateMaxBi * iSelectedCount;
|
|
GameUIMgr.SOpenPopupGoods(reward);
|
|
escrDungeonSelect.scroller.RefreshActiveCellViews();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
autoProgress = false;
|
|
|
|
btnDungeonSkip.interactable = (DataHandler.GetDungeonTicketCount(dungeonKind) > 0 && DungeonLevel > 1);
|
|
|
|
//BattleMgr.Instance.ChangeBattleTypeNormal();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
switch (dungeonKind)
|
|
{
|
|
case DungeonKind.DeepCave:
|
|
DataHandler.PlayDgGold = data.playDgGold;
|
|
break;
|
|
case DungeonKind.Atlantis:
|
|
DataHandler.PlayDgReinStone = data.playDgReinStone;
|
|
break;
|
|
case DungeonKind.ProtectTheMerchant:
|
|
DataHandler.PlayDgPet = data.playDgPet;
|
|
break;
|
|
case DungeonKind.DevelopTheJungle:
|
|
DataHandler.PlayDgAwakenStone = data.playDgAwakenStone;
|
|
break;
|
|
case DungeonKind.Train:
|
|
DataHandler.PlayDgAwaken = data.playDgAwaken;
|
|
break;
|
|
case DungeonKind.HuntEagle:
|
|
DataHandler.PlayDgRelic = data.playDgRelic;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
MissionMgr.SRefreshMission();
|
|
GameUIMgr.SSetGoods();
|
|
BattleMgr.Instance.ResetSkillCooltime();
|
|
tryData = null;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
private void ADungeonTryFail(SvError error, object request)
|
|
{
|
|
//BattleMgr.Instance.ChangeBattleTypeNormal();
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
public static bool IsDungeonProgressOK(int isNotSV)
|
|
{
|
|
if (Instance.DungeonLevel + isNotSV > DataHandler.GetDungeonTypeInfo(Instance.dungeonKind).diffs.Length)
|
|
{
|
|
return false;
|
|
}
|
|
if (DataHandler.GetDungeonTicketCount(Instance.dungeonKind) - isNotSV <= 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
#endif
|
|
}
|