👨💻个人主页:@元宇宙-秩沅
👨💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!
👨💻 本文由 秩沅 原创
👨💻 收录于专栏:就业宝典
⭐🅰️推荐专栏⭐
⭐-软件设计师高频考点大全⭐
文章目录
- ⭐前言⭐
- 🎶(==1==) 胜利面板逻辑
- 🎶(==2==) 排行榜面板逻辑
- ⭐🅰️⭐
⭐前言⭐
🎶(1) 胜利面板逻辑
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;//-------------------------------
//-------功能:胜利结算面板
//-------创建者: -------
//------------------------------public class VectoryPanel : BasePanel
{public Text other;public Text sorce;public Button backBtu;public Image[] itemStar = new Image[3];public GameObject gamePanel;int off;void Start(){backBtu.onClick.AddListener(()=>{for (int i = 0; i < itemStar.Length; i++){ itemStar[i].enabled = false; }gamePanel.SetActive(false);DataContorl.GetInstance().CloseALL(); //关闭所有状态UIManager.GetInstance().ShowPanel<SelectPanel>("SelectPanel"); //加载模式选择面板 gameObject.SetActive(false);});}void Update(){sorce.text = other.text; }
}
if (Convert.ToInt32(sorce.text) > 8000) //三星{for (int i = 0; i < itemStar.Length; i++){ itemStar[i].enabled = true; } }else if (Convert.ToInt32(sorce.text) > 7000 && Convert.ToInt32(sorce.text) < 8000 )//二星{for (int i = 0; i < itemStar.Length-1; i++){ itemStar[i].enabled = true; }}else //一星{itemStar[0].enabled = true;}
🎶(2) 排行榜面板逻辑
-
关卡模式排行榜
-
生存模式排行榜
-
无尽模式排行榜
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.UI;
using UnityEngine;
using UnityEngine.UI;//-------------------------------
//-------功能: 关卡模式排行榜面板
//-------创建者: -------
//------------------------------public class RankPanel1: BasePanel
{public Button back;//返回按钮public Text[] nameArray = new Text[3]; //姓名数组public Text[] SocerArray = new Text[3]; //分数数组public AcountData acountData;public Dictionary<string, int> keyValuePairs = new Dictionary<string, int>(); //账号信息和分数的字典PlayerData playerDatas;int index = 0;void Start(){UpdatRank();//更新排行榜面板AllEvent();}// Update is called once per framevoid Update(){}public void AllEvent(){//给返回按钮添加逻辑GetControl<Button>("Back").onClick.AddListener(() => {UIManager.GetInstance().RemovePanel("RankPanel1");//移除背景面板 UIManager.GetInstance().ShowPanel<SelectPanel>("SelectPanel"); //加载模式选择面板});}public void UpdatRank()//更新排行榜面板{acountData = JsonManager.Instance.LoadData<AcountData>("acountArrary");foreach (var item in acountData.aount){playerDatas = JsonManager.Instance.LoadData<PlayerData>(item); //遍历所有的账号信息keyValuePairs.Add(playerDatas.userName, playerDatas.AllScore ); //获取账号信息和关卡模式的分数}//进行排序var myList = keyValuePairs.ToList();myList.Sort((pair1, pair2) => pair2.Value.CompareTo(pair1.Value));foreach (var item in myList)Debug.Log(item);//更新排行榜数据for (int i = 0; i < 3; i++){try{nameArray[i].text = myList[i].Key;SocerArray[i].text = myList[i].Value.ToString();}catch { }}}
}
⭐🅰️⭐
⭐【Unityc#专题篇】之c#进阶篇】
⭐【Unityc#专题篇】之c#核心篇】
⭐【Unityc#专题篇】之c#基础篇】
⭐【Unity-c#专题篇】之c#入门篇】
⭐【Unityc#专题篇】—进阶章题单实践练习
⭐【Unityc#专题篇】—基础章题单实践练习
⭐【Unityc#专题篇】—核心章题单实践练习
你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!、