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

民宿预订网站制作个人网页怎么制作

民宿预订网站制作,个人网页怎么制作,dz论坛seo,佛冈县住房和城乡建设局网站此章节在原视频缺失#xff0c;此过程为根据源代码推断而来#xff0c;并非原视频步骤 Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释#xff0c;可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩…此章节在原视频缺失此过程为根据源代码推断而来并非原视频步骤  Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili UI_CraftSlot using UnityEngine.EventSystems;public class UI_CraftSlot : UI_itemSlot {protected override void Start(){base.Start();}public void SetUpCraftSlot(ItemData_Equipment _data){item.data _data;}private void OnValidate(){UpdateSlots(item);}// Update is called once per framepublic override void OnPointerDown(PointerEventData eventData){ItemData_Equipment craftData item.data as ItemData_Equipment;Inventory.instance.CanCraft(craftData, craftData.craftingMaterials);} }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 ListItemData startingItem;public ListInventoryItem equipment;//inventoryItems类型的列表public DictionaryItemData_Equipment, InventoryItem equipmentDictionary;//以ItemData为Key寻找InventoryItem的字典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;[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 ListInventoryItem();inventoryDictionary new DictionaryItemData, InventoryItem();stash new ListInventoryItem();stashDictionary new DictionaryItemData, InventoryItem();equipment new ListInventoryItem();equipmentDictionary new DictionaryItemData_Equipment, InventoryItem();inventoryItemSlot inventorySlotParent.GetComponentsInChildrenUI_itemSlot();//拿到的方式有点绕显示拿到Canvas 里的 Inventory 然后通过GetComponentsInChildren拿到其下的使用UISlotstashItemSlot stashSlotParent.GetComponentsInChildrenUI_itemSlot();equipmentSlot equipmentSlotParent.GetComponentsInChildrenUI_equipementSlots();statSlot statSlotParent.GetComponentsInChildrenUI_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 (KeyValuePairItemData_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 (KeyValuePairItemData_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){return false; }return true;}public ListInventoryItem GetEquipmentList() equipment;public ListInventoryItem GetStashList() stash;public ItemData_Equipment GetEquipment(EquipmentType _Type)//通过Type找到对应的已装备装备的函数{ItemData_Equipment equipedItem null;foreach (KeyValuePairItemData_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;}public bool CanCraft(ItemData_Equipment _itemToCraft, ListInventoryItem _requiredMaterials){ListInventoryItem materialsToRemove new ListInventoryItem();for (int i 0; i _requiredMaterials.Count; i){if (stashDictionary.TryGetValue(_requiredMaterials[i].data, out InventoryItem stashValue))//判断数量是否足够{if (stashValue.stackSize _requiredMaterials[i].stackSize){Debug.Log(not enough materials);return false;}else{materialsToRemove.Add(stashValue);}}else{Debug.Log(not enough materials);return false;}}for (int i 0; i materialsToRemove.Count; i){RemoveItem(materialsToRemove[i].data);}AddItem(_itemToCraft);Debug.Log(Here is your item _itemToCraft.name);return true;}//检测材料足够制造对应装备的函数 } ItemData_Equipment.cs using System.Collections; using System.Collections.Generic; using UnityEngine;public enum EquipmentType {Weapon,Armor,Amulet,Flask}[CreateAssetMenu(fileName New Item Data, menuName Data/Equipment)] public class ItemData_Equipment : ItemData {public EquipmentType equipmentType;public float itemCooldown;public ItemEffect[] itemEffects;[Header(Major stats)]public int strength; // 力量 增伤1点 爆伤增加 1% 物抗public int agility;// 敏捷 闪避 1% 闪避几率增加 1%public int intelligence;// 1 点 魔法伤害 1点魔抗 public int vitality;//加血的[Header(Offensive stats)]public int damage;public int critChance; // 暴击率public int critPower; //150% 爆伤[Header(Defensive stats)]public int health;public int armor;public int evasion;//闪避值public int magicResistance;[Header(Magic stats)]public int fireDamage;public int iceDamage;public int lightingDamage;[Header(Craft requirements)]public ListInventoryItem craftingMaterials;public int descriptionLength;public void AddModifiers(){PlayerStats playerStats PlayerManager.instance.player.GetComponentPlayerStats();playerStats.strength.AddModifier(strength);playerStats.agility.AddModifier(agility);playerStats.intelligence.AddModifier(intelligence);playerStats.vitality.AddModifier(vitality);playerStats.damage.AddModifier(damage);playerStats.critChance.AddModifier(critChance);playerStats.critPower.AddModifier(critPower);playerStats.Health.AddModifier(health);playerStats.armor.AddModifier(armor);playerStats.evasion.AddModifier(evasion);playerStats.magicResistance.AddModifier(magicResistance);playerStats.fireDamage.AddModifier(fireDamage);playerStats.iceDamage.AddModifier(iceDamage);playerStats.lightingDamage.AddModifier(lightingDamage);}public void RemoveModifiers(){PlayerStats playerStats PlayerManager.instance.player.GetComponentPlayerStats();playerStats.strength.RemoveModifier(strength);playerStats.agility.RemoveModifier(agility);playerStats.intelligence.RemoveModifier(intelligence);playerStats.vitality.RemoveModifier(vitality);playerStats.damage.RemoveModifier(damage);playerStats.critChance.RemoveModifier(critChance);playerStats.critPower.RemoveModifier(critPower);playerStats.Health.RemoveModifier(health);playerStats.armor.RemoveModifier(armor);playerStats.evasion.RemoveModifier(evasion);playerStats.magicResistance.RemoveModifier(magicResistance);playerStats.fireDamage.RemoveModifier(fireDamage);playerStats.iceDamage.RemoveModifier(iceDamage);playerStats.lightingDamage.RemoveModifier(lightingDamage);}public void Effect(Transform _enemyPosition)//循环调用Effect类里的Effect的函数{foreach(var item in itemEffects){item.ExecuteEffect(_enemyPosition);}}public override string GetDescription()//让外界能够拿到拼出字符串的函数{sb.Length 0;descriptionLength 0;AddItemDescription(strength, strength);AddItemDescription(agility, agility);AddItemDescription(intelligence, intelligence);AddItemDescription(vitality, vitality);AddItemDescription(damage, damage);AddItemDescription(critChance, critChance);AddItemDescription(critPower, critPower);AddItemDescription(health, health);AddItemDescription(evasion, evasion);AddItemDescription(armor, armor);AddItemDescription(magicResistance, magicResistance);AddItemDescription(fireDamage, fireDamage);AddItemDescription(iceDamage, iceDamage);AddItemDescription(lightingDamage, lightingDamage);Debug.Log(In GetDescription);if(descriptionLength 5)//使窗口拥有最小尺寸{for(int i 0;i 5- descriptionLength;i){sb.AppendLine();sb.Append();}}return sb.ToString();}private void AddItemDescription(int _value,string _name)//通过判断拼出想要的字符串的函数{if(_value ! 0){if(sb.Length 0)sb.AppendLine();//这是控制行数的if(_value 0)sb.Append( _value _name);//这是实打实添加字符串的descriptionLength;}} }
http://www.hkea.cn/news/14416557/

相关文章:

  • 信息管理网站开发的视频教程wordpress安全权限
  • 软件下载站网站源码免费知名品牌营销策略
  • 商务网站的分类wordpress 果蔬主题
  • 品牌网站建设4a小蝌蚪体验营销是什么
  • 重庆平台网站建设费用做网站的图片Pc端和手机端的区别
  • 苏州网站关键词优化个人建设网站维护费是多少
  • 网站建设有什么理论依据市场营销策划报告
  • 网站如何做软文推广如何创建wordpress数据库文件夹
  • 新华社两学一做网站wordpress打开要卡一下
  • 专做服装的网站营销网站建设是什么意思
  • h5如何做多页面网站建设局全称是什么
  • wordpress腾讯云济南百度推广seo
  • wordpress 自动发微博怀化优化办主任
  • 成都网站建设v芯ee8888e软件如何推广
  • 苏州网站设计公司济南兴田德润厉害吗松原市新闻
  • 长宁移动网站建设做机器人的网站
  • 电商网站建设方案模板php做网站脑图
  • 客户在我这做的网站被罚seo推广平台服务
  • 甘肃省建设厅注册中心网站室内设计效果图图片
  • 网站设计标语网站设计素材图片
  • 毕业设计网站选题wordpress 速度很慢
  • p2p商城网站建设中国机械加工网17s
  • 法库综合网站建设方案电子科技东莞网站建设
  • 南京专业做网站九洲建设app
  • 郑东新区网站开发合肥市建设厅官方网站
  • 仿土巴兔网站建设淘宝店铺可以做网站优化么
  • 做暧暧网站免费wordpress说说伪静态
  • 一线城市做网站工资有多少钱好的室内设计网站推荐
  • 上海手机网站开发确定网站建设的目的
  • 花店网页设计代码昭通网站seo优化