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.
441 lines
15 KiB
441 lines
15 KiB
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using IVDataFormat;
|
|
using IVServerFormat;
|
|
using TMPro;
|
|
using EnhancedUI;
|
|
using UnityEngine.UI;
|
|
|
|
public class MaskMgr : MonoBehaviour
|
|
{
|
|
#region Const
|
|
private static MaskMgr curMgr = null;
|
|
#endregion Const
|
|
|
|
#region UI
|
|
[SerializeField]
|
|
TextMeshProUGUI txtMainT;
|
|
[SerializeField]
|
|
Canvas canvasUI;
|
|
[SerializeField]
|
|
Canvas leftWindow;
|
|
|
|
//오른쪽 상단탭
|
|
TextMeshProUGUI txtT;
|
|
ButtonIV[] btnTabs;
|
|
GameObject[] goTabLocks;
|
|
GameObject[] goTabBadges;
|
|
|
|
//왼쪽 상단탭
|
|
TextMeshProUGUI LtxtT;
|
|
GameObject groupSubTab3;
|
|
ButtonIV[] btnSubTabs3;
|
|
TextMeshProUGUI[] txtSubTabs3;
|
|
GameObject[] SubTabsLocks;
|
|
|
|
//오른쪽 창
|
|
GameObject effectLv;
|
|
Image[] maskParts;
|
|
GameObject arrowEffect;
|
|
Image[] arrows;
|
|
|
|
Color disableCol = new Color(91f / 255f, 91f / 255f, 91f / 255f);
|
|
Color enableCol = new Color(93f / 255f, 227f / 255f, 232f / 255f);
|
|
|
|
TextMeshProUGUI[] txtPartName;
|
|
TextMeshProUGUI[] txtPartLv;
|
|
ParticleSystem[] partSucc;
|
|
TextMeshProUGUI txtPercent;
|
|
ButtonIV btnEnhance;
|
|
TextMeshProUGUI txtEnhance;
|
|
TextMeshProUGUI txtEnhancePrice;
|
|
GameObject maxPanel;
|
|
|
|
//왼쪽 창
|
|
GameObject effectSet;
|
|
GameObject[] maskEffect;
|
|
Image[] imgMaskParts;
|
|
TextMeshProUGUI[] maskLv;
|
|
TextMeshProUGUI[] maskName;
|
|
TextMeshProUGUI[] txtMaskEffect;
|
|
TextMeshProUGUI[] maskPrev;
|
|
GameObject[] maskArrow;
|
|
TextMeshProUGUI[] maskNext;
|
|
#endregion
|
|
|
|
[SerializeField]
|
|
ParticleSystem ptcSucc, ptcFail;
|
|
|
|
bool bInitNeed = true;
|
|
private int iLoading = 1;
|
|
private bool bReLocalize = true;
|
|
int relicTypeTab = -1;
|
|
|
|
#region Base
|
|
public static void SLocalize(bool bmain)
|
|
{
|
|
curMgr?.Localize(bmain);
|
|
}
|
|
|
|
private void Localize(bool bmain)
|
|
{
|
|
if (bmain)
|
|
{
|
|
txtMainT.text = LocalizationText.GetText("mask_title");
|
|
}
|
|
else
|
|
{
|
|
txtT= canvasUI.transform.Find("txtT").GetComponent<TextMeshProUGUI>();
|
|
txtT.text = LocalizationText.GetText("mask_title");
|
|
btnTabs = canvasUI.transform.Find("tabWrapTop").GetComponentsInChildren<ButtonIV>(true);
|
|
goTabLocks = new GameObject[btnTabs.Length];
|
|
goTabBadges = new GameObject[btnTabs.Length];
|
|
for (int i = 0; i < btnTabs.Length; i++)
|
|
{
|
|
goTabLocks[i] = btnTabs[i].transform.Find("lock").gameObject;
|
|
goTabBadges[i] = btnTabs[i].transform.Find("badge").gameObject;
|
|
}
|
|
|
|
btnTabs[0].transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("mask_kind_1");
|
|
|
|
|
|
LtxtT = leftWindow.transform.Find("txtT").GetComponent<TextMeshProUGUI>();
|
|
LtxtT.text = LocalizationText.GetText("mask_title_left");
|
|
groupSubTab3 = leftWindow.transform.Find("groupSubTab3").gameObject;
|
|
btnSubTabs3 = groupSubTab3.transform.GetComponentsInChildren<ButtonIV>();
|
|
txtSubTabs3 = new TextMeshProUGUI[btnSubTabs3.Length];
|
|
SubTabsLocks = new GameObject[btnSubTabs3.Length];
|
|
|
|
for (int i = 0; i < btnSubTabs3.Length; i++)
|
|
{
|
|
txtSubTabs3[i] = btnSubTabs3[i].transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
SubTabsLocks[i] = btnSubTabs3[i].transform.Find("lock").gameObject;
|
|
}
|
|
|
|
txtSubTabs3[0].text = LocalizationText.GetText("own_effect_title");
|
|
|
|
effectLv = canvasUI.transform.Find("EffectLv").gameObject;
|
|
maskParts = effectLv.transform.GetComponentsInChildren<Image>();
|
|
arrowEffect = canvasUI.transform.Find("Arrows").gameObject;
|
|
arrows = arrowEffect.transform.GetComponentsInChildren<Image>();
|
|
|
|
txtPartName = new TextMeshProUGUI[maskParts.Length];
|
|
txtPartLv = new TextMeshProUGUI[maskParts.Length];
|
|
partSucc = new ParticleSystem[maskParts.Length - 1];
|
|
|
|
for (int i = 0;i < maskParts.Length;i++)
|
|
{
|
|
txtPartName[i] = maskParts[i].transform.Find("txtPartName").GetComponent<TextMeshProUGUI>();
|
|
txtPartLv[i] = maskParts[i].transform.Find("txtPartLv").GetComponent<TextMeshProUGUI>();
|
|
if(maskParts.Length - 1 != i)
|
|
{
|
|
partSucc[i] = maskParts[i].transform.Find("enhance_succ").GetComponent<ParticleSystem>();
|
|
}
|
|
}
|
|
|
|
txtPercent = canvasUI.transform.Find("txtPercent").GetComponent<TextMeshProUGUI>();
|
|
|
|
btnEnhance = canvasUI.transform.Find("btnEnhance").GetComponent<ButtonIV>();
|
|
txtEnhance = btnEnhance.transform.Find("txt").GetComponent<TextMeshProUGUI>();
|
|
txtEnhancePrice = btnEnhance.transform.Find("txtPrice").GetComponent<TextMeshProUGUI>();
|
|
|
|
maxPanel = canvasUI.transform.Find("bgoCMax").gameObject;
|
|
|
|
effectSet = leftWindow.transform.Find("OwnEffectSet").transform.Find("Content").gameObject;
|
|
maskEffect = new GameObject[5];
|
|
for (int i = 0; i < 5; i++)
|
|
{
|
|
maskEffect[i] = effectSet.transform.GetChild(i).gameObject;
|
|
}
|
|
|
|
imgMaskParts = new Image[maskEffect.Length];
|
|
maskLv = new TextMeshProUGUI[maskEffect.Length];
|
|
maskName = new TextMeshProUGUI[maskEffect.Length];
|
|
txtMaskEffect = new TextMeshProUGUI[maskEffect.Length];
|
|
maskPrev = new TextMeshProUGUI[maskEffect.Length];
|
|
maskArrow = new GameObject[maskEffect.Length];
|
|
maskNext = new TextMeshProUGUI[maskEffect.Length];
|
|
|
|
for (int i = 0; i < maskEffect.Length; i++)
|
|
{
|
|
imgMaskParts[i] = maskEffect[i].transform.Find("imgMaskParts").GetComponent<Image>();
|
|
maskLv[i] = maskEffect[i].transform.Find("txtLv").GetComponent<TextMeshProUGUI>();
|
|
maskName[i] = maskEffect[i].transform.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
txtMaskEffect[i] = maskEffect[i].transform.Find("txtEffect").GetComponent<TextMeshProUGUI>();
|
|
maskPrev[i] = maskEffect[i].transform.Find("txtPrev").GetComponent<TextMeshProUGUI>();
|
|
maskArrow[i] = maskEffect[i].transform.Find("txtArrow").gameObject;
|
|
maskNext[i] = maskEffect[i].transform.Find("txtNext").GetComponent<TextMeshProUGUI>();
|
|
}
|
|
}
|
|
}
|
|
|
|
// 설정에서 언어 변경 시 처리.
|
|
public static void SReLocalize()
|
|
{
|
|
curMgr.Localize(true);
|
|
curMgr.bReLocalize = true;
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
curMgr = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
iLoading--;
|
|
CalcRelicEnhance();
|
|
}
|
|
#endregion Base
|
|
|
|
void Init()
|
|
{
|
|
bInitNeed = false;
|
|
Localize(false);
|
|
}
|
|
|
|
#region Mask UI OnOff
|
|
public void MaskWindowOn()//마스크 창 열기
|
|
{
|
|
if (iLoading > 0) return;
|
|
iLoading++;
|
|
|
|
if (bInitNeed)
|
|
Init();
|
|
if (bReLocalize)
|
|
Localize(false);
|
|
|
|
canvasUI.enabled = true;
|
|
leftWindow.enabled = true;
|
|
GameUIMgr.SRightWindowClose();
|
|
GameUIMgr.SSetMainUiOn(false);
|
|
BattleMgr.CloseFailScroll();
|
|
GameUIMgr.SCloseMenu();
|
|
GameUIMgr.SOpenLeftPanel(maskenhance: true);
|
|
OpenTabMask(0);
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
iLoading--;
|
|
}
|
|
|
|
public void MaskWindowOff()//마스크 창 닫기
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
curMgr.canvasUI.enabled = false;
|
|
curMgr.leftWindow.enabled = false;
|
|
GameUIMgr.SCloseLeftPanel();
|
|
GameUIMgr.SSetMainUiOn(true);
|
|
MissionMgr.SRefreshMission();
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
iLoading--;
|
|
}
|
|
#endregion
|
|
|
|
#region Tab
|
|
public void OpenTabMask(int tab)//마스크 탭 열기. 마스크의 세트만큼 탭 수가 있다. 각 마스크당 유물 수는 5개.
|
|
{
|
|
relicTypeTab = tab + 1;
|
|
|
|
IList<dSysRelic> targetRelics = DataHandler.GetSysRelicGroup(relicTypeTab);
|
|
cPlayRelic playRelic = DataHandler.GetPlayRelic(relicTypeTab);
|
|
|
|
int[] maskLevel = new int[5]
|
|
{
|
|
playRelic.assistLv1,
|
|
playRelic.assistLv2,
|
|
playRelic.assistLv3,
|
|
playRelic.assistLv4,
|
|
playRelic.ancientLv
|
|
};
|
|
|
|
for (int i = 0; i < maskEffect.Length; ++i)
|
|
{
|
|
if(i == maskParts.Length - 1)
|
|
{
|
|
maskParts[i].sprite = AddressableMgr.GetRelicIcon(i + 10000);
|
|
imgMaskParts[i].sprite = AddressableMgr.GetRelicIcon(i + ((relicTypeTab - 1) * 5));
|
|
}
|
|
else
|
|
{
|
|
maskParts[i].sprite = AddressableMgr.GetRelicIcon(i + ((relicTypeTab - 1) * 5));
|
|
imgMaskParts[i].sprite = AddressableMgr.GetRelicIcon(i + ((relicTypeTab - 1) * 5));
|
|
}
|
|
|
|
txtPartName[i].text = LocalizationText.GetText(FormatString.CombineAll("mask_part_", i + ((relicTypeTab - 1) * 5)));
|
|
maskName[i].text = LocalizationText.GetText(FormatString.CombineAll("mask_part_", i + ((relicTypeTab - 1) * 5)));
|
|
txtMaskEffect[i].text = FormatString.TextEffectTitle((eEffectType)targetRelics[i].abilityType);
|
|
|
|
txtPartLv[i].text = FormatString.CombineAll("Lv. ", maskLevel[i]);
|
|
maskLv[i].text = FormatString.CombineAll("Lv. ", maskLevel[i]);
|
|
maskPrev[i].text = FormatString.TextIntPer0(targetRelics[i].abilityValue + (targetRelics[i].abilityValueInc * (maskLevel[i] - 1)));
|
|
if (maskLevel[i] < targetRelics[i].maxLv)
|
|
{
|
|
maskNext[i].text = FormatString.TextIntPer0(targetRelics[i].abilityValue + (targetRelics[i].abilityValueInc * maskLevel[i]));
|
|
maskNext[i].gameObject.SetActive(true);
|
|
maskArrow[i].SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
maskNext[i].gameObject.SetActive(false);
|
|
maskArrow[i].SetActive(false);
|
|
}
|
|
}
|
|
|
|
txtEnhance.text = LocalizationText.GetText("mask_enhance");
|
|
|
|
int enhancePrice = targetRelics[playRelic.nextRelic - 1].buyingCnt;
|
|
int enhancePriceInc = targetRelics[playRelic.nextRelic - 1].buyingCntInc;
|
|
int level = maskLevel[playRelic.nextRelic - 1];
|
|
|
|
txtEnhancePrice.text = FormatString.TextInt(enhancePrice + (enhancePriceInc * level));
|
|
|
|
btnEnhance.interactable = DataHandler.Goods.condMight >= (enhancePrice + (enhancePriceInc * level));
|
|
|
|
if (maskLevel[4] >= targetRelics[4].maxLv)
|
|
{
|
|
maxPanel.SetActive(true);
|
|
btnEnhance.interactable = false;
|
|
}
|
|
|
|
if (playRelic.nextRelic == 5)
|
|
{
|
|
txtPercent.text = FormatString.StringFormat(LocalizationText.GetText("all_succrate"), FormatString.TextIntPer0(DataHandler.GetRelicEnhanceProp(maskLevel[4])));
|
|
txtPercent.gameObject.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
txtPercent.gameObject.SetActive(false);
|
|
}
|
|
|
|
SetArrows(relicTypeTab);
|
|
}
|
|
|
|
public void SetArrows(int iRelicTypeTab)
|
|
{
|
|
for(int i = 1; i < maskParts.Length; i++)
|
|
{
|
|
if (i < DataHandler.GetPlayRelic(iRelicTypeTab).nextRelic)
|
|
{
|
|
arrows[i-1].color = enableCol;
|
|
}
|
|
else
|
|
arrows[i-1].color = disableCol;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
bool upgradeSuccess = false;
|
|
|
|
#region Enhance And Calc
|
|
public void MaskEnhance()//유물 강화. 마지막 유물을 제외한 유물은 확정적으로 강화된다. 마지막 유물은 확률.
|
|
{
|
|
cPlayRelic playRelic = DataHandler.GetPlayRelic(relicTypeTab);
|
|
|
|
//check current level up relic is last relic
|
|
if (playRelic.nextRelic == 5)
|
|
{
|
|
if (DataHandler.LvUpRelicEnhance(relicTypeTab))
|
|
{
|
|
upgradeSuccess = true;
|
|
ptcSucc.Play();
|
|
SoundMgr.PlaySfx(SoundName.ReinforceSuccess);
|
|
}
|
|
else
|
|
{
|
|
upgradeSuccess = false;
|
|
ptcFail.Play();
|
|
SoundMgr.PlaySfx(SoundName.ReinforceFailed);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
upgradeSuccess = true;
|
|
partSucc[playRelic.nextRelic - 1].Play();
|
|
SoundMgr.PlaySfx(SoundName.ReinforceSuccess);
|
|
}
|
|
|
|
SetArrows(relicTypeTab);
|
|
TrySVMaskEnhance();
|
|
}
|
|
|
|
public void CalcRelicEnhance()//마스크 효과를 계산하는 부분.
|
|
{
|
|
BuffMgr.Instance.RelicStatReset();
|
|
|
|
for(int i = 0; i < DataHandler.sysRelicsGroupedByType.Count; ++i)
|
|
{
|
|
IList<dSysRelic> targetRelics = DataHandler.GetSysRelicGroup(i + 1);
|
|
cPlayRelic playRelic = DataHandler.GetPlayRelic(i + 1);
|
|
|
|
int[] maskLevel = new int[5]
|
|
{
|
|
playRelic.assistLv1,
|
|
playRelic.assistLv2,
|
|
playRelic.assistLv3,
|
|
playRelic.assistLv4,
|
|
playRelic.ancientLv
|
|
};
|
|
|
|
for (int j = 0; j < targetRelics.Count; ++j)
|
|
{
|
|
dSysRelic sysRelic = targetRelics[j];
|
|
BuffMgr.Instance.ChangeRelicStat((eEffectType)sysRelic.abilityType, sysRelic.abilityValue + (sysRelic.abilityValueInc * (maskLevel[j] - 1)), false);
|
|
}
|
|
}
|
|
|
|
BuffMgr.Instance.CalcAllStat();
|
|
}
|
|
#endregion
|
|
|
|
#region SV
|
|
public void TrySVMaskEnhance()//유물의 강화 정보를 서버에 통신한다. 이때 강화의 성공 여부는 로컬에서 계산해서 서버로 보낸다.
|
|
{
|
|
var data = new nMaskEnhancePost();
|
|
|
|
data.relicType = DataHandler.GetPlayRelic(relicTypeTab).relicType;
|
|
data.isUpgrade = upgradeSuccess;
|
|
|
|
CoverCamera.Hold();
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.MaskEnhance), typeof(nMaskEnhanceReturn), AMaskEnhancSucc, AMaskEnhancFail, data, true);
|
|
}
|
|
|
|
private void AMaskEnhancFail(IVServerFormat.SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 레벨 강화 통신 성공.
|
|
private void AMaskEnhancSucc(object result, object request)
|
|
{
|
|
nMaskEnhanceReturn data = result as nMaskEnhanceReturn;
|
|
if (data == null)
|
|
{
|
|
AMaskEnhancFail(new IVServerFormat.SvError(IVServerFormat.eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.SetGoods(data.playCurrency, true);
|
|
DataHandler.SetPlayRelic(relicTypeTab, data.playRelic);
|
|
OpenTabMask(relicTypeTab - 1);
|
|
|
|
CalcRelicEnhance();
|
|
|
|
CoverCamera.Release();
|
|
}
|
|
#endregion
|
|
|
|
public void HelpMsg()
|
|
{
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
GameUIMgr.SOpenHelp(LocalizationText.GetText("help_upgrade"));
|
|
}
|
|
}
|