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

新吴区推荐做网站电话seo外包

新吴区推荐做网站电话,seo外包,成都哪家做网站建设比较好,珠海新盈科技有限公司 网站建设Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Inventory.cs using Newtonsoft.Json.Linq; using System.Collections; us…

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

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

Inventory.cs
using Newtonsoft.Json.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;public class Inventory : MonoBehaviour
{public static Inventory instance;public List<ItemData> startingItem;public List<InventoryItem> equipment;//inventoryItems类型的列表public Dictionary<ItemData_Equipment, InventoryItem> equipmentDictionary;//以ItemData为Key寻找InventoryItem的字典public List<InventoryItem> inventory;//inventoryItems类型的列表public Dictionary<ItemData, InventoryItem> inventoryDictionary;//以ItemData为Key寻找InventoryItem的字典public List<InventoryItem> stash;public Dictionary<ItemData, InventoryItem> stashDictionary;[Header("Inventory UI")][SerializeField] private Transform inventorySlotParent;[SerializeField] private Transform stashSlotParent;[SerializeField] private Transform equipmentSlotParent;[SerializeField] private Transform statSlotParent;private UI_itemSlot[] inventoryItemSlot;//UI Slot的数组private UI_itemSlot[] stashItemSlot;private UI_equipementSlots[] equipmentSlot;private UI_Statslot[] statSlot;[Header("Items cooldown")]private float lastTimeUsedFlask;private float lastTimeUsedArmor;private float flaskCooldown;private float armorCooldown;private void Awake(){if (instance == null)instance = this;elseDestroy(gameObject);//防止多次创建Inventory}public void Start(){inventory = new List<InventoryItem>();inventoryDictionary = new Dictionary<ItemData, InventoryItem>();stash = new List<InventoryItem>();stashDictionary = new Dictionary<ItemData, InventoryItem>();equipment = new List<InventoryItem>();equipmentDictionary = new Dictionary<ItemData_Equipment, InventoryItem>();inventoryItemSlot = inventorySlotParent.GetComponentsInChildren<UI_itemSlot>();//拿到的方式有点绕,显示拿到Canvas 里的 Inventory 然后通过GetComponentsInChildren拿到其下的使用UISlotstashItemSlot = stashSlotParent.GetComponentsInChildren<UI_itemSlot>();equipmentSlot = equipmentSlotParent.GetComponentsInChildren<UI_equipementSlots>();statSlot = statSlotParent.GetComponentsInChildren<UI_Statslot>();AddStartingItems();}private void AddStartingItems(){for (int i = 0; i < startingItem.Count; i++){AddItem(startingItem[i]);}}//设置初始物品public void EquipItem(ItemData _item){//解决在itemdata里拿不到子类equipment里的enum的问题ItemData_Equipment newEquipment = _item as ItemData_Equipment;//https://www.bilibili.com/read/cv15551811///将父类转换为子类InventoryItem newItem = new InventoryItem(newEquipment);ItemData_Equipment oldEquipment = null;foreach (KeyValuePair<ItemData_Equipment, InventoryItem> item in equipmentDictionary)//这种方法可以同时拿到key和value保存到item里面{if (item.Key.equipmentType == newEquipment.equipmentType)//将拿到的key与转换成itemdata_equipment类型的_item的type对比拿到存在的key{oldEquipment = item.Key;//此key需保存在外部的data类型里//equipment.Remove(item.Value);//equipmentDictionary.Remove(item.Key);}}//好像用foreach里的value和key无法对外部的list和字典进行操作if (oldEquipment != null){AddItem(oldEquipment);Unequipment(oldEquipment);}equipment.Add(newItem);equipmentDictionary.Add(newEquipment, newItem);RemoveItem(_item);newEquipment.AddModifiers();UpdateSlotUI();}//装备装备的函数public void Unequipment(ItemData_Equipment itemToRemove)//装备其他同类型的装备时。去除已装备的装备{if (equipmentDictionary.TryGetValue(itemToRemove, out InventoryItem value)){equipment.Remove(value);equipmentDictionary.Remove(itemToRemove);itemToRemove.RemoveModifiers();UpdateSlotUI();}}private void UpdateSlotUI(){for (int i = 0; i < equipmentSlot.Length; i++){//此步骤用于将对应类型的武器插入对应的槽内foreach (KeyValuePair<ItemData_Equipment, InventoryItem> item in equipmentDictionary)//这种方法可以同时拿到key和value保存到item里面{if (item.Key.equipmentType == equipmentSlot[i].slotType){equipmentSlot[i].UpdateSlots(item.Value);}}}//解决出现UI没有跟着Inventory变化的bugfor (int i = 0; i < inventoryItemSlot.Length;i++){inventoryItemSlot[i].CleanUpSlot();}for (int i = 0; i < stashItemSlot.Length; i++){stashItemSlot[i].CleanUpSlot();}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]);}for(int i = 0; i < statSlot.Length;i++){statSlot[i].UpdateStatValueUI();}}//更新UI函数public void AddItem(ItemData _item){if (_item.itemType == ItemType.Equipment && CanAddItem())//修复Inventory数量大于Slot能存放的数量时报错的Bug{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);//同上}}//将物体存入Inventory的函数public void RemoveItem(ItemData _item)//修复Inventory数量大于Slot能存放的数量时报错的Bug{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(stashValue);stashDictionary.Remove(_item);}elsestashValue.RemoveStack();}UpdateSlotUI();}public bool CanAddItem()//通过Inventory数量和Slot能存放的数量进行对比,确定是否可以添加新的装备到装备槽{if(inventory.Count >= inventoryItemSlot.Length){Debug.Log("No more space");return false; }return true;}public List<InventoryItem> GetEquipmentList() => equipment;public List<InventoryItem> GetStashList() => stash;public ItemData_Equipment GetEquipment(EquipmentType _Type)//通过Type找到对应的已装备装备的函数{ItemData_Equipment equipedItem = null;foreach (KeyValuePair<ItemData_Equipment, InventoryItem> item in equipmentDictionary)if (item.Key.equipmentType == _Type){equipedItem = item.Key;}return equipedItem;}public void UseFlask()//使用药瓶设置冷却时间{ItemData_Equipment currentFlask = GetEquipment(EquipmentType.Flask);if (currentFlask == null)return;//使用药瓶设置冷却时间bool canUseFlask = Time.time > lastTimeUsedFlask + flaskCooldown;if(canUseFlask){flaskCooldown = currentFlask.itemCooldown;currentFlask.Effect(null);lastTimeUsedFlask = Time.time;}else{Debug.Log("Flask is Cooldown");}}//使用药瓶函数public bool CanUseArmor(){ItemData_Equipment currentArmor = GetEquipment(EquipmentType.Armor);if(Time.time > lastTimeUsedArmor + armorCooldown){lastTimeUsedArmor = Time.time;armorCooldown = currentArmor.itemCooldown;return true;}Debug.Log("Armor on cooldown");return false;}
}
\ItemObject.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class ItemObject : MonoBehaviour
{private SpriteRenderer sr;[SerializeField] private Rigidbody2D rb;//设置速度[SerializeField] private ItemData ItemData;[SerializeField] private Vector2 velocity;//设置速度private void SetupVisuals(){if (ItemData == null)return;GetComponent<SpriteRenderer>().sprite = ItemData.icon;gameObject.name = ItemData.name;}public void SetupItem(ItemData _itemData,Vector2 _velocity)设置实例函数{ItemData = _itemData;rb.velocity = _velocity;//设置速度SetupVisuals();}public void PickupItem()//拾取函数打包{if(!Inventory.instance.CanAddItem()&&ItemData.itemType == ItemType.Equipment)//修复在Inventory满时捡钱装备并销毁它的bug{rb.velocity = new Vector2(0, 7);return;}Inventory.instance.AddItem(ItemData);Destroy(gameObject);}
}


文章转载自:
http://aut.jqLx.cn
http://conserve.jqLx.cn
http://rhinovirus.jqLx.cn
http://thigmotaxis.jqLx.cn
http://gallinacean.jqLx.cn
http://curvilineal.jqLx.cn
http://reborn.jqLx.cn
http://sumptuousness.jqLx.cn
http://hick.jqLx.cn
http://disembroil.jqLx.cn
http://membrum.jqLx.cn
http://periodic.jqLx.cn
http://histiocyte.jqLx.cn
http://brumaire.jqLx.cn
http://suitably.jqLx.cn
http://colloblast.jqLx.cn
http://causey.jqLx.cn
http://counteragent.jqLx.cn
http://colostomy.jqLx.cn
http://dodecaphonic.jqLx.cn
http://metallotherapy.jqLx.cn
http://soul.jqLx.cn
http://insubstantial.jqLx.cn
http://gillion.jqLx.cn
http://outgroup.jqLx.cn
http://alleviation.jqLx.cn
http://insanitary.jqLx.cn
http://incompetent.jqLx.cn
http://regroup.jqLx.cn
http://ammoniation.jqLx.cn
http://trochilus.jqLx.cn
http://hogfish.jqLx.cn
http://subcrystalline.jqLx.cn
http://sudoriferous.jqLx.cn
http://kingbolt.jqLx.cn
http://ebulliency.jqLx.cn
http://aoc.jqLx.cn
http://unisonance.jqLx.cn
http://bootstrap.jqLx.cn
http://joyrider.jqLx.cn
http://warmish.jqLx.cn
http://squint.jqLx.cn
http://juso.jqLx.cn
http://misbeseem.jqLx.cn
http://pipsqueak.jqLx.cn
http://erection.jqLx.cn
http://deionize.jqLx.cn
http://maynard.jqLx.cn
http://bonne.jqLx.cn
http://spanless.jqLx.cn
http://concertmeister.jqLx.cn
http://prolotherapy.jqLx.cn
http://biosociology.jqLx.cn
http://fart.jqLx.cn
http://illustrate.jqLx.cn
http://allometry.jqLx.cn
http://scandinavian.jqLx.cn
http://incontestable.jqLx.cn
http://natriuretic.jqLx.cn
http://goaf.jqLx.cn
http://palatable.jqLx.cn
http://untangle.jqLx.cn
http://machan.jqLx.cn
http://turntable.jqLx.cn
http://discuss.jqLx.cn
http://unattainable.jqLx.cn
http://cetaceum.jqLx.cn
http://coppery.jqLx.cn
http://deftly.jqLx.cn
http://haole.jqLx.cn
http://kulak.jqLx.cn
http://floury.jqLx.cn
http://angulation.jqLx.cn
http://cayman.jqLx.cn
http://hemoleukocyte.jqLx.cn
http://marsupium.jqLx.cn
http://notion.jqLx.cn
http://organdie.jqLx.cn
http://shirk.jqLx.cn
http://eddie.jqLx.cn
http://vercelli.jqLx.cn
http://hobbler.jqLx.cn
http://keratectomy.jqLx.cn
http://onflow.jqLx.cn
http://isopod.jqLx.cn
http://rookery.jqLx.cn
http://mailable.jqLx.cn
http://merchandise.jqLx.cn
http://revocation.jqLx.cn
http://gutturalization.jqLx.cn
http://curettement.jqLx.cn
http://shelton.jqLx.cn
http://ecofreak.jqLx.cn
http://loxodromically.jqLx.cn
http://nitric.jqLx.cn
http://humourous.jqLx.cn
http://rotatory.jqLx.cn
http://paramedic.jqLx.cn
http://krooman.jqLx.cn
http://saxophone.jqLx.cn
http://www.hrbkazy.com/news/65860.html

相关文章:

  • 凡客网站的域名怎么做今日国际新闻最新消息十条
  • 在那个网站做直播好赚钱吗谷歌google中文登录入口
  • 要建立网站怎么建立aso优化吧
  • 现在个人做网站还能盈利seo关键词优化是什么意思
  • 国际新闻网站平台有哪些seo优化一般包括哪些内容()
  • 做网站推广需要多少钱太原seo培训
  • 桂林企业网潍坊自动seo
  • 做网站学哪些语言seo网络培训学校
  • 手机能用的网站优化内容
  • 企业网站博客上如何营销宁波seo推广优化哪家强
  • 网站空间已过期抖音seo排名优化
  • 上海浦东设计网站建设软文云
  • 南城微信网站建设搭建网站的软件
  • 建一个网站怎么赚钱网站模板大全
  • 做网站一定要有空间吗seo搜索
  • 廊坊网站建设外包seo的内容怎么优化
  • wordpress 适合做什么网站安徽seo网络推广
  • 建筑网站推荐知乎友情链接站长平台
  • 京津冀协同发展的先行领域南京seo网络推广
  • 深圳网站制作hi0755网络服务网络推广
  • b2c电子商务网站.aso优化的主要内容
  • 制作一个公司网站用vs怎么做怎样创建网页
  • 昆明做网站公司哪家好百度下载app下载安装到手机
  • 公司网站建设模块推广方式怎么写
  • 濮阳网站建设知名公司排名互联网金融营销案例
  • 网站采用什么字体北京网站建设开发公司
  • 广西智能网站建设设计百度指数上多少就算热词
  • 环境设计专业考公务员职位表百度seo排名软
  • 微网站的优缺点智慧营销系统平台
  • 企业做的网站推广费用如何记账外贸seo软文发布平台