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

设计网站与建设xp优化大师

设计网站与建设,xp优化大师,百度关键词推广公司,课程培训网站模板下载1、目标 保存下面库存栏中信息到文件中。 2、修改SceneSave.cs脚本 添加2行代码: 3、修改InventoryManager对象 添加Generate GUID组件。 4、修改InventoryManager.cs脚本 添加继承自ISaveable 添加属性信息: private string _iSaveableUniqueID;pub…

1、目标

保存下面库存栏中信息到文件中。

2、修改SceneSave.cs脚本

添加2行代码:

3、修改InventoryManager对象

添加Generate GUID组件。

4、修改InventoryManager.cs脚本

添加继承自ISaveable

添加属性信息:

    private string _iSaveableUniqueID;public string ISaveableUniqueID { get { return _iSaveableUniqueID; } set { _iSaveableUniqueID = value; } }private GameObjectSave _gameObjectSave;public GameObjectSave GameObjectSave { get { return _gameObjectSave; } set { _gameObjectSave = value; } }private UIInventoryBar inventoryBar;

在Awake()方法中添加2行代码:

添加如下几个方法:

 private void OnDisable(){ISaveableDeregister();}private void OnEnable(){ISaveableRegister();}private void Start()
{inventoryBar = FindObjectOfType<UIInventoryBar>();
}public void ISaveableRegister(){SaveLoadManager.Instance.iSaveableObjectList.Add(this);}public void ISaveableDeregister(){SaveLoadManager.Instance.iSaveableObjectList.Remove(this);}public GameObjectSave ISaveableSave(){// Create new scene saveSceneSave sceneSave = new SceneSave();// Remove any existing scene save for persistent scene for this gameobjectGameObjectSave.sceneData.Remove(Settings.PersistentScene);// Add inventory lists array to persistent scene savesceneSave.listInvItemArray = inventoryLists;// Add inventory list capacity array to persistent scene savesceneSave.intArrayDictionary = new Dictionary<string, int[]>();sceneSave.intArrayDictionary.Add("inventoryListCapacityArray", inventoryListCapacityIntArray);// Add scene save for gameobjectGameObjectSave.sceneData.Add(Settings.PersistentScene, sceneSave);return GameObjectSave;}public void ISaveableLoad(GameSave gameSave){if(gameSave.gameObjectData.TryGetValue(ISaveableUniqueID, out GameObjectSave gameObjectSave)){GameObjectSave = gameObjectSave;// Need to find inventory lists - start by trying to locate saveScene for game objectif(gameObjectSave.sceneData.TryGetValue(Settings.PersistentScene, out SceneSave sceneSave)){// list inv items array exists for persistent sceneif(sceneSave.listInvItemArray != null){inventoryLists = sceneSave.listInvItemArray;// Send events that inventory has been updatedfor(int i = 0; i < (int)InventoryLocation.count; i++){EventHandler.CallInventoryUpdatedEvent((InventoryLocation)i, inventoryLists[i]);}// Clear any items player was carryingPlayer.Instance.ClearCarriedItem();// Clear any highlights on inventory barinventoryBar.ClearHighlightOnInventorySlots();}// int array dictionary exists for sceneif(sceneSave.intArrayDictionary != null && sceneSave.intArrayDictionary.TryGetValue("inventoryListCapacityArray", out int[] inventoryCapacityArray)){inventoryListCapacityIntArray = inventoryCapacityArray;}}}}public void ISaveableStoreScene(string sceneName){// Nothing required here since the inventory manager is on a persistent scene;}public void ISaveableRestoreScene(string sceneName){// Nothing required here since the inventory manager is on a persistent scene;}

5、运行游戏

角色收集的item放到库存栏中,save game后退出游戏,重新进入游戏后load game,库存栏中的信息保持不变。

http://www.dtcms.com/wzjs/266860.html

相关文章:

  • 做移动网站点击软件seo管理系统创作
  • 游戏网站建设方案百度文库谷歌seo课程
  • 营销型网站建设模板下载如何提高关键词搜索排名
  • 做网站点击率赚钱吗百度app客服人工在线咨询
  • wordpress上传文件自动按时间命名aso优化软件
  • 网站建设需求意见征求表网店培训教程
  • 泰安网站制作工作室百度网盘登录入口官网
  • 微信小程序一起生活怎么注册百度推广seo自学
  • 安徽省住房和建设厅门户网站深圳seo排名哪家好
  • 重庆网站开发设计公司电话优化营商环境心得体会
  • 榆林哪里做网站google网站推广
  • 建网站要多少钱一台新闻头条最新消息今日头条
  • 网页背景做的比较好的网站怎样做网络推广营销
  • 网站开发属于什么资产网络营销的现状及问题
  • 陕西省住房城乡建设厅网站管理中心搜索引擎竞价排名
  • 国外企业网站怎么做网址大全
  • 怎样提高网站流量站长工具seo
  • 天津 网站设计公司网页设计欣赏
  • 加热器网站怎么做的威海seo优化公司
  • 网站建设对企业的作用google play官网下载
  • 网站域名解析时间新闻媒体发布平台
  • 红色政府建站模板企业营销策划有限公司
  • 连云港网站建设制作seo排名优化北京
  • 昆明建设咨询监理有限公司网站哪个公司的网站制作
  • 晋城有做网站的吗seo职业技能培训班
  • 东莞网站制作免费网站优化排名
  • 网站开发的技术流程seo搜索优化服务
  • 广州网站建设网站托管运营优秀网页设计作品
  • 设计师可以做兼职的网站网站统计
  • 宁波网站建设服务公司电hua自助建站系统破解版