351 lines
9.5 KiB
C#
351 lines
9.5 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Cute;
|
|
using UnityEngine;
|
|
using Wizard;
|
|
|
|
public class AreaSelInfo : MonoBehaviour
|
|
{
|
|
private enum eTableCategory
|
|
{
|
|
}
|
|
|
|
private static readonly Vector3 CLEARPRESENT_CARD_COLLISIONSIZE = new Vector3(175f, 230f, 1f);
|
|
|
|
private static readonly string[] CLEARPRESENT_NAME = new string[10] { "", "Common_0205", "", "Common_0201", "", "", "", "", "", "Common_0115" };
|
|
|
|
private static readonly string[] CLEARPRESENT_THUMBNAIL_SPRITENAME = new string[10] { "", "thumbnail_liquid", "", "thumbnail_crystal", "", "", "thumbnail_card", "thumbnail_emblem", "thumbnail_title", "thumbnail_rupy" };
|
|
|
|
private readonly Vector3 REWARD_TABLE_DEFAULT_POSITION = new Vector3(45f, -85.3f, 0f);
|
|
|
|
private readonly Vector3 REWARD_TABLE_CARD_POSITION = new Vector3(28.5f, -85.3f, 0f);
|
|
|
|
private readonly Dictionary<UserGoods.Type, float> REWARD_BG_OFFSET_MAGNIFICATION = new Dictionary<UserGoods.Type, float>
|
|
{
|
|
{
|
|
UserGoods.Type.Degree,
|
|
2f
|
|
},
|
|
{
|
|
UserGoods.Type.Card,
|
|
1.2f
|
|
},
|
|
{
|
|
UserGoods.Type.Sleeve,
|
|
1.2f
|
|
},
|
|
{
|
|
UserGoods.Type.Skin,
|
|
1.2f
|
|
},
|
|
{
|
|
UserGoods.Type.RedEther,
|
|
1f
|
|
},
|
|
{
|
|
UserGoods.Type.Rupy,
|
|
1f
|
|
},
|
|
{
|
|
UserGoods.Type.Item,
|
|
1f
|
|
},
|
|
{
|
|
UserGoods.Type.Emblem,
|
|
1f
|
|
}
|
|
};
|
|
|
|
[SerializeField]
|
|
private GameObject _clearRewardPrefab;
|
|
|
|
private List<AreaSelectClearReward> _clearRewardList = new List<AreaSelectClearReward>();
|
|
|
|
[SerializeField]
|
|
private UITable _tableRoot;
|
|
|
|
[SerializeField]
|
|
private UITable[] _tableRewardsCategory = new UITable[3];
|
|
|
|
[SerializeField]
|
|
private GameObject _cardObjEvacuationRoot;
|
|
|
|
[SerializeField]
|
|
private UISprite _spriteRewardBackground;
|
|
|
|
[SerializeField]
|
|
private UILabel _labelAcquired;
|
|
|
|
private List<UIBase_CardManager.CardObjData> _cardObjList = new List<UIBase_CardManager.CardObjData>();
|
|
|
|
[SerializeField]
|
|
private GameObject CardDetailRoot;
|
|
|
|
[SerializeField]
|
|
private CardDetailUI CardDetailPrefab;
|
|
|
|
private CardDetailUI _cardDetail;
|
|
|
|
private List<string> _loadFileList = new List<string>();
|
|
|
|
private bool _isLoadEnd = true;
|
|
|
|
private void RepositionRewards()
|
|
{
|
|
for (int i = 0; i < _tableRewardsCategory.Length; i++)
|
|
{
|
|
_tableRewardsCategory[i].gameObject.SetActive(value: false);
|
|
}
|
|
for (int j = 0; j < _clearRewardList.Count; j++)
|
|
{
|
|
if (_clearRewardList[j].gameObject.activeSelf)
|
|
{
|
|
int num = _clearRewardList[j].RewardGoodsType switch
|
|
{
|
|
UserGoods.Type.Card => 0,
|
|
UserGoods.Type.Sleeve => 1,
|
|
_ => 2,
|
|
};
|
|
Transform obj = _clearRewardList[j].gameObject.transform;
|
|
obj.SetParent(_tableRewardsCategory[num].transform);
|
|
obj.SetAsLastSibling();
|
|
_tableRewardsCategory[num].gameObject.SetActive(value: true);
|
|
}
|
|
}
|
|
for (int k = 0; k < _tableRewardsCategory.Length; k++)
|
|
{
|
|
if (_tableRewardsCategory[k].gameObject.activeInHierarchy)
|
|
{
|
|
_tableRewardsCategory[k].Reposition();
|
|
}
|
|
}
|
|
_tableRoot.Reposition();
|
|
if (_tableRewardsCategory[0].gameObject.activeInHierarchy)
|
|
{
|
|
_tableRoot.transform.localPosition = REWARD_TABLE_CARD_POSITION;
|
|
for (int l = 0; l < _tableRewardsCategory.Length; l++)
|
|
{
|
|
if (l != 0)
|
|
{
|
|
Vector3 localPosition = _tableRewardsCategory[l].transform.localPosition;
|
|
localPosition.x += -16f;
|
|
_tableRewardsCategory[l].transform.localPosition = localPosition;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_tableRoot.transform.localPosition = REWARD_TABLE_DEFAULT_POSITION;
|
|
}
|
|
}
|
|
|
|
private void SetRewardBackgroundWidth()
|
|
{
|
|
float num = 0f;
|
|
for (int i = 0; i < _clearRewardList.Count; i++)
|
|
{
|
|
if (_clearRewardList[i].gameObject.activeInHierarchy)
|
|
{
|
|
UserGoods.Type rewardGoodsType = _clearRewardList[i].RewardGoodsType;
|
|
num += REWARD_BG_OFFSET_MAGNIFICATION[rewardGoodsType];
|
|
}
|
|
}
|
|
int width = 250 + (int)(90f * num);
|
|
_spriteRewardBackground.width = width;
|
|
}
|
|
|
|
private void SetAcquiredLabel(bool isAcquired)
|
|
{
|
|
_labelAcquired.gameObject.SetActive(isAcquired);
|
|
if (!isAcquired)
|
|
{
|
|
return;
|
|
}
|
|
float a = float.MaxValue;
|
|
float num = float.MinValue;
|
|
bool flag = true;
|
|
for (int i = 0; i < _clearRewardList.Count; i++)
|
|
{
|
|
if (_clearRewardList[i].gameObject.activeInHierarchy)
|
|
{
|
|
Transform rewardTransform = _clearRewardList[i].GetRewardTransform();
|
|
a = Mathf.Min(a, rewardTransform.position.x);
|
|
num = Mathf.Max(num, rewardTransform.position.x);
|
|
if (_clearRewardList[i].RewardGoodsType != UserGoods.Type.Degree)
|
|
{
|
|
flag = false;
|
|
}
|
|
}
|
|
}
|
|
Vector3 position = _labelAcquired.transform.position;
|
|
position.x = Mathf.Lerp(a, num, 0.5f);
|
|
_labelAcquired.transform.position = position;
|
|
Vector3 localPosition = _labelAcquired.transform.localPosition;
|
|
localPosition.y = _tableRoot.transform.localPosition.y + (flag ? (-10f) : 0f);
|
|
_labelAcquired.transform.localPosition = localPosition;
|
|
}
|
|
|
|
private IEnumerator LoadClearPresentInner(List<int> cardidlist, List<string> rewardPathList)
|
|
{
|
|
UIManager uiMgr = UIManager.GetInstance();
|
|
UIBase_CardManager uiCardMgr = uiMgr.getUIBase_CardManager();
|
|
bool isLoadRewardEnd = false;
|
|
_loadFileList.Clear();
|
|
bool isLoadCard = cardidlist.Count > 0;
|
|
if (isLoadCard)
|
|
{
|
|
int layer = LayerMask.NameToLayer("FrontUI");
|
|
uiMgr.CardLoadSelect(base.gameObject, cardidlist, layer, is2D: true);
|
|
}
|
|
StartCoroutine(Toolbox.ResourcesManager.LoadAssetGroupAsync(rewardPathList, delegate
|
|
{
|
|
_loadFileList.AddRange(rewardPathList);
|
|
isLoadRewardEnd = true;
|
|
}));
|
|
while ((isLoadCard && (!uiCardMgr.getCreateEndFlag() || !uiCardMgr.isAssetAllReady)) || !isLoadRewardEnd)
|
|
{
|
|
yield return null;
|
|
}
|
|
_cardObjList = uiMgr.getCardList2DObjs();
|
|
if (_cardObjList != null)
|
|
{
|
|
for (int num = 0; num < _cardObjList.Count; num++)
|
|
{
|
|
GameObject cardObj = _cardObjList[num].CardObj;
|
|
if (!(cardObj == null))
|
|
{
|
|
cardObj.SetActive(value: false);
|
|
UITexture[] componentsInChildren = cardObj.GetComponentsInChildren<UITexture>(includeInactive: true);
|
|
for (int num2 = 0; num2 < componentsInChildren.Length; num2++)
|
|
{
|
|
componentsInChildren[num2].depth += 50;
|
|
}
|
|
UILabel[] componentsInChildren2 = cardObj.GetComponentsInChildren<UILabel>(includeInactive: true);
|
|
for (int num3 = 0; num3 < componentsInChildren2.Length; num3++)
|
|
{
|
|
componentsInChildren2[num3].depth += 50;
|
|
}
|
|
UISprite[] componentsInChildren3 = cardObj.GetComponentsInChildren<UISprite>(includeInactive: true);
|
|
for (int num4 = 0; num4 < componentsInChildren3.Length; num4++)
|
|
{
|
|
componentsInChildren3[num4].depth += 50;
|
|
}
|
|
cardObj.GetComponent<CardListTemplate>().HideNum();
|
|
cardObj.AddComponent<BoxCollider>().size = CLEARPRESENT_CARD_COLLISIONSIZE;
|
|
cardObj.AddComponent<UIEventListener>().onClick = _cardDetail.OnPushCardDetailOn;
|
|
}
|
|
}
|
|
}
|
|
for (int num5 = 0; num5 < 3; num5++)
|
|
{
|
|
_clearRewardList[num5].Init(_cardObjList, _cardObjEvacuationRoot);
|
|
}
|
|
_isLoadEnd = true;
|
|
}
|
|
|
|
public void ReleaseClearPresent()
|
|
{
|
|
if (_cardDetail != null)
|
|
{
|
|
Object.Destroy(_cardDetail.gameObject);
|
|
_cardDetail = null;
|
|
}
|
|
if (_cardObjList != null)
|
|
{
|
|
for (int i = 0; i < _cardObjList.Count; i++)
|
|
{
|
|
Object.Destroy(_cardObjList[i].CardObj.gameObject);
|
|
}
|
|
_cardObjList.Clear();
|
|
}
|
|
Toolbox.ResourcesManager.RemoveAssetGroup(_loadFileList);
|
|
_loadFileList.Clear();
|
|
}
|
|
|
|
private void OnCardDetailClose()
|
|
{
|
|
}
|
|
|
|
public void MoveToScreenObj(GameObject target, float localPosX, float time)
|
|
{
|
|
if (Mathf.Approximately(time, 0f))
|
|
{
|
|
Vector3 localPosition = target.transform.localPosition;
|
|
localPosition.x = localPosX;
|
|
target.transform.localPosition = localPosition;
|
|
return;
|
|
}
|
|
iTween.MoveTo(target, iTween.Hash("islocal", true, "x", localPosX, "time", time));
|
|
}
|
|
|
|
public static string GetPresentItemName(int itemID, long userGoodsId)
|
|
{
|
|
switch ((UserGoods.Type)itemID)
|
|
{
|
|
case UserGoods.Type.RedEther:
|
|
case UserGoods.Type.Rupy:
|
|
return Data.SystemText.Get(CLEARPRESENT_NAME[itemID]);
|
|
case UserGoods.Type.Item:
|
|
{
|
|
Item item = Data.Master.ItemList.Find((Item data) => data.UserGoodsId == userGoodsId);
|
|
if (item == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return item.name;
|
|
}
|
|
case UserGoods.Type.Sleeve:
|
|
{
|
|
Sleeve sleeve = Data.Master.SleeveMgr.Get(userGoodsId);
|
|
if (sleeve == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return sleeve.sleeve_name;
|
|
}
|
|
case UserGoods.Type.Emblem:
|
|
{
|
|
Emblem emblem = Data.Master.EmblemMgr.Get(userGoodsId);
|
|
if (emblem == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return emblem._name;
|
|
}
|
|
case UserGoods.Type.Degree:
|
|
{
|
|
Degree degree = Data.Master.DegreeMgr.Get((int)userGoodsId);
|
|
if (degree == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return degree._name;
|
|
}
|
|
case UserGoods.Type.Skin:
|
|
{
|
|
ClassCharacterMasterData charaPrmByCharaId = null; // Pre-Phase-5b: no chara master headless
|
|
if (charaPrmByCharaId == null)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return charaPrmByCharaId.chara_name;
|
|
}
|
|
case UserGoods.Type.SpotCardPoint:
|
|
return Data.SystemText.Get("Common_0161");
|
|
case UserGoods.Type.MyPageBG:
|
|
return Data.Master.MyPageCustomBGMaster[userGoodsId.ToString()].Name;
|
|
default:
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
public static string GetPresentItemSpriteName(int itemID)
|
|
{
|
|
if (itemID < 0 || itemID >= CLEARPRESENT_THUMBNAIL_SPRITENAME.Length)
|
|
{
|
|
return string.Empty;
|
|
}
|
|
return CLEARPRESENT_THUMBNAIL_SPRITENAME[itemID];
|
|
}
|
|
}
|