using IVDataFormat; using IVServerFormat; using System.Collections; using System.Collections.Generic; using System.Numerics; using TMPro; using UnityEngine; using UnityEngine.UI; using Vector2 = UnityEngine.Vector2; public class PetMgr : MonoBehaviour { #region Const private static PetMgr curMgr = null; private const float F_LeftGoodsLeft = -190f; private const float F_LeftGoodsMid = 0f; #endregion Const #region UI [Header("UI")] [SerializeField] private TextMeshProUGUI txtMainT; [SerializeField] Button mainPetButton; GameObject mainLock; [SerializeField] private GameObject goMainBadge; [SerializeField] private Canvas canvasUI; private ButtonIV[] btnTabs; private Image[] imgTabLineBottoms; private Image[] imgTabLineRights; private GameObject[] goTabBadges; private RectTransform rtrfSvPet; // 통합 레벨 효과. private GameObject groupTotalEfc; private TextMeshProUGUI txtTotalEfcT, txtTotalLv, txtTotalEfc; private ButtonIV btnComposeAll; // 프리셋. private GameObject groupPreset; private ButtonIV[] btnPresetTabs; private GoodsItem[] goodsPresets; private GameObject[] goPresetUnsets, goPresetEmptys; [SerializeField] float petSpiritScrTopValue = 149f; [SerializeField] float petScrTopValue = 429f; [SerializeField] EScrController escrPet; // 왼쪽 정보창. [SerializeField] Canvas petLeftInfo; private GoodsItem goodsInfo; private RectTransform rtrfGoodsInfo; private GameObject goBtnInfoHelp; private TextMeshProUGUI txtInfoT; // 펫 정보창. private GameObject groupInfoPet; private TextMeshProUGUI txtInfoUnlockLv; private TextMeshProUGUI txtInfoName; private GraphicsColorSetter txtInfoNameColorSetter; private TextMeshProUGUI txtInfoLv; private GameObject goInfoMax; private Image imgBtnInfoEnhance; private ButtonIV btnInfoEnhance, btnInfoAwaken; private TextMeshProUGUI txtInfoEnhance; // 펫 효과 탭. private GameObject goBtnInfoEfcAddLock; private Image imgTabInfoLineRight; private ButtonIV btnTabInfoEffect, btnTabInfoEffectAdd; private GameObject groupInfoPetEffect, groupInfoPetEffectAdd; private GameObject[] goInfoEfcs; [SerializeField] TextMeshProUGUI[] txtInfoEfcTs; [SerializeField] TextMeshProUGUI[] txtInfoEfcCurs; [SerializeField] GameObject[] InfoEfcArrowObjs; [SerializeField] TextMeshProUGUI[] txtInfoEfcNexts; // 펫 추가 효과. private EfcAddItem[] efcAddItems; private EfcAddItem efcAddOption; private ButtonIV btnEfcAdd, btnEfcAddAuto; private GameObject groupAutoNow; private TextMeshProUGUI txtEfcAddPrice; // 추가 효과 자동 변경. private GameObject groupOptionAuto; private ButtonIV btnEfcAddAutoStart; private TextMeshProUGUI txtEfcAddPriceStart; private EScrEfcOption[] efcOptionRarties; [SerializeField] private EScrController escrEfcAddAuto; // 펫 스피릿 정보창. private GameObject groupInfoSpirit; private TextMeshProUGUI txtInfoSpiritName, txtInfoSpiritDesc; private ButtonIV btnInfoSpiritCompose; #endregion UI #region Variables private int iLoading = 1; private bool bReLocalize = true; private bool bReLocalizePet = false; private bool bInitNeedPet = true; private int iSelectedTab = -1; private int iSelectedPreset = -1; private int iSvType = -1; private int iSelectedId = -1; private int iSelectedCount = 0; private int[][] iPresetPets; private bool bChangePreset = false; private EnhancedUI.SmallList petRows; private int[] petIds; private bool bInitNeedOption = true; // 자동 변경인지. private bool bEfcAddAuto = false; public static bool GetEfcAddAuto() { return curMgr.bEfcAddAuto; } // 변경 통신 중인지. private bool bEfcAddChanging = false; private int iEfcAddSlots = 0; // 자동 변경 옵션 선택. private bool[] bSelectedOptions; // 자동 변경 옵션. private eEffectType[] efcOptions; private bool bClicking = false; private nIdEnhance dataEnhance = null; bool isUnlockPet = false; #endregion Variables #region Base public static void SLocalize(bool bmain) { if (curMgr != null) curMgr.Localize(bmain); } private void Localize(bool bmain) { if (bmain) { txtMainT.text = LocalizationText.GetText("pet_title"); //IsUnlock(); } else { bReLocalize = false; Transform trfcanvas = canvasUI.transform; trfcanvas.Find("txtT").GetComponent().text = LocalizationText.GetText("pet_title"); btnTabs = trfcanvas.Find("tabWrapTop").GetComponentsInChildren(true); goTabBadges = new GameObject[btnTabs.Length]; for (int i = 0; i < btnTabs.Length; i++) { goTabBadges[i] = btnTabs[i].transform.Find("badge").gameObject; } btnTabs[0].transform.Find("txt").GetComponent().text = LocalizationText.GetText("pet_title"); btnTabs[1].transform.Find("txt").GetComponent().text = LocalizationText.GetText("pet_spirit"); imgTabLineBottoms = new Image[btnTabs.Length]; imgTabLineRights = new Image[btnTabs.Length]; for (int i = 0; i < btnTabs.Length; i++) { imgTabLineBottoms[i] = btnTabs[i].transform.Find("linebottom").GetComponent(); imgTabLineRights[i] = btnTabs[i].transform.Find("lineright").GetComponent(); } rtrfSvPet = trfcanvas.Find("SvPet").GetComponent(); Transform trfefc = trfcanvas.Find("groupTotalEffect"); groupTotalEfc = trfefc.gameObject; trfefc.Find("txtTotalLvT").GetComponent().text = LocalizationText.GetText("pet_totallv"); txtTotalEfcT = trfefc.Find("txtTotalEfcT").GetComponent(); txtTotalLv = trfefc.Find("txtTotalLv").GetComponent(); txtTotalEfc = trfefc.Find("txtTotalEfc").GetComponent(); btnComposeAll = trfcanvas.Find("btnComposeAll").GetComponent(); btnComposeAll.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_composeall"); Transform trfpreset = trfcanvas.Find("groupPreset"); groupPreset = trfpreset.gameObject; trfpreset.Find("btnSave").Find("txt").GetComponent().text = LocalizationText.GetText("all_save"); btnPresetTabs = new ButtonIV[6]; btnPresetTabs[0] = trfpreset.Find("tab0").GetComponent(); btnPresetTabs[1] = trfpreset.Find("tab1").GetComponent(); btnPresetTabs[2] = trfpreset.Find("tab2").GetComponent(); btnPresetTabs[3] = trfpreset.Find("tab3").GetComponent(); btnPresetTabs[4] = trfpreset.Find("tab4").GetComponent(); btnPresetTabs[5] = trfpreset.Find("tab5").GetComponent(); goodsPresets = trfpreset.GetComponentsInChildren(true); goPresetUnsets = new GameObject[goodsPresets.Length]; goPresetEmptys = new GameObject[goodsPresets.Length]; for (int i = 0; i < goodsPresets.Length; i++) { goPresetUnsets[i] = goodsPresets[i].transform.Find("unset").gameObject; goPresetEmptys[i] = goodsPresets[i].transform.Find("empty").gameObject; } // 왼쪽 정보창. Transform trfleft = petLeftInfo.transform; goodsInfo = trfleft.Find("GoodsItem").GetComponent(); rtrfGoodsInfo = goodsInfo.GetComponent(); goBtnInfoHelp = trfleft.Find("btnInfo").gameObject; txtInfoT = trfleft.Find("txtT").GetComponent(); Transform trfleftpet = trfleft.Find("groupPet"); groupInfoPet = trfleftpet.gameObject; txtInfoUnlockLv = trfleftpet.Find("txtUnlockLv").GetComponent(); txtInfoName = trfleftpet.Find("txtName").GetComponent(); txtInfoNameColorSetter = txtInfoName.GetComponent(); txtInfoLv = trfleftpet.Find("txtLv").GetComponent(); btnInfoEnhance = trfleftpet.Find("btnEnhance").GetComponent(); imgBtnInfoEnhance = btnInfoEnhance.GetComponent(); txtInfoEnhance = btnInfoEnhance.transform.Find("txtPrice").GetComponent(); btnInfoEnhance.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_enhance"); btnInfoAwaken = trfleftpet.Find("btnAwaken").GetComponent(); btnInfoAwaken.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_awaken"); goInfoMax = trfleftpet.Find("goMax").gameObject; goInfoMax.transform.Find("txt").GetComponent().text = LocalizationText.GetText(Global.STR_MAX); goBtnInfoEfcAddLock = trfleftpet.Find("goEffectAddLock").gameObject; imgTabInfoLineRight = trfleftpet.Find("tabSubLine2").GetComponent(); btnTabInfoEffect = trfleftpet.Find("tabEffect").GetComponent(); btnTabInfoEffect.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_effectset"); btnTabInfoEffectAdd = trfleftpet.Find("tabEffectAdd").GetComponent(); btnTabInfoEffectAdd.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_effectadd"); // 펫 장착 효과. groupInfoPetEffect = trfleftpet.Find("groupEffect").gameObject; Transform trfinfoefc = groupInfoPetEffect.transform; goInfoEfcs = new GameObject[3]; for (int i = 0; i < goInfoEfcs.Length; i++) goInfoEfcs[i] = trfinfoefc.GetChild(i).gameObject; // 펫 추가 효과. groupInfoPetEffectAdd = trfleftpet.Find("groupEffectAdd").gameObject; EfcAddItem[] additems = groupInfoPetEffectAdd.GetComponentsInChildren(); efcAddItems = new EfcAddItem[additems.Length - 1]; for (int i = 0; i < additems.Length; i++) { additems[i].Init(); if (i < additems.Length - 1) { efcAddItems[i] = additems[i]; efcAddItems[i].SetCondition(i + 1); } else { efcAddOption = additems[i]; efcAddOption.SetCondition(FormatString.StringFormat(LocalizationText.GetText("all_optionopen"), Global.STR_Rarity[cGoods.RLegend])); } } groupInfoPetEffectAdd.transform.Find("txtOptionT").GetComponent().text = LocalizationText.GetText("all_optionhaveefc"); btnEfcAdd = groupInfoPetEffectAdd.transform.Find("btnChange").GetComponent(); txtEfcAddPrice = btnEfcAdd.transform.Find("txtPrice").GetComponent(); btnEfcAdd.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_changego"); btnEfcAddAuto = groupInfoPetEffectAdd.transform.Find("btnChangeAuto").GetComponent(); btnEfcAddAuto.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_changeauto"); groupAutoNow = groupInfoPetEffectAdd.transform.Find("groupAutoNow").gameObject; groupAutoNow.transform.Find("txtProgress").GetComponent().text = LocalizationText.GetText("all_autoprocessing"); // 추가 효과 자동 변경. groupOptionAuto = trfleft.Find("groupOptionAuto").gameObject; groupOptionAuto.transform.Find("txtInfo").GetComponent().text = LocalizationText.GetText("bag_efcautomsg"); groupOptionAuto.transform.Find("txtRarityT").GetComponent().text = LocalizationText.GetText("all_selectrarity"); groupOptionAuto.transform.Find("txtOptionT").GetComponent().text = LocalizationText.GetText("all_selectefc"); btnEfcAddAutoStart = groupOptionAuto.transform.Find("btnChange").GetComponent(); txtEfcAddPriceStart = btnEfcAddAutoStart.transform.Find("txtPrice").GetComponent(); btnEfcAddAutoStart.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_changego"); efcOptionRarties = groupOptionAuto.transform.Find("rarities").GetComponentsInChildren(); efcOptionRarties[0].SetType(cGoods.TPet); efcOptionRarties[1].SetType(cGoods.TPet); efcOptionRarties[0].InitCell(); efcOptionRarties[1].InitCell(); efcOptionRarties[0].SetData(-1); efcOptionRarties[1].SetData(-2); efcOptionRarties[0].SetText(LocalizationText.GetText("awaken_grade_hero_up")); efcOptionRarties[1].SetText(LocalizationText.GetText("awaken_grade_mystic")); // 소모품. groupInfoSpirit = trfleft.Find("groupSpirit").gameObject; txtInfoSpiritName = groupInfoSpirit.transform.Find("txtName").GetComponent(); txtInfoSpiritDesc = groupInfoSpirit.transform.Find("txtDesc").GetComponent(); btnInfoSpiritCompose = groupInfoSpirit.transform.Find("btnCompose").GetComponent(); btnInfoSpiritCompose.transform.Find("txt").GetComponent().text = LocalizationText.GetText("all_compose"); } } public static void IsUnlock() { if (curMgr.isUnlockPet) { return; } curMgr.mainLock = curMgr.mainPetButton.transform.Find("Image").gameObject; curMgr.mainLock.SetActive(!DataHandler.IsClearStage(DataHandler.GetDungeonTypeInfo(DungeonMgr.DungeonKind.PetDG).openStage)); ColorBlock colorBlock = curMgr.mainPetButton.colors; if (curMgr.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); curMgr.mainPetButton.colors = colorBlock; } else { curMgr.isUnlockPet = 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); curMgr.mainPetButton.colors = colorBlock; } } // 설정에서 언어 변경 시 처리. public static void SReLocalize() { curMgr.Localize(true); curMgr.bReLocalize = true; curMgr.bReLocalizePet = true; } // 백버튼 처리. public static bool SCloseMenu() { return curMgr.CloseMenu(); } private bool CloseMenu() { // 게임 시작 후 열린적 없음. if (iSelectedTab < 0) return false; // 추가 효과 자동 변경 설정. if (groupOptionAuto.activeSelf) { BtnEfcAddAutoClose(); return true; } // 추가 효과 자동 변경 진행중. if (bEfcAddAuto) { BtnEfcAddChangeAutoStop(); return true; } if (canvasUI.enabled) { ClosePet(); return true; } return false; } private void Awake() { curMgr = this; } void Start() { SetBadge(); iLoading--; //if (!DataHandler.GetPet(1).have) //{ // TestGetPet(); //} } #endregion Base #region UI public static void SMovePet(eEventMoveType content) { curMgr.OpenPet(); switch (content) { case eEventMoveType.pet: curMgr.TabPress(0); break; case eEventMoveType.petSprit: curMgr.TabPress(1); break; } } // 펫창 열기. public void OpenPet() { if (mainLock.activeSelf) { GameUIMgr.SOpenToast(FormatString.TextOpenStageClear(DataHandler.GetDungeonTypeInfo(DungeonMgr.DungeonKind.PetDG).openStage));//펫 던전 해금될때 해금됨 return; } if (iLoading > 0) return; iLoading++; if (bReLocalize) Localize(false); if (iSelectedTab < 0) { iPresetPets = new int[6][]; for (int i = 0; i < iPresetPets.Length; i++) { iPresetPets[i] = new int[3]; for (int k = 0; k < iPresetPets[i].Length; k++) { iPresetPets[i][k] = DataHandler.PlayData.petPresets[i][k]; } } TabPress(0); } else { escrPet.scroller.RefreshActiveCellViews(); SetLeftPetInfo(); TabLeftEffect(); if (iSelectedTab == 1) btnComposeAll.interactable = DataHandler.IsPetSpiritComposable(fRangeRarity.All); } SetBadge(); SetTotalLvEfc(); canvasUI.enabled = true; petLeftInfo.enabled = true; //rtrfGoodsInfo.gameObject.SetActive(true); //groupInfoPet.SetActive(true); GameUIMgr.SRightWindowClose(); GameUIMgr.SOpenLeftPanel(change: true, pudding: true); GameUIMgr.SSetMainUiOn(false); BattleMgr.CloseFailScroll(); if (bReLocalizePet) { bReLocalizePet = false; if (iSelectedTab == 0) { txtInfoT.text = LocalizationText.GetText("pet_info"); } else { txtInfoT.text = LocalizationText.GetText("petspirit_info"); } escrPet.Localize(); } TabPress(iSelectedTab); iLoading--; } public void TestGetPet() { SettingMgr.SGetPetT(); } // 펫창 닫기. public void ClosePet() { if (!canvasUI.enabled) return; if (iLoading > 0) return; iLoading++; ResetPetPreset(); MissionMgr.SRefreshMission(); canvasUI.enabled = false; petLeftInfo.enabled = false; groupOptionAuto.SetActive(false); GameUIMgr.SCloseLeftPanel(); GameUIMgr.SSetMainUiOn(true); if (isSave > 0) { GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved)); isSave = 0; } SoundMgr.PlaySfx(SoundName.BtnPress); iLoading--; } // 도움말 열기. public void OpenHelp() { } #endregion UI #region Tab public void TabPress(int index) { if (iSelectedTab == index) return; iLoading++; if (iSelectedTab >= 0) { btnTabs[iSelectedTab].interactable = true; } iSelectedTab = index; btnTabs[iSelectedTab].interactable = false; SoundMgr.PlaySfx(SoundName.BtnPress); // 펫. if (iSelectedTab == 0) { Vector2 v2pos = rtrfSvPet.offsetMax; v2pos.y = -petScrTopValue; rtrfSvPet.offsetMax = v2pos; groupTotalEfc.SetActive(true); groupPreset.SetActive(true); txtInfoT.text = LocalizationText.GetText("pet_info"); btnComposeAll.gameObject.SetActive(false); TabPreset(DataHandler.PlayData.usePetPreset); iSvType = cGoods.TPet; if (bInitNeedPet) { bInitNeedPet = false; // 초기화. int irowcnt = 4; Dictionary datas = DataHandler.GetPets(); petRows = new EnhancedUI.SmallList(); petIds = new int[datas.Count]; int itemindex = 0; foreach (var item in datas) { if (itemindex % irowcnt == 0) petRows.Add(petRows.Count); petIds[itemindex] = item.Key; itemindex++; } int ipet = DataHandler.PlayData.petPresets[iSelectedPreset][0] - 1; if (ipet < 0) SelectPet(0, 0,true); else SelectPet(ipet / 4, ipet % 4,true); escrPet.LoadDatas(petRows); } else { int ipet = DataHandler.PlayData.petPresets[iSelectedPreset][0] - 1; if (ipet < 0) SelectPet(0, 0,true); else SelectPet(ipet / 4, ipet % 4,true); escrPet.scroller.RefreshActiveCellViews(); escrPet.scroller.SetScrollPositionImmediately(0f); } } // 스피릿. else { Vector2 v2pos = rtrfSvPet.offsetMax; v2pos.y = -petSpiritScrTopValue; rtrfSvPet.offsetMax = v2pos; groupTotalEfc.SetActive(false); groupPreset.SetActive(false); txtInfoT.text = LocalizationText.GetText("petspirit_info"); btnComposeAll.interactable = DataHandler.IsPetSpiritComposable(fRangeRarity.All); btnComposeAll.gameObject.SetActive(true); iSvType = cGoods.TPetSpirit; // 추가효과 자동 변경창 열려있으면 닫기. if (groupOptionAuto.activeSelf) { rtrfGoodsInfo.gameObject.SetActive(true); groupInfoPet.SetActive(true); //goBtnInfoHelp.SetActive(true); groupOptionAuto.SetActive(false); btnEfcAdd.gameObject.SetActive(true); btnEfcAddAuto.gameObject.SetActive(true); groupAutoNow.SetActive(false); } SelectPet(0, 0,true); escrPet.scroller.RefreshActiveCellViews(); escrPet.scroller.SetScrollPositionImmediately(0f); } // 선 표시. for (int i = 0; i < imgTabLineBottoms.Length; i++) { imgTabLineBottoms[i].enabled = iSelectedTab != i; if (i == iSelectedTab) { imgTabLineBottoms[i].enabled = false; imgTabLineRights[i].enabled = true; } else { imgTabLineBottoms[i].enabled = true; imgTabLineRights[i].enabled = true; } } SetBadge(); iLoading--; } // 현재 스크롤뷰 타입. public static int SGetSvType() { return curMgr.iSvType; } public static void SSetBadge() { curMgr.SetBadge(); } // 탭 뱃지 표시. private void SetBadge() { if (bInitNeedPet) { goMainBadge.SetActive(DataHandler.IsPetNewHave()); return; } goTabBadges[0].SetActive(DataHandler.IsPetNewHave()); goTabBadges[1].SetActive(false); if (goTabBadges[0].activeSelf || goTabBadges[1].activeSelf) goMainBadge.SetActive(true); else goMainBadge.SetActive(false); } // 총합 레벨 효과 표시. private void SetTotalLvEfc() { int[] ilvefcs = DataHandler.GetPetTotalLevels(); txtTotalLv.text = FormatString.TextLv(ilvefcs[1]); txtTotalEfc.text = FormatString.TextCntPerBlank(ilvefcs[0].ToString(), ilvefcs[3].ToString()); txtTotalEfcT.text = FormatString.StringFormat(LocalizationText.GetText("pet_addefc"), FormatString.TextEffectValue(eEffectType.PetBuff, ilvefcs[2])); } #endregion Tab #region Pet public static int SGetPetId(int irow, int icolumn) { return curMgr.GetPetId(irow, icolumn); } // 펫 번호. private int GetPetId(int irow, int icolumn) { int index = irow * 4 + icolumn; if (index >= petIds.Length) return -1; return petIds[index]; } public static bool SIsSetPet(int idx) { return curMgr.IsSetPet(idx); } // 프리셋에 장착된 펫인지. private bool IsSetPet(int idx) { if (iSelectedPreset < 0) return false; int[] ipresets = iPresetPets[iSelectedPreset]; for (int i = 0; i < ipresets.Length; i++) { if (ipresets[i] == idx) return true; } return false; } // 선택된 펫인지. public static bool SIsSelectPet(int idx) { return idx == curMgr.iSelectedId; } public static void SSelectPet(int irow, int icolumn) { if (curMgr.iLoading > 0) return; curMgr.isChange = true; curMgr.SelectPet(irow, icolumn, false); } // 펫 선택. public void SelectPet(int irow, int icolumn, bool isOpen) { iLoading++; int key = GetPetId(irow, icolumn); iSelectedId = key; SetLeftPetInfo(); TabLeftEffect(); escrPet.scroller.RefreshActiveCellViews(); if (groupOptionAuto.activeSelf) { groupOptionAuto.SetActive(false); rtrfGoodsInfo.gameObject.SetActive(true); groupInfoPet.SetActive(true); } iLoading--; if (!isOpen) { for (int i = 0; i < 3; i++) { if (AutoBtnPresetSlot(i)) { break; } } } } #endregion Pet #region Preset // 프리셋 버튼 선택. public void TabPreset(int index) { if (iSelectedPreset == index) return; if (iSelectedPreset >= 0) btnPresetTabs[iSelectedPreset].interactable = true; iSelectedPreset = index; btnPresetTabs[iSelectedPreset].interactable = false; SoundMgr.PlaySfx(SoundName.BtnPress); SetPetPreset(); escrPet.scroller.RefreshActiveCellViews(); } int isSave = 0; // 프리셋 세팅. private void SetPetPreset() { for (int k = 0; k < goodsPresets.Length; k++) { if (iPresetPets[iSelectedPreset][k] < 0) { goodsPresets[k].ReleaseData(); goPresetUnsets[k].SetActive(false); goPresetEmptys[k].SetActive(true); } else { goodsPresets[k].SetGoods(cGoods.TPet, iPresetPets[iSelectedPreset][k], 0L); goPresetUnsets[k].SetActive(true); goPresetEmptys[k].SetActive(false); } } ApplyPetPreset(); } // 프리셋 초기화. 수정한 내용 취소. private void ResetPetPreset() { if (!bChangePreset) return; bChangePreset = false; for (int i = 0; i < iPresetPets.Length; i++) { for (int k = 0; k < iPresetPets[i].Length; k++) { if (iPresetPets[i][k] == DataHandler.PlayData.petPresets[i][k]) continue; iPresetPets[i][k] = DataHandler.PlayData.petPresets[i][k]; if (i == iSelectedPreset) { if (iPresetPets[i][k] < 0) { goodsPresets[k].ReleaseData(); goPresetUnsets[k].SetActive(false); goPresetEmptys[k].SetActive(true); } else { goodsPresets[k].SetGoods(cGoods.TPet, iPresetPets[i][k], 0L); goPresetUnsets[k].SetActive(true); goPresetEmptys[k].SetActive(false); } } } } TabPreset(DataHandler.PlayData.usePetPreset); } // 프리셋 저장. public void ApplyPetPreset() { if (iSelectedPreset != DataHandler.PlayData.usePetPreset) bChangePreset = true; if (iLoading > 0 || !bChangePreset) return; iLoading++; bool[] bchanges = new bool[6]; for (int i = 0; i < iPresetPets.Length; i++) { for (int k = 0; k < iPresetPets[i].Length; k++) { if (iPresetPets[i][k] != DataHandler.PlayData.petPresets[i][k]) { bchanges[i] = true; DataHandler.EditPetPreset(i, k, iPresetPets[i][k]); } } } // 프리셋 번호 변경. if (iSelectedPreset != DataHandler.PlayData.usePetPreset) { DataHandler.ChangePetPreset(iSelectedPreset); DataHandler.PlayData.Save(); DataHandler.CalcPetEquipExtra(DataHandler.PlayData.usePetPreset); BattleMgr.SSetPet(DataHandler.PlayData.usePetPreset); //GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved)); isSave++; } // 프리셋 내용 변경. else if (bchanges[0] || bchanges[1] || bchanges[2] || bchanges[3] || bchanges[4] || bchanges[5]) { DataHandler.PlayData.Save(); if (bchanges[DataHandler.PlayData.usePetPreset]) { DataHandler.CalcPetEquipExtra(DataHandler.PlayData.usePetPreset); BattleMgr.SSetPet(DataHandler.PlayData.usePetPreset); } //GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved)); isSave++; } bChangePreset = false; iLoading--; } // 프리셋의 슬롯 선택. public bool AutoBtnPresetSlot(int islotindex) { if (iSelectedTab > 0) return false; if (iLoading > 0) return false; iLoading++; // 선택중인 펫이 없는 경우. if (iSelectedId < 0) { iLoading--; return false; } // 획득하지 않은 펫. if (!DataHandler.GetPet(iSelectedId).have) { iLoading--; return false; } // 선택중인 펫에 있는 펫이 선택된 슬롯에 이미 장착되어 있으면 아무것도 하지 않음. if (iPresetPets[iSelectedPreset][islotindex] == iSelectedId) { iLoading--; return false; } // 선택중인 펫이 해당 프리셋의 다른 슬롯에 있는지 확인. int iprevslot = -1; for (int k = 0; k < iPresetPets[iSelectedPreset].Length; k++) { if (iPresetPets[iSelectedPreset][k] == iSelectedId) { iprevslot = k; iLoading--; return false; } } // 선택한 슬롯에 다른 펫 없으면 펫 세팅. if (iPresetPets[iSelectedPreset][islotindex] < 0) { //// 선택중인 펫이 이미 다른 슬롯에 있으면 그 슬롯 해제. //if (iprevslot >= 0) //{ // iPresetPets[iSelectedPreset][iprevslot] = -1; // goodsPresets[iprevslot].ReleaseData(); // goPresetUnsets[iprevslot].SetActive(false); // goPresetEmptys[iprevslot].SetActive(true); //} // 선택한 슬롯에 펫 세팅. iPresetPets[iSelectedPreset][islotindex] = iSelectedId; goodsPresets[islotindex].SetGoods(cGoods.TPet, iSelectedId, 0L); goPresetUnsets[islotindex].SetActive(true); goPresetEmptys[islotindex].SetActive(false); } // 선택한 슬롯에 이미 장착된 다른 펫이 있는 경우 서로 교체. else { iLoading--; return false; //// 선택중인 펫이 이미 다른 슬롯에 있으면 그 슬롯에 선택한 슬롯에 장착중인 펫을 장착. //if (iprevslot >= 0) //{ // iPresetPets[iSelectedPreset][iprevslot] = iPresetPets[iSelectedPreset][islotindex]; // goodsPresets[iprevslot].SetGoods(cGoods.TPet, iPresetPets[iSelectedPreset][iprevslot], 0L); // goPresetUnsets[iprevslot].SetActive(true); // goPresetEmptys[iprevslot].SetActive(false); //} // //// 선택한 슬롯에 펫 세팅. //iPresetPets[iSelectedPreset][islotindex] = iSelectedId; //goodsPresets[islotindex].SetGoods(cGoods.TPet, iSelectedId, 0L); //goPresetUnsets[islotindex].SetActive(true); //goPresetEmptys[islotindex].SetActive(false); } escrPet.scroller.RefreshActiveCellViews(); bChangePreset = true; iLoading--; ApplyPetPreset(); return true; } // 프리셋의 슬롯 선택. public void BtnPresetSlot(int islotindex) { if (iSelectedTab > 0) return; if (iLoading > 0) return; iLoading++; // 선택중인 펫이 없는 경우. if (iSelectedId < 0) { iLoading--; return; } // 획득하지 않은 펫. if (!DataHandler.GetPet(iSelectedId).have) { iLoading--; return; } // 선택중인 펫에 있는 펫이 선택된 슬롯에 이미 장착되어 있으면 아무것도 하지 않음. if (iPresetPets[iSelectedPreset][islotindex] == iSelectedId) { iLoading--; return; } // 선택중인 펫이 해당 프리셋의 다른 슬롯에 있는지 확인. int iprevslot = -1; for (int k = 0; k < iPresetPets[iSelectedPreset].Length; k++) { if (iPresetPets[iSelectedPreset][k] == iSelectedId) { iprevslot = k; break; } } // 선택한 슬롯에 다른 펫 없으면 펫 세팅. if (iPresetPets[iSelectedPreset][islotindex] < 0) { // 선택중인 펫이 이미 다른 슬롯에 있으면 그 슬롯 해제. if (iprevslot >= 0) { iPresetPets[iSelectedPreset][iprevslot] = -1; goodsPresets[iprevslot].ReleaseData(); goPresetUnsets[iprevslot].SetActive(false); goPresetEmptys[iprevslot].SetActive(true); } // 선택한 슬롯에 펫 세팅. iPresetPets[iSelectedPreset][islotindex] = iSelectedId; goodsPresets[islotindex].SetGoods(cGoods.TPet, iSelectedId, 0L); goPresetUnsets[islotindex].SetActive(true); goPresetEmptys[islotindex].SetActive(false); } // 선택한 슬롯에 이미 장착된 다른 펫이 있는 경우 서로 교체. else { // 선택중인 펫이 이미 다른 슬롯에 있으면 그 슬롯에 선택한 슬롯에 장착중인 펫을 장착. if (iprevslot >= 0) { iPresetPets[iSelectedPreset][iprevslot] = iPresetPets[iSelectedPreset][islotindex]; goodsPresets[iprevslot].SetGoods(cGoods.TPet, iPresetPets[iSelectedPreset][iprevslot], 0L); goPresetUnsets[iprevslot].SetActive(true); goPresetEmptys[iprevslot].SetActive(false); } // 선택한 슬롯에 펫 세팅. iPresetPets[iSelectedPreset][islotindex] = iSelectedId; goodsPresets[islotindex].SetGoods(cGoods.TPet, iSelectedId, 0L); goPresetUnsets[islotindex].SetActive(true); goPresetEmptys[islotindex].SetActive(false); } escrPet.scroller.RefreshActiveCellViews(); bChangePreset = true; iLoading--; ApplyPetPreset(); } // 프리셋의 슬롯 해제. public void BtnPresetRelease(int islotindex) { if (iSelectedTab > 0) return; if (iLoading > 0) return; iLoading++; // 슬롯에 펫 없으면 아무것도 하지 않음. if (iPresetPets[iSelectedPreset][islotindex] < 0) { iLoading--; return; } // 선택한 슬롯에 있는 펫을 해제. iPresetPets[iSelectedPreset][islotindex] = -1; goodsPresets[islotindex].ReleaseData(); goPresetUnsets[islotindex].SetActive(false); goPresetEmptys[islotindex].SetActive(true); escrPet.scroller.RefreshActiveCellViews(); SoundMgr.PlaySfx(SoundName.BtnPress); bChangePreset = true; iLoading--; ApplyPetPreset(); } #endregion Preset #region Pet Enhance // 펫 강화 시작. public void OnBtnPetEnhanceDown() { if (iLoading > 0) return; if (bClicking) return; iLoading++; bClicking = true; int ibeflv = DataHandler.GetPet(iSelectedId).level; dataEnhance = new nIdEnhance(iSelectedId, ibeflv); StartCoroutine("CPetEnhance"); } // 펫 강화 진행. private IEnumerator CPetEnhance() { int imaxlv = DataHandler.GetPetMaxLv(iSelectedId); dPet pet = DataHandler.GetPet(iSelectedId); BigInteger calcmultiply = BigInteger.Pow(pet.buyingCountInc, dataEnhance.aftLv - 1); BigInteger calcdivide = BigInteger.Pow(dConst.RateMaxBi, dataEnhance.aftLv - 1); BigInteger biprice = pet.buyingCount * calcmultiply / calcdivide; //int ipricebase = pet.buyingCount; //int ipriceinc = pet.buyingCountInc; int iprice = (int)biprice; if (iprice > DataHandler.Goods.pudding || dataEnhance.aftLv >= imaxlv) { OnBtnPetEnhanceUp(); yield break; } dataEnhance.aftLv++; dataEnhance.tryCount++; dataEnhance.useGoods += iprice; DataHandler.SubPudding(iprice); DataHandler.LvUpPet(iSelectedId, dataEnhance.aftLv, false); SetLeftPetInfo(); GameUIMgr.SPlayEfcLeftEnhance(); SoundMgr.PlaySfx(SoundName.BtnPress); SoundMgr.PlaySfx(SoundName.ReinforceSuccess); yield return YieldInstructionCache.WaitForSeconds(0.4f); while (bClicking) { calcmultiply = BigInteger.Pow(pet.buyingCountInc, dataEnhance.aftLv - 1); calcdivide = BigInteger.Pow(dConst.RateMaxBi, dataEnhance.aftLv - 1); biprice = pet.buyingCount * calcmultiply / calcdivide; iprice = (int)biprice; if (iprice > DataHandler.Goods.pudding || dataEnhance.aftLv >= imaxlv) { OnBtnPetEnhanceUp(); yield break; } dataEnhance.aftLv++; dataEnhance.tryCount++; dataEnhance.useGoods += iprice; DataHandler.SubPudding(iprice); DataHandler.LvUpPet(iSelectedId, dataEnhance.aftLv, false); SetLeftPetInfo(); GameUIMgr.SPlayEfcLeftEnhance(); SoundMgr.PlaySfx(SoundName.BtnPress); SoundMgr.PlaySfx(SoundName.ReinforceSuccess); yield return YieldInstructionCache.WaitForSeconds(0.1f); } } // 펫 강화 종료. public void OnBtnPetEnhanceUp() { if (!bClicking) return; CoverCamera.Hold(); StopCoroutine("CPetEnhance"); bClicking = false; SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.PetEnhance), typeof(nPetReturn), APetEnhanceSucc, APetEnhanceFail, dataEnhance, false); } // 펫 강화 통신 실패. private void APetEnhanceFail(SvError error, object request) { DataHandler.AddEnhanceStone(dataEnhance.useGoods); DataHandler.LvUpPet(dataEnhance.sid, dataEnhance.befLv, true); escrPet.scroller.RefreshActiveCellViews(); SetTotalLvEfc(); SetLeftPetInfo(); dataEnhance = null; CoverCamera.Release(); iLoading--; } // 펫 강화 통신 성공. private void APetEnhanceSucc(object result, object request) { nPetReturn data = result as nPetReturn; if (data == null) { APetEnhanceFail(new SvError(eErrorCode.NULL_OR_EMPTY), request); return; } DataHandler.SetGoods(data.playCurrency, true); DataHandler.LvUpPet(data.playPet.sid, data.playPet.lv, true); escrPet.scroller.RefreshActiveCellViews(); SetTotalLvEfc(); SetLeftPetInfo(); dataEnhance = null; CoverCamera.Release(); iLoading--; } #endregion Pet Enhance #region Pet Awaken // 펫 각성. public void BtnPetAwaken() { if (iSelectedId < 0) return; if (iLoading > 0) return; iLoading++; // 스피릿. dAwaken awaken = DataHandler.GetPetAwakenNext(iSelectedId); int[] ihavecounts = new int[1] { DataHandler.GetPetSpiritCount(iSelectedId) }; int[] ineedcounts = new int[1] { awaken.buyingCnt1 }; nGoods[] goodsneeds = new nGoods[1] { new nGoods(cGoods.TPetSpirit, iSelectedId, ihavecounts[0]) }; SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOpenPopupItemsUseTo(goodsneeds, new nGoods(cGoods.TPet, iSelectedId, -1), APetAwaken, null, LocalizationText.GetText("pet_awaken"), LocalizationText.GetText("pet_awakenmsg"), LocalizationText.GetText("all_awakengo"), LocalizationText.GetText(Global.STR_CANCEL)); GameUIMgr.SSetPopupItemsUseToCount(ihavecounts, ineedcounts); iLoading--; } // 펫 각성하기. private void APetAwaken() { if (iLoading > 0) return; iLoading++; CoverCamera.Hold(); SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.PetAwaken), typeof(nPetReturn), APetAwakenSucc, APetAwakenFail, new nIdCnt(iSelectedId), false); } // 펫 각성 통신 실패. private void APetAwakenFail(SvError error, object request) { CoverCamera.Release(); iLoading--; } // 펫 각성 통신 성공. private void APetAwakenSucc(object result, object request) { nPetReturn data = result as nPetReturn; if (data == null) { APetAwakenFail(new SvError(eErrorCode.NULL_OR_EMPTY), request); return; } // 펫 각성 및 스피릿 수량 감소. DataHandler.AwakenPet(data.playPet.sid, data.playPet.awaken, data.playPet.cnt); SetLeftPetInfo(); if (groupInfoPetEffectAdd.activeSelf) { SetEfcAddList(true); SetEfcAddCost(); } GameUIMgr.SOpenToast(LocalizationText.GetText("msg_petawaken")); CoverCamera.Release(); iLoading--; } #endregion Pet Awaken #region Pet Effect Add public static void SSetEfcAddCost() { curMgr.SetEfcAddCost(); } // 효과 변경 가격 표시. private void SetEfcAddCost() { int icnt = 0; for (int i = 0; i < efcAddItems.Length; i++) { if (efcAddItems[i].IsChangable()) icnt++; } int iprice = DataHandler.Const.petExtraChangeStonePrice * icnt; txtEfcAddPrice.text = FormatString.TextInt(iprice); btnEfcAdd.interactable = DataHandler.Goods.changeStone >= iprice; btnEfcAddAuto.interactable = btnEfcAdd.interactable; txtEfcAddPriceStart.text = txtEfcAddPrice.text; btnEfcAddAutoStart.interactable = btnEfcAdd.interactable; } bool isChange = false; // 추가 효과 표시. private void SetEfcAddList(bool breset) { dPet pet = DataHandler.GetPet(iSelectedId); bool bopenoption = true; if (breset) { for (int i = 0; i < efcAddItems.Length; i++) { if (i + 1 >= pet.maxAwaken) { efcAddItems[i].gameObject.SetActive(false); continue; } efcAddItems[i].gameObject.SetActive(true); bool bopen = pet.awaken > i + 1; if (isChange) { efcAddItems[i].SetChangeOpen(bopen); isChange = false; } else { efcAddItems[i].SetOpen(bopen); } if (bopen) { efcAddItems[i].SetEffect(pet.extraEffects[i]); if (pet.extraEffects[i] < 0 || DataHandler.GetExtraAbility(pet.extraEffects[i]).rarity < cGoods.RLegend) bopenoption = false; } else { bopenoption = false; } } } else { for (int i = 0; i < efcAddItems.Length; i++) { if (i + 1 >= pet.maxAwaken) { continue; } bool bopen = pet.awaken > i + 1; if (bopen) { efcAddItems[i].SetEffect(pet.extraEffects[i]); if (pet.extraEffects[i] < 0 || DataHandler.GetExtraAbility(pet.extraEffects[i]).rarity < cGoods.RLegend) bopenoption = false; } else { bopenoption = false; } } } efcAddOption.SetOpen(bopenoption); if (bopenoption) { efcAddOption.SetEffect(pet.abilityTypeOption, pet.abilityValueOption); } } // 아이템 효과 종류. public static eEffectType SGetEfcAddAutoType(int index) { if (index < 0) return eEffectType.None; return curMgr.efcOptions[index]; } // 아이템 선택 상태. public static bool SGetEfcAddAutoSelect(int index) { if (index < 0) return false; return curMgr.bSelectedOptions[index]; } // 추가 효과 자동 변경 창 열기. public void BtnEfcAddChangeAuto() { if (iLoading > 0) return; iLoading++; txtInfoT.text = LocalizationText.GetText("all_effectadd"); rtrfGoodsInfo.gameObject.SetActive(false); groupInfoPet.SetActive(false); goBtnInfoHelp.SetActive(false); groupOptionAuto.SetActive(true); // 초기화. if (bInitNeedOption) { bInitNeedOption = false; Dictionary dicdatas = DataHandler.GetExtraAbilityIds()[0]; EnhancedUI.SmallList datas = new EnhancedUI.SmallList(); bSelectedOptions = new bool[dicdatas.Count]; efcOptions = new eEffectType[dicdatas.Count]; int index = 0; foreach (var item in dicdatas) { bSelectedOptions[index] = true; efcOptions[index] = DataHandler.GetExtraAbility(item.Value).abilityType; datas.Add(index); index++; } escrEfcAddAuto.SetType(cGoods.TPet); escrEfcAddAuto.LoadDatas(datas); } else { escrEfcAddAuto.scroller.RefreshActiveCellViews(); } efcOptionRarties[0].SetToggle(); SoundMgr.PlaySfx(SoundName.BtnPress); iLoading--; } // 추가 효과 자동 변경 창 닫기. public void BtnEfcAddAutoClose() { if (iLoading > 0) return; iLoading++; txtInfoT.text = LocalizationText.GetText("pet_info"); rtrfGoodsInfo.gameObject.SetActive(true); groupInfoPet.SetActive(true); goBtnInfoHelp.SetActive(true); groupOptionAuto.SetActive(false); btnEfcAdd.gameObject.SetActive(true); btnEfcAddAuto.gameObject.SetActive(true); groupAutoNow.SetActive(false); iLoading--; } // 추가 효과 토글 변경. public static void SToggleSelect(int itemid, bool bselect) { if (itemid < 0) { if (bselect) { if (itemid == -1) { curMgr.efcOptionRarties[0].SetSelected(true); curMgr.efcOptionRarties[1].SetSelected(false); } else { curMgr.efcOptionRarties[0].SetSelected(false); curMgr.efcOptionRarties[1].SetSelected(true); } } return; } curMgr.bSelectedOptions[itemid] = bselect; curMgr.escrEfcAddAuto.scroller.RefreshActiveCellViews(); } // 추가 효과 자동 변경 시작. public void BtnEfcAddChangeAutoStart() { if (iLoading > 0) return; iLoading++; bEfcAddAuto = true; int icheck = CheckEfcAdd(true); if (icheck > 0) { iLoading--; return; } AEfcAddChange(); } // 추가 효과 자동 변경 종료. public void BtnEfcAddChangeAutoStop() { if (!bEfcAddAuto) return; ProcessEfcAddAutoStop(); SoundMgr.PlaySfx(SoundName.BtnPress); // UI 표시 변경. 통신 도중일 경우 Cover 켜기(bEfcAddAuto = false 이므로 통신 종료 후 1회 변경과 같은 처리에서 꺼지게 됨). if (bEfcAddChanging) CoverCamera.Hold(); } // 추가 효과 자동 변경 종료시 처리. private void ProcessEfcAddAutoStop() { bEfcAddAuto = false; CancelInvoke("IEfcAddChangeAuto"); btnEfcAdd.gameObject.SetActive(true); btnEfcAddAuto.gameObject.SetActive(true); groupAutoNow.SetActive(false); // 장착 펫 추가 효과 적용. int slotindex = DataHandler.GetPetSlot(iSelectedId); if (slotindex >= 0) DataHandler.CalcPetExtra(DataHandler.PlayData.usePetPreset, slotindex, true); } // 1회 변경 버튼 클릭. public void BtnEfcAddChange() { if (iLoading > 0) return; iLoading++; bEfcAddAuto = false; int icheck = CheckEfcAdd(false); if (icheck > 0) { iLoading--; return; } AEfcAddChange(); } // 추가 효과 바꾸기 전 현재 옵션 검사. private int CheckEfcAdd(bool bauto) { iEfcAddSlots = 0; if (efcAddItems[0].IsChangable()) iEfcAddSlots += 1; if (efcAddItems[1].IsChangable()) iEfcAddSlots += 2; if (efcAddItems[2].IsChangable()) iEfcAddSlots += 4; // 변경 가능한 슬롯이 없습니다. if (iEfcAddSlots == 0) { GameUIMgr.SOpenToast(LocalizationText.GetText("msg_noslotchange")); return 1; } // 자동 설정 효과 선택되었는지. if (bauto) { bool bselectany = false; for (int k = 0; k < bSelectedOptions.Length; k++) { if (bSelectedOptions[k]) { bselectany = true; break; } } // 효과를 선택해주세요. if (!bselectany) { GameUIMgr.SOpenToast(LocalizationText.GetText("msg_abilityselect")); return 2; } } dPet pet = DataHandler.GetPet(iSelectedId); int iraritymin = cGoods.RLegend; if (bauto && efcOptionRarties[1].IsSelected()) iraritymin = cGoods.RMyth; bool bhaveefc = false; bool bheroup = false; for (int i = 0; i < efcAddItems.Length; i++) { if (i + 1 >= pet.maxAwaken) break; // 미해금 또는 잠긴 상태. if (!efcAddItems[i].IsChangable()) continue; // 현재 효과 없음. if (pet.extraEffects[i] < 0) continue; dExtraAbility ability = DataHandler.GetExtraAbility(pet.extraEffects[i]); // 자동 설정에 포함된 효과 검사. if (bauto && !bhaveefc) { // 희귀도 조건 만족. if (ability.rarity >= iraritymin) { for (int k = 0; k < efcOptions.Length; k++) { // 조건 종류 만족. if (ability.abilityType == efcOptions[k]) { // 선택된 조건일 경우. if (bSelectedOptions[k]) bhaveefc = true; break; } } } } // 높은 등급 효과 검사. if (ability.rarity >= cGoods.RLegend) bheroup = true; } // 슬롯에 이미 획득한 옵션이 존재합니다. if (bhaveefc) { GameUIMgr.SOpenToast(LocalizationText.GetText("msg_abilityhave")); return 3; } // 높은 희귀도의 옵션이 포함되어있습니다. 변경하시겠습니까? if (bheroup) { GameUIMgr.SOpenPopup2Button(LocalizationText.GetText("msg_highgrade"), AEfcAddChange); return 4; } return 0; } // 자동 변경된 추가 효과에 원하는 옵션이 있는지 검사. private bool CheckEfcAddChanging(int[] extras) { int iraritymin = cGoods.RLegend; if (efcOptionRarties[1].IsSelected()) iraritymin = cGoods.RMyth; for (int i = 0; i < extras.Length; i++) { // 미해금 또는 잠긴 상태. if (!efcAddItems[i].IsChangable()) continue; // 현재 효과 없음. if (extras[i] < 0) continue; dExtraAbility ability = DataHandler.GetExtraAbility(extras[i]); // 희귀도 조건 만족. if (ability.rarity >= iraritymin) { for (int k = 0; k < efcOptions.Length; k++) { // 조건 종류 만족. if (ability.abilityType == efcOptions[k]) { // 선택된 조건일 경우. if (bSelectedOptions[k]) return true; } } } } return false; } // 추가 효과 변경. private void AEfcAddChange() { // 자동 변경일 경우 UI 표시 수정. if (bEfcAddAuto) { txtInfoT.text = LocalizationText.GetText("pet_info"); rtrfGoodsInfo.gameObject.SetActive(true); groupInfoPet.SetActive(true); goBtnInfoHelp.SetActive(true); groupOptionAuto.SetActive(false); btnEfcAdd.gameObject.SetActive(false); btnEfcAddAuto.gameObject.SetActive(false); groupAutoNow.SetActive(true); } else { CoverCamera.Hold(); } bEfcAddChanging = true; SoundMgr.PlaySfx(SoundName.BtnPress); nIdSlot data = new nIdSlot(iSelectedId, iEfcAddSlots); SvConnectManager.Instance.RequestSvPost(false, 0, UrlApi.GetUrl(UrlApi.PetEfcAdd), typeof(nPetReturn), AEfcAddChangeSucc, AEfcAddChangeFail, data, true); } // 추가 효과 자동 변경. Invoke에서 호출. private void IEfcAddChangeAuto() { if (!bEfcAddAuto) return; bEfcAddChanging = true; nIdSlot data = new nIdSlot(iSelectedId, iEfcAddSlots); SvConnectManager.Instance.RequestSvPost(false, 0, UrlApi.GetUrl(UrlApi.PetEfcAdd), typeof(nPetReturn), AEfcAddChangeSucc, AEfcAddChangeFail, data, true); } // 추가 효과 변경 통신 실패. private void AEfcAddChangeFail(SvError error, object request) { // 자동 변경 종료. if (bEfcAddAuto) { ProcessEfcAddAutoStop(); } else { CoverCamera.Release(); } bEfcAddChanging = false; iLoading--; } // 추가 효과 변경 성공. private void AEfcAddChangeSucc(object result, object request) { nPetReturn data = result as nPetReturn; if (data == null) { AEfcAddChangeFail(new SvError(eErrorCode.NULL_OR_EMPTY), request); return; } DataHandler.SetGoods(data.playCurrency, true); nIdLvInfo playdata = data.playPet; DataHandler.ChangePetExtras(playdata.sid, playdata.extras); // 자동 변경일 경우. if (bEfcAddAuto) { // 원하는 효과를 얻었으면 종료. 재화가 부족해도 종료. if (CheckEfcAddChanging(playdata.extras)) { ProcessEfcAddAutoStop(); // 설정한 추가 효과를 획득하였습니다. GameUIMgr.SOpenToast(LocalizationText.GetText("msg_abilityget")); } else { int icnt = 0; for (int i = 0; i < efcAddItems.Length; i++) { if (efcAddItems[i].IsChangable()) icnt++; } int iprice = DataHandler.Const.petExtraChangeStonePrice * icnt; // 재화가 부족하면 종료. if (iprice > DataHandler.Goods.changeStone) { GameUIMgr.SOpenToast(LocalizationText.GetText("msg_nodice")); ProcessEfcAddAutoStop(); } // 원하는 효과가 없는 경우 다시 시도. else Invoke("IEfcAddChangeAuto", Time.timeScale > 0f ? 0.5f * Time.timeScale : 0.5f); } } // 자동 변경이 아닐 경우 종료. else { // 장착 펫 추가 효과 적용. int slotindex = DataHandler.GetPetSlot(iSelectedId); if (slotindex >= 0) DataHandler.CalcPetExtra(DataHandler.PlayData.usePetPreset, slotindex, true); CoverCamera.Release(); } SetEfcAddList(false); SetEfcAddCost(); bEfcAddChanging = false; iLoading--; } #endregion Pet Effect Add #region Spirit Compose // 스피릿 합성. public void BtnSpiritCompose() { if (iSelectedId < 0) return; if (iLoading > 0) return; iLoading++; dPet pet = DataHandler.GetPet(iSelectedId); int iunit = DataHandler.Const.petSpiritComposePrice; iSelectedCount = 1; GameUIMgr.SOpenPopupItemUseTo(new nGoods(iSvType, iSelectedId, pet.count), new nGoods(iSvType, -1, -1L), ASpiritComposeSub, ASpiritComposeAdd, ASpiritComposeMin, ASpiritComposeMax, ASpiritCompose, null, LocalizationText.GetText("petspirit_compose"), LocalizationText.GetText("all_composedo"), LocalizationText.GetText(Global.STR_CANCEL)); GameUIMgr.SSetPopupItemUseToCount(iSelectedCount, iSelectedCount * iunit, iSelectedCount); iLoading--; } // 스피릿 합성 수 감소. private void ASpiritComposeSub() { if (iLoading > 0) return; iLoading++; if (iSelectedCount <= 1) { iLoading--; return; } iSelectedCount--; int iunit = DataHandler.Const.petSpiritComposePrice; GameUIMgr.SSetPopupItemUseToCount(iSelectedCount, iSelectedCount * iunit, iSelectedCount); iLoading--; } // 스피릿 합성 수 증가. private void ASpiritComposeAdd() { if (iLoading > 0) return; iLoading++; int iunit = DataHandler.Const.petSpiritComposePrice; int imaxcount = DataHandler.GetPetSpiritCount(iSelectedId) / iunit; if (iSelectedCount >= imaxcount) { iLoading--; return; } iSelectedCount++; GameUIMgr.SSetPopupItemUseToCount(iSelectedCount, iSelectedCount * iunit, iSelectedCount); iLoading--; } // 스피릿 합성 수 최소. private void ASpiritComposeMin() { if (iLoading > 0) return; iLoading++; if (iSelectedCount <= 1) { iLoading--; return; } iSelectedCount = 1; int iunit = DataHandler.Const.petSpiritComposePrice; GameUIMgr.SSetPopupItemUseToCount(iSelectedCount, iSelectedCount * iunit, iSelectedCount); iLoading--; } // 스피릿 합성 수 최대. private void ASpiritComposeMax() { if (iLoading > 0) return; iLoading++; int iunit = DataHandler.Const.petSpiritComposePrice; int imaxcount = DataHandler.GetPetSpiritCount(iSelectedId) / iunit; if (iSelectedCount >= imaxcount) { iLoading--; return; } iSelectedCount = imaxcount; GameUIMgr.SSetPopupItemUseToCount(iSelectedCount, iSelectedCount * iunit, iSelectedCount); iLoading--; } // 스피릿 합성하기. private void ASpiritCompose() { if (iLoading > 0) return; iLoading++; CoverCamera.Hold(); int iunit = DataHandler.Const.petSpiritComposePrice; nIdCnt data = new nIdCnt(iSelectedId, iSelectedCount * iunit); SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.PetSpiritCompose), typeof(nPetsReturn), ASpiritComposeSucc, ASpiritComposeFail, data, false); } // 스피릿 일괄 합성. public void BtnSpiritComposeAll() { if (iLoading > 0) return; iLoading++; fRangeRarity rarities = (fRangeRarity)ES3.Load(Global.ES3_PetSpiritRarity, FormatString.StringFormat(Global.ES3_Server, DataHandler.PlayData.server.ToString()), (int)fRangeRarity.All); SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOpenPopupRarityCheck(new nGoods(cGoods.TPetSpirit, -1, -1L), rarities, ASpiritComposeAllToggle, ASpiritComposeAll, ASpiritComposeAllSave, LocalizationText.GetText("petspirit_composeall"), LocalizationText.GetText("msg_composerarity"), LocalizationText.GetText("all_composedo"), LocalizationText.GetText(Global.STR_CANCEL)); GameUIMgr.SSetPopupRarityCheckYes(DataHandler.IsPetSpiritComposable(rarities)); iLoading--; } // 스피릿 일괄 합성 희귀도 선택 상태 저장. private void ASpiritComposeAllSave() { fRangeRarity rarities = GameUIMgr.SGetPopupRarityCheck(); ES3.Save(Global.ES3_PetSpiritRarity, (int)rarities, FormatString.StringFormat(Global.ES3_Server, DataHandler.PlayData.server.ToString())); } // 스피릿 일괄 합성 토글. private void ASpiritComposeAllToggle() { fRangeRarity rarities = GameUIMgr.SGetPopupRarityCheck(); GameUIMgr.SSetPopupRarityCheckYes(DataHandler.IsPetSpiritComposable(rarities)); } // 스피릿 일괄 합성하기. private void ASpiritComposeAll() { if (iLoading > 0) return; iLoading++; CoverCamera.Hold(); fRangeRarity rarities = GameUIMgr.SGetPopupRarityCheck(); ES3.Save(Global.ES3_PetSpiritRarity, (int)rarities, FormatString.StringFormat(Global.ES3_Server, DataHandler.PlayData.server.ToString())); nRarity data = new nRarity(rarities); SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.PetSpiritComposeAll), typeof(nPetsReturn), ASpiritComposeSucc, ASpiritComposeFail, data, false); } // 스피릿 합성 통신 실패. private void ASpiritComposeFail(SvError error, object request) { CoverCamera.Release(); iLoading--; } // 스피릿 합성 통신 성공. private void ASpiritComposeSucc(object result, object request) { nPetsReturn data = result as nPetsReturn; if (data == null) { ASpiritComposeFail(new SvError(eErrorCode.NULL_OR_EMPTY), request); return; } DataHandler.AddRecord(eCondition.PetspiritCompose, iSelectedCount); DataHandler.UpdatePetsPlay(data.playPet); if (data.result != null && data.result.Length > 0) { GameUIMgr.SOpenPopupGoods(data.result); } escrPet.scroller.RefreshActiveCellViews(); if (iSelectedId >= 0) SetLeftPetInfo(); btnComposeAll.interactable = DataHandler.IsPetSpiritComposable(fRangeRarity.All); CoverCamera.Release(); iLoading--; } #endregion Spirit Compose #region Left Info // 왼쪽 정보창 펫 정보 표시. private void SetLeftPetInfo() { // 스피릿. if (iSvType == cGoods.TPetSpirit) { int icount = DataHandler.GetPetSpiritCount(iSelectedId); goodsInfo.SetGoods(iSvType, iSelectedId, -1L); btnInfoSpiritCompose.interactable = icount >= DataHandler.Const.petSpiritComposePrice; txtInfoSpiritName.text = FormatString.GetGoodsName(iSvType, iSelectedId); txtInfoSpiritDesc.text = FormatString.GetGoodsDesc(iSvType, iSelectedId); if (groupInfoPet.activeSelf) { groupInfoPet.SetActive(false); groupInfoSpirit.SetActive(true); Vector2 v2pos = rtrfGoodsInfo.anchoredPosition; v2pos.x = F_LeftGoodsMid; rtrfGoodsInfo.anchoredPosition = v2pos; goBtnInfoHelp.SetActive(false); } return; } // 펫. dPet pet = DataHandler.GetPet(iSelectedId); int imaxlv = DataHandler.GetPetMaxLv(iSelectedId); if (DataHandler.RemovePetNew(iSelectedId)) SetBadge(); goodsInfo.SetGoods(iSvType, iSelectedId, -1L); txtInfoUnlockLv.text = FormatString.TextCondition(eCondition.DgStagePet, pet.condValue); txtInfoName.text = FormatString.GetGoodsName(iSvType, iSelectedId); txtInfoNameColorSetter?.SetColor(pet.rarity.ToString()); txtInfoLv.text = FormatString.TextLvPerMax(pet.have ? pet.level : 0, imaxlv); bool bmaxawaken = pet.awaken >= pet.maxAwaken; bool bmaxlv = pet.level >= imaxlv; int ilevel = pet.level - 1; // 최고 레벨이 아니면 강화 버튼 표시. btnInfoEnhance.gameObject.SetActive(!bmaxlv); // 최고 레벨에 각성이 가능하면 각성 버튼 표시. btnInfoAwaken.gameObject.SetActive(bmaxlv && !bmaxawaken); // 최고 레벨에 각성이 불가능하면 Max 버튼 표시. goInfoMax.SetActive(bmaxlv && bmaxawaken); // 각성 가능 펫는 추가 효과 탭 표시. imgTabInfoLineRight.enabled = pet.maxAwaken > 1; btnTabInfoEffectAdd.gameObject.SetActive(imgTabInfoLineRight.enabled); goBtnInfoEfcAddLock.SetActive(imgTabInfoLineRight.enabled && pet.awaken <= 1); goBtnInfoHelp.SetActive(imgTabInfoLineRight.enabled); goBtnInfoHelp.SetActive(!groupOptionAuto.activeSelf); string[] strefccurs = new string[3]; string[] strefcnexts = new string[3]; // 미소지. if (!pet.have) { txtInfoEnhance.text = FormatString.S_Hypen; btnInfoEnhance.interactable = false; if (pet.abilityType1 != eEffectType.None) { strefccurs[0] = FormatString.TextEffectValue(pet.abilityType1, 0L); strefcnexts[0] = FormatString.TextEffectValue(pet.abilityType1, pet.abilityValue1); } if (pet.abilityType2 != eEffectType.None) { strefccurs[1] = FormatString.TextEffectValue(pet.abilityType2, 0L); strefcnexts[1] = FormatString.TextEffectValue(pet.abilityType2, pet.abilityValue2); } if (pet.abilityType3 != eEffectType.None) { strefccurs[2] = FormatString.TextEffectValue(pet.abilityType3, 0L); strefcnexts[2] = FormatString.TextEffectValue(pet.abilityType3, pet.abilityValue3); } } // 최고 레벨. else if (bmaxlv) { if (pet.abilityType1 != eEffectType.None) { strefccurs[0] = FormatString.TextEffectValue(pet.abilityType1, ilevel * pet.abilityValueInc1 + pet.abilityValue1); } if (pet.abilityType2 != eEffectType.None) { strefccurs[1] = FormatString.TextEffectValue(pet.abilityType2, ilevel * pet.abilityValueInc2 + pet.abilityValue2); } if (pet.abilityType3 != eEffectType.None) { strefccurs[2] = FormatString.TextEffectValue(pet.abilityType3, ilevel * pet.abilityValueInc3 + pet.abilityValue3); } } // 최고 레벨 아님. else { BigInteger calcmultiply = BigInteger.Pow(pet.buyingCountInc, ilevel); BigInteger calcdivide = BigInteger.Pow(dConst.RateMaxBi, ilevel); BigInteger biprice = pet.buyingCount * calcmultiply / calcdivide; long iprice = (int)biprice; txtInfoEnhance.text = FormatString.TextInt(iprice); btnInfoEnhance.interactable = iprice <= DataHandler.Goods.pudding; int ilevelnext = ilevel + 1; if (pet.abilityType1 != eEffectType.None) { strefccurs[0] = FormatString.TextEffectValue(pet.abilityType1, ilevel * pet.abilityValueInc1 + pet.abilityValue1); strefcnexts[0] = FormatString.TextEffectValue(pet.abilityType1, ilevelnext * pet.abilityValueInc1 + pet.abilityValue1); } if (pet.abilityType2 != eEffectType.None) { strefccurs[1] = FormatString.TextEffectValue(pet.abilityType2, ilevel * pet.abilityValueInc2 + pet.abilityValue2); strefcnexts[1] = FormatString.TextEffectValue(pet.abilityType2, ilevelnext * pet.abilityValueInc2 + pet.abilityValue2); } if (pet.abilityType3 != eEffectType.None) { strefccurs[2] = FormatString.TextEffectValue(pet.abilityType3, ilevel * pet.abilityValueInc3 + pet.abilityValue3); strefcnexts[2] = FormatString.TextEffectValue(pet.abilityType3, ilevelnext * pet.abilityValueInc3 + pet.abilityValue3); } } // 펫 장착 효과 표시. if (pet.abilityType1 == eEffectType.None) { txtInfoEfcTs[0].enabled = false; txtInfoEfcCurs[0].enabled = false; InfoEfcArrowObjs[0].SetActive(false); txtInfoEfcNexts[0].enabled = false; } else { txtInfoEfcTs[0].text = FormatString.TextEffectTitle(pet.abilityType1); txtInfoEfcCurs[0].text = strefccurs[0]; txtInfoEfcNexts[0].text = strefcnexts[0]; txtInfoEfcTs[0].enabled = true; txtInfoEfcCurs[0].enabled = true; InfoEfcArrowObjs[0].SetActive(!bmaxlv); txtInfoEfcNexts[0].enabled = !bmaxlv; } if (pet.abilityType2 == eEffectType.None) { txtInfoEfcTs[1].enabled = false; txtInfoEfcCurs[1].enabled = false; InfoEfcArrowObjs[1].SetActive(false); txtInfoEfcNexts[1].enabled = false; } else { txtInfoEfcTs[1].text = FormatString.TextEffectTitle(pet.abilityType2); txtInfoEfcCurs[1].text = strefccurs[1]; txtInfoEfcNexts[1].text = strefcnexts[1]; txtInfoEfcTs[1].enabled = true; txtInfoEfcCurs[1].enabled = true; InfoEfcArrowObjs[1].SetActive(!bmaxlv); txtInfoEfcNexts[1].enabled = !bmaxlv; } if (pet.abilityType3 == eEffectType.None) { txtInfoEfcTs[2].enabled = false; txtInfoEfcCurs[2].enabled = false; InfoEfcArrowObjs[2].SetActive(false); txtInfoEfcNexts[2].enabled = false; } else { txtInfoEfcTs[2].text = FormatString.TextEffectTitle(pet.abilityType3); txtInfoEfcCurs[2].text = strefccurs[2]; txtInfoEfcNexts[2].text = strefcnexts[2]; txtInfoEfcTs[2].enabled = true; txtInfoEfcCurs[2].enabled = true; InfoEfcArrowObjs[2].SetActive(!bmaxlv); txtInfoEfcNexts[2].enabled = !bmaxlv; } imgBtnInfoEnhance.raycastTarget = btnInfoEnhance.interactable; if (groupInfoSpirit.activeSelf) { groupInfoPet.SetActive(true); groupInfoSpirit.SetActive(false); Vector2 v2pos = rtrfGoodsInfo.anchoredPosition; v2pos.x = F_LeftGoodsLeft; rtrfGoodsInfo.anchoredPosition = v2pos; } } // 왼쪽 정보창 펫 효과 탭. public void TabLeftEffect() { iLoading++; btnTabInfoEffect.interactable = false; btnTabInfoEffectAdd.interactable = true; groupInfoPetEffect.SetActive(true); groupInfoPetEffectAdd.SetActive(false); SoundMgr.PlaySfx(SoundName.BtnPress); iLoading--; } // 왼쪽 정보창 추가 효과 탭. public void TabLeftEffectAdd() { if (goBtnInfoEfcAddLock.activeSelf) { GameUIMgr.SOpenToast(LocalizationText.GetText("msg_petawakenneed")); SoundMgr.PlaySfx(SoundName.BtnPress); return; } iLoading++; btnTabInfoEffect.interactable = true; btnTabInfoEffectAdd.interactable = false; groupInfoPetEffect.SetActive(false); groupInfoPetEffectAdd.SetActive(true); SoundMgr.PlaySfx(SoundName.BtnPress); SetEfcAddList(true); SetEfcAddCost(); iLoading--; } // 왼쪽 정보창 도움말. public void OpenInfoHelp() { SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOpenPopupRarityRate(); } #endregion Left Info public static void SResetPreset() { if(curMgr.iSelectedTab < 0) { return; } for (int i = 0; i < curMgr.iPresetPets.Length; i++) { for (int k = 0; k < curMgr.iPresetPets[i].Length; k++) { curMgr.iPresetPets[i][k] = DataHandler.PlayData.petPresets[i][k]; } } curMgr.TabPreset(DataHandler.PlayData.usePetPreset); } public void HelpMsg() { SoundMgr.PlaySfx(SoundName.BtnPress); GameUIMgr.SOpenHelp(LocalizationText.GetText("help_pet")); } }