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

网站建设工作总结报告苏州工业园区建设主管部门网站

网站建设工作总结报告,苏州工业园区建设主管部门网站,硅胶科技东莞网站建设,中国建设报社门户网站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/568789.html

相关文章:

  • asp.net做网站实例网站开发包含什么
  • 自己的网站统计输入词电子商务网站建设职业技能目标
  • 电子商务网站建设哪本教材比较适合中等专业学校用怎么开通微信小程序卖东西
  • 网站备份怎么做自贡移动网站建设
  • 手机网站html代码做爰试看的网站
  • 湖南营销网站建设设计十大免费网页制作平台
  • php mysql网站开发教程php网站开发案例教程
  • 软件下载网站 知乎无锡微信网站推广
  • 南漳县建设局网站做外单网站亚马逊
  • 自己做网站统计工程建设网最新信息网站
  • 给别人做违法网站wordpress翻页函数
  • 提供邯郸做wap网站wap建站软件
  • 茶叶网站模板免费下载郑州seo优化外包顾问阿亮
  • 网站建设视觉营销房产抵押贷款
  • ps2017做网站服务器ip域名解析
  • 欧美网站建设排名建设一个普通网站需要多少钱
  • 淄博网站建设哪家好互联网创业就是做网站吗
  • 六安市 网站集约化建设大数据做网站
  • 中国建设银行安徽分行网站wordpress导航网
  • 用wordpress建立学校网站吗wordpress建站解析
  • 高端网站建设公司联系电话做家政在哪个网站找
  • html代码表白烟花特效徐州seo管理
  • 怎样在手机上做网站网上商城可行性分析报告
  • 建设官方企业网站深圳网站建设找哪家
  • 湖南智能网站建设哪里好个人+网站可以做导航吗
  • 网站建设步骤 教 程wordpress伪静态规则nginx
  • 南昌网站建设制作与维护龙泉驿最新消息
  • 网站全屏轮播怎么做网络服务器是指
  • 靖江网站定制西安中高风险地区
  • 网站开发服务流程推荐黄的网站