Unity类银河恶魔城学习记录12-2 p124 Character Stats UI源代码

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

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

UI_Statslot.cs
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;public class UI_Statslot : MonoBehaviour
{[SerializeField] private StatType statType;[SerializeField] private TextMeshProUGUI statValueText;[SerializeField] private TextMeshProUGUI statNameText;private void OnValidate(){gameObject.name = "Stat - " + statType.ToString();if(statNameText != null){statNameText.text = statType.ToString();}}private void Start(){UpdateStatValueUI();}public void UpdateStatValueUI(){PlayerStats playerStats = PlayerManager.instance.player.GetComponent<PlayerStats>();if(playerStats != null){statValueText.text = playerStats.GetStats(statType).GetValue().ToString();}}
}

UI_equipementSlots.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;public class UI_equipementSlots : UI_itemSlot
{public EquipmentType slotType;//这怎么拿到的private void OnValidate(){gameObject.name = "Equipment slot -" + slotType.ToString();}public override void OnPointerDown(PointerEventData eventData){if (item == null || item.data == null)//修复点击空白处会报错的bugreturn;//点击装备槽后卸下装备Inventory.instance.AddItem(item.data as ItemData_Equipment);Inventory.instance.Unequipment(item.data as ItemData_Equipment);  CleanUpSlot();}
}

UI_itemSlot.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using UnityEngine.EventSystems;public class UI_itemSlot : MonoBehaviour ,IPointerDownHandler
{[SerializeField] private Image itemImage;[SerializeField] private TextMeshProUGUI itemText;public InventoryItem item;public void UpdateSlots(InventoryItem _newItem){item = _newItem;itemImage.color = Color.white;if (item != null){itemImage.sprite = item.data.icon;if (item.stackSize > 1){itemText.text = item.stackSize.ToString();}else{itemText.text = "";}}}public void CleanUpSlot()//解决出现UI没有跟着Inventory变化的bug{item = null;itemImage.sprite = null;itemImage.color = Color.clear;itemText.text = "";}public virtual void OnPointerDown(PointerEventData eventData){if(item == null)//修复点击空白处会报错的bug{return;}if(Input.GetKey(KeyCode.LeftControl)){Inventory.instance.RemoveItem(item.data);return;}if (item.data.itemType == ItemType.Equipment)Inventory.instance.EquipItem(item.data);}
}
Buff_Effcet.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;[CreateAssetMenu(fileName = "BUff effect", menuName = "Data/Item effect/Buff effect")]public class Buff_Effect :ItemEffect
{private PlayerStats stats;[SerializeField] private StatType buffType;[SerializeField] private float buffDuration;[SerializeField] private int buffAmount;public override void ExecuteEffect(Transform _respawnPosition){stats = PlayerManager.instance.player.GetComponent<PlayerStats>();stats.IncreaseStatBy(buffAmount, buffDuration, stats.GetStats(buffType));}}
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){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的函数{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 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;}
}
CharacterStats.cs
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting.Antlr3.Runtime.Misc;
using UnityEngine;
public enum StatType
{strength,agility,intelligence,vitality,damage,critChance,critPower,Health,armor,evasion,magicResistance,fireDamage,iceDamage,lightingDamage
}
public class CharacterStats : MonoBehaviour
{private EntityFX fx;[Header("Major stats")]public Stat strength; // 力量 增伤1点 爆伤增加 1% 物抗public Stat agility;// 敏捷 闪避 1% 闪避几率增加 1%public Stat intelligence;// 1 点 魔法伤害 1点魔抗 public Stat vitality;//加血的[Header("Offensive stats")]public Stat damage;public Stat critChance;      // 暴击率public Stat critPower;       //150% 爆伤[Header("Defensive stats")]public Stat Health;public Stat armor;public Stat evasion;//闪避值public Stat magicResistance;[Header("Magic stats")]public Stat fireDamage;public Stat iceDamage;public Stat lightingDamage;public bool isIgnited;  // 持续烧伤public bool isChilded;  // 削弱护甲 20%public bool isShocked;  // 降低敌人命中率[SerializeField] private float ailmentsDuration = 4;private float ignitedTimer;private float chilledTimer;private float shockedTimer;private float igniteDamageCooldown = .3f;private float ignitedDamageTimer;private int igniteDamage;[SerializeField] private GameObject shockStrikePrefab;private int shockDamage;public System.Action onHealthChanged;//使角色在Stat里调用UI层的函数//此函数调用了更新HealthUI函数public bool isDead { get; private set; }[SerializeField] public int currentHealth;protected virtual void Start(){critPower.SetDefaultValue(150);//设置默认爆伤currentHealth = GetMaxHealthValue();fx = GetComponent<EntityFX>();}protected virtual void Update(){//所有的状态都设置上默认持续时间,持续过了就结束状态ignitedTimer -= Time.deltaTime;chilledTimer -= Time.deltaTime;shockedTimer -= Time.deltaTime;ignitedDamageTimer -= Time.deltaTime;if (ignitedTimer < 0)isIgnited = false;if (chilledTimer < 0)isChilded = false;if (shockedTimer < 0)isShocked = false;//被点燃后,出现多段伤害后点燃停止if(isIgnited)ApplyIgnitedDamage();}public virtual void IncreaseStatBy(int _modifier, float _duration,Stat _statToModify){StartCoroutine(StatModCoroutine(_modifier, _duration, _statToModify));}private IEnumerator StatModCoroutine(int _modifier, float _duration, Stat _statToModify){_statToModify.AddModifier(_modifier);yield return new WaitForSeconds(_duration);_statToModify.RemoveModifier(_modifier);}public virtual void DoDamage(CharacterStats _targetStats)//计算后造成伤害函数{if (TargetCanAvoidAttack(_targetStats))设置闪避{return;}int totleDamage = damage.GetValue() + strength.GetValue();//爆伤设置if (CanCrit()){totleDamage = CalculateCriticalDamage(totleDamage);}totleDamage = CheckTargetArmor(_targetStats, totleDamage);//设置防御_targetStats.TakeDamage(totleDamage);DoMagicaDamage(_targetStats); // 可以去了也可以不去}protected virtual void Die(){isDead = true;}public virtual void TakeDamage(int _damage)//造成伤害是出特效{fx.StartCoroutine("FlashFX");//IEnumertor本质就是将一个函数分块执行,只有满足某些条件才能执行下一段代码,此函数有StartCoroutine调用//https://www.zhihu.com/tardis/bd/art/504607545?source_id=1001DecreaseHealthBy(_damage);GetComponent<Entity>().DamageImpact();if (currentHealth < 0 && !isDead)Die();}public virtual void IncreaseHealthBy(int _amount)//添加回血函数{currentHealth += _amount;if (currentHealth > GetMaxHealthValue())currentHealth = GetMaxHealthValue();if (onHealthChanged != null)onHealthChanged();}protected virtual void DecreaseHealthBy(int _damage)//此函数用来改变当前生命值,不调用特效{currentHealth -= _damage;if (onHealthChanged != null){onHealthChanged();}}#region Magical damage and ailementsprivate void ApplyIgnitedDamage(){if (ignitedDamageTimer < 0 ){DecreaseHealthBy(igniteDamage);if (currentHealth < 0 && !isDead)Die();ignitedDamageTimer = igniteDamageCooldown;}}被点燃后,出现多段伤害后点燃停止public virtual void DoMagicaDamage(CharacterStats _targetStats)//法伤计算和造成元素效果调用的地方{int _fireDamage = fireDamage.GetValue();int _iceDamage = iceDamage.GetValue();int _lightingDamage = lightingDamage.GetValue();int totleMagicalDamage = _fireDamage + _iceDamage + _lightingDamage + intelligence.GetValue();totleMagicalDamage = CheckTargetResistance(_targetStats, totleMagicalDamage);_targetStats.TakeDamage(totleMagicalDamage);//防止循环在所有元素伤害为0时出现死循环if (Mathf.Max(_fireDamage, _iceDamage, _lightingDamage) <= 0)return;//让元素效果取决与伤害//为了防止出现元素伤害一致而导致无法触发元素效果//循环判断触发某个元素效果AttemptyToApplyAilement(_targetStats, _fireDamage, _iceDamage, _lightingDamage);}private  void AttemptyToApplyAilement(CharacterStats _targetStats, int _fireDamage, int _iceDamage, int _lightingDamage){bool canApplyIgnite = _fireDamage > _iceDamage && _fireDamage > _lightingDamage;bool canApplyChill = _iceDamage > _lightingDamage && _iceDamage > _fireDamage;bool canApplyShock = _lightingDamage > _fireDamage && _lightingDamage > _iceDamage;while (!canApplyIgnite && !canApplyChill && !canApplyShock){if (Random.value < .25f){canApplyIgnite = true;Debug.Log("Ignited");_targetStats.ApplyAilments(canApplyIgnite, canApplyChill, canApplyShock);return;}if (Random.value < .35f){canApplyChill = true;Debug.Log("Chilled");_targetStats.ApplyAilments(canApplyIgnite, canApplyChill, canApplyShock);return;}if (Random.value < .55f){canApplyShock = true;Debug.Log("Shocked");_targetStats.ApplyAilments(canApplyIgnite, canApplyChill, canApplyShock);return;}}if (canApplyIgnite){_targetStats.SetupIgniteDamage(Mathf.RoundToInt(_fireDamage * .2f));}if (canApplyShock)_targetStats.SetupShockStrikeDamage(Mathf.RoundToInt(_lightingDamage * .1f));//给点燃伤害赋值_targetStats.ApplyAilments(canApplyIgnite, canApplyChill, canApplyShock);}//造成元素效果public void ApplyAilments(bool _ignite, bool _chill, bool _shock)//判断异常状态{bool canApplyIgnite = !isIgnited && !isChilded && !isShocked;bool canApplyChill = !isIgnited && !isChilded && !isShocked;bool canApplyShock = !isIgnited && !isChilded;//使当isShock为真时Shock里的函数仍然可以调用if (_ignite && canApplyIgnite){isIgnited = _ignite;ignitedTimer = ailmentsDuration;fx.IgniteFxFor(ailmentsDuration);}if (_chill && canApplyChill){isChilded = _chill;chilledTimer = ailmentsDuration;float slowPercentage = .2f;GetComponent<Entity>().SlowEntityBy(slowPercentage, ailmentsDuration);fx.ChillFxFor(ailmentsDuration);}if (_shock && canApplyShock){if(!isShocked){ApplyShock(_shock);}else{if (GetComponent<Player>() != null)//防止出现敌人使玩家进入shock状态后也出现闪电return;HitNearestTargetWithShockStrike();}//isShock为真时反复执行的函数为寻找最近的敌人,创建闪电实例并传入数据}}public void ApplyShock(bool _shock){if (isShocked)return;isShocked = _shock;shockedTimer = ailmentsDuration;fx.ShockFxFor(ailmentsDuration);}//触电变色效果private void HitNearestTargetWithShockStrike(){Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 25);//找到环绕自己的所有碰撞器float closestDistance = Mathf.Infinity;//正无穷大的表示形式(只读)Transform closestEnemy = null;//https://docs.unity3d.com/cn/current/ScriptReference/Mathf.Infinity.htmlforeach (var hit in colliders){if (hit.GetComponent<Enemy>() != null && Vector2.Distance(transform.position, hit.transform.position) > 1)// 防止最近的敌人就是Shock状态敌人自己{float distanceToEnemy = Vector2.Distance(transform.position, hit.transform.position);//拿到与敌人之间的距离if (distanceToEnemy < closestDistance)//比较距离,如果离得更近,保存这个敌人的位置,更改最近距离{closestDistance = distanceToEnemy;closestEnemy = hit.transform;}}if (closestEnemy == null)closestEnemy = transform;}if (closestEnemy != null){GameObject newShockStrike = Instantiate(shockStrikePrefab, transform.position, Quaternion.identity);newShockStrike.GetComponent<ShockStrike_Controller>().Setup(shockDamage, closestEnemy.GetComponent<CharacterStats>());}}//给最近的敌人以雷劈public void SetupIgniteDamage(int _damage) => igniteDamage = _damage;//给点燃伤害赋值public void SetupShockStrikeDamage(int _damage) => shockDamage = _damage;//雷电伤害赋值#endregion#region Stat calculationsprivate int CheckTargetResistance(CharacterStats _targetStats, int totleMagicalDamage)//法抗计算{totleMagicalDamage -= _targetStats.magicResistance.GetValue() + (_targetStats.intelligence.GetValue() * 3);totleMagicalDamage = Mathf.Clamp(totleMagicalDamage, 0, int.MaxValue);return totleMagicalDamage;}private static int CheckTargetArmor(CharacterStats _targetStats, int totleDamage)//防御计算{//被冰冻后,角色护甲减少if (_targetStats.isChilded)totleDamage -= Mathf.RoundToInt(_targetStats.armor.GetValue() * .8f);elsetotleDamage -= _targetStats.armor.GetValue();totleDamage = Mathf.Clamp(totleDamage, 0, int.MaxValue);return totleDamage;}private bool TargetCanAvoidAttack(CharacterStats _targetStats)//闪避计算{int totleEvation = _targetStats.evasion.GetValue() + _targetStats.agility.GetValue();//我被麻痹后//敌人的闪避率提升if (isShocked)totleEvation += 20;if (Random.Range(0, 100) < totleEvation){return true;}return false;}private bool CanCrit()//判断是否暴击{int totleCriticalChance = critChance.GetValue() + agility.GetValue();if (Random.Range(0, 100) <= totleCriticalChance){return true;}return false;}private int CalculateCriticalDamage(int _damage)//计算暴击后伤害{float totleCirticalPower = (critPower.GetValue() + strength.GetValue()) * .01f;float critDamage = _damage * totleCirticalPower;return Mathf.RoundToInt(critDamage);//返回舍入为最近整数的}public int GetMaxHealthValue(){return Health.GetValue() + vitality.GetValue() * 10;}//统计生命值函数public  Stat GetStats(StatType _statType){if (_statType == StatType.strength) return strength;else if (_statType == StatType.agility) return agility;else if (_statType == StatType.intelligence) return intelligence;else if (_statType == StatType.vitality) return vitality;else if (_statType == StatType.damage) return damage;else if (_statType == StatType.critChance) return critChance;else if (_statType == StatType.critPower) return critPower;else if (_statType == StatType.Health) return Health;else if (_statType == StatType.armor) return armor;else if (_statType == StatType.evasion) return evasion;else if (_statType == StatType.magicResistance) return magicResistance;else if (_statType == StatType.fireDamage) return fireDamage;else if (_statType == StatType.iceDamage) return iceDamage;else if (_statType == StatType.lightingDamage) return lightingDamage;return null;}#endregion
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/790268.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

基于深度学习的条形码二维码检测系统(网页版+YOLOv8/v7/v6/v5代码+训练数据集)

摘要&#xff1a;本文深入研究了基于YOLOv8/v7/v6/v5的条形码二维码检测系统。核心采用YOLOv8并整合了YOLOv7、YOLOv6、YOLOv5算法&#xff0c;进行性能指标对比&#xff1b;详述了国内外研究现状、数据集处理、算法原理、模型构建与训练代码&#xff0c;及基于Streamlit的交互…

Leetcode-894-所有可能的真二叉树-c++

题目详见https://leetcode.cn/problems/all-possible-full-binary-trees/ 主搞动态规划&#xff0c;因为这玩意儿我还不是很懂 关于节点个数为奇数偶数的证明请见官方题解方法一中的如下内容&#xff1a; 这里DP的一个主要思想是&#xff1a;对于任何一个满二叉树&#xff…

4 月 8 日至 9 日 ICP Hacker House 邀你共赴 IC 生态项目开发新风口

为了更好地探索区块链技术前沿&#xff0c;体验作为全面智能合约云平台的互联网计算机&#xff08;Internet Computer Protocol&#xff09;&#xff0c;将数据、内容、计算和用户体验全部托管于链上&#xff0c;IC 生态致力于推动去中心化互联网的深度发展&#xff0c;并将更安…

jpg、bmp、png图像的位深度分别有多少种?分别表示什么意思?如果操作时需要注意什么?

JPG (JPEG) JPEG 格式通常使用 24 位颜色深度&#xff0c;这意味着每个像素由三个 8 位颜色通道组成&#xff1a;红色、绿色和蓝色&#xff08;RGB&#xff09;。因此&#xff0c;它可以表示大约 1600 万种颜色&#xff08;2^24&#xff09;。不过&#xff0c;JPEG 也支持有损…

ES6学习(四)-- Reflect / Promise / Generator 函数 / Class

文章目录 1. Reflect1.1 代替Object 的某些方法1.2 修改某些Object 方法返回结果1.3 命令式变为函数行为1.4 ! 配合Proxy 2. ! Promise2.1 回调地狱2.2 Promise 使用2.3 Promise 对象的状态2.4 解决回调地狱的方法2.5 Promise.all2.6 Promise.race 3. Generator 函数3.1 基本语…

Android Studio学习5——布局layout与视图view

wrap_content&#xff0c;内容有多大&#xff0c;就有多宽&#xff08;包裹&#xff09; 布局 padding 边框与它自身的内容 margin 控件与控件之间

This app has no Android key hashes configured. . Configure your app key

Unity 接入 Facebook SDK 的过程中遇到这个问题&#xff0c;查了很多帖子&#xff0c;不太直观&#xff0c;记录下来方便需要的同学参考 报上面错误的原因是在https://developers.facebook.com/apps/ 设置里没有填入有效的密钥 怎么填入这个密钥呢&#xff0c;其实很简单&…

Redis性能管理及集群三种模式(一)

一、前期准备 至少准备三台服务器为主从复制、哨兵的实验做准备 一台主redis、两台从redis 二、Redis性能管理 2.1 查看Redis内存使用 查看Redis内存使用——info memory 2.2 内存使用率 1<内存碎片<1.5表示合理的内存碎片大于>1.5&#xff0c;需要输入shutdown save…

创建vue3项目及基本常用配置

1、创建vue3项目 1.1 创建vue3项目 确保电脑中安装了nodejs&#xff0c;新建文件夹&#xff0c;输入以下命令&#xff1a; npm create vuelatest 看是否为自己需要的vue版本&#xff0c;选择Y 各配置具体如下&#xff0c;根据自己的需求选择是或者否 npm create vuelatest …

阿里云数据库服务器价格表查询,一键查询报价

阿里云数据库服务器价格表&#xff0c;优惠99元一年起&#xff0c;ECS云服务器2核2G、3M固定带宽、40G ESSD Entry云盘&#xff0c;优惠价格99元一年&#xff1b;阿里云数据库MySQL版2核2G基础系列经济版99元1年、2核4GB 227.99元1年&#xff0c;云数据库PostgreSQL、SQL Serve…

OpenHarmony实战:标准系统移植指南

本文描述了移植一块开发板的通用步骤&#xff0c;和具体芯片相关的详细移植过程无法在此一一列举。后续社区还会陆续发布开发板移植的实例供开发者参考。 定义开发板 本文以移植名为MyProduct的开发板为例讲解移植过程&#xff0c;假定MyProduct是MyProductVendor公司的开发板…

RC滤波电路

RC滤波电路 综述&#xff1a;本文简单讲述了RC低通滤波电路和RC高通滤波电路。 滤波电路是指过滤输入信号中不需要的信号&#xff0c;保留需要的信号。 一、RC低通滤波电路 1.定义&#xff1a;RC低通滤波电路&#xff1a;保留低频信号&#xff0c;衰减高频信号。 2.截止频率…

突破校园网限速:使用 iKuai 多拨分流负载均衡 + Clash 代理(内网带宽限制通用)

文章目录 1. 简介2. iKuai 部署2.1 安装 VMware2.2 安装 iKuai(1) 下载固件(2) 安装 iKuai 虚拟机(3) 配置 iKuai 虚拟机(4) 配置 iKuai(5) 配置多拨分流 2.3 测试速度 3. Clash 部署3.1 准备工作(1) 配置磁盘分区(2) 安装 Docker(3) 安装 Clash(4) 设置代理 1. 简介 由于博主…

014——超声波模块驱动开发Plus(基于I.MX6uLL、SR04和poll机制)

目录 一、基础知识 二、分析为什么打印会影响中断 三、驱动程序 四、应用程序 五、验证及其它 一、基础知识 013——超声波模块驱动开发&#xff08;基于I.MX6uLL与SR04&#xff09;-CSDN博客 二、分析为什么打印会影响中断 asmlinkage __visible int printk(const ch…

一条SQL查询语句是如何执行的

这是专栏的第一篇文章&#xff0c;我想来跟你聊聊 MySQL 的基础架构。我们经常说&#xff0c;看一个事儿千万不要直接陷入细节里&#xff0c;你应该先鸟瞰其全貌&#xff0c;这样能够帮助你从高维度理解问题。同样&#xff0c;对于 MySQL 的学习也是这样。平时我们使用数据库&a…

Windows11安装MySql-8.0.36安装详细教程(保姆级教程)

之前一直用的mysql5.7&#xff0c;最近导入一个项目一直报错&#xff0c;经查阅发现数据库mysql版本太老&#xff0c;今天特地重头下载安装配置一下&#xff0c;做个记录供大家参考。 下载安装包&#xff1a; 下载地址&#xff1a;https://dev.mysql.com/downloads/ 进入后选…

C++STL--排序算法

sort 使用快速排序,平均性能好O(nlogn),但最差情况可能很差O(n^2)。不稳定。 sort(v.begin(),v.end());//对v容器进行排序,默认升序 sort(v.begin(),v.end(),greater<int>());//降序排序对于支持随机访问的迭代器的容器&#xff0c; 都可以利用sort算法直接对其进行排序…

基于SSM的师生交流平台

目录 背景 技术简介 系统简介 界面预览 背景 传统的师生互动平台主要依赖于面对面的线下交流&#xff0c;用户必须亲自到场以获取和交流相关信息。然而&#xff0c;随着信息技术的广泛传播&#xff0c;众多教育机构开始转向线上发展&#xff0c;寻求更多样化的发展途径。线…

C++11:声明 初始化

C11&#xff1a;声明 & 初始化 初始化{ }初始化initializer_list 声明autodecltypenullptr 初始化 { }初始化 在C98中&#xff0c;允许使用花括号{ }对数组或者结构体元素进行统一的列表初始化。 用{ }初始化数组&#xff1a; int arr[] { 1, 2, 3, 4, 5 };用{ }初始化…

详解2024年阿里云服务器租用价格表,最新报价

阿里云服务器租用价格表2024年最新&#xff0c;云服务器ECS经济型e实例2核2G、3M固定带宽99元一年&#xff0c;轻量应用服务器2核2G3M带宽轻量服务器一年61元&#xff0c;ECS u1服务器2核4G5M固定带宽199元一年&#xff0c;2核4G4M带宽轻量服务器一年165元12个月&#xff0c;2核…