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

怎么做外贸个人网站张掖高端网站建设公司

怎么做外贸个人网站,张掖高端网站建设公司,登录信产部网站,青海网站建设企业Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释#xff0c;可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili ItemData_Equipment.cs using System.Collections; using System.Collecti…Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili ItemData_Equipment.cs using System.Collections; using System.Collections.Generic; using UnityEngine;public enum EquipmentType {sword,armor }[CreateAssetMenu(fileName New Item Data, menuName Data/Equipment)] public class ItemData_Equipment : ItemData {public EquipmentType equipmentType; }Inventory.cs using System.Collections; using System.Collections.Generic; using UnityEngine;public class Inventory : MonoBehaviour {public static Inventory instance;public ListInventoryItem inventory;//inventoryItems类型的列表public DictionaryItemData, InventoryItem inventoryDictionary;//以ItemData为Key寻找InventoryItem的字典public ListInventoryItem stash;public DictionaryItemData, InventoryItem stashDictionary;[Header(Inventory UI)][SerializeField] private Transform inventorySlotParent;[SerializeField] private Transform stashSlotParent;private UI_itemSlot[] inventoryItemSlot;//UI Slot的数组private UI_itemSlot[] stashItemSlot;private void Awake(){if (instance null)instance this;elseDestroy(gameObject);//防止多次创建Inventory}public void Start(){inventory new ListInventoryItem();inventoryDictionary new DictionaryItemData, InventoryItem();stash new ListInventoryItem();stashDictionary new DictionaryItemData, InventoryItem();inventoryItemSlot inventorySlotParent.GetComponentsInChildrenUI_itemSlot();//拿到的方式有点绕显示拿到Canvas 里的 Inventory 然后通过GetComponentsInChildren拿到其下的使用UISlotstashItemSlot stashSlotParent.GetComponentsInChildrenUI_itemSlot();}private void UpdateSlotUI(){for(int i 0;i inventory.Count;i ){inventoryItemSlot[i].UpdateSlots(inventory[i]);}for(int i 0;i stash.Count; i){stashItemSlot[i].UpdateSlots(stash[i]);}}public void AddItem(ItemData _item)//将物体存入Inventory的函数{if(_item.itemType ItemType.Equipment){AddToInventory(_item);}else if(_item.itemType ItemType.Material){AddToStash(_item);}UpdateSlotUI();}private void AddToStash(ItemData _item)//向stash加物体的函数{if (stashDictionary.TryGetValue(_item, out InventoryItem value))//只有这种方法才能在查找到是否存在key对应value是否存在的同时能够同时拿到value其他方法的拿不到value{value.AddStack();}//字典的使用通过ItemData类型的数据找到InventoryItem里的与之对应的同样类型的数据else//初始时由于没有相同类型的物体故调用else是为了初始化库存使其中含有一个基本的值{InventoryItem newItem new InventoryItem(_item);stash.Add(newItem);//填进列表里只有一次stashDictionary.Add(_item, newItem);//同上}}private void AddToInventory(ItemData _item){if (inventoryDictionary.TryGetValue(_item, out InventoryItem value))//只有这种方法才能在查找到是否存在key对应value是否存在的同时能够同时拿到value其他方法的拿不到value{value.AddStack();}//字典的使用通过ItemData类型的数据找到InventoryItem里的与之对应的同样类型的数据else//初始时由于没有相同类型的物体故调用else是为了初始化库存使其中含有一个基本的值{InventoryItem newItem new InventoryItem(_item);inventory.Add(newItem);//填进列表里只有一次inventoryDictionary.Add(_item, newItem);//同上}}public void RemoveItem(ItemData _item)//将物体剔除Inventory的函数{if(inventoryDictionary.TryGetValue(_item,out InventoryItem value)){if (value.stackSize 1){inventory.Remove(value);inventoryDictionary.Remove(_item);}elsevalue.RemoveStack();}if (stashDictionary.TryGetValue(_item, out InventoryItem stashValue)){if (stashValue.stackSize 1){stash.Remove(value);stashDictionary.Remove(_item);}elsestashValue.RemoveStack();}UpdateSlotUI();}} using System.Collections; using System.Collections.Generic; using UnityEngine;public class Inventory : MonoBehaviour {public static Inventory instance;public ListInventoryItem inventory;//inventoryItems类型的列表public DictionaryItemData, InventoryItem inventoryDictionary;//以ItemData为Key寻找InventoryItem的字典public ListInventoryItem stash;public DictionaryItemData, InventoryItem stashDictionary;[Header(Inventory UI)][SerializeField] private Transform inventorySlotParent;[SerializeField] private Transform stashSlotParent;private UI_itemSlot[] inventoryItemSlot;//UI Slot的数组private UI_itemSlot[] stashItemSlot;private void Awake(){if (instance null)instance this;elseDestroy(gameObject);//防止多次创建Inventory}public void Start(){inventory new ListInventoryItem();inventoryDictionary new DictionaryItemData, InventoryItem();stash new ListInventoryItem();stashDictionary new DictionaryItemData, InventoryItem();inventoryItemSlot inventorySlotParent.GetComponentsInChildrenUI_itemSlot();//拿到的方式有点绕显示拿到Canvas 里的 Inventory 然后通过GetComponentsInChildren拿到其下的使用UISlotstashItemSlot stashSlotParent.GetComponentsInChildrenUI_itemSlot();}private void UpdateSlotUI(){for(int i 0;i inventory.Count;i ){inventoryItemSlot[i].UpdateSlots(inventory[i]);}for(int i 0;i stash.Count; i){stashItemSlot[i].UpdateSlots(stash[i]);}}public void AddItem(ItemData _item)//将物体存入Inventory的函数{if(_item.itemType ItemType.Equipment){AddToInventory(_item);}else if(_item.itemType ItemType.Material){AddToStash(_item);}UpdateSlotUI();}private void AddToStash(ItemData _item)//向stash加物体的函数{if (stashDictionary.TryGetValue(_item, out InventoryItem value))//只有这种方法才能在查找到是否存在key对应value是否存在的同时能够同时拿到value其他方法的拿不到value{value.AddStack();}//字典的使用通过ItemData类型的数据找到InventoryItem里的与之对应的同样类型的数据else//初始时由于没有相同类型的物体故调用else是为了初始化库存使其中含有一个基本的值{InventoryItem newItem new InventoryItem(_item);stash.Add(newItem);//填进列表里只有一次stashDictionary.Add(_item, newItem);//同上}}private void AddToInventory(ItemData _item){if (inventoryDictionary.TryGetValue(_item, out InventoryItem value))//只有这种方法才能在查找到是否存在key对应value是否存在的同时能够同时拿到value其他方法的拿不到value{value.AddStack();}//字典的使用通过ItemData类型的数据找到InventoryItem里的与之对应的同样类型的数据else//初始时由于没有相同类型的物体故调用else是为了初始化库存使其中含有一个基本的值{InventoryItem newItem new InventoryItem(_item);inventory.Add(newItem);//填进列表里只有一次inventoryDictionary.Add(_item, newItem);//同上}}public void RemoveItem(ItemData _item)//将物体剔除Inventory的函数{if(inventoryDictionary.TryGetValue(_item,out InventoryItem value)){if (value.stackSize 1){inventory.Remove(value);inventoryDictionary.Remove(_item);}elsevalue.RemoveStack();}if (stashDictionary.TryGetValue(_item, out InventoryItem stashValue)){if (stashValue.stackSize 1){stash.Remove(value);stashDictionary.Remove(_item);}elsestashValue.RemoveStack();}UpdateSlotUI();}}
http://www.pierceye.com/news/479758/

相关文章:

  • 运城做网站费用高吗高端模板建站
  • 凡客诚品网站设计合肥网红打卡地
  • 淘宝网站代理怎么做的广西送变电建设公司铁塔厂网站
  • 自媒体网站开发网站的推广方式包括
  • 教育做的比较好的网站有哪些网站的建设及维护
  • dw设计做网站案例建设网站杭州
  • 做网站认证对网站有什么好处广西网站建设开发团队
  • 建一个网站需要哪些知识无锡大型互联网公司
  • 餐饮公司 网站建设做网站一年大概的盈利
  • 做金融怎么进基金公司网站免费行情软件网站游戏
  • 网站推广解释创立一个网站要多少钱
  • 绍兴专业网站建设公司大型网站建设哪家好
  • 天河网站设计响应式视频网站模板
  • 网站制作老了手机网站模板开发
  • 哪家网站建设比较好海拉尔建网站
  • 丹东网站推广海南行指专业网站开发
  • 网站如何调用手机淘宝做淘宝客中国企业网站查询
  • 淄博建设工程学校官方网站专门做商标的网站有哪些
  • 私人免费网站怎么下载企业网站设计方案
  • 做阿里巴巴网站找谁互联网推广公司
  • 网站如何做微信支付宝支付宝支付网页传奇发布网
  • 网站建设语录谷歌浏览器官网下载
  • 互动营销网站免费学高中课程的软件
  • 沈阳网站建设活动方案公司网站建设攻略
  • 建网站 方法喜来健cms系统
  • 甘肃 网站备案关于网站开发费用的入账
  • 南昌建网站的公司个人博客模板网站
  • 银川建设局网站丹江口网站制作
  • 做化工的 有那些网站自动的东莞网站制作公司
  • 做网站要求高吗中国建设教育网