From 59b8e3d0a85571d07675ce24ce3d81ccbfe6fed1 Mon Sep 17 00:00:00 2001 From: liuliang <597380732@qq.com> Date: Fri, 27 Dec 2024 22:17:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8B=89=E6=96=B0=E6=A6=9CUI=E7=9A=84=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BB=A5=E5=8F=8A=E6=8E=A5=E5=8F=A3=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E7=9A=84=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Resources/Prefabs/players.prefab | 20 +- meng_yao/Assets/Scenes/scene_Main.unity | 183 ++++++++++++++++-- .../script/scene_Main/Promotion_Rank.cs | 53 ++++- .../scene_Main/ui/Promotion_Rankitem.cs | 23 +++ .../scene_Main/ui/Promotion_Rankitem.cs.meta | 11 ++ 5 files changed, 275 insertions(+), 15 deletions(-) create mode 100644 meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs create mode 100644 meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs.meta diff --git a/meng_yao/Assets/Resources/Prefabs/players.prefab b/meng_yao/Assets/Resources/Prefabs/players.prefab index 5a36c7225..84faf7938 100644 --- a/meng_yao/Assets/Resources/Prefabs/players.prefab +++ b/meng_yao/Assets/Resources/Prefabs/players.prefab @@ -79,7 +79,7 @@ MonoBehaviour: m_HorizontalOverflow: 0 m_VerticalOverflow: 0 m_LineSpacing: 1 - m_Text: 4 + m_Text: --- !u!1 &1908348282893993410 GameObject: m_ObjectHideFlags: 0 @@ -402,6 +402,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1908348284012044740} + - component: {fileID: 3461516469826489107} m_Layer: 5 m_Name: players m_TagString: Untagged @@ -433,6 +434,23 @@ RectTransform: m_AnchoredPosition: {x: -0.011657715, y: 517.78} m_SizeDelta: {x: 1080, y: 220.73} m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &3461516469826489107 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1908348284012044747} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a8534ac41d2237341ad7afa395ddb9c1, type: 3} + m_Name: + m_EditorClassIdentifier: + Rankingtext: {fileID: 716069678} + userImage: {fileID: 1908348282911385789} + username: {fileID: 1908348283343277311} + prize: {fileID: 1908348284013975805} + count: {fileID: 1908348282893993020} --- !u!1 &1908348284013975683 GameObject: m_ObjectHideFlags: 0 diff --git a/meng_yao/Assets/Scenes/scene_Main.unity b/meng_yao/Assets/Scenes/scene_Main.unity index 9fc540544..cb100336e 100644 --- a/meng_yao/Assets/Scenes/scene_Main.unity +++ b/meng_yao/Assets/Scenes/scene_Main.unity @@ -30283,8 +30283,9 @@ MonoBehaviour: ThirdName: {fileID: 95657181} Thirdcount: {fileID: 1312713360} ThirdPrize: {fileID: 1784087689} - Promotionitem: {fileID: 0} + Promotionitem: {fileID: 1908348284012044747, guid: b3cee309124aad94bb7e7397124dc142, type: 3} Content: {fileID: 1439471775} + countdown: {fileID: 688128787} --- !u!1 &351765137 GameObject: m_ObjectHideFlags: 0 @@ -63529,14 +63530,15 @@ RectTransform: m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 m_Children: + - {fileID: 1401714812} - {fileID: 1025123358} - m_Father: {fileID: 2145544678} - m_RootOrder: 0 + m_Father: {fileID: 1812984222} + m_RootOrder: 4 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 1, y: 0.5} - m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 21, y: -1} - m_SizeDelta: {x: 44, y: 44} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -71, y: -193} + m_SizeDelta: {x: 120, y: 88} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &695223666 MonoBehaviour: @@ -63617,7 +63619,7 @@ MonoBehaviour: m_OnCullStateChanged: m_PersistentCalls: m_Calls: [] - m_Sprite: {fileID: 21300000, guid: 7ce7af3934d417046a698b8e4caae747, type: 3} + m_Sprite: {fileID: 21300000, guid: c165058eb9d7ba1458ea801c23c8fc3e, type: 3} m_Type: 0 m_PreserveAspect: 1 m_FillCenter: 1 @@ -91634,11 +91636,11 @@ RectTransform: m_Children: - {fileID: 1672551387} m_Father: {fileID: 695223665} - m_RootOrder: 0 + m_RootOrder: 1 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5} - m_AnchoredPosition: {x: 142, y: -195} + m_AnchoredPosition: {x: -355, y: -195} m_SizeDelta: {x: 470, y: 318} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &1025123359 @@ -97654,6 +97656,86 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1085202524} m_CullTransparentMesh: 1 +--- !u!1 &1085210367 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1085210368} + - component: {fileID: 1085210370} + - component: {fileID: 1085210369} + m_Layer: 6 + m_Name: Text (Legacy) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1085210368 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085210367} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 1401714812} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 138.75, y: 30} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1085210369 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085210367} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.9716981, g: 0.9716981, b: 0.9716981, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 28 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 0 + m_MaxSize: 40 + m_Alignment: 4 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 1 + m_VerticalOverflow: 1 + m_LineSpacing: 1 + m_Text: "\u62C9\u65B0\u89C4\u5219" +--- !u!222 &1085210370 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1085210367} + m_CullTransparentMesh: 1 --- !u!1 &1091244400 GameObject: m_ObjectHideFlags: 0 @@ -124963,6 +125045,83 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1401636240} m_CullTransparentMesh: 1 +--- !u!1 &1401714811 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1401714812} + - component: {fileID: 1401714814} + - component: {fileID: 1401714813} + m_Layer: 6 + m_Name: textbg + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1401714812 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1401714811} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: + - {fileID: 1085210368} + m_Father: {fileID: 695223665} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: -62.060425} + m_SizeDelta: {x: 138.7515, y: 52.1208} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1401714813 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1401714811} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_Sprite: {fileID: 21300000, guid: bd5a4df145ebd3f43879257c0dc3d8ee, type: 3} + m_Type: 0 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1401714814 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1401714811} + m_CullTransparentMesh: 1 --- !u!1 &1402686383 GameObject: m_ObjectHideFlags: 0 @@ -161027,6 +161186,7 @@ RectTransform: - {fileID: 548326727} - {fileID: 1777432578} - {fileID: 2145544678} + - {fileID: 695223665} m_Father: {fileID: 350671369} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -193685,8 +193845,7 @@ RectTransform: m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 1, y: 1, z: 1} m_ConstrainProportionsScale: 0 - m_Children: - - {fileID: 695223665} + m_Children: [] m_Father: {fileID: 1812984222} m_RootOrder: 3 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/meng_yao/Assets/script/scene_Main/Promotion_Rank.cs b/meng_yao/Assets/script/scene_Main/Promotion_Rank.cs index 8e684f9f8..b419c4635 100644 --- a/meng_yao/Assets/script/scene_Main/Promotion_Rank.cs +++ b/meng_yao/Assets/script/scene_Main/Promotion_Rank.cs @@ -24,8 +24,12 @@ public class Promotion_Rank : MonoBehaviour public GameObject Promotionitem; public Transform Content; + + public Text countdown; + List Items = new List(); // Start is called before the first frame update + float remainingTime=0f; void OnEnable() { Init(); @@ -35,23 +39,68 @@ public class Promotion_Rank : MonoBehaviour async void Init() { PromotionRankResponse response = await Scene_main_jiekou.instance.PromotionRanks(); + + Firstlevel.text = response.data.ranks[0].rank.ToString(); FirstName.text = response.data.ranks[0].nickname; Firstcount.text = response.data.ranks[0].quantity + "/" + response.data.ranks[0].require; FitstPrize.text = response.data.ranks[0].reward.ToString(); + Secondlevel.text = response.data.ranks[1].rank.ToString(); SecondName.text = response.data.ranks[1].nickname; Secondcount.text = response.data.ranks[1].quantity + "/" + response.data.ranks[1].require; SecondPrize.text = response.data.ranks[1].reward.ToString(); + Thirdlevel.text = response.data.ranks[2].rank.ToString(); ThirdName.text = response.data.ranks[2].nickname; Thirdcount.text = response.data.ranks[2].quantity + "/" + response.data.ranks[2].require; ThirdPrize.text = response.data.ranks[2].reward.ToString(); + + remainingTime = response.data.countdown; + + for (int i = 3; i < response.data.ranks.Count; i++) + { + GameObject obj = Instantiate(Promotionitem,Content); + Items.Add(obj); + obj.GetComponent().Rankingtext.text = response.data.ranks[i].rank.ToString(); + obj.GetComponent().username.text = response.data.ranks[i].nickname; + obj.GetComponent().prize.text = response.data.ranks[i].reward+"元现金奖励"; + obj.GetComponent().count.text = response.data.ranks[i].quantity + "/" + response.data.ranks[i].require; + } + + + } + + void UpdateCountdownText(float remainingTime) + { + // 将剩余时间转换为小时、分钟和秒 + int hours = Mathf.FloorToInt(remainingTime / 3600); + int minutes = Mathf.FloorToInt((remainingTime % 3600) / 60); + int seconds = Mathf.FloorToInt(remainingTime % 60); + + // 使用格式化字符串显示倒计时(00:00:00) + countdown.text = string.Format("{0:D2}:{1:D2}:{2:D2}", hours, minutes, seconds); + } + + private void Update() + { + if (remainingTime > 0) + { + // 每帧减少剩余时间 + remainingTime -= Time.deltaTime; + + // 更新倒计时显示 + UpdateCountdownText(remainingTime); + } } // Update is called once per frame - void Update() + private void OnDisable() { - + foreach (GameObject item in Items) + { + Destroy(item); + } + Items.Clear(); } } diff --git a/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs b/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs new file mode 100644 index 000000000..25d0239fd --- /dev/null +++ b/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class Promotion_Rankitem : MonoBehaviour +{ + public Text Rankingtext; + public Image userImage; + public Text username; + public Text prize; + public Text count; + void Start() + { + + } + + // Update is called once per frame + void Update() + { + + } +} diff --git a/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs.meta b/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs.meta new file mode 100644 index 000000000..9555a915f --- /dev/null +++ b/meng_yao/Assets/script/scene_Main/ui/Promotion_Rankitem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a8534ac41d2237341ad7afa395ddb9c1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: