👨💻个人主页 :@元宇宙-秩沅
👨💻 hallo 欢迎 点赞👍 收藏⭐ 留言📝 加关注✅!
👨💻 本文由 秩沅 原创
👨💻 收录于专栏 :就业宝典
⭐🅰️推荐专栏⭐
⭐-软件设计师高频考点大全⭐
文章目录
⭐前言⭐
🎶(3) 选择模式面板逻辑
csharp
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//-------------------------------
//-------功能: 模式选择面板
//-------创建者: -------
//------------------------------
public class SelectPanel : BasePanel
{
// Start is called before the first frame update
void Start()
{
AllEvent();
}
// Update is called once per frame
void 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) 关卡模式面板逻辑
- 一共有五个关卡。每一个关卡的场景都不一样,并且音符下落的速度也不一样
csharp
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 frame
void 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) 生存模式面板逻辑
- 生存模式中的音符下降速度会越来越快
- 生存模式场景
csharp
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"); //加载模式选择面板
});
}
}
⭐🅰️⭐
你们的点赞👍 收藏⭐ 留言📝 关注✅是我持续创作,输出优质内容的最大动力!、