软件开发招标网站,手机海报制作免费软件,广州网络营销学校,直播开放平台入驻#x1f468;#x1f4bb;个人主页#xff1a;元宇宙-秩沅
#x1f468;#x1f4bb; hallo 欢迎 点赞#x1f44d; 收藏⭐ 留言#x1f4dd; 加关注✅!
#x1f468;#x1f4bb; 本文由 秩沅 原创 #x1f468;#x1f4bb; 收录于专栏#xff1a;就业… 个人主页元宇宙-秩沅
hallo 欢迎 点赞 收藏⭐ 留言 加关注✅!
本文由 秩沅 原创 收录于专栏就业宝典
⭐️推荐专栏⭐
⭐-软件设计师高频考点大全⭐ 文章目录 ⭐前言⭐1 特效结算特效游戏特效场景特效 2 控制器账户控制器数据控制器音轨控制器面板启动器 ⭐️⭐ ⭐前言⭐ 1 特效 结算特效 游戏特效 场景特效 2 控制器 账户控制器
using System.Collections;
using System.Collections.Generic;
using UnityEngine;//-------------------------------
//-------功能 账户控制器
//-------创建者: -------
//------------------------------public class acountContorller : SingleManageracountContorller
{public AcountData foreverAcountData new AcountData(); //用来存储上一次的账户/// summary/// 用Json序列化存储数据/// /summary/// param namename/parampublic void SaveData(AcountData acountData, string name){if (acountData null) //如果为空的话{Debug.Log(为空);foreverAcountData.aount.Add(name); //直接存名字JsonManager.Instance.SaveData(foreverAcountData, acountArrary);}acountData.aount.Add(name);JsonManager.Instance.SaveData(acountData, acountArrary);}/// summary/// Json序列化读取数据/// /summary/// param namename/param/// returns/returnspublic AcountData ReadData(){return JsonManager.Instance.LoadDataAcountData(acountArrary);}}
数据控制器
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目: ______________
//___________功能 数据管理
//___________创建者
//_____________________________________
//-------------------------------------
public class DataContorl : SingleManagerDataContorl
{//场景public bool levelGame; //是否是关卡游戏public bool livingGame; //是否是生存模式public bool foreverGame;//是否是无尽模式public float speed;//中介存储供外部调用public AudioClip[] audioClip new AudioClip[5];public int index 0;//单例模式中单个全局信息不会随着改变public PlayerData foreverPalyerdata new PlayerData(); //用来存储上一次选中的item数据//private ListServerData serverLists new ListServerData();//public ListServerData ServerLists serverLists;/// summary/// 用Json序列化存储数据/// /summary/// param namename/parampublic void SaveData(string name, PlayerData data){JsonManager.Instance.SaveData(data, name);}//更新存储高分信息public void UpdateHightSocer( int socers , int index){switch (index){case 1:if (socers foreverPalyerdata.AllScore) //如果大于关卡模式的最高星星就保留否则不保留{foreverPalyerdata.AllScore socers;}break;case 2:if (socers foreverPalyerdata.livingScore) //如果大于生存模式的最高分数就保留否则不保留{foreverPalyerdata.livingScore socers;}break;case 3:if (socers foreverPalyerdata.foreverScore) //如果大于无尽模式的最高分数就保留否则不保留{foreverPalyerdata.foreverScore socers;}break;default:break;}SaveData(foreverPalyerdata.userName , foreverPalyerdata);}public void CloseALL(){levelGame false;livingGame false;foreverGame false;}/// summary/// Json序列化读取数据/// /summary/// param namename/param/// returns/returnspublic PlayerData ReadData(string name){return JsonManager.Instance.LoadDataPlayerData(name);}/// summary/// 供外部调用识别账号密码是否正确/// /summary/// param nameuserName/param/// param namepassword/param/// returns/returnspublic bool Tip(string userName, string password){try{string pass ReadData(userName).password ;Debug.Log(pass);if (userName ! null pass password){return true;}else return false;}catch{ return false; }}/// summary/// 供外部调用识别注册时是否有相同的账号/// /summarypublic bool TipSame(string userName){Debug.Log(该账号已注册);return false;}/// summary/// 全局性玩家数据存盘/// /summarypublic void UpdataPlayerInfo(){SaveData(foreverPalyerdata.userName, foreverPalyerdata);}}
音轨控制器
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using SonicBloom.Koreo;public class LaneController : MonoBehaviour {//-------------------------------//-------功能 音轨管理器脚本 //-------创建者: //------------------------------RhythmGameController gameController;[Tooltip(此音轨使用的键盘按键)]public KeyCode keyboardButton;[Tooltip(此音轨对应事件的编号)]public int laneID;//对“目标”位置的键盘按下的视觉效果public Transform targetVisuals;//上下边界public Transform targetTopTrans;public Transform targetBottomTrans;//包含在此音轨中的所有事件列表ListKoreographyEvent laneEvents new ListKoreographyEvent();//包含此音轨当前活动的所有音符对象的队列QueueNoteObject trackedNotes new QueueNoteObject();//检测此音轨中的生成的下一个事件的索引int pendingEventIdx 0;public GameObject downVisual;//音符移动的目标位置public Vector3 TargetPosition{get{return transform.position;}}public bool hasLongNote;public float timeVal 0;public GameObject longNoteHitEffectGo;// Update is called once per framevoid Update() {if (gameController.isPauseState){return;}//清除无效音符while (trackedNotes.Count0trackedNotes.Peek().IsNoteMissed()){if (trackedNotes.Peek().isLongNoteEnd){hasLongNote false;timeVal 0;downVisual.SetActive(false);longNoteHitEffectGo.SetActive(false);}gameController.comboNum 0;gameController.HideComboNumText();gameController.ChangeHitLevelSprite(0);gameController.UpdateHP();trackedNotes.Dequeue();}//检测新音符的产生CheckSpawnNext();//检测玩家的输入if (Input.GetKeyDown(keyboardButton)){CheckNoteHit();downVisual.SetActive(true);}else if (Input.GetKey(keyboardButton)){//检测长音符if (hasLongNote){if (timeVal0.15f){//显示命中等级Great Perfectif (!longNoteHitEffectGo.activeSelf){gameController.ChangeHitLevelSprite(2);CreateHitLongEffect();}timeVal 0;}else{timeVal Time.deltaTime;}}}else if (Input.GetKeyUp(keyboardButton)){downVisual.SetActive(false);//检测长音符if (hasLongNote){longNoteHitEffectGo.SetActive(false);CheckNoteHit();}}}//初始化public void Initialize(RhythmGameController controller){gameController controller;}//检测事件是否匹配当前编号的音轨public bool DoesMatch(int noteID){return noteID laneID;}//如果匹配则把当前事件添加进音轨所持有的事件列表public void AddEventToLane(KoreographyEvent evt){laneEvents.Add(evt);}//音符在音谱上产生的位置偏移量int GetSpawnSampleOffset(){//出生位置与目标点的位置float spawnDistToTarget targetTopTrans.position.z - transform.position.z;//到达目标点的时间float spawnPosToTargetTime spawnDistToTarget / gameController.noteSpeed;return (int)spawnPosToTargetTime * gameController.SampleRate;}//检测是否生成下一个新音符void CheckSpawnNext(){int samplesToTarget GetSpawnSampleOffset();int currentTime gameController.DelayedSampleTime;while (pendingEventIdx laneEvents.Count laneEvents[pendingEventIdx].StartSample currentTime samplesToTarget){KoreographyEvent evt laneEvents[pendingEventIdx];int noteNum evt.GetIntValue();NoteObject newObj gameController.GetFreshNoteObject();bool isLongNoteStart false;bool isLongNoteEnd false;if (noteNum 6){isLongNoteStart true;noteNum noteNum - 6;if (noteNum 6){isLongNoteEnd true;isLongNoteStart false;noteNum noteNum - 6;}}newObj.Initialize(evt, noteNum, this, gameController, isLongNoteStart, isLongNoteEnd);trackedNotes.Enqueue(newObj);pendingEventIdx;}}/// summary/// 生成特效的有关方法/// /summaryvoid CreateDownEffect(){GameObject downEffectGo gameController.GetFreshEffectObject(gameController.downEffectObjectPool, gameController.downEffectGo);downEffectGo.transform.position targetVisuals.position;}void CreateHitEffect(){GameObject hitEffectGo gameController.GetFreshEffectObject(gameController.hitEffectObjectPool, gameController.hitEffectGo);hitEffectGo.transform.position targetVisuals.position;}void CreateHitLongEffect(){longNoteHitEffectGo.SetActive(true);longNoteHitEffectGo.transform.position targetVisuals.position;}//检测是否有击中音符对象//如果是它将执行命中并删除public void CheckNoteHit(){if (!gameController.gameStart){CreateDownEffect();return;}if (trackedNotes.Count0){NoteObject noteObject trackedNotes.Peek();if (noteObject.hitOffset-6000){trackedNotes.Dequeue();int hitLevel noteObject.IsNoteHittable();gameController.ChangeHitLevelSprite(hitLevel);if (hitLevel0){//更新分数gameController.UpdateScoreText(100 * hitLevel);if (noteObject.isLongNote){hasLongNote true;CreateHitLongEffect();}else if (noteObject.isLongNoteEnd){hasLongNote false;}else{CreateHitEffect();}//增加连接数gameController.comboNum;}else{//未击中//减少玩家HPgameController.UpdateHP();//断掉玩家命中连接数gameController.HideComboNumText();gameController.comboNum 0;}noteObject.OnHit();}else{CreateDownEffect();}}else{CreateDownEffect();}}
}
面板启动器
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//-------------------------------------
//—————————————————————————————————————
//___________项目:
//___________功能 UI面板启动器
//___________创建者
//_____________________________________
//-------------------------------------
public class UIContorl : SingletonMonoUIContorl
{// Start is called before the first frame updatevoid Start(){UIManager.GetInstance().ShowPanelBKPanel(BKPanel); //先加载背景面板 UIManager.GetInstance().ShowPanelLoginPanel(LoginPanel); //先加载开始登陆面板// DataContorl.GetInstance().LoadServerData(); //加载所有区服数据到数据管理器中Debug.Log(Application.persistentDataPath); } /// summary/// 提供改变提示面板内容的方法并显示/// /summary/// param namecomponent/parampublic void ChangeTipPanel(string component){UIManager.GetInstance().ShowPanelTipPanel(TipPanel, E_UI_Layer.Top, (panel) {panel.ChangComponent(component);});}
}
⭐️⭐ ⭐【Unityc#专题篇】之c#进阶篇】
⭐【Unityc#专题篇】之c#核心篇】
⭐【Unityc#专题篇】之c#基础篇】
⭐【Unity-c#专题篇】之c#入门篇】
⭐【Unityc#专题篇】—进阶章题单实践练习
⭐【Unityc#专题篇】—基础章题单实践练习
⭐【Unityc#专题篇】—核心章题单实践练习 你们的点赞 收藏⭐ 留言 关注✅是我持续创作输出优质内容的最大动力、