1
This commit is contained in:
@@ -31,11 +31,13 @@ public enum PropEnum
|
||||
[Serializable]
|
||||
public class BackPackPropItemData
|
||||
{
|
||||
/// <summary>道具图标地址(完整 URL,含 baseURL)</summary>
|
||||
/// <summary>道具图标地址(完整 URL,含 baseURL)。giftType 为金币/钻石时可为空</summary>
|
||||
public string url;
|
||||
/// <summary>道具数量</summary>
|
||||
/// <summary>数量</summary>
|
||||
public int count;
|
||||
/// <summary>道具类型</summary>
|
||||
/// <summary>奖励类型 1=金币 2=钻石 3=道具(默认道具)</summary>
|
||||
public int giftType = 3;
|
||||
/// <summary>道具子类型(仅 giftType==3 时有意义,用于背景框等)</summary>
|
||||
public PropEnum propEnum = PropEnum.none;
|
||||
}
|
||||
|
||||
@@ -45,50 +47,79 @@ public class BackPackPropItem : MonoBehaviour
|
||||
public Dictionary<PropEnum, Image> item_Type=new Dictionary<PropEnum, Image>();
|
||||
public Image img_Prop;
|
||||
public TextMeshProUGUI propCount;
|
||||
|
||||
// 金币/钻石图标从 Resources 读取(放 Assets/Resources 根目录),静态缓存避免重复加载
|
||||
private const string GoldResName = "gild";
|
||||
private const string DiamondResName = "diamond";
|
||||
private static Sprite _goldSprite;
|
||||
private static Sprite _diamondSprite;
|
||||
|
||||
private static Sprite GetGoldSprite()
|
||||
{
|
||||
if (_goldSprite == null) _goldSprite = Resources.Load<Sprite>(GoldResName);
|
||||
return _goldSprite;
|
||||
}
|
||||
private static Sprite GetDiamondSprite()
|
||||
{
|
||||
if (_diamondSprite == null) _diamondSprite = Resources.Load<Sprite>(DiamondResName);
|
||||
return _diamondSprite;
|
||||
}
|
||||
|
||||
public void Init(BackPackPropItemData data)
|
||||
{
|
||||
if (data == null) return;
|
||||
|
||||
PropEnum propEnum = data.propEnum;
|
||||
switch (propEnum)
|
||||
// 道具子类型背景框(仅道具类才显示)
|
||||
if (data.giftType == 3)
|
||||
{
|
||||
case PropEnum.none:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (propEnum)
|
||||
{
|
||||
case PropEnum.none:
|
||||
break;
|
||||
case PropEnum.炮塔碎片:
|
||||
case PropEnum.翅膀碎片:
|
||||
item_Bg[1].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.战神碎片:
|
||||
item_Bg[0].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.刮刮卡:
|
||||
case PropEnum.召唤卡:
|
||||
case PropEnum.技能:
|
||||
item_Bg[2].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.改名卡:
|
||||
case PropEnum.大喇叭:
|
||||
item_Bg[3].gameObject.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
WebTool.DownImage(data.url, (texture) =>
|
||||
{
|
||||
if (texture!=null)
|
||||
PropEnum propEnum = data.propEnum;
|
||||
switch (propEnum)
|
||||
{
|
||||
img_Prop.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one * 0.5f);
|
||||
|
||||
case PropEnum.炮塔碎片:
|
||||
case PropEnum.翅膀碎片:
|
||||
item_Bg[1].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.战神碎片:
|
||||
item_Bg[0].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.刮刮卡:
|
||||
case PropEnum.召唤卡:
|
||||
case PropEnum.技能:
|
||||
item_Bg[2].gameObject.SetActive(true);
|
||||
break;
|
||||
case PropEnum.改名卡:
|
||||
case PropEnum.大喇叭:
|
||||
item_Bg[3].gameObject.SetActive(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 图标来源:金币/钻石用 Resources 本地图,道具下载图片
|
||||
if (data.giftType == 1)
|
||||
{
|
||||
var gold = GetGoldSprite();
|
||||
if (gold != null) img_Prop.sprite = gold;
|
||||
}
|
||||
else if (data.giftType == 2)
|
||||
{
|
||||
var diamond = GetDiamondSprite();
|
||||
if (diamond != null) img_Prop.sprite = diamond;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(data.url))
|
||||
{
|
||||
WebTool.DownImage(data.url, (texture) =>
|
||||
{
|
||||
// 回调触发时本物体可能已被销毁(切换等级/关闭面板清空父节点),需判空
|
||||
if (this == null || img_Prop == null) return;
|
||||
if (texture != null)
|
||||
{
|
||||
img_Prop.sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.one * 0.5f);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
this.propCount.text = data.count.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,30 +106,22 @@ public class RankLineItem : MonoBehaviour
|
||||
foreach (var gift in giftItems)
|
||||
{
|
||||
int count = gift.isRandom ? gift.minCount : gift.count;
|
||||
var data = new BackPackPropItemData { count = count, giftType = gift.type };
|
||||
|
||||
// GiftConfig 已移除 product,道具图标与类型通过 otherId 查道具表
|
||||
string imageUrl = "";
|
||||
int propType = 0;
|
||||
if (!string.IsNullOrEmpty(gift.otherId))
|
||||
// 道具(type==3)才需要查道具表拿图标与子类型;金币/钻石用本地 sprite
|
||||
if (gift.type == 3 && !string.IsNullOrEmpty(gift.otherId))
|
||||
{
|
||||
var match = GameManager.Instance?.gameConfig?.propConfig?.Find(p => p.number == gift.otherId);
|
||||
if (match != null)
|
||||
{
|
||||
imageUrl = match.imageUrl;
|
||||
propType = match.type;
|
||||
data.url = APIManager.baseURL + match.imageUrl;
|
||||
data.propEnum = (PropEnum)match.type;
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(imageUrl)) continue;
|
||||
|
||||
GameObject obj = Instantiate(backPackPropItemPrefab.gameObject, backPackPropItemRarent);
|
||||
var tempItem = obj.GetComponent<BackPackPropItem>();
|
||||
tempItem.Init(new BackPackPropItemData
|
||||
{
|
||||
url = APIManager.baseURL + imageUrl,
|
||||
count = count,
|
||||
propEnum = (PropEnum)propType
|
||||
});
|
||||
tempItem.Init(data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -227,16 +227,17 @@ public class UIHome_BY_VIPPanel : SubUIBase
|
||||
switch (gift.type)
|
||||
{
|
||||
case 1:
|
||||
item.Init(new BackPackPropItemData { count = count });
|
||||
item.Init(new BackPackPropItemData { count = count, giftType = 1 });
|
||||
break;
|
||||
case 2:
|
||||
item.Init(new BackPackPropItemData { count = count });
|
||||
item.Init(new BackPackPropItemData { count = count, giftType = 2 });
|
||||
break;
|
||||
case 3:
|
||||
item.Init(new BackPackPropItemData
|
||||
{
|
||||
url = gift.product != null ? APIManager.baseURL + gift.product.imageUrl : "",
|
||||
count = count,
|
||||
giftType = 3,
|
||||
propEnum = (PropEnum)gift.product.type
|
||||
});
|
||||
break;
|
||||
|
||||
@@ -2588,6 +2588,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 4554469987512757028}
|
||||
- component: {fileID: 9024122951089552775}
|
||||
- component: {fileID: 7077415828172661238}
|
||||
- component: {fileID: 3055358872832868132}
|
||||
m_Layer: 0
|
||||
m_Name: Content
|
||||
m_TagString: Untagged
|
||||
@@ -2640,6 +2642,40 @@ MonoBehaviour:
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &7077415828172661238
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 718532043346567689}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 2
|
||||
m_VerticalFit: 0
|
||||
--- !u!114 &3055358872832868132
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 718532043346567689}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreLayout: 0
|
||||
m_MinWidth: 426
|
||||
m_MinHeight: -1
|
||||
m_PreferredWidth: -1
|
||||
m_PreferredHeight: -1
|
||||
m_FlexibleWidth: -1
|
||||
m_FlexibleHeight: -1
|
||||
m_LayoutPriority: 1
|
||||
--- !u!1 &734192645085970957
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -3950,6 +3986,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 8611253591427440167}
|
||||
- component: {fileID: 6286865268592279310}
|
||||
- component: {fileID: 2523951118879727695}
|
||||
- component: {fileID: 5871928142295922042}
|
||||
m_Layer: 0
|
||||
m_Name: Content
|
||||
m_TagString: Untagged
|
||||
@@ -4002,6 +4040,40 @@ MonoBehaviour:
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &2523951118879727695
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1085506753628414110}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 2
|
||||
m_VerticalFit: 0
|
||||
--- !u!114 &5871928142295922042
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1085506753628414110}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreLayout: 0
|
||||
m_MinWidth: 426
|
||||
m_MinHeight: -1
|
||||
m_PreferredWidth: -1
|
||||
m_PreferredHeight: -1
|
||||
m_FlexibleWidth: -1
|
||||
m_FlexibleHeight: -1
|
||||
m_LayoutPriority: 1
|
||||
--- !u!1 &1104899787520883883
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -4975,7 +5047,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Content: {fileID: 8522877395895291193}
|
||||
m_Horizontal: 1
|
||||
m_Vertical: 1
|
||||
m_Vertical: 0
|
||||
m_MovementType: 1
|
||||
m_Elasticity: 0.1
|
||||
m_Inertia: 1
|
||||
@@ -7723,7 +7795,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &6733921030653514108
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -8536,7 +8608,7 @@ RectTransform:
|
||||
m_Father: {fileID: 4025192357767497114}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: -0.0000047683716}
|
||||
m_SizeDelta: {x: 30, y: 7}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
@@ -11423,6 +11495,7 @@ GameObject:
|
||||
- component: {fileID: 4364187792569028836}
|
||||
- component: {fileID: 5164773768723089219}
|
||||
- component: {fileID: 6699724044070482830}
|
||||
- component: {fileID: 8151148980994447716}
|
||||
m_Layer: 0
|
||||
m_Name: NZXL_New_fightgod_suipian_add
|
||||
m_TagString: Untagged
|
||||
@@ -11487,6 +11560,50 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &8151148980994447716
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3505582394909929759}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 6699724044070482830}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &3525845443501861603
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -24189,7 +24306,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Content: {fileID: 8611253591427440167}
|
||||
m_Horizontal: 1
|
||||
m_Vertical: 1
|
||||
m_Vertical: 0
|
||||
m_MovementType: 1
|
||||
m_Elasticity: 0.1
|
||||
m_Inertia: 1
|
||||
@@ -24450,6 +24567,7 @@ GameObject:
|
||||
- component: {fileID: 5005030936867475645}
|
||||
- component: {fileID: 1919314936902253070}
|
||||
- component: {fileID: 5493128021201696150}
|
||||
- component: {fileID: 2984555924908709581}
|
||||
m_Layer: 0
|
||||
m_Name: NZXL_New_fightgod_suipian_impules
|
||||
m_TagString: Untagged
|
||||
@@ -24514,6 +24632,50 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &2984555924908709581
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6613841056811058563}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 5493128021201696150}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &6635157633526583869
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -25687,7 +25849,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 117.685, y: -25}
|
||||
m_SizeDelta: {x: 0, y: 50}
|
||||
m_SizeDelta: {x: 235.37, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &4614401808319948171
|
||||
CanvasRenderer:
|
||||
@@ -26929,6 +27091,8 @@ MonoBehaviour:
|
||||
btn_Buy: {fileID: 837267387750453869}
|
||||
tmp_PriceNum: {fileID: 1193562588815078309}
|
||||
tmp_BuyLabel: {fileID: 5895704420953922786}
|
||||
btn_Up: {fileID: 8151148980994447716}
|
||||
btn_Down: {fileID: 2984555924908709581}
|
||||
huoDongToggleItemPrefab: {fileID: 3542276533729162296}
|
||||
huoDongToggleItemParent: {fileID: 6568873253317409902}
|
||||
btn_JinJie: {fileID: 5442973199467095328}
|
||||
@@ -27050,7 +27214,7 @@ RectTransform:
|
||||
m_Father: {fileID: 4799252558641680687}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: -0.8265}
|
||||
m_SizeDelta: {x: 10, y: 1.6531}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
@@ -27333,7 +27497,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
m_Content: {fileID: 4554469987512757028}
|
||||
m_Horizontal: 1
|
||||
m_Vertical: 1
|
||||
m_Vertical: 0
|
||||
m_MovementType: 1
|
||||
m_Elasticity: 0.1
|
||||
m_Inertia: 1
|
||||
@@ -31325,6 +31489,8 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 8522877395895291193}
|
||||
- component: {fileID: 6166466634899681303}
|
||||
- component: {fileID: 360350492556303408}
|
||||
- component: {fileID: 8301434656585845490}
|
||||
m_Layer: 0
|
||||
m_Name: Content
|
||||
m_TagString: Untagged
|
||||
@@ -31377,6 +31543,40 @@ MonoBehaviour:
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &360350492556303408
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8051457460745199296}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_HorizontalFit: 2
|
||||
m_VerticalFit: 0
|
||||
--- !u!114 &8301434656585845490
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8051457460745199296}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 306cc8c2b49d7114eaa3623786fc2126, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_IgnoreLayout: 0
|
||||
m_MinWidth: 426
|
||||
m_MinHeight: -1
|
||||
m_PreferredWidth: -1
|
||||
m_PreferredHeight: -1
|
||||
m_FlexibleWidth: -1
|
||||
m_FlexibleHeight: -1
|
||||
m_LayoutPriority: 1
|
||||
--- !u!1 &8062925924427561578
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -40,6 +40,8 @@ public class ZhanLing_Panel : SubUIBase
|
||||
public Button btn_Buy;
|
||||
public TextMeshProUGUI tmp_PriceNum;
|
||||
public TextMeshProUGUI tmp_BuyLabel; //购买<color=yellow> 99999 </color>点经验值升至 <color=green>100 </color>级
|
||||
public Button btn_Up;
|
||||
public Button btn_Down;
|
||||
|
||||
[Header("活动切换项")]
|
||||
public GameObject huoDongToggleItemPrefab;
|
||||
@@ -252,6 +254,17 @@ public class ZhanLing_Panel : SubUIBase
|
||||
slider_BuyLevelExpCount.onValueChanged.RemoveAllListeners();
|
||||
slider_BuyLevelExpCount.onValueChanged.AddListener(OnBuyLevelSliderChanged);
|
||||
|
||||
if (btn_Up != null)
|
||||
{
|
||||
btn_Up.onClick.RemoveAllListeners();
|
||||
btn_Up.onClick.AddListener(OnBuyLevelUp);
|
||||
}
|
||||
if (btn_Down != null)
|
||||
{
|
||||
btn_Down.onClick.RemoveAllListeners();
|
||||
btn_Down.onClick.AddListener(OnBuyLevelDown);
|
||||
}
|
||||
|
||||
_selectedBuyLevel = _userData.level;
|
||||
UpdateBuyLevelGifts(_selectedBuyLevel);
|
||||
UpdateBuyPrice();
|
||||
@@ -264,22 +277,39 @@ public class ZhanLing_Panel : SubUIBase
|
||||
UpdateBuyPrice();
|
||||
}
|
||||
|
||||
/// <summary>购买等级 +1(受 maxLevel 限制)</summary>
|
||||
private void OnBuyLevelUp()
|
||||
{
|
||||
if (slider_BuyLevelExpCount == null) return;
|
||||
int target = Mathf.Min(_selectedBuyLevel + 1, _maxLevel);
|
||||
if (target == _selectedBuyLevel) return;
|
||||
slider_BuyLevelExpCount.value = target; // 触发 OnBuyLevelSliderChanged
|
||||
}
|
||||
|
||||
/// <summary>购买等级 -1(不低于当前等级)</summary>
|
||||
private void OnBuyLevelDown()
|
||||
{
|
||||
if (slider_BuyLevelExpCount == null) return;
|
||||
int minLevel = Mathf.Max(1, _userData.level);
|
||||
int target = Mathf.Max(_selectedBuyLevel - 1, minLevel);
|
||||
if (target == _selectedBuyLevel) return;
|
||||
slider_BuyLevelExpCount.value = target; // 触发 OnBuyLevelSliderChanged
|
||||
}
|
||||
|
||||
private void UpdateBuyLevelGifts(int targetLevel)
|
||||
{
|
||||
ClearBuyGiftParent(buyLevelGiftitemMianFeiParent);
|
||||
ClearBuyGiftParent(buyLevelGiftitemJingYingParent);
|
||||
ClearBuyGiftParent(buyLevelGiftitemZhiZunParent);
|
||||
|
||||
// 从当前等级+1到目标等级,累加所有礼包
|
||||
for (int lv = _userData.level + 1; lv <= targetLevel; lv++)
|
||||
{
|
||||
var cfg = _config?.levelConfig?.Find(c => c.level == lv);
|
||||
if (cfg == null) continue;
|
||||
// 从当前等级+1到目标等级,累加所有礼包并合并相同奖励(数量累加)
|
||||
var mergedNormal = MergeGifts(_config?.levelConfig, _userData.level + 1, targetLevel, c => c.normalGiftList);
|
||||
var mergedLuxury = MergeGifts(_config?.levelConfig, _userData.level + 1, targetLevel, c => c.luxuryGiftList);
|
||||
var mergedSupreme = MergeGifts(_config?.levelConfig, _userData.level + 1, targetLevel, c => c.supremeGiftList);
|
||||
|
||||
AddBuyGiftList(buyLevelGiftitemMianFeiParent, cfg.normalGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemJingYingParent, cfg.luxuryGiftList);
|
||||
AddBuyGiftList(buyLevelGiftitemZhiZunParent, cfg.supremeGiftList);
|
||||
}
|
||||
AddBuyGiftList(buyLevelGiftitemMianFeiParent, mergedNormal);
|
||||
AddBuyGiftList(buyLevelGiftitemJingYingParent, mergedLuxury);
|
||||
AddBuyGiftList(buyLevelGiftitemZhiZunParent, mergedSupreme);
|
||||
}
|
||||
|
||||
private void ClearBuyGiftParent(Transform parent)
|
||||
@@ -289,29 +319,75 @@ public class ZhanLing_Panel : SubUIBase
|
||||
Destroy(parent.GetChild(i).gameObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 把指定等级范围内每一级的同种礼包合并:相同奖励(giftType 相同,
|
||||
/// 道具再按 otherId 区分)数量累加,返回合并后的列表。
|
||||
/// </summary>
|
||||
private List<GiftConfig> MergeGifts(List<BattleOrderLevelInfo> levelConfig, int fromLevel, int toLevel,
|
||||
System.Func<BattleOrderLevelInfo, List<GiftConfig>> selector)
|
||||
{
|
||||
var result = new List<GiftConfig>();
|
||||
if (levelConfig == null) return result;
|
||||
|
||||
// 合并键:金币="1",钻石="2",道具="3:otherId"
|
||||
foreach (var cfg in levelConfig)
|
||||
{
|
||||
if (cfg.level < fromLevel || cfg.level > toLevel) continue;
|
||||
var gifts = selector(cfg);
|
||||
if (gifts == null) continue;
|
||||
|
||||
foreach (var gift in gifts)
|
||||
{
|
||||
if (gift == null) continue;
|
||||
string key = gift.type == 3 ? $"3:{gift.otherId}" : gift.type.ToString();
|
||||
|
||||
int idx = result.FindIndex(g =>
|
||||
(g.type == 3 ? $"3:{g.otherId}" : g.type.ToString()) == key);
|
||||
if (idx >= 0)
|
||||
{
|
||||
// 已存在同种奖励,数量累加(随机取值用 minCount 之和)
|
||||
if (gift.isRandom)
|
||||
result[idx].minCount += gift.minCount;
|
||||
else
|
||||
result[idx].count += gift.count;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 克隆一份避免修改原始配置
|
||||
var copy = new GiftConfig
|
||||
{
|
||||
type = gift.type,
|
||||
otherId = gift.otherId,
|
||||
isRandom = gift.isRandom,
|
||||
count = gift.count,
|
||||
minCount = gift.minCount,
|
||||
maxCount = gift.maxCount
|
||||
};
|
||||
result.Add(copy);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void AddBuyGiftList(Transform parent, List<GiftConfig> gifts)
|
||||
{
|
||||
if (parent == null || gifts == null) return;
|
||||
foreach (var gift in gifts)
|
||||
{
|
||||
var obj = Instantiate(buyLevelGiftitemPrefab, parent);
|
||||
// GiftConfig 已移除 product,道具(type==3)图标与类型通过 otherId 查道具表
|
||||
string url = "";
|
||||
PropEnum pe = PropEnum.none;
|
||||
int count = gift.isRandom ? gift.minCount : gift.count;
|
||||
var data = new BackPackPropItemData { count = count, giftType = gift.type };
|
||||
|
||||
// 道具(type==3)才需要查道具表拿图标与子类型;金币/钻石用本地 sprite
|
||||
if (gift.type == 3)
|
||||
{
|
||||
string imageUrl = ResolveGiftImageUrl(gift);
|
||||
if (!string.IsNullOrEmpty(imageUrl))
|
||||
url = APIManager.baseURL + imageUrl;
|
||||
pe = (PropEnum)ResolveGiftPropType(gift);
|
||||
data.url = APIManager.baseURL + imageUrl;
|
||||
data.propEnum = (PropEnum)ResolveGiftPropType(gift);
|
||||
}
|
||||
int count = gift.isRandom ? gift.minCount : gift.count;
|
||||
obj.Init(new BackPackPropItemData
|
||||
{
|
||||
url = url,
|
||||
count = count,
|
||||
propEnum = pe
|
||||
});
|
||||
obj.Init(data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user