1
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
@@ -208,12 +208,40 @@ public class UIManager : MonoSingleton<UIManager>
|
||||
}
|
||||
public GameObject BoardPanelParefab;
|
||||
public GameObject BoardPanelParefabGongGao;
|
||||
public GameObject HuoDeParefab;
|
||||
public void ShowBoardError(string str)
|
||||
{
|
||||
|
||||
StartCoroutine(IEShowBoard(str));
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 显示"恭喜获得"奖励面板(随时访问,类似公告)。10秒未关闭则自动关闭。
|
||||
/// </summary>
|
||||
/// <param name="backPackPropItemDatas">奖励道具数据列表</param>
|
||||
/// <param name="onCloseAction">关闭面板时回调(处理特殊情况)</param>
|
||||
public void ShowHuoDe(List<BackPackPropItemData> backPackPropItemDatas, Action onCloseAction = null)
|
||||
{
|
||||
StartCoroutine(IEShowHuoDe(backPackPropItemDatas, onCloseAction));
|
||||
}
|
||||
IEnumerator IEShowHuoDe(List<BackPackPropItemData> backPackPropItemDatas, Action onCloseAction)
|
||||
{
|
||||
if (HuoDeParefab == null)
|
||||
{
|
||||
Debug.LogWarning("HuoDeParefab 未赋值");
|
||||
yield break;
|
||||
}
|
||||
var obj = Instantiate(HuoDeParefab, uiRoot);
|
||||
obj.transform.SetAsLastSibling();
|
||||
var huode = obj.GetComponent<HuoDe>();
|
||||
if (huode != null)
|
||||
huode.Init(backPackPropItemDatas, onCloseAction);
|
||||
|
||||
// 10秒后未手动关闭则自动关闭
|
||||
yield return new WaitForSeconds(10f);
|
||||
if (obj != null)
|
||||
huode?.Close();
|
||||
}
|
||||
public void ShowBoardGongGao(string str)
|
||||
{
|
||||
|
||||
|
||||
+133
-1334
File diff suppressed because it is too large
Load Diff
@@ -1,18 +1,118 @@
|
||||
using Spine;
|
||||
using Spine.Unity;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class HuoDe : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
public Button btn_Close;
|
||||
public BackPackPropItem backPackPropItemPrefab;
|
||||
public Transform backPackPropItemParent;
|
||||
|
||||
[Header("Spine 动画(固定配置)")]
|
||||
[Tooltip("Spine 动画组件,留空则自动获取")]
|
||||
public SkeletonGraphic skeletonGraphic;
|
||||
[Tooltip("出现动画(播放一次)")]
|
||||
public string appear;
|
||||
[Tooltip("待机动画(循环播放)")]
|
||||
public string loop;
|
||||
[Tooltip("离开动画(关闭时播放一次再销毁)")]
|
||||
public string leave;
|
||||
|
||||
public Action action;
|
||||
private bool _closed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
|
||||
if (skeletonGraphic == null)
|
||||
skeletonGraphic = GetComponent<SkeletonGraphic>();
|
||||
if (btn_Close != null)
|
||||
btn_Close.onClick.AddListener(Close);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
/// <summary>
|
||||
/// 按奖励数据列表克隆预制体并初始化,并播放出现动画→待机循环。
|
||||
/// </summary>
|
||||
/// <param name="dataList">奖励道具数据列表</param>
|
||||
/// <param name="onCloseAction">关闭面板时回调(处理特殊情况)</param>
|
||||
public void Init(List<BackPackPropItemData> dataList, Action onCloseAction = null)
|
||||
{
|
||||
|
||||
action = onCloseAction;
|
||||
|
||||
// 清空旧列表
|
||||
if (backPackPropItemParent != null)
|
||||
{
|
||||
for (int i = backPackPropItemParent.childCount - 1; i >= 0; i--)
|
||||
Destroy(backPackPropItemParent.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
if (dataList != null && backPackPropItemPrefab != null && backPackPropItemParent != null)
|
||||
{
|
||||
foreach (var data in dataList)
|
||||
{
|
||||
if (data == null) continue;
|
||||
var obj = Instantiate(backPackPropItemPrefab.gameObject, backPackPropItemParent);
|
||||
var item = obj.GetComponent<BackPackPropItem>();
|
||||
if (item == null) continue;
|
||||
item.Init(data);
|
||||
}
|
||||
}
|
||||
|
||||
PlayAppearThenLoop();
|
||||
}
|
||||
|
||||
/// <summary>播放出现动画(一次),播完自动切到待机(循环)</summary>
|
||||
private void PlayAppearThenLoop()
|
||||
{
|
||||
if (skeletonGraphic == null) return;
|
||||
var state = skeletonGraphic.AnimationState;
|
||||
if (state == null) return;
|
||||
|
||||
state.ClearTrack(0);
|
||||
if (!string.IsNullOrEmpty(appear))
|
||||
{
|
||||
state.SetAnimation(0, appear, false);
|
||||
if (!string.IsNullOrEmpty(loop))
|
||||
state.AddAnimation(0, loop, true, 0f);
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(loop))
|
||||
{
|
||||
state.SetAnimation(0, loop, true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭面板(手动点击或自动超时都会调用,重复调用安全)。
|
||||
/// 有 leave 动画则播完再销毁,否则直接销毁。
|
||||
/// </summary>
|
||||
public void Close()
|
||||
{
|
||||
if (_closed) return;
|
||||
_closed = true;
|
||||
action?.Invoke();
|
||||
|
||||
if (skeletonGraphic != null && !string.IsNullOrEmpty(leave))
|
||||
{
|
||||
var state = skeletonGraphic.AnimationState;
|
||||
if (state != null)
|
||||
{
|
||||
var entry = state.SetAnimation(0, leave, false);
|
||||
StartCoroutine(IEWaitThenDestroy(entry));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Destroy(gameObject);
|
||||
}
|
||||
|
||||
private IEnumerator IEWaitThenDestroy(TrackEntry entry)
|
||||
{
|
||||
if (entry != null)
|
||||
yield return new WaitForSpineAnimationComplete(entry, true);
|
||||
if (this != null && gameObject != null)
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -24,14 +24,32 @@ public enum PropEnum
|
||||
技能 = 10,
|
||||
召唤卡 = 11,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// BackPackPropItem 初始化数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BackPackPropItemData
|
||||
{
|
||||
/// <summary>道具图标地址(完整 URL,含 baseURL)</summary>
|
||||
public string url;
|
||||
/// <summary>道具数量</summary>
|
||||
public int count;
|
||||
/// <summary>道具类型</summary>
|
||||
public PropEnum propEnum = PropEnum.none;
|
||||
}
|
||||
|
||||
public class BackPackPropItem : MonoBehaviour
|
||||
{
|
||||
public List<Image> item_Bg;
|
||||
public Dictionary<PropEnum, Image> item_Type=new Dictionary<PropEnum, Image>();
|
||||
public Image img_Prop;
|
||||
public TextMeshProUGUI propCount;
|
||||
public void Init(string url,int propCount, PropEnum propEnum= PropEnum.none)
|
||||
public void Init(BackPackPropItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
|
||||
PropEnum propEnum = data.propEnum;
|
||||
switch (propEnum)
|
||||
{
|
||||
case PropEnum.none:
|
||||
@@ -62,7 +80,7 @@ public class BackPackPropItem : MonoBehaviour
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WebTool.DownImage(url, (texture) =>
|
||||
WebTool.DownImage(data.url, (texture) =>
|
||||
{
|
||||
if (texture!=null)
|
||||
{
|
||||
@@ -71,6 +89,6 @@ public class BackPackPropItem : MonoBehaviour
|
||||
}
|
||||
|
||||
});
|
||||
this.propCount.text = propCount.ToString();
|
||||
this.propCount.text = data.count.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,12 @@ public class RankLineItem : MonoBehaviour
|
||||
|
||||
GameObject obj = Instantiate(backPackPropItemPrefab.gameObject, backPackPropItemRarent);
|
||||
var tempItem = obj.GetComponent<BackPackPropItem>();
|
||||
tempItem.Init(APIManager.baseURL + imageUrl, count, (PropEnum)propType);
|
||||
tempItem.Init(new BackPackPropItemData
|
||||
{
|
||||
url = APIManager.baseURL + imageUrl,
|
||||
count = count,
|
||||
propEnum = (PropEnum)propType
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,7 +156,12 @@ public class UIHome_BY_BackPackPanel : SubUIBase
|
||||
|
||||
GameObject obj = Instantiate(prefabItem.gameObject, pageParent);
|
||||
var tempItem = obj.GetComponent<BackPackPropItem>();
|
||||
tempItem.Init(APIManager.baseURL + product.imageUrl, product.count, (PropEnum)product.type);
|
||||
tempItem.Init(new BackPackPropItemData
|
||||
{
|
||||
url = APIManager.baseURL + product.imageUrl,
|
||||
count = product.count,
|
||||
propEnum = (PropEnum)product.type
|
||||
});
|
||||
|
||||
propsObjHashCode_Dic[obj.GetHashCode()] = product;
|
||||
string capturedNum = product.number;
|
||||
|
||||
@@ -227,15 +227,18 @@ public class UIHome_BY_VIPPanel : SubUIBase
|
||||
switch (gift.type)
|
||||
{
|
||||
case 1:
|
||||
item.Init("", count, PropEnum.none);
|
||||
item.Init(new BackPackPropItemData { count = count });
|
||||
break;
|
||||
case 2:
|
||||
item.Init("", count, PropEnum.none);
|
||||
item.Init(new BackPackPropItemData { count = count });
|
||||
break;
|
||||
case 3:
|
||||
string url = gift.product != null ? APIManager.baseURL + gift.product.imageUrl : "";
|
||||
PropEnum propType = (PropEnum)gift.product.type;
|
||||
item.Init(url, count, propType);
|
||||
item.Init(new BackPackPropItemData
|
||||
{
|
||||
url = gift.product != null ? APIManager.baseURL + gift.product.imageUrl : "",
|
||||
count = count,
|
||||
propEnum = (PropEnum)gift.product.type
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,12 @@ public class UserInfoPanel : SubUIBase
|
||||
obj.SetActive(true);
|
||||
var item = obj.GetComponent<BackPackPropItem>();
|
||||
if (item == null) continue;
|
||||
item.Init(APIManager.baseURL + product.imageUrl, product.count, (PropEnum)product.type);
|
||||
item.Init(new BackPackPropItemData
|
||||
{
|
||||
url = APIManager.baseURL + product.imageUrl,
|
||||
count = product.count,
|
||||
propEnum = (PropEnum)product.type
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,18 +264,22 @@ public class ZhanLing_Panel : SubUIBase
|
||||
UpdateBuyPrice();
|
||||
}
|
||||
|
||||
private void UpdateBuyLevelGifts(int level)
|
||||
private void UpdateBuyLevelGifts(int targetLevel)
|
||||
{
|
||||
ClearBuyGiftParent(buyLevelGiftitemMianFeiParent);
|
||||
ClearBuyGiftParent(buyLevelGiftitemJingYingParent);
|
||||
ClearBuyGiftParent(buyLevelGiftitemZhiZunParent);
|
||||
|
||||
var cfg = _config?.levelConfig?.Find(c => c.level == level);
|
||||
if (cfg == null) return;
|
||||
// 从当前等级+1到目标等级,累加所有礼包
|
||||
for (int lv = _userData.level + 1; lv <= targetLevel; lv++)
|
||||
{
|
||||
var cfg = _config?.levelConfig?.Find(c => c.level == lv);
|
||||
if (cfg == null) continue;
|
||||
|
||||
AddBuyGiftList(buyLevelGiftitemMianFeiParent, cfg.normalGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemJingYingParent, cfg.luxuryGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemZhiZunParent, cfg.supremeGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemMianFeiParent, cfg.normalGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemJingYingParent, cfg.luxuryGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemZhiZunParent, cfg.supremeGiftList);
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearBuyGiftParent(Transform parent)
|
||||
@@ -302,7 +306,12 @@ public class ZhanLing_Panel : SubUIBase
|
||||
pe = (PropEnum)ResolveGiftPropType(gift);
|
||||
}
|
||||
int count = gift.isRandom ? gift.minCount : gift.count;
|
||||
obj.Init(url, count, pe);
|
||||
obj.Init(new BackPackPropItemData
|
||||
{
|
||||
url = url,
|
||||
count = count,
|
||||
propEnum = pe
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user