中文亚洲精品无码_熟女乱子伦免费_人人超碰人人爱国产_亚洲熟妇女综合网

當前位置: 首頁 > news >正文

做傳銷網(wǎng)站違法嗎自己搭建網(wǎng)站需要什么

做傳銷網(wǎng)站違法嗎,自己搭建網(wǎng)站需要什么,深圳企業(yè)網(wǎng)站公司,做網(wǎng)站賣什么發(fā)財前言 注意,本文是本人的學習筆記記錄,這里先記錄基本的代碼,后面用到了再回來進行實現(xiàn)和整理 素材 https://assetstore.unity.com/packages/2d/gui/icons/2d-simple-ui-pack-218050 框架: RedPointSystem.cs using System.…

前言

注意,本文是本人的學習筆記記錄,這里先記錄基本的代碼,后面用到了再回來進行實現(xiàn)和整理

素材

https://assetstore.unity.com/packages/2d/gui/icons/2d-simple-ui-pack-218050
在這里插入圖片描述

框架:

RedPointSystem.cs

using System.Collections.Generic;
using UnityEngine;namespace RedpointSystem
{public class RedPointNode{public int redNum; // 紅點數(shù)量public string strKey; // 節(jié)點關鍵字public Dictionary<string, RedPointNode> children; // 子節(jié)點字典public delegate void RedPointChangeDelegate(int redNum); // 紅點變化委托public RedPointChangeDelegate OnRedPointChange; // 紅點變化事件public RedPointNode(string key){strKey = key;children = new Dictionary<string, RedPointNode>();}}public class RedPointSystem{private static RedPointSystem instance = new RedPointSystem(); // 單例實例public static RedPointSystem Instance // 單例訪問屬性{get { return instance; }}public RedPointNode root; // 根節(jié)點private RedPointSystem(){this.root = new RedPointNode(RedPointKey.Root); // 根節(jié)點初始化}// 添加節(jié)點public RedPointNode AddNode(string key){if (FindNode(key) != null){return null; // 如果節(jié)點已存在,則返回空}string[] keys = key.Split('|'); // 按'|'分割關鍵字RedPointNode curNode = root;curNode.redNum += 1; // 根節(jié)點紅點數(shù)量加一curNode.OnRedPointChange?.Invoke(curNode.redNum); // 觸發(fā)紅點變化事件foreach (string k in keys){if (!curNode.children.ContainsKey(k)){curNode.children.Add(k, new RedPointNode(k)); // 如果子節(jié)點不包含該關鍵字,則添加新節(jié)點}curNode = curNode.children[k];curNode.redNum += 1; // 子節(jié)點紅點數(shù)量加一curNode.OnRedPointChange?.Invoke(curNode.redNum); // 觸發(fā)紅點變化事件}return curNode;}// 查找節(jié)點public RedPointNode FindNode(string key){string[] keys = key.Split('|'); // 按'|'分割關鍵字RedPointNode curNode = root;foreach (string k in keys){if (!curNode.children.ContainsKey(k)){return null; // 如果子節(jié)點不包含該關鍵字,則返回空}curNode = curNode.children[k];}return curNode;}// 刪除節(jié)點public void DeleteNode(string key){if (FindNode(key) == null){return; // 如果節(jié)點不存在,則返回}DeleteNode(key, root);}// 遞歸刪除節(jié)點private RedPointNode DeleteNode(string key, RedPointNode node){string[] keys = key.Split('|'); // 按'|'分割關鍵字if (key == "" || keys.Length == 0){node.redNum = Mathf.Clamp(node.redNum - 1, 0, node.redNum); // 調(diào)整節(jié)點紅點數(shù)量node.OnRedPointChange?.Invoke(node.redNum); // 觸發(fā)紅點變化事件return node;}string newKey = string.Join("|", keys, 1, keys.Length - 1); // 獲取新的關鍵字RedPointNode curNode = DeleteNode(newKey, node.children[keys[0]]); // 遞歸刪除子節(jié)點node.redNum = Mathf.Clamp(node.redNum - 1, 0, node.redNum); // 調(diào)整節(jié)點紅點數(shù)量node.OnRedPointChange?.Invoke(node.redNum); // 觸發(fā)紅點變化事件// 移除紅點數(shù)量為零的子節(jié)點if (curNode.children.Count > 0){foreach (RedPointNode child in curNode.children.Values){if (child.redNum == 0){child.children.Remove(child.strKey);}}}return node;}// 設置回調(diào)函數(shù)public void SetCallBack(string key, RedPointNode.RedPointChangeDelegate cb){RedPointNode node = FindNode(key);if (node == null){return; // 如果節(jié)點不存在,則返回}node.OnRedPointChange += cb; // 設置紅點變化事件的回調(diào)函數(shù)}// 獲取紅點數(shù)量public int GetRedpointNum(string key){RedPointNode node = FindNode(key);if (node == null){return 0; // 如果節(jié)點不存在,則返回0}return node.redNum; // 返回節(jié)點的紅點數(shù)量}}public class RedPointKey{// 根節(jié)點關鍵字public const string Root = "Root";// Play節(jié)點及其子節(jié)點關鍵字public const string Play = "Play";public const string Play_LEVEL1 = "Play|Level1";  // Play節(jié)點下的Level1節(jié)點public const string Play_LEVEL1_HOME = "Play|Level1|HOME";  // Level1節(jié)點下的HOME子節(jié)點public const string Play_LEVEL1_SHOP = "Play|Level1|SHOP";  // Level1節(jié)點下的SHOP子節(jié)點public const string Play_LEVEL2 = "Play|Level2";  // Play節(jié)點下的Level2節(jié)點public const string Play_LEVEL2_HOME = "Play|Level2|HOME";  // Level2節(jié)點下的HOME子節(jié)點public const string Play_LEVEL2_SHOP = "Play|Level2|SHOP";  // Level2節(jié)點下的SHOP子節(jié)點}}

使用案例

RootPanel.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RedpointSystem;public class RootPanel : MonoBehaviour
{public GameObject Canvas; // UI畫布對象public MenuPanel menuPanel; // 菜單面板對象public LevelPanel levelPanel; // 關卡面板對象private void Awake(){// 在Awake方法中初始化紅點節(jié)點,表示需要顯示紅點的條件// 示例:如果跨過每月最后一天的0點,則顯示Play|Level1|HOME節(jié)點的紅點RedPointSystem.Instance.AddNode(RedPointKey.Play_LEVEL1_HOME);// 示例:如果任務完成,可以領獎,則顯示Play|Level1|SHOP節(jié)點的紅點RedPointSystem.Instance.AddNode(RedPointKey.Play_LEVEL1_SHOP);// 其他條件類似,根據(jù)具體邏輯添加不同的紅點節(jié)點RedPointSystem.Instance.AddNode(RedPointKey.Play_LEVEL2_HOME);RedPointSystem.Instance.AddNode(RedPointKey.Play_LEVEL2_SHOP);}private void Start() {// 在Start方法中設置菜單面板可見,關卡面板不可見menuPanel.gameObject.SetActive(true);levelPanel.gameObject.SetActive(false);}
}

MenuPanel.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using RedpointSystem;public class MenuPanel : MonoBehaviour
{public GameObject playBtn; // 播放按鈕對象public GameObject continueBtn; // 繼續(xù)按鈕對象public GameObject optionsBtn; // 選項按鈕對象public GameObject QuitBtn; // 退出按鈕對象public LevelPanel LevelPanel; // 關卡面板對象void Start(){// 在Start方法中為播放按鈕添加點擊事件監(jiān)聽器,綁定到OnPlay方法playBtn.GetComponent<Button>().onClick.AddListener(OnPlay);// 初始化紅點狀態(tài)InitRedPointState();}void OnPlay(){// 點擊播放按鈕后,隱藏菜單面板,顯示關卡面板this.gameObject.SetActive(false);LevelPanel.gameObject.SetActive(true);}void InitRedPointState(){// 獲取Play節(jié)點的紅點數(shù)量int redNum = RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play);// 根據(jù)紅點數(shù)量更新紅點狀態(tài)RefreshRedPointState(redNum);// 設置回調(diào)函數(shù),當Play節(jié)點的紅點數(shù)量發(fā)生變化時刷新紅點狀態(tài)RedPointSystem.Instance.SetCallBack(RedPointKey.Play, RefreshRedPointState);}void RefreshRedPointState(int redNum){// 查找播放按鈕下的紅點和數(shù)字對象Transform redPoint = playBtn.transform.Find("RedPoint");Transform redNumText = redPoint.transform.Find("Num");// 根據(jù)紅點數(shù)量決定是否顯示紅點if (redNum <= 0){redPoint.gameObject.SetActive(false);}else{redPoint.gameObject.SetActive(true);redNumText.GetComponent<Text>().text = redNum.ToString(); // 更新紅點數(shù)字文本}}
}

LevelPanel.cs

using RedpointSystem;
using UnityEngine;
using UnityEngine.UI;public class LevelPanel : MonoBehaviour
{// UI元素引用public GameObject Back1Btn; // 返回按鈕public MenuPanel menuPanel; // 菜單面板引用public GameObject Level1Btn; // 關卡1按鈕public GameObject Level1Container; // 關卡1容器public GameObject Level1HomeBtn; // 關卡1的主頁按鈕public GameObject Level1ShopBtn; // 關卡1的商店按鈕public GameObject Level2Btn; // 關卡2按鈕public GameObject Level2Container; // 關卡2容器public GameObject Level2HomeBtn; // 關卡2的主頁按鈕public GameObject Level2ShopBtn; // 關卡2的商店按鈕void Start(){// 初始時隱藏關卡容器Level1Container.SetActive(false);Level2Container.SetActive(false);// 給返回按鈕添加點擊事件監(jiān)聽器Back1Btn.GetComponent<Button>().onClick.AddListener(OnBackClick);// 給關卡1按鈕添加點擊事件監(jiān)聽器Level1Btn.GetComponent<Button>().onClick.AddListener(OnLevel1Click);// 給關卡2按鈕添加點擊事件監(jiān)聽器Level2Btn.GetComponent<Button>().onClick.AddListener(OnLevel2Click);// 給關卡1主頁按鈕添加點擊事件監(jiān)聽器Level1HomeBtn.GetComponent<Button>().onClick.AddListener(OnLevel1HomeBtn);// 給關卡1商店按鈕添加點擊事件監(jiān)聽器Level1ShopBtn.GetComponent<Button>().onClick.AddListener(OnLevel1ShopBtn);// 給關卡2主頁按鈕添加點擊事件監(jiān)聽器Level2HomeBtn.GetComponent<Button>().onClick.AddListener(OnLevel2HomeBtn);// 給關卡2商店按鈕添加點擊事件監(jiān)聽器Level2ShopBtn.GetComponent<Button>().onClick.AddListener(OnLevel2ShopBtn);// 初始化紅點狀態(tài)InitRedPointState();}// 返回按鈕點擊事件處理void OnBackClick(){// 隱藏當前關卡面板,顯示菜單面板this.gameObject.SetActive(false);menuPanel.gameObject.SetActive(true);}// 關卡1按鈕點擊事件處理void OnLevel1Click(){// 切換顯示關卡1容器的可見性Level1Container.gameObject.SetActive(!Level1Container.gameObject.activeSelf);}// 關卡2按鈕點擊事件處理void OnLevel2Click(){// 切換顯示關卡2容器的可見性Level2Container.gameObject.SetActive(!Level2Container.gameObject.activeSelf);}// 關卡1主頁按鈕點擊事件處理void OnLevel1HomeBtn(){// 刪除關卡1主頁紅點RedPointSystem.Instance.DeleteNode(RedPointKey.Play_LEVEL1_HOME);}// 關卡1商店按鈕點擊事件處理void OnLevel1ShopBtn(){// 刪除關卡1商店紅點RedPointSystem.Instance.DeleteNode(RedPointKey.Play_LEVEL1_SHOP);}// 關卡2主頁按鈕點擊事件處理void OnLevel2HomeBtn(){// 刪除關卡2主頁紅點RedPointSystem.Instance.DeleteNode(RedPointKey.Play_LEVEL2_HOME);}// 關卡2商店按鈕點擊事件處理void OnLevel2ShopBtn(){// 刪除關卡2商店紅點RedPointSystem.Instance.DeleteNode(RedPointKey.Play_LEVEL2_SHOP);}void InitRedPointState(){// 初始化關卡1按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL1),Level1Btn.transform.Find("RedPoint"));// 設置關卡1紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL1, (int redNum) =>{RefreshRedPointState(redNum, Level1Btn.transform.Find("RedPoint"));});// 初始化關卡2按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL2),Level2Btn.transform.Find("RedPoint"));// 設置關卡2紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL2, (int redNum) =>{RefreshRedPointState(redNum, Level2Btn.transform.Find("RedPoint"));});// 初始化關卡1主頁按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL1_HOME),Level1HomeBtn.transform.Find("RedPoint"));// 設置關卡1主頁紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL1_HOME, (int redNum) =>{RefreshRedPointState(redNum, Level1HomeBtn.transform.Find("RedPoint"));});// 初始化關卡1商店按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL1_SHOP),Level1ShopBtn.transform.Find("RedPoint"));// 設置關卡1商店紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL1_SHOP, (int redNum) =>{RefreshRedPointState(redNum, Level1ShopBtn.transform.Find("RedPoint"));});// 初始化關卡2主頁按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL2_HOME),Level2HomeBtn.transform.Find("RedPoint"));// 設置關卡2主頁紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL2_HOME, (int redNum) =>{RefreshRedPointState(redNum, Level2HomeBtn.transform.Find("RedPoint"));});// 初始化關卡2商店按鈕的紅點狀態(tài)RefreshRedPointState(RedPointSystem.Instance.GetRedpointNum(RedPointKey.Play_LEVEL2_SHOP),Level2ShopBtn.transform.Find("RedPoint"));// 設置關卡2商店紅點回調(diào)RedPointSystem.Instance.SetCallBack(RedPointKey.Play_LEVEL2_SHOP, (int redNum) =>{RefreshRedPointState(redNum, Level2ShopBtn.transform.Find("RedPoint"));});}void RefreshRedPointState(int redNum, Transform redPoint){Transform redNumText = redPoint.transform.Find("Num");// 如果紅點數(shù)小于等于0,隱藏紅點圖標if (redNum <= 0){redPoint.gameObject.SetActive(false);}else{// 否則顯示紅點圖標,并更新紅點數(shù)顯示redPoint.gameObject.SetActive(true);redNumText.GetComponent<Text>().text = redNum.ToString();}}
}

源碼

整理好了會放上來

參考

https://www.bilibili.com/video/BV1jx4y1t7Uz/?spm_id_from=333.999.0.0&vd_source=2526a18398a079ddb95468a0c73f126e
https://www.bilibili.com/read/cv35873128/

完結

贈人玫瑰,手有余香!如果文章內(nèi)容對你有所幫助,請不要吝嗇你的點贊評論和關注,以便我第一時間收到反饋,你的每一次支持都是我不斷創(chuàng)作的最大動力。當然如果你發(fā)現(xiàn)了文章中存在錯誤或者有更好的解決方法,也歡迎評論私信告訴我哦!

好了,我是向宇,https://xiangyu.blog.csdn.net

一位在小公司默默奮斗的開發(fā)者,出于興趣愛好,最近開始自學unity,閑暇之余,邊學習邊記錄分享,站在巨人的肩膀上,通過學習前輩們的經(jīng)驗總是會給我很多幫助和啟發(fā)!php是工作,unity是生活!如果你遇到任何問題,也歡迎你評論私信找我, 雖然有些問題我也不一定會,但是我會查閱各方資料,爭取給出最好的建議,希望可以幫助更多想學編程的人,共勉~
在這里插入圖片描述

http://www.risenshineclean.com/news/12043.html

相關文章:

  • 星海灣建設管理中心網(wǎng)站百度知道登錄
  • 網(wǎng)站建設優(yōu)化文檔網(wǎng)站外包
  • 網(wǎng)站和管理系統(tǒng)的區(qū)別會計培訓班要多少錢一般要學多久
  • 網(wǎng)站專題頁面設計欣賞騰訊企業(yè)郵箱登錄入口
  • 武漢網(wǎng)站制作公司排名中國進入一級戰(zhàn)備狀態(tài)了嗎
  • oa辦公系統(tǒng)下載安裝seo引擎優(yōu)化專員
  • 泰安工作招聘seo企業(yè)站收錄
  • 網(wǎng)站開發(fā)一個多少錢bt磁力兔子引擎
  • 網(wǎng)站有哪些類型和它的成功案例微商怎么找客源人脈
  • 基層建設網(wǎng)站是不是停辦了做一個公司網(wǎng)站大概要多少錢
  • 廣州個人網(wǎng)站備案要多久貼吧推廣400一個月
  • vipkid網(wǎng)站開發(fā)團隊守游網(wǎng)絡推廣平臺登陸
  • 網(wǎng)站有很多304狀態(tài)碼口碑營銷公司
  • 如何做網(wǎng)站賺流量錢市場推廣外包團隊
  • 呼市建設官方網(wǎng)站四川網(wǎng)絡推廣seo
  • 上海地區(qū)網(wǎng)站建設百度指數(shù)預測
  • 網(wǎng)頁 代碼怎么做網(wǎng)站廣告推廣
  • 專業(yè)做公墓 陵園的網(wǎng)站網(wǎng)站seo去哪個網(wǎng)站找好
  • 商務網(wǎng)站規(guī)劃與網(wǎng)頁制作微信小程序開發(fā)工具
  • 網(wǎng)站做文獻格式福州百度seo排名
  • 朵朵軟件網(wǎng)站建設個人網(wǎng)站
  • 電子商務網(wǎng)站建設移動電商開發(fā)web網(wǎng)站模板
  • 中國建設銀行網(wǎng)站無法訪問國通快速建站
  • 徐州網(wǎng)站建設魔站設計網(wǎng)站都有哪些
  • 天津微信網(wǎng)站本地推廣最好用的平臺
  • 網(wǎng)站權重能帶來什么作用百度一下瀏覽器
  • 寧夏做網(wǎng)站建設公司最新國際新聞10條
  • 國外好的做電視包裝的網(wǎng)站鏈接轉二維碼
  • 豬八戒網(wǎng)做網(wǎng)站怎么樣今日新聞快報
  • 哪個網(wǎng)站做外貿(mào)好互聯(lián)網(wǎng)營銷師