👨💻个人主页:@元宇宙-秩沅
👨💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!
👨💻 本文由 秩沅 原创
👨💻 收录于专栏:就业宝典
⭐🅰️推荐专栏⭐
⭐-软件设计师高频考点大全⭐
文章目录
- ⭐前言⭐
- 🎶(==3==) 选择模式面板逻辑
- 🎶(==4==) 关卡模式面板逻辑
- 🎶(==5==) 五个关卡场景逻辑
- 🎶(==6==) 生存模式面板逻辑
- ⭐🅰️⭐
⭐前言⭐
🎶(3) 选择模式面板逻辑
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;//-------------------------------
//-------功能: 模式选择面板
//-------创建者: -------
//------------------------------public class SelectPanel : BasePanel
{// Start is called before the first frame updatevoid Start(){AllEvent();}// Update is called once per framevoid Update(){}public void AllEvent(){GetControl<Button>("Button1").onClick.AddListener(() => {UIManager.GetInstance().RemovePanel ("SelectPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<LevelsMPanel>("LevelsMPanel"); //加载关卡模式选择面板 });GetControl<Button>("Button2").onClick.AddListener(()=> {UIManager.GetInstance().RemovePanel("SelectPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<EndlessMPanel>("EndlessMPanel"); //加载生存模式选择面板 });GetControl<Button>("Button3").onClick.AddListener(()=> {UIManager.GetInstance().RemovePanel("SelectPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<FreeMPanel>("FreeMPanel"); //加载自由模式选择面板 });}
}
🎶(4) 关卡模式面板逻辑
- 一共有五个关卡。每一个关卡的场景都不一样,并且音符下落的速度也不一样
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;//-------------------------------
//-------功能:关卡模式面板
//-------创建者: -------
//------------------------------public class LevelsMPanel : BasePanel
{public Text hight;void Start(){hight.text = DataContorl.GetInstance().foreverPalyerdata.AllScore .ToString(); //更新最高分AllEnvent();}// Update is called once per framevoid Update(){}public void AllEnvent(){//关卡按钮逻辑GetControl<Button>("level1").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除此面板 DataContorl.GetInstance().levelGame = true; //进入关卡模式SceneManager.LoadScene(1);});GetControl<Button>("level2").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除此面板 DataContorl.GetInstance().levelGame = true;SceneManager.LoadScene(2);});GetControl<Button>("level3").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除此面板 DataContorl.GetInstance().levelGame = true;SceneManager.LoadScene(3);});GetControl<Button>("level4").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除此面板 DataContorl.GetInstance().levelGame = true;SceneManager.LoadScene(4);});GetControl<Button>("level5").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除此面板 DataContorl.GetInstance().levelGame = true;SceneManager.LoadScene(5);});GetControl<Button>("Back").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<SelectPanel>("SelectPanel"); //加载模式选择面板});GetControl<Button>("rank").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<RankPanel1>("RankPanel1"); //加载模式选择面板});}
}
🎶(5) 五个关卡场景逻辑
- level1 ——下落的速度为3
- level2——下落的速度为5
- level3——下落的速度为8
-
level4——下落的速度为10
-
level5——下落的速度为12
🎶(6) 生存模式面板逻辑
- 生存模式中的音符下降速度会越来越快
- 生存模式场景
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;//-------------------------------
//-------功能: 生存模式面板
//-------创建者: -------
//------------------------------public class FreeMPanel : BasePanel
{public Text hight;public Text speed;public Slider slider;public AudioClip[] audioClips = new AudioClip[5];public Dropdown dropdown;//下拉列表void Start(){for (int i = 0; i < audioClips.Length; i++){DataContorl.GetInstance().audioClip[i] = audioClips[i];}hight.text = DataContorl.GetInstance().foreverPalyerdata.livingScore.ToString();AllEvent();}void Update(){DataContorl.GetInstance().index = dropdown.value; //获取下拉列表的值Debug.Log(dropdown.value);speed.text = (slider.value*15) .ToString (); //速度实时更新(最大设置为15)DataContorl.GetInstance().speed = slider.value * 15; //设置速度}public void AllEvent(){//给返回按钮添加逻辑GetControl<Button>("Back").onClick.AddListener(() => {UIManager.GetInstance().RemovePanel("FreeMPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<SelectPanel>("SelectPanel"); //加载模式选择面板});//给开始按钮添加逻辑GetControl<Button>("Start").onClick.AddListener(() => {UIManager.GetInstance().RemovePanel("FreeMPanel");//移除此面板 DataContorl.GetInstance().livingGame = true;SceneManager.LoadScene(6);});GetControl<Button>("rank").onClick.AddListener(() =>{UIManager.GetInstance().RemovePanel("LevelsMPanel");//移除背景面板 UIManager.GetInstance().ShowPanel<RankPanel2>("RankPanel2"); //加载模式选择面板});}
}
⭐🅰️⭐
⭐【Unityc#专题篇】之c#进阶篇】
⭐【Unityc#专题篇】之c#核心篇】
⭐【Unityc#专题篇】之c#基础篇】
⭐【Unity-c#专题篇】之c#入门篇】
⭐【Unityc#专题篇】—进阶章题单实践练习
⭐【Unityc#专题篇】—基础章题单实践练习
⭐【Unityc#专题篇】—核心章题单实践练习
你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!、