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.
1609 lines
53 KiB
1609 lines
53 KiB
using DG.Tweening;
|
|
using IVDataFormat;
|
|
using IVServerFormat;
|
|
using Spine;
|
|
using Spine.Unity.AttachmentTools;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
// 커스터마이징 매니저.
|
|
public class CustomizeMgr : MonoBehaviour
|
|
{
|
|
#region Const
|
|
private static CustomizeMgr curMgr = null;
|
|
|
|
// 스파인 애니메이션에서 지정되어있는 이름들.
|
|
private const string SkinName = "default";
|
|
private const string SlotName = "weapon";
|
|
private const string AtchName = "weapon";
|
|
|
|
private const int I_ColorX = 251;
|
|
#endregion Const
|
|
|
|
|
|
#region Spine
|
|
[SerializeField]
|
|
private IVCharSimple ivChar;
|
|
// 캐릭터 기본 애니메이션에서 사용하는 머테리얼.
|
|
[SerializeField]
|
|
private Material matBase;
|
|
#endregion Battle
|
|
|
|
|
|
#region UI
|
|
[SerializeField]
|
|
private TextMeshProUGUI txtMainT;
|
|
|
|
[SerializeField]
|
|
private Canvas canvasUI;
|
|
private GameObject goBtnInfo;
|
|
private Button btnApply, btnCompose;
|
|
private TextMeshProUGUI txtName, txtEfcInfoT, txtInfo, txtComposeCnt;
|
|
private ButtonIV[] btnTabs;
|
|
private GameObject[] groupTabs;
|
|
|
|
[SerializeField]
|
|
private EScrController escrCloth, escrWeapon;
|
|
[SerializeField]
|
|
private EScrController[] escrClrs;
|
|
|
|
// 슬롯 선택 연출.
|
|
private GameObject goSelectEfc;
|
|
private RectTransform rtrfSelectBorder, rtrfPresetSelect;
|
|
private GameObject[] goPresetSelects;
|
|
private RectTransform[][] rtrfClrPresets;
|
|
private Image[][] imgClrPresets;
|
|
private GameObject[][] goClrPresetEmptys;
|
|
private GameObject[][] goClrPresetLocks;
|
|
|
|
//GameObject dust;
|
|
[SerializeField]
|
|
Canvas leftCanvasUI;
|
|
TextMeshProUGUI leftTitle;
|
|
#endregion UI
|
|
|
|
#region Variables
|
|
private int iLoading = 1;
|
|
private bool bReLocalize = true;
|
|
private bool bReLocalizeCloth, bReLocalizeWeapon = false;
|
|
private bool bInitNeed = true;
|
|
private bool bInitNeedCloth = true;
|
|
private bool bInitNeedWeapon = true;
|
|
private bool bInitNeedClr = true;
|
|
|
|
// 변경됨.
|
|
private bool bChange = false;
|
|
// 선택된 메인 탭. 0:의상, 1:무기, 2:색상.
|
|
private int iSelectedTab = -1;
|
|
// 슬롯에서 선택된 인덱스.
|
|
private int[] iSelectedSlotIndexs = new int[3] { -1, -1, -1 };
|
|
// 색상 목록에서 선택됨.
|
|
private bool bSelectedColor = false;
|
|
// 색상 목록에서 선택된 종류. 0:헤어, 1:꼭지, 2:눈.
|
|
private int iSelectedClrType = -1;
|
|
// 목록에서 선택되었는지.
|
|
private bool[] bSelectedLists = new bool[3];
|
|
// 목록에서 선택된 색상 번호.
|
|
private int[] iSelectedListIds = new int[3] { 0, 0, 0 };
|
|
// 보기에 적용된 색상 번호.
|
|
private int[] iSelectedClr = new int[3] { 0, 0, 0 };
|
|
// 색상을 변경하려는 슬롯 인덱스.
|
|
private int iChangeSlotIndex = -1;
|
|
|
|
// 보유 색상 목록.
|
|
private EnhancedUI.SmallList<int>[] haveClrRows;
|
|
private List<int>[] haveClrLists;
|
|
private bool[] bUpdateClrs = new bool[3];
|
|
|
|
|
|
// 보기에 적용된(선택중인) 의상 번호.
|
|
private int iSelectedCloth = -1;
|
|
// 보기에 적용된(선택중인) 무기 번호.
|
|
private int iSelectedWeapon = -1;
|
|
|
|
private int iSlotIndexWp = 0;
|
|
private Skeleton skeleton;
|
|
private Skin skinCustom = null;
|
|
private Attachment atchWeaponBase = null;
|
|
private Attachment atchWeapon = null;
|
|
|
|
private int iLoadCos = 0;
|
|
private Texture2D tx2dSelectedCloth = null;
|
|
#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("cos_title");
|
|
}
|
|
else
|
|
{
|
|
bReLocalize = false;
|
|
canvasUI.transform.Find("txtT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_title");
|
|
|
|
btnTabs[0].transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_cloth");
|
|
btnTabs[1].transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_weapon");
|
|
btnTabs[2].transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_dyeing");
|
|
|
|
groupTabs[2].transform.Find("groupHair").Find("txtGroupT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_hair");
|
|
groupTabs[2].transform.Find("groupTop").Find("txtGroupT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_hairtop");
|
|
groupTabs[2].transform.Find("groupEye").Find("txtGroupT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_eye");
|
|
|
|
groupTabs[2].transform.Find("groupHair").Find("txtPresetT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_apply_color");
|
|
groupTabs[2].transform.Find("groupTop").Find("txtPresetT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_apply_color");
|
|
groupTabs[2].transform.Find("groupEye").Find("txtPresetT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_apply_color");
|
|
|
|
groupTabs[2].transform.Find("groupHair").Find("txtHaveT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_have_color");
|
|
groupTabs[2].transform.Find("groupTop").Find("txtHaveT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_have_color");
|
|
groupTabs[2].transform.Find("groupEye").Find("txtHaveT").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_have_color");
|
|
|
|
btnApply.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("cos_apply");
|
|
|
|
btnCompose.transform.Find("txt").GetComponent<TextMeshProUGUI>().text = LocalizationText.GetText("all_compose");
|
|
|
|
if (iSelectedTab < 0)
|
|
{
|
|
}
|
|
// 염색.
|
|
else if (iSelectedTab >= 2)
|
|
{
|
|
txtEfcInfoT.text = LocalizationText.GetText("all_tip");
|
|
}
|
|
// 의상, 무기.
|
|
else
|
|
{
|
|
txtEfcInfoT.text = LocalizationText.GetText("own_effect_title");
|
|
}
|
|
|
|
leftTitle = leftCanvasUI.transform.Find("txtT").GetComponent<TextMeshProUGUI>();
|
|
leftTitle.text = LocalizationText.GetText("cos_info");
|
|
}
|
|
}
|
|
|
|
// 설정에서 언어 변경 시 처리.
|
|
public static void SReLocalize()
|
|
{
|
|
curMgr.Localize(true);
|
|
curMgr.bReLocalize = true;
|
|
curMgr.bReLocalizeCloth = true;
|
|
curMgr.bReLocalizeWeapon = true;
|
|
}
|
|
|
|
// 백버튼 처리.
|
|
public static bool SCloseMenu()
|
|
{
|
|
return curMgr.CloseMenu();
|
|
}
|
|
|
|
private bool CloseMenu()
|
|
{
|
|
// 게임 시작 후 열린적 없음.
|
|
if (bInitNeed)
|
|
return false;
|
|
|
|
if (canvasUI.enabled)
|
|
{
|
|
CloseCustomize();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
curMgr = this;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
iLoading--;
|
|
}
|
|
#endregion Base
|
|
|
|
|
|
#region Init
|
|
public static void SInitSkin(Skeleton sk) => curMgr?.InitSkin(sk);
|
|
|
|
// 게임 처음 시작 시 BattleMgr에서 코스튬 정보 획득을 위해 초기화 호출.
|
|
private void InitSkin(Skeleton sk)
|
|
{
|
|
bInitNeed = true;
|
|
iSelectedCloth = DataHandler.PlayEquipCostume.outfitId;
|
|
iSelectedWeapon = DataHandler.PlayEquipCostume.weaponId;
|
|
iSelectedClr[0] = DataHandler.PlayEquipCostume.hairColor;
|
|
iSelectedClr[1] = DataHandler.PlayEquipCostume.topColor;
|
|
iSelectedClr[2] = DataHandler.PlayEquipCostume.eyeColor;
|
|
|
|
skeleton = sk;
|
|
AddressableMgr.InitWeaponSkin(sk, matBase);
|
|
}
|
|
|
|
// 창을 열 때 창의 의상/무기 세팅.
|
|
private IEnumerator LoadCostume()
|
|
{
|
|
RectTransform rtrfchar = ivChar.GetComponent<RectTransform>();
|
|
Vector3 v3pos = rtrfchar.anchoredPosition3D;
|
|
v3pos.z = -10000f;
|
|
rtrfchar.anchoredPosition3D = v3pos;
|
|
|
|
iLoadCos += 2;
|
|
CoverCamera.Hold();
|
|
CoverCamera.Hold();
|
|
AddressableMgr.LoadClothSpine(iSelectedCloth, ALoadCloth);
|
|
AddressableMgr.LoadWeaponSpine(iSelectedWeapon, ALoadWeapon);
|
|
|
|
while (iLoadCos > 0)
|
|
yield return null;
|
|
yield return null;
|
|
yield return null;
|
|
|
|
ivChar.SetCostume(tx2dSelectedCloth);
|
|
ivChar.InitColor();
|
|
ivChar.SetColor(0, DataHandler.GetColor(iSelectedClr[0]));
|
|
ivChar.SetColor(1, DataHandler.GetColor(iSelectedClr[1]));
|
|
ivChar.SetColor(2, DataHandler.GetColor(iSelectedClr[2]));
|
|
|
|
v3pos.z = -0f;
|
|
rtrfchar.anchoredPosition3D = v3pos;
|
|
}
|
|
|
|
|
|
public static void SReleaseCostume()
|
|
{
|
|
curMgr.ReleaseCostume();
|
|
}
|
|
|
|
// 창 닫을 때 의상/무기 리소스 해제.
|
|
private void ReleaseCostume()
|
|
{
|
|
tx2dSelectedCloth = null;
|
|
AddressableMgr.ReleaseClothSpine(iSelectedCloth);
|
|
AddressableMgr.ReleaseWeaponSpine(iSelectedWeapon);
|
|
|
|
iSelectedCloth = DataHandler.PlayEquipCostume.outfitId;
|
|
iSelectedWeapon = DataHandler.PlayEquipCostume.weaponId;
|
|
|
|
iSelectedClrType = -1;
|
|
for (int i = 0; i < iSelectedListIds.Length; i++)
|
|
{
|
|
iSelectedListIds[i] = 0;
|
|
bSelectedLists[i] = false;
|
|
}
|
|
escrClrs[0].scroller.RefreshActiveCellViews();
|
|
escrClrs[1].scroller.RefreshActiveCellViews();
|
|
escrClrs[2].scroller.RefreshActiveCellViews();
|
|
|
|
iSelectedClr[0] = DataHandler.PlayEquipCostume.hairColor;
|
|
iSelectedClr[1] = DataHandler.PlayEquipCostume.topColor;
|
|
iSelectedClr[2] = DataHandler.PlayEquipCostume.eyeColor;
|
|
|
|
if (iSelectedTab == 2)
|
|
{
|
|
SetSlotSelected(-1);
|
|
SetComposeColor();
|
|
}
|
|
btnApply.interactable = false;
|
|
}
|
|
|
|
private void Init()
|
|
{
|
|
btnTabs = canvasUI.transform.Find("tabWrapTop").GetComponentsInChildren<ButtonIV>(true);
|
|
|
|
groupTabs = new GameObject[btnTabs.Length];
|
|
groupTabs[0] = canvasUI.transform.Find("SvCloth").gameObject;
|
|
groupTabs[1] = canvasUI.transform.Find("SvWeapon").gameObject;
|
|
groupTabs[2] = canvasUI.transform.Find("groupColor").gameObject;
|
|
|
|
txtName = ivChar.transform.parent.Find("txtName").GetComponent<TextMeshProUGUI>();
|
|
goBtnInfo = canvasUI.transform.Find("btnInfo").gameObject;
|
|
btnApply = ivChar.transform.parent.Find("btnApply").GetComponent<Button>();
|
|
|
|
txtEfcInfoT = leftCanvasUI.transform.Find("EfcInfo").Find("txtEfcInfoT").GetComponent<TextMeshProUGUI>();
|
|
txtInfo = txtEfcInfoT.transform.parent.Find("txtInfo").GetComponent<TextMeshProUGUI>();
|
|
btnCompose = txtEfcInfoT.transform.parent.Find("btnCompose").GetComponent<Button>();
|
|
txtComposeCnt = btnCompose.transform.Find("txtCount").GetComponent<TextMeshProUGUI>();
|
|
|
|
//dust = canvasUI.transform.Find("all_dust").gameObject;
|
|
}
|
|
#endregion Init
|
|
|
|
|
|
#region UI
|
|
// 커스터마이즈 메뉴 열기.
|
|
public void OpenCustomize()
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
canvasUI.enabled = true;
|
|
leftCanvasUI.enabled = true;
|
|
ivChar.gameObject.SetActive(true);
|
|
|
|
if (bInitNeed)
|
|
{
|
|
bInitNeed = false;
|
|
Init();
|
|
ivChar.Init();
|
|
}
|
|
if (bReLocalize)
|
|
Localize(false);
|
|
StartCoroutine(nameof(LoadCostume));
|
|
|
|
if (iSelectedTab < 0)
|
|
{
|
|
TabCloth();
|
|
}
|
|
else if (iSelectedTab == 0)
|
|
{
|
|
if (bReLocalizeCloth)
|
|
{
|
|
bReLocalizeCloth = false;
|
|
escrCloth.Localize();
|
|
}
|
|
escrCloth.scroller.RefreshActiveCellViews();
|
|
SetCosNameEffect(DataHandler.GetCosCloth(iSelectedCloth));
|
|
}
|
|
else if (iSelectedTab == 1)
|
|
{
|
|
if (bReLocalizeWeapon)
|
|
{
|
|
bReLocalizeWeapon = false;
|
|
escrWeapon.Localize();
|
|
}
|
|
escrWeapon.scroller.RefreshActiveCellViews();
|
|
SetCosNameEffect(DataHandler.GetCosWeapon(iSelectedWeapon));
|
|
}
|
|
else if (iSelectedTab == 2)
|
|
{
|
|
CheckUpdateColor();
|
|
}
|
|
|
|
GameUIMgr.SRightWindowClose();
|
|
GameUIMgr.SOpenLeftPanel(dia: true);
|
|
GameUIMgr.SSetMainUiOn(false);
|
|
//BattleMgr.SSetBattleUiOn(false);
|
|
//BattleMgr.SSetClearFailUiOn(false);
|
|
//BattleMgr.SSetCameraOn(false);
|
|
|
|
bChange = false;
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
//dust.SetActive(true);
|
|
iLoading--;
|
|
}
|
|
|
|
// 커스터마이즈 메뉴 닫기.
|
|
public void CloseCustomize()
|
|
{
|
|
if (!canvasUI.enabled)
|
|
return;
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
ReleaseCostume();
|
|
|
|
DataHandler.CheckAchivement(eContent.Etc);
|
|
ivChar.gameObject.SetActive(false);
|
|
canvasUI.enabled = false;
|
|
leftCanvasUI.enabled = false;
|
|
GameUIMgr.SCloseUpPanel();
|
|
GameUIMgr.SSetMainUiOn(true);
|
|
//BattleMgr.SSetBattleUiOn(true);
|
|
//BattleMgr.SSetClearFailUiOn(true);
|
|
//BattleMgr.SSetCameraOn(true);
|
|
BattleMgr.SRefreshCharCloth();
|
|
OffPresetSelect();
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
//dust.SetActive(false);
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 갱신 필요.
|
|
public static void SSetUpdateColor(int iclrtype)
|
|
{
|
|
curMgr.bUpdateClrs[iclrtype] = true;
|
|
}
|
|
|
|
// 전체 효과 정보 보기.
|
|
public void OpenCostumeInfo()
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
GameUIMgr.SOpenPopupHaveEfc(LocalizationText.GetText("all_effecttotalhave"), BuffMgr.Instance.GetCostumeEfcs());
|
|
iLoading--;
|
|
}
|
|
#endregion UI
|
|
|
|
|
|
#region Tab
|
|
// 의상 탭.
|
|
public void TabCloth()
|
|
{
|
|
if (iSelectedTab == 0)
|
|
return;
|
|
|
|
// 선택이 변경되었을 경우(적용은 하지 않음) 실제 적용된 항목으로 선택 되돌리기.
|
|
if (bChange)
|
|
ResetCustomize();
|
|
|
|
if (iSelectedTab >= 0)
|
|
{
|
|
btnTabs[iSelectedTab].interactable = true;
|
|
groupTabs[iSelectedTab].SetActive(false);
|
|
}
|
|
|
|
iSelectedTab = 0;
|
|
btnTabs[iSelectedTab].interactable = false;
|
|
groupTabs[iSelectedTab].SetActive(true);
|
|
OffPresetSelect();
|
|
|
|
// 초기화.
|
|
if (bInitNeedCloth)
|
|
{
|
|
bInitNeedCloth = false;
|
|
iSelectedCloth = DataHandler.PlayEquipCostume.outfitId;
|
|
|
|
Dictionary<int, dCostumeSet> datas = DataHandler.GetCosClothSets();
|
|
EnhancedUI.SmallList<int> cossets = new EnhancedUI.SmallList<int>();
|
|
foreach (var item in datas)
|
|
{
|
|
cossets.Add(item.Key);
|
|
}
|
|
escrCloth.SetType(0);
|
|
escrCloth.LoadDatas(cossets);
|
|
}
|
|
else
|
|
{
|
|
escrCloth.scroller.RefreshActiveCellViews();
|
|
}
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
txtEfcInfoT.text = LocalizationText.GetText("own_effect_title");
|
|
goBtnInfo.SetActive(true);
|
|
btnCompose.gameObject.SetActive(false);
|
|
|
|
btnApply.interactable = false;
|
|
SetCosNameEffect(DataHandler.GetCosCloth(iSelectedCloth));
|
|
|
|
if (bReLocalizeCloth)
|
|
{
|
|
bReLocalizeCloth = false;
|
|
escrCloth.Localize();
|
|
}
|
|
}
|
|
|
|
// 무기 탭.
|
|
public void TabWeapon()
|
|
{
|
|
if (iSelectedTab == 1)
|
|
return;
|
|
|
|
// 선택이 변경되었을 경우(적용은 하지 않음) 실제 적용된 항목으로 선택 되돌리기.
|
|
if (bChange)
|
|
ResetCustomize();
|
|
|
|
if (iSelectedTab >= 0)
|
|
{
|
|
btnTabs[iSelectedTab].interactable = true;
|
|
groupTabs[iSelectedTab].SetActive(false);
|
|
}
|
|
|
|
iSelectedTab = 1;
|
|
btnTabs[iSelectedTab].interactable = false;
|
|
groupTabs[iSelectedTab].SetActive(true);
|
|
OffPresetSelect();
|
|
|
|
// 초기화.
|
|
if (bInitNeedWeapon)
|
|
{
|
|
bInitNeedWeapon = false;
|
|
iSelectedWeapon = DataHandler.PlayEquipCostume.weaponId;
|
|
|
|
Dictionary<int, dCostumeSet> datas = DataHandler.GetCosWeaponSets();
|
|
EnhancedUI.SmallList<int> cossets = new EnhancedUI.SmallList<int>();
|
|
foreach (var item in datas)
|
|
{
|
|
cossets.Add(item.Key);
|
|
}
|
|
escrWeapon.SetType(1);
|
|
escrWeapon.LoadDatas(cossets);
|
|
}
|
|
else
|
|
{
|
|
escrWeapon.scroller.RefreshActiveCellViews();
|
|
}
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
txtEfcInfoT.text = LocalizationText.GetText("own_effect_title");
|
|
goBtnInfo.SetActive(true);
|
|
btnCompose.gameObject.SetActive(false);
|
|
|
|
btnApply.interactable = false;
|
|
SetCosNameEffect(DataHandler.GetCosWeapon(iSelectedWeapon));
|
|
|
|
if (bReLocalizeWeapon)
|
|
{
|
|
bReLocalizeWeapon = false;
|
|
escrWeapon.Localize();
|
|
}
|
|
}
|
|
|
|
// 색상 탭.
|
|
public void TabColor()
|
|
{
|
|
if (iSelectedTab == 2)
|
|
return;
|
|
|
|
// 선택이 변경되었을 경우(적용은 하지 않음) 실제 적용된 항목으로 선택 되돌리기.
|
|
if (bChange)
|
|
ResetCustomize();
|
|
|
|
if (iSelectedTab >= 0)
|
|
{
|
|
btnTabs[iSelectedTab].interactable = true;
|
|
groupTabs[iSelectedTab].SetActive(false);
|
|
}
|
|
|
|
iSelectedTab = 2;
|
|
btnTabs[iSelectedTab].interactable = false;
|
|
groupTabs[iSelectedTab].SetActive(true);
|
|
|
|
// 색상 초기화.
|
|
if (bInitNeedClr)
|
|
{
|
|
bInitNeedClr = false;
|
|
|
|
#region Init Slots
|
|
// 슬롯 초기화.
|
|
goSelectEfc = groupTabs[2].transform.Find("selectEfc").gameObject;
|
|
rtrfSelectBorder = groupTabs[2].transform.Find("select").GetComponent<RectTransform>();
|
|
rtrfPresetSelect = goSelectEfc.transform.Find("preset").GetComponent<RectTransform>();
|
|
goPresetSelects = new GameObject[6];
|
|
for (int i = 0; i < goPresetSelects.Length; i++)
|
|
goPresetSelects[i] = rtrfPresetSelect.GetChild(i).gameObject;
|
|
rtrfClrPresets = new RectTransform[3][];
|
|
imgClrPresets = new Image[3][];
|
|
goClrPresetEmptys = new GameObject[3][];
|
|
goClrPresetLocks = new GameObject[3][];
|
|
haveClrRows = new EnhancedUI.SmallList<int>[3];
|
|
haveClrLists = new List<int>[3];
|
|
|
|
Button[] btnpresets0 = groupTabs[2].transform.Find("groupHair").Find("presets").GetComponentsInChildren<Button>(true);
|
|
Button[] btnpresets1 = groupTabs[2].transform.Find("groupTop").Find("presets").GetComponentsInChildren<Button>(true);
|
|
Button[] btnpresets2 = groupTabs[2].transform.Find("groupEye").Find("presets").GetComponentsInChildren<Button>(true);
|
|
int ilen = btnpresets0.Length;
|
|
rtrfClrPresets[0] = new RectTransform[ilen];
|
|
rtrfClrPresets[1] = new RectTransform[ilen];
|
|
rtrfClrPresets[2] = new RectTransform[ilen];
|
|
imgClrPresets[0] = new Image[ilen];
|
|
imgClrPresets[1] = new Image[ilen];
|
|
imgClrPresets[2] = new Image[ilen];
|
|
goClrPresetEmptys[0] = new GameObject[ilen];
|
|
goClrPresetEmptys[1] = new GameObject[ilen];
|
|
goClrPresetEmptys[2] = new GameObject[ilen];
|
|
goClrPresetLocks[0] = new GameObject[ilen];
|
|
goClrPresetLocks[1] = new GameObject[ilen];
|
|
goClrPresetLocks[2] = new GameObject[ilen];
|
|
|
|
for (int i = 0; i < ilen; i++)
|
|
{
|
|
rtrfClrPresets[0][i] = btnpresets0[i].GetComponent<RectTransform>();
|
|
rtrfClrPresets[1][i] = btnpresets1[i].GetComponent<RectTransform>();
|
|
rtrfClrPresets[2][i] = btnpresets2[i].GetComponent<RectTransform>();
|
|
imgClrPresets[0][i] = btnpresets0[i].GetComponent<Image>();
|
|
imgClrPresets[1][i] = btnpresets1[i].GetComponent<Image>();
|
|
imgClrPresets[2][i] = btnpresets2[i].GetComponent<Image>();
|
|
goClrPresetEmptys[0][i] = rtrfClrPresets[0][i].Find("empty").gameObject;
|
|
goClrPresetEmptys[1][i] = rtrfClrPresets[1][i].Find("empty").gameObject;
|
|
goClrPresetEmptys[2][i] = rtrfClrPresets[2][i].Find("empty").gameObject;
|
|
goClrPresetLocks[0][i] = rtrfClrPresets[0][i].Find("lock").gameObject;
|
|
goClrPresetLocks[1][i] = rtrfClrPresets[1][i].Find("lock").gameObject;
|
|
goClrPresetLocks[2][i] = rtrfClrPresets[2][i].Find("lock").gameObject;
|
|
SetPreset(0, i);
|
|
SetPreset(1, i);
|
|
SetPreset(2, i);
|
|
}
|
|
#endregion Init Slots
|
|
|
|
// 색상 초기화.
|
|
Dictionary<int, dColor> clrdatas = DataHandler.GetColors();
|
|
Dictionary<int, int>[] clrcnts = DataHandler.GetColorCounts();
|
|
for (int i = 0; i < haveClrLists.Length; i++)
|
|
{
|
|
bUpdateClrs[i] = false;
|
|
haveClrRows[i] = new EnhancedUI.SmallList<int>();
|
|
haveClrLists[i] = new List<int>();
|
|
foreach (var item in clrdatas)
|
|
{
|
|
if (clrcnts[i][item.Key] <= 0)
|
|
continue;
|
|
if (haveClrLists[i].Count % 3 == 0)
|
|
haveClrRows[i].Add(haveClrRows[i].Count);
|
|
haveClrLists[i].Add(item.Key);
|
|
}
|
|
escrClrs[i].SetType(i);
|
|
escrClrs[i].LoadDatas(haveClrRows[i]);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CheckUpdateColor();
|
|
}
|
|
|
|
txtEfcInfoT.text = LocalizationText.GetText("all_tip");
|
|
txtInfo.text = LocalizationText.GetText("cos_infodesc");
|
|
SetSlotSelected(-1);
|
|
SetComposeColor();
|
|
goBtnInfo.SetActive(false);
|
|
btnCompose.gameObject.SetActive(true);
|
|
btnApply.interactable = false;
|
|
}
|
|
|
|
// 색상 목록 업데이트.
|
|
private void CheckUpdateColor(int iclrtype = -1)
|
|
{
|
|
if (bInitNeedClr)
|
|
return;
|
|
|
|
Dictionary<int, int>[] clrcnts = new Dictionary<int, int>[3];
|
|
clrcnts[0] = new Dictionary<int, int>(DataHandler.GetColorCounts()[0]);
|
|
clrcnts[1] = new Dictionary<int, int>(DataHandler.GetColorCounts()[1]);
|
|
clrcnts[2] = new Dictionary<int, int>(DataHandler.GetColorCounts()[2]);
|
|
|
|
if (iclrtype < 0)
|
|
{
|
|
for (int i = 0; i < bUpdateClrs.Length; i++)
|
|
{
|
|
if (bUpdateClrs[i])
|
|
{
|
|
bUpdateClrs[i] = false;
|
|
|
|
// 사라진 항목 제거.
|
|
for (int k = haveClrLists[i].Count - 1; k >= 0; k--)
|
|
{
|
|
int key = haveClrLists[i][k];
|
|
if (clrcnts[i][key] <= 0)
|
|
haveClrLists[i].RemoveAt(k);
|
|
clrcnts[i].Remove(key);
|
|
}
|
|
|
|
// 새로 생긴 항목 추가.
|
|
int index = 0;
|
|
foreach (var item in clrcnts[i])
|
|
{
|
|
if (item.Value <= 0)
|
|
continue;
|
|
bool baddneed = true;
|
|
for (int k = index; k < haveClrLists[i].Count; k++)
|
|
{
|
|
if (item.Key < haveClrLists[i][k])
|
|
{
|
|
haveClrLists[i].Insert(k, item.Key);
|
|
index = k + 1;
|
|
baddneed = false;
|
|
break;
|
|
}
|
|
}
|
|
if (baddneed)
|
|
haveClrLists[i].Add(item.Key);
|
|
}
|
|
|
|
// 행 추가.
|
|
int irowcnt = haveClrLists[i].Count / 3 + 1;
|
|
while (irowcnt > haveClrRows[i].Count)
|
|
{
|
|
haveClrRows[i].Add(haveClrRows[i].Count);
|
|
}
|
|
while (irowcnt < haveClrRows[i].Count)
|
|
{
|
|
haveClrRows[i].RemoveEnd();
|
|
}
|
|
escrClrs[i].LoadDatas(haveClrRows[i]);
|
|
}
|
|
else
|
|
{
|
|
escrClrs[i].scroller.RefreshActiveCellViews();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bUpdateClrs[iclrtype])
|
|
{
|
|
bUpdateClrs[iclrtype] = false;
|
|
|
|
// 사라진 항목 제거.
|
|
for (int k = haveClrLists[iclrtype].Count - 1; k >= 0; k--)
|
|
{
|
|
int key = haveClrLists[iclrtype][k];
|
|
if (clrcnts[iclrtype][key] <= 0)
|
|
haveClrLists[iclrtype].RemoveAt(k);
|
|
clrcnts[iclrtype].Remove(key);
|
|
}
|
|
|
|
// 새로 생긴 항목 추가.
|
|
int index = 0;
|
|
foreach (var item in clrcnts[iclrtype])
|
|
{
|
|
if (item.Value <= 0)
|
|
continue;
|
|
bool baddneed = true;
|
|
for (int k = index; k < haveClrLists[iclrtype].Count; k++)
|
|
{
|
|
if (item.Key < haveClrLists[iclrtype][k])
|
|
{
|
|
haveClrLists[iclrtype].Insert(k, item.Key);
|
|
index = k + 1;
|
|
baddneed = false;
|
|
break;
|
|
}
|
|
}
|
|
if (baddneed)
|
|
haveClrLists[iclrtype].Add(item.Key);
|
|
}
|
|
|
|
// 행 추가.
|
|
int irowcnt = haveClrLists[iclrtype].Count / 3 + 1;
|
|
while (irowcnt > haveClrRows[iclrtype].Count)
|
|
{
|
|
haveClrRows[iclrtype].Add(haveClrRows[iclrtype].Count);
|
|
}
|
|
while (irowcnt < haveClrRows[iclrtype].Count)
|
|
{
|
|
haveClrRows[iclrtype].RemoveEnd();
|
|
}
|
|
escrClrs[iclrtype].LoadDatas(haveClrRows[iclrtype]);
|
|
}
|
|
else
|
|
{
|
|
escrClrs[iclrtype].scroller.RefreshActiveCellViews();
|
|
}
|
|
}
|
|
}
|
|
#endregion Tab
|
|
|
|
|
|
#region Reset & Apply
|
|
// 적용하기 버튼 활성화 상태 변경.
|
|
private void SetBtnApply()
|
|
{
|
|
// 의상.
|
|
if (iSelectedTab == 0)
|
|
{
|
|
// 현재 장착중이 아니면서 소지했을 경우에만 적용 가능.
|
|
btnApply.interactable = DataHandler.IsCosClothHave(iSelectedCloth) && iSelectedCloth != DataHandler.PlayEquipCostume.outfitId;
|
|
}
|
|
// 무기.
|
|
else if (iSelectedTab == 1)
|
|
{
|
|
// 현재 장착중이 아니면서 소지했을 경우에만 적용 가능.
|
|
btnApply.interactable = DataHandler.IsCosWeaponHave(iSelectedWeapon) && iSelectedWeapon != DataHandler.PlayEquipCostume.weaponId;
|
|
}
|
|
// 염색.
|
|
else
|
|
{
|
|
btnApply.interactable = !bSelectedLists[0] && !bSelectedLists[1] && !bSelectedLists[2];
|
|
}
|
|
}
|
|
|
|
// 실제 적용되어있는 항목으로 선택 되돌리기.
|
|
public void ResetCustomize()
|
|
{
|
|
SelectCloth(DataHandler.PlayEquipCostume.outfitId);
|
|
SelectWeapon(DataHandler.PlayEquipCostume.weaponId);
|
|
|
|
iSelectedClrType = -1;
|
|
for (int i = 0; i < iSelectedListIds.Length; i++)
|
|
{
|
|
iSelectedListIds[i] = 0;
|
|
bSelectedLists[i] = false;
|
|
}
|
|
escrClrs[0].scroller.RefreshActiveCellViews();
|
|
escrClrs[1].scroller.RefreshActiveCellViews();
|
|
escrClrs[2].scroller.RefreshActiveCellViews();
|
|
|
|
iSelectedClr[0] = DataHandler.PlayEquipCostume.hairColor;
|
|
ivChar.SetColor(0, DataHandler.GetColor(iSelectedClr[0]));
|
|
iSelectedClr[1] = DataHandler.PlayEquipCostume.topColor;
|
|
ivChar.SetColor(1, DataHandler.GetColor(iSelectedClr[1]));
|
|
iSelectedClr[2] = DataHandler.PlayEquipCostume.eyeColor;
|
|
ivChar.SetColor(2, DataHandler.GetColor(iSelectedClr[2]));
|
|
|
|
if (iSelectedTab == 2)
|
|
{
|
|
SetSlotSelected(-1);
|
|
SetComposeColor();
|
|
}
|
|
btnApply.interactable = false;
|
|
}
|
|
|
|
// 선택한 항목을 적용.
|
|
public void ApplyCustomize()
|
|
{
|
|
if (!bChange)
|
|
return;
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
SoundMgr.PlaySfx(SoundName.BtnPress);
|
|
|
|
// 의상.
|
|
if (iSelectedTab == 0)
|
|
{
|
|
bool bchangecloth = iSelectedCloth != DataHandler.PlayEquipCostume.outfitId;
|
|
if (bchangecloth)
|
|
{
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.CosClothEquip), typeof(nCostumeReturn), AClothEquipSucc, AClothEquipFail, new nIdCnt(iSelectedCloth), false);
|
|
}
|
|
else
|
|
{
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
}
|
|
// 무기.
|
|
else if (iSelectedTab == 1)
|
|
{
|
|
bool bchangeweapon = iSelectedWeapon != DataHandler.PlayEquipCostume.weaponId;
|
|
if (bchangeweapon)
|
|
{
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.CosWeaponEquip), typeof(nCostumeReturn), AWeaponEquipSucc, AWeaponEquipFail, new nIdCnt(iSelectedWeapon), false);
|
|
}
|
|
else
|
|
{
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
}
|
|
// 염색.
|
|
else
|
|
{
|
|
bool bchangeclrhair = iSelectedClr[0] != DataHandler.PlayEquipCostume.hairColor;
|
|
bool bchangeclrtop = iSelectedClr[1] != DataHandler.PlayEquipCostume.topColor;
|
|
bool bchangeclreye = iSelectedClr[2] != DataHandler.PlayEquipCostume.eyeColor;
|
|
|
|
if (bchangeclrhair || bchangeclrtop || bchangeclreye)
|
|
{
|
|
nColorSet data = new nColorSet();
|
|
data.hairColor = iSelectedClr[0];
|
|
data.topColor = iSelectedClr[1];
|
|
data.eyeColor = iSelectedClr[2];
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorSet), typeof(nCostumeReturn), AColorSetSucc, AColorSetFail, data, false);
|
|
}
|
|
else
|
|
{
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
}
|
|
}
|
|
|
|
// 의상 장착 통신 실패.
|
|
private void AClothEquipFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 의상 장착 통신 성공.
|
|
private void AClothEquipSucc(object result, object request)
|
|
{
|
|
nCostumeReturn data = result as nCostumeReturn;
|
|
if (data == null)
|
|
{
|
|
AClothEquipFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.ChangeCustomize(iSelectedCloth, iSelectedWeapon, iSelectedClr[0], iSelectedClr[1], iSelectedClr[2]);
|
|
BattleMgr.SSetCharCostume();
|
|
|
|
GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved));
|
|
escrCloth.scroller.RefreshActiveCellViews();
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 무기 장착 통신 실패.
|
|
private void AWeaponEquipFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 무기 장착 통신 성공.
|
|
private void AWeaponEquipSucc(object result, object request)
|
|
{
|
|
nCostumeReturn data = result as nCostumeReturn;
|
|
if (data == null)
|
|
{
|
|
AWeaponEquipFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.ChangeCustomize(iSelectedCloth, iSelectedWeapon, iSelectedClr[0], iSelectedClr[1], iSelectedClr[2]);
|
|
BattleMgr.SSetCharCostume();
|
|
|
|
GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved));
|
|
escrWeapon.scroller.RefreshActiveCellViews();
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 염색 적용 통신 실패.
|
|
private void AColorSetFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 염색 적용 통신 성공.
|
|
private void AColorSetSucc(object result, object request)
|
|
{
|
|
nCostumeReturn data = result as nCostumeReturn;
|
|
if (data == null)
|
|
{
|
|
AColorSetFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.ChangeCustomize(iSelectedCloth, iSelectedWeapon, iSelectedClr[0], iSelectedClr[1], iSelectedClr[2]);
|
|
BattleMgr.SSetCharCostume();
|
|
|
|
GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Saved));
|
|
btnApply.interactable = false;
|
|
bChange = false;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
#endregion Reset & Apply
|
|
|
|
|
|
public void HiddenCostume()
|
|
{
|
|
RectTransform rtrfchar = curMgr.ivChar.GetComponent<RectTransform>();
|
|
Vector3 v3pos = rtrfchar.anchoredPosition3D;
|
|
v3pos.z = -10000f;
|
|
|
|
//v3pos.z = -0f;
|
|
rtrfchar.anchoredPosition3D = v3pos;
|
|
}
|
|
|
|
public void PopCostume()
|
|
{
|
|
RectTransform rtrfchar = curMgr.ivChar.GetComponent<RectTransform>();
|
|
Vector3 v3pos = rtrfchar.anchoredPosition3D;
|
|
v3pos.z = -0f;
|
|
rtrfchar.anchoredPosition3D = v3pos;
|
|
}
|
|
|
|
|
|
#region Select Costume
|
|
// 선택된 코스튬인지.
|
|
public static bool SIsSelectCostume(int itype, int idx)
|
|
{
|
|
if (itype == 0)
|
|
return idx == curMgr.iSelectedCloth;
|
|
else
|
|
return idx == curMgr.iSelectedWeapon;
|
|
}
|
|
|
|
public static void SSelectCostume(int itype, int isetid, int ichildindex)
|
|
{
|
|
if (itype == 0)
|
|
curMgr.SelectCloth(DataHandler.GetCosClothId(isetid, ichildindex));
|
|
else
|
|
curMgr.SelectWeapon(DataHandler.GetCosWeaponId(isetid, ichildindex));
|
|
}
|
|
|
|
// 의상 선택.
|
|
public void SelectCloth(int key)
|
|
{
|
|
if (iLoadCos > 0 || iSelectedCloth == key)
|
|
return;
|
|
iLoadCos++;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
int iclothprev = iSelectedCloth;
|
|
iSelectedCloth = key;
|
|
bChange = true;
|
|
escrCloth.scroller.RefreshActiveCellViews();
|
|
SetBtnApply();
|
|
SetCosNameEffect(DataHandler.GetCosCloth(key));
|
|
|
|
HiddenCostume();
|
|
|
|
AddressableMgr.LoadClothSpine(iSelectedCloth, ALoadClothChange);
|
|
AddressableMgr.ReleaseClothSpine(iclothprev);
|
|
}
|
|
|
|
// 무기 선택.
|
|
public void SelectWeapon(int key)
|
|
{
|
|
if (iLoadCos > 0 || iSelectedWeapon == key)
|
|
return;
|
|
iLoadCos++;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
int iwpprev = iSelectedWeapon;
|
|
iSelectedWeapon = key;
|
|
bChange = true;
|
|
escrWeapon.scroller.RefreshActiveCellViews();
|
|
SetBtnApply();
|
|
SetCosNameEffect(DataHandler.GetCosWeapon(key));
|
|
|
|
AddressableMgr.LoadWeaponSpine(iSelectedWeapon, ALoadWeaponChange);
|
|
AddressableMgr.ReleaseWeaponSpine(iwpprev);
|
|
}
|
|
#endregion Select Costume
|
|
|
|
|
|
#region Select Color
|
|
public static int SGetColorId(int iclrtype, int irow, int icolumn)
|
|
{
|
|
return curMgr.GetColorId(iclrtype, irow, icolumn);
|
|
}
|
|
|
|
// 색상 번호.
|
|
private int GetColorId(int iclrtype, int irow, int icolumn)
|
|
{
|
|
int index = irow * 3 + icolumn;
|
|
if (index >= haveClrLists[iclrtype].Count)
|
|
return -1;
|
|
return haveClrLists[iclrtype][index];
|
|
}
|
|
|
|
// 선택된 색상인지.
|
|
public static bool SIsSelectColor(int iclrtype, int idx)
|
|
{
|
|
return idx == curMgr.iSelectedListIds[iclrtype] && curMgr.bSelectedLists[iclrtype];
|
|
}
|
|
|
|
public static void SSelectColor(int iclrtype, int irow, int icolumn)
|
|
{
|
|
curMgr.SelectClr(iclrtype, irow, icolumn);
|
|
}
|
|
|
|
// 색상 선택.
|
|
public void SelectClr(int iclrtype, int irow, int icolumn)
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
bChange = true;
|
|
int key = GetColorId(iclrtype, irow, icolumn);
|
|
if (iSelectedClrType >= 0)
|
|
iSelectedListIds[iSelectedClrType] = 0;
|
|
iSelectedListIds[iclrtype] = key;
|
|
bSelectedLists[iclrtype] = true;
|
|
iSelectedClr[iclrtype] = key;
|
|
SetSlotSelected(iclrtype);
|
|
ivChar.SetColor(iclrtype, DataHandler.GetColor(iSelectedClr[iclrtype]));
|
|
|
|
OnPresetSelect(iclrtype);
|
|
iSelectedClrType = iclrtype;
|
|
escrClrs[0].scroller.RefreshActiveCellViews();
|
|
escrClrs[1].scroller.RefreshActiveCellViews();
|
|
escrClrs[2].scroller.RefreshActiveCellViews();
|
|
|
|
txtName.text = FormatString.GetGoodsName(cGoods.TCosClrHair, key);
|
|
SetComposeColor();
|
|
|
|
// 슬롯에 등록하지 않은 색상은 적용 불가능.
|
|
btnApply.interactable = false;
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 선택 해제.
|
|
public void UnselectClr()
|
|
{
|
|
// 색상 선택중이 아닐 경우.
|
|
if (!bSelectedColor)
|
|
return;
|
|
iSelectedListIds[iSelectedClrType] = 0;
|
|
escrClrs[iSelectedClrType].scroller.RefreshActiveCellViews();
|
|
|
|
SetComposeColor();
|
|
OffPresetSelect();
|
|
}
|
|
|
|
// 색상 슬롯 적용 후 해제.
|
|
public void UnselectClrSlot()
|
|
{
|
|
iSelectedListIds[iSelectedClrType] = 0;
|
|
bSelectedLists[iSelectedClrType] = false;
|
|
escrClrs[iSelectedClrType].scroller.RefreshActiveCellViews();
|
|
|
|
SetComposeColor();
|
|
OffPresetSelect();
|
|
SetSlotSelected(iSelectedClrType);
|
|
}
|
|
#endregion Select Color
|
|
|
|
|
|
#region Preset Color
|
|
// 슬롯 세팅.
|
|
private void SetPreset(int iclrtype, int index)
|
|
{
|
|
if (iclrtype > 2 || index < 0)
|
|
return;
|
|
|
|
int icolorid = DataHandler.PlayEquipCostume.paletteSlots[iclrtype][index];
|
|
// 잠긴 셀.
|
|
if (index >= DataHandler.PlayEquipCostume.paletteOpens[iclrtype])
|
|
{
|
|
imgClrPresets[iclrtype][index].color = Global.CLR_PresetEmpty;
|
|
goClrPresetEmptys[iclrtype][index].SetActive(false);
|
|
goClrPresetLocks[iclrtype][index].SetActive(true);
|
|
}
|
|
// 빈 셀.
|
|
else if (icolorid <= 0)
|
|
{
|
|
imgClrPresets[iclrtype][index].color = Global.CLR_PresetEmpty;
|
|
goClrPresetEmptys[iclrtype][index].SetActive(true);
|
|
goClrPresetLocks[iclrtype][index].SetActive(false);
|
|
}
|
|
// 색상 있는 셀.
|
|
else
|
|
{
|
|
// 슬롯에서 선택한 색상일 경우.
|
|
if (icolorid == iSelectedClr[iclrtype])
|
|
iSelectedSlotIndexs[iclrtype] = index;
|
|
imgClrPresets[iclrtype][index].color = DataHandler.GetColor(icolorid);
|
|
goClrPresetEmptys[iclrtype][index].SetActive(false);
|
|
goClrPresetLocks[iclrtype][index].SetActive(false);
|
|
}
|
|
}
|
|
|
|
// 슬롯 선택 상태 표시.
|
|
private void SetSlotSelected(int iclrtype)
|
|
{
|
|
if (bInitNeedClr)
|
|
return;
|
|
|
|
if (iclrtype < 0)
|
|
{
|
|
rtrfSelectBorder.gameObject.SetActive(false);
|
|
txtName.text = FormatString.GetGoodsName(cGoods.TCosClrHair, DataHandler.PlayEquipCostume.hairColor);
|
|
return;
|
|
}
|
|
|
|
if (bSelectedLists[iclrtype])
|
|
{
|
|
rtrfSelectBorder.gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
rtrfSelectBorder.gameObject.SetActive(true);
|
|
int index = iSelectedSlotIndexs[iclrtype];
|
|
rtrfSelectBorder.position = rtrfClrPresets[iclrtype][index].position;
|
|
txtName.text = FormatString.GetGoodsName(cGoods.TCosClrHair, DataHandler.PlayEquipCostume.paletteSlots[iclrtype][index]);
|
|
}
|
|
|
|
// 슬롯 선택 연출 켜기.
|
|
private void OnPresetSelect(int iclrtype)
|
|
{
|
|
if (bInitNeedClr)
|
|
return;
|
|
|
|
if (iclrtype != iSelectedClrType)
|
|
{
|
|
Vector2 v2pos = rtrfPresetSelect.anchoredPosition;
|
|
v2pos.x = I_ColorX * (iclrtype - 1);
|
|
rtrfPresetSelect.anchoredPosition = v2pos;
|
|
}
|
|
|
|
for (int i = 0; i < goClrPresetLocks[iclrtype].Length; i++)
|
|
goPresetSelects[i].SetActive(!goClrPresetLocks[iclrtype][i].activeSelf);
|
|
|
|
bSelectedColor = true;
|
|
goSelectEfc.SetActive(true);
|
|
DOTween.Play("colorpreset");
|
|
}
|
|
|
|
// 슬롯 선택 연출 끄기.
|
|
private void OffPresetSelect()
|
|
{
|
|
if (bInitNeedClr)
|
|
return;
|
|
bSelectedColor = false;
|
|
DOTween.Pause("colorpreset");
|
|
goSelectEfc.SetActive(false);
|
|
}
|
|
|
|
// 헤어 슬롯 선택.
|
|
public void SelectClrPresetHair(int index)
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
SelectClrPreset(0, index);
|
|
}
|
|
|
|
// 꼭지 슬롯 선택.
|
|
public void SelectClrPresetTop(int index)
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
SelectClrPreset(1, index);
|
|
}
|
|
|
|
// 눈 슬롯 선택.
|
|
public void SelectClrPresetEye(int index)
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
SelectClrPreset(2, index);
|
|
}
|
|
|
|
// 슬롯 선택시 처리.
|
|
private void SelectClrPreset(int iclrtype, int index)
|
|
{
|
|
// 색상 선택된 상태에서 다른 카테고리 슬롯 선택하면 선택 해제.
|
|
if (bSelectedColor && iSelectedClrType != iclrtype)
|
|
{
|
|
UnselectClr();
|
|
return;
|
|
}
|
|
|
|
// 잠긴 슬롯.
|
|
if (index >= DataHandler.PlayEquipCostume.paletteOpens[iclrtype])
|
|
{
|
|
UnselectClr();
|
|
iSelectedClrType = iclrtype;
|
|
GameUIMgr.SOpenPopup2Button(FormatString.StringFormat(LocalizationText.GetText("msg_confirmslotdia"), DataHandler.Const.colorSlotPrice.ToString()),
|
|
OpenPreset, stryes: LocalizationText.GetText(Global.STR_YES));
|
|
return;
|
|
}
|
|
|
|
// 색상 선택된 상태. 슬롯 색상을 변경.
|
|
if (bSelectedColor)
|
|
{
|
|
// 중복 색상.
|
|
if (DataHandler.IsColorInSlot(iclrtype, iSelectedListIds[iclrtype]))
|
|
{
|
|
GameUIMgr.SOpenToast(LocalizationText.GetText(Global.STR_Included));
|
|
UnselectClr();
|
|
return;
|
|
}
|
|
iChangeSlotIndex = index;
|
|
|
|
// 색상 있는 슬롯. 색상 덮어쓰기 확인.
|
|
if (DataHandler.PlayEquipCostume.paletteSlots[iclrtype][index] > 0)
|
|
{
|
|
GameUIMgr.SOpenPopup2Button(LocalizationText.GetText("msg_clroverwrite"), OverwritePreset, UnselectClr, stryes: LocalizationText.GetText(Global.STR_SET));
|
|
}
|
|
// 빈 슬롯. 색상 변경 확인.
|
|
else
|
|
{
|
|
GameUIMgr.SOpenPopup2Button(LocalizationText.GetText("msg_clrset"), OverwritePreset, UnselectClr, stryes: LocalizationText.GetText(Global.STR_SET));
|
|
}
|
|
return;
|
|
}
|
|
|
|
// 색상 선택하지 않은 상태에서 색상 있는 슬롯 선택. 슬롯의 색상을 적용.
|
|
if (DataHandler.PlayEquipCostume.paletteSlots[iclrtype][index] > 0)
|
|
{
|
|
bChange = true;
|
|
iSelectedClr[iclrtype] = DataHandler.PlayEquipCostume.paletteSlots[iclrtype][index];
|
|
ivChar.SetColor(iclrtype, DataHandler.GetColor(iSelectedClr[iclrtype]));
|
|
iSelectedListIds[iclrtype] = 0;
|
|
iSelectedSlotIndexs[iclrtype] = index;
|
|
bSelectedLists[iclrtype] = false;
|
|
|
|
escrClrs[iclrtype].scroller.RefreshActiveCellViews();
|
|
SetSlotSelected(iclrtype);
|
|
txtName.text = FormatString.GetGoodsName(cGoods.TCosClrHair, iSelectedClr[iclrtype]);
|
|
SetBtnApply();
|
|
}
|
|
}
|
|
|
|
// 슬롯 색상을 선택중인 색상으로 변경 확인.
|
|
private void OverwritePreset()
|
|
{
|
|
if (iSelectedClrType < 0 || iChangeSlotIndex < 0)
|
|
return;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
nIdSlot data = new nIdSlot();
|
|
data.sid = iSelectedListIds[iSelectedClrType];
|
|
data.slot = iChangeSlotIndex + 1;
|
|
data.type = iSelectedClrType;
|
|
|
|
if (iSelectedClrType == 0)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteHair), typeof(nCostumeReturn), AColorPaletteSucc, AColorPaletteFail, data, false);
|
|
else if (iSelectedClrType == 1)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteTop), typeof(nCostumeReturn), AColorPaletteSucc, AColorPaletteFail, data, false);
|
|
else
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteEye), typeof(nCostumeReturn), AColorPaletteSucc, AColorPaletteFail, data, false);
|
|
}
|
|
|
|
// 색상 팔레트 통신 실패.
|
|
private void AColorPaletteFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 팔레트 통신 성공.
|
|
private void AColorPaletteSucc(object result, object request)
|
|
{
|
|
nCostumeReturn data = result as nCostumeReturn;
|
|
if (data == null)
|
|
{
|
|
AColorPaletteFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
nIdSlot reqdata = request as nIdSlot;
|
|
if (DataHandler.ChangeSlotColor(reqdata.type, reqdata.slot - 1, reqdata.sid))
|
|
{
|
|
SetPreset(reqdata.type, reqdata.slot - 1);
|
|
UnselectClrSlot();
|
|
SetBtnApply();
|
|
CheckUpdateColor(reqdata.type);
|
|
}
|
|
iChangeSlotIndex = -1;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 잠긴 슬롯 열기.
|
|
private void OpenPreset()
|
|
{
|
|
if (iSelectedClrType < 0)
|
|
return;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
nIdSlot data = new nIdSlot();
|
|
data.type = iSelectedClrType;
|
|
|
|
if (iSelectedClrType == 0)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteOpenHair), typeof(nCostumeReturn), AOpenPaletteSucc, AOpenPaletteFail, data, true);
|
|
else if (iSelectedClrType == 1)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteOpenTop), typeof(nCostumeReturn), AOpenPaletteSucc, AOpenPaletteFail, data, true);
|
|
else
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorPaletteOpenEye), typeof(nCostumeReturn), AOpenPaletteSucc, AOpenPaletteFail, data, true);
|
|
}
|
|
|
|
// 색상 팔레트 통신 실패.
|
|
private void AOpenPaletteFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 팔레트 통신 성공.
|
|
private void AOpenPaletteSucc(object result, object request)
|
|
{
|
|
nCostumeReturn data = result as nCostumeReturn;
|
|
if (data == null)
|
|
{
|
|
AOpenPaletteFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.SetGoods(data.playCurrency, true);
|
|
|
|
nIdSlot reqdata = request as nIdSlot;
|
|
int index = DataHandler.OpenSlotColor(reqdata.type);
|
|
SetPreset(reqdata.type, index);
|
|
iSelectedClrType = -1;
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
#endregion Preset Color
|
|
|
|
|
|
#region Compose Color
|
|
// 색상 정보 표시.
|
|
private void SetComposeColor()
|
|
{
|
|
// 빈 슬롯.
|
|
if (iSelectedClrType < 0 || !bSelectedLists[iSelectedClrType] || iSelectedListIds[iSelectedClrType] <= 0)
|
|
{
|
|
txtComposeCnt.text = FormatString.TextCntPerRedBlank(-1, DataHandler.Const.colorComposeCount);
|
|
btnCompose.interactable = false;
|
|
}
|
|
// 색상 있음.
|
|
else
|
|
{
|
|
int icount = DataHandler.GetColorCount(iSelectedClrType, iSelectedListIds[iSelectedClrType]);
|
|
txtComposeCnt.text = FormatString.TextCntPerRedBlank(icount, DataHandler.Const.colorComposeCount);
|
|
btnCompose.interactable = icount >= DataHandler.Const.colorComposeCount;
|
|
}
|
|
}
|
|
|
|
// 색상 합성.
|
|
public void BtnComposeColor()
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
|
|
string strtype;
|
|
if (iSelectedClrType == 0)
|
|
strtype = LocalizationText.GetText("cos_hair");
|
|
else if (iSelectedClrType == 1)
|
|
strtype = LocalizationText.GetText("cos_hairtop");
|
|
else
|
|
strtype = LocalizationText.GetText("cos_eye");
|
|
GameUIMgr.SOpenPopup2Button(FormatString.StringFormat(LocalizationText.GetText("msg_clrcompose"), DataHandler.Const.colorComposeCount, strtype),
|
|
ComposeColor, stryes: LocalizationText.GetText("all_composedo"));
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 합성 시도.
|
|
private void ComposeColor()
|
|
{
|
|
if (iLoading > 0)
|
|
return;
|
|
iLoading++;
|
|
CoverCamera.Hold();
|
|
|
|
nIdCnt data = new nIdCnt(iSelectedListIds[iSelectedClrType]);
|
|
if (iSelectedClrType == 0)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorComposeHair), typeof(nColorComposeReturn), AColorComposeSucc, AColorComposeFail, data, false);
|
|
else if (iSelectedClrType == 1)
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorComposeTop), typeof(nColorComposeReturn), AColorComposeSucc, AColorComposeFail, data, false);
|
|
else
|
|
SvConnectManager.Instance.RequestSvPost(true, 0, UrlApi.GetUrl(UrlApi.ColorComposeEye), typeof(nColorComposeReturn), AColorComposeSucc, AColorComposeFail, data, false);
|
|
}
|
|
|
|
// 색상 합성 통신 실패.
|
|
private void AColorComposeFail(SvError error, object request)
|
|
{
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
|
|
// 색상 합성 통신 성공.
|
|
private void AColorComposeSucc(object result, object request)
|
|
{
|
|
nColorComposeReturn data = result as nColorComposeReturn;
|
|
if (data == null)
|
|
{
|
|
AColorComposeFail(new SvError(eErrorCode.NULL_OR_EMPTY), request);
|
|
return;
|
|
}
|
|
|
|
DataHandler.SubColor(iSelectedClrType, iSelectedListIds[iSelectedClrType], DataHandler.Const.colorComposeCount);
|
|
DataHandler.AddColor(iSelectedClrType, data.result, 1);
|
|
|
|
nGoods[] results = new nGoods[1] { new nGoods() };
|
|
if (iSelectedClrType == 0)
|
|
results[0].propertyType = cGoods.TCosClrHair;
|
|
else if (iSelectedClrType == 1)
|
|
results[0].propertyType = cGoods.TCosClrTop;
|
|
else
|
|
results[0].propertyType = cGoods.TCosClrEye;
|
|
results[0].propertyId = data.result;
|
|
results[0].propertyCount = 1;
|
|
|
|
StartCoroutine(ShowColorCompose(results));
|
|
}
|
|
|
|
// 색상 합성 연출.
|
|
private IEnumerator ShowColorCompose(nGoods[] results)
|
|
{
|
|
GameUIMgr.SPlayEfcClrCompose();
|
|
yield return YieldInstructionCache.WaitForSeconds(0.35f);
|
|
|
|
SetComposeColor();
|
|
CheckUpdateColor();
|
|
|
|
GameUIMgr.SOpenPopupGoods(results);
|
|
yield return YieldInstructionCache.WaitForSeconds(0.35f);
|
|
|
|
GameUIMgr.SStopEfcClrCompose();
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
}
|
|
#endregion Compose Color
|
|
|
|
|
|
#region Addressable
|
|
private void ALoadCloth(Texture2D obj)
|
|
{
|
|
tx2dSelectedCloth = obj;
|
|
|
|
PopCostume();
|
|
CoverCamera.Release();
|
|
iLoadCos--;
|
|
}
|
|
|
|
private void ALoadWeapon(Skin obj)
|
|
{
|
|
ivChar.SetWeapon(obj);
|
|
|
|
if (tx2dSelectedCloth != null)
|
|
ivChar.SetCostume(tx2dSelectedCloth);
|
|
ivChar.InitColor();
|
|
ivChar.SetColor(0, DataHandler.GetColor(iSelectedClr[0]));
|
|
ivChar.SetColor(1, DataHandler.GetColor(iSelectedClr[1]));
|
|
ivChar.SetColor(2, DataHandler.GetColor(iSelectedClr[2]));
|
|
|
|
CoverCamera.Release();
|
|
iLoadCos--;
|
|
}
|
|
|
|
private void ALoadClothChange(Texture2D obj)
|
|
{
|
|
tx2dSelectedCloth = obj;
|
|
ivChar.SetCostume(tx2dSelectedCloth);
|
|
|
|
PopCostume();
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
iLoadCos--;
|
|
}
|
|
|
|
private void ALoadWeaponChange(Skin obj)
|
|
{
|
|
ivChar.SetWeapon(obj);
|
|
|
|
if (tx2dSelectedCloth != null)
|
|
ivChar.SetCostume(tx2dSelectedCloth);
|
|
ivChar.InitColor();
|
|
ivChar.SetColor(0, DataHandler.GetColor(iSelectedClr[0]));
|
|
ivChar.SetColor(1, DataHandler.GetColor(iSelectedClr[1]));
|
|
ivChar.SetColor(2, DataHandler.GetColor(iSelectedClr[2]));
|
|
|
|
CoverCamera.Release();
|
|
iLoading--;
|
|
iLoadCos--;
|
|
}
|
|
#endregion Addressable
|
|
|
|
|
|
#region Name & Effect Text
|
|
private void SetCosNameEffect(dCostume data)
|
|
{
|
|
if (data == null)
|
|
return;
|
|
|
|
txtName.text = FormatString.GetGoodsName(iSelectedTab == 0 ? cGoods.TCosCloth : cGoods.TCosWeapon, data.id);
|
|
txtInfo.text = FormatString.TextEffectTitleValuesBreakline(data.abilityType1, data.abilityValue1, data.abilityType2, data.abilityValue2);
|
|
}
|
|
#endregion Name & Effect Text
|
|
}
|