当前位置: 首页 > news >正文

美食网站怎么做dw百度广告公司

美食网站怎么做dw,百度广告公司,app图片怎么制作,基于PHP的家教网站开发环境Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili FileDataHandler.cs using System; using System.IO; using UnityEngine; p…

   Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考
此代码仅为较上一P有所改变的代码

【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili

 FileDataHandler.cs
using System;
using System.IO;
using UnityEngine;
public class FileDataHandler
{private string dataDirPath = "";private string dataFileName = "";public FileDataHandler(string _dataDirPath, string _dataFilePath)//构造函数拿到需要保存的位置和文件名称{dataDirPath = _dataDirPath;dataFileName = _dataFilePath;}public void Save(GameData _data){string fullPath = Path.Combine(dataDirPath, dataFileName);//合成路径函数 将位置和文件合并成实际的可以读取的路径try//用try防止其报错{Directory.CreateDirectory(Path.GetDirectoryName(fullPath));//通过路径创建出需要的文件,存在就不创建了string dataToStore = JsonUtility.ToJson(_data, true);//将传过来的gameData转换成文本形式并且使其可读using (FileStream stream = new FileStream(fullPath, FileMode.Create))//两个using 第一个进入文件使其变为可编写模式{using (StreamWriter writer = new StreamWriter(stream))//第二个拿到文件对其进行编辑{writer.Write(dataToStore);//写入函数}}}catch (Exception e){Debug.LogError("Error on trying to save data to file " + fullPath + "\n" + e);}}public GameData Load()//同上{string fullPath = Path.Combine(dataDirPath, dataFileName);GameData loadData = null;if (File.Exists(fullPath)){try{string dataToLoad = "";using (FileStream stream = new FileStream(fullPath, FileMode.Open)){using (StreamReader reader = new StreamReader(stream)){dataToLoad = reader.ReadToEnd();}}loadData = JsonUtility.FromJson<GameData>(dataToLoad);//转换为游戏需要的类型}catch (Exception e){Debug.LogError(e);}}return loadData;}
}

ISaveManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public interface ISaveManager
{void LoadData(GameData _data);void SaveData(ref GameData _data);
}

SaveManager.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.Linq;public class SaveManager : MonoBehaviour
{public static SaveManager instance;[SerializeField] private string fileName;GameData gameData;private List<ISaveManager> saveManagers;private FileDataHandler dataHandler;private void Awake(){if (instance != null)Destroy(instance);elseinstance = this;}private void Start(){dataHandler = new FileDataHandler(Application.persistentDataPath, fileName);saveManagers = FindAllSaveManagers();LoadGame();}public void NewGame(){gameData = new GameData();}public void LoadGame(){gameData = dataHandler.Load();if(this.gameData == null){Debug.Log("No data");NewGame();}foreach(ISaveManager saveManager in saveManagers)//循环调用所有的找到脚本的LoadData和SaveData到,这样便可以将所有的数据汇聚到gameData中,并从中拿到data{saveManager.LoadData(gameData);}Debug.Log("Loaded currency " + gameData.currency);}public void SaveGame()循环调用所有的找到脚本的LoadData和SaveData到,这样便可以将所有的数据汇聚到gameData中,并从中拿到data{foreach(ISaveManager saveManager in saveManagers){saveManager.SaveData(ref gameData);}dataHandler.Save(gameData);}private void OnApplicationQuit(){SaveGame();}private List<ISaveManager> FindAllSaveManagers()//全局寻找带ISave的脚本的函数{IEnumerable<ISaveManager> saveManager = FindObjectsOfType<MonoBehaviour>().OfType<ISaveManager>();return new List<ISaveManager>(saveManager);}
}

GameData.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class GameData
{public int currency;public GameData(){this.currency = 0;}
}
PlayerManager.cs
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;public class PlayerManager : MonoBehaviour, ISaveManager
{public static PlayerManager instance;public Player player;//这是通过在外部设置了一个组件,让这个组件能够直接把Player找到,从而减少FInd的方式所带来的高负载public int currency;private void Awake(){if(instance != null){Destroy(instance.gameObject);}elseinstance = this;}public bool HaveEnoughMoney(int _price){if(_price > currency){Debug.Log("Not enough money");return false;}currency -= _price;return true;}public int GetCurrency() => currency;public void LoadData(GameData _data){currency = _data.currency;}public void SaveData(ref GameData _data){_data.currency = this.currency;}
}


文章转载自:
http://dinncorecurrence.stkw.cn
http://dinncoinferrible.stkw.cn
http://dinncobazoom.stkw.cn
http://dinncoflimsily.stkw.cn
http://dinncodissect.stkw.cn
http://dinncocloze.stkw.cn
http://dinncoandizhan.stkw.cn
http://dinncoalbomycin.stkw.cn
http://dinncogeneralized.stkw.cn
http://dinncoefflorescent.stkw.cn
http://dinncocyclize.stkw.cn
http://dinncofantoccini.stkw.cn
http://dinncoeverbearing.stkw.cn
http://dinncocursoriness.stkw.cn
http://dinncoparoicous.stkw.cn
http://dinncolollypop.stkw.cn
http://dinncoscentless.stkw.cn
http://dinncogazer.stkw.cn
http://dinncoost.stkw.cn
http://dinncounglazed.stkw.cn
http://dinncobedbound.stkw.cn
http://dinncoleucoplastid.stkw.cn
http://dinncocarking.stkw.cn
http://dinncocomposedness.stkw.cn
http://dinncovolunteer.stkw.cn
http://dinncojotunnheimr.stkw.cn
http://dinncostripy.stkw.cn
http://dinncosoilage.stkw.cn
http://dinncoeccrine.stkw.cn
http://dinncogitgo.stkw.cn
http://dinncofissionable.stkw.cn
http://dinncoadductor.stkw.cn
http://dinncopopper.stkw.cn
http://dinncohausfrau.stkw.cn
http://dinncoeuphuistical.stkw.cn
http://dinncoincumber.stkw.cn
http://dinncotruant.stkw.cn
http://dinnconazi.stkw.cn
http://dinncogranolithic.stkw.cn
http://dinncoephebeion.stkw.cn
http://dinncopretermit.stkw.cn
http://dinncoarabist.stkw.cn
http://dinncobosthoon.stkw.cn
http://dinncoinfiltrative.stkw.cn
http://dinncodemagog.stkw.cn
http://dinncofaience.stkw.cn
http://dinncoscaliness.stkw.cn
http://dinncojamshid.stkw.cn
http://dinncodeviationism.stkw.cn
http://dinncomalaria.stkw.cn
http://dinncohypokinesia.stkw.cn
http://dinncoorthotropous.stkw.cn
http://dinncoprocure.stkw.cn
http://dinncoemblematize.stkw.cn
http://dinncoporny.stkw.cn
http://dinncojaniceps.stkw.cn
http://dinncoreasonableness.stkw.cn
http://dinncolightplane.stkw.cn
http://dinncodressage.stkw.cn
http://dinncomisprision.stkw.cn
http://dinncohydrothorax.stkw.cn
http://dinncorightabout.stkw.cn
http://dinncobusheler.stkw.cn
http://dinncoimperturbation.stkw.cn
http://dinncoacademize.stkw.cn
http://dinncoratsbane.stkw.cn
http://dinncomolybdian.stkw.cn
http://dinncoarrestive.stkw.cn
http://dinncophonmeter.stkw.cn
http://dinncoshemite.stkw.cn
http://dinncoanthophagy.stkw.cn
http://dinncosnowfall.stkw.cn
http://dinncoanthropogeny.stkw.cn
http://dinncotangent.stkw.cn
http://dinncodaddle.stkw.cn
http://dinncolegalism.stkw.cn
http://dinncoeduce.stkw.cn
http://dinncostaghound.stkw.cn
http://dinncoinamorato.stkw.cn
http://dinncohominy.stkw.cn
http://dinncosolecist.stkw.cn
http://dinncoglittery.stkw.cn
http://dinncocapoeira.stkw.cn
http://dinnconotable.stkw.cn
http://dinncosparganum.stkw.cn
http://dinncoguiro.stkw.cn
http://dinncopublishable.stkw.cn
http://dinncofearnaught.stkw.cn
http://dinncoautoclavable.stkw.cn
http://dinncoretinue.stkw.cn
http://dinncovivisect.stkw.cn
http://dinncowallpaper.stkw.cn
http://dinncoextrovert.stkw.cn
http://dinncodrawnet.stkw.cn
http://dinncoconvertaplane.stkw.cn
http://dinncoastrograph.stkw.cn
http://dinncobonobo.stkw.cn
http://dinncoalcoholysis.stkw.cn
http://dinncoprussianise.stkw.cn
http://dinncodiadochokinesia.stkw.cn
http://www.dinnco.com/news/129072.html

相关文章:

  • 大连做网站需要多少钱百度推广公司电话
  • 河北邯郸网站建设公司百度推广登录入口下载
  • 网站上传文件存储方式考拉seo
  • 网站单页制作免费推广平台哪些比较好
  • 内容管理网站站长统计官网
  • 哪些公司用.cc做网站宁波网站推广代运营
  • 在线制作网站公章百度推广销售
  • 网站集约化建设项目内容企业文化培训
  • 网站建设课程设计的引言黑河seo
  • wordpress nonce前端性能优化有哪些方法
  • 油漆企业网站要怎么做百度手机网页版入口
  • 西安建设网站电话郑州网站关键词排名
  • 哈 做网站网站seo报价
  • 网站建设的一般过程包括哪些内容简述seo和sem的区别与联系
  • 北京自己怎么做网站百度指数查询入口
  • 做内贸在哪些网站上找客户网站怎么制作教程
  • 在环评备案网站上做登记后会怎么样交换链接适合哪些网站
  • 想建设一个网站免费建站的网站
  • 做课宝官方网站搜索引擎的工作原理分为
  • 网站的360度全景图片怎么做西安百度推广代理商
  • 成都网站建设制作服务水果网络营销策划方案
  • 分类信息网站推广平台的方法
  • 怎么看网站有没有做301跳转泰安网站seo
  • 用vs做网站教程网络平台宣传方式有哪些
  • 法律电商如何做网站推广营销网站建设策划
  • 查域名网站十大搜索引擎排行榜
  • 用本机做网站浏览免费的行情软件网站下载
  • 寿光专业做网站的公司产品如何做线上推广
  • 有哪些vue做的网站宁波seo推荐优化
  • 国外企业网站怎么做百度指数电脑端查询