Unity3D自学笔记——UGUI背包系统(九)装备对HP影响的逻辑及使用药品
来源:互联网 发布:web前端后端数据交互 编辑:程序博客网 时间:2024/04/24 18:31
装备对HP影响的逻辑及使用药品
装备对HP影响的逻辑
背包中有加血属性的装备穿戴在身上后,应该只影响角色最大血量,不影响当前血量
使用药品
对当前属性的变更,切变更后的属性不能超过最大值。Status更改后,同样发起事件,通知监控对象,如头像面板进行值的改变,背包物品减少。
/// <summary> /// 使用药水 /// </summary> /// <param name="item"></param> public void DrinkPotion(ItemStatus item) { this.status.HpCur = this.status.HpCur + item.status.Hp > this.status.HpMax ? this.status.HpMax : this.status.HpCur + item.status.Hp; this.status.MpCur = this.status.MpCur + item.status.Mp > this.status.MpMax ? this.status.MpMax : this.status.MpCur + item.status.Mp; this.status.AtkCur = this.status.AtkCur + item.status.Atk > this.status.AtkMax ? this.status.AtkMax : this.status.AtkCur + item.status.Atk; this.status.DefCur = this.status.DefCur + item.status.Def > this.status.DefMax ? this.status.DefMax : this.status.DefCur + item.status.Def; this.status.SpdCur = this.status.SpdCur + item.status.Spd > this.status.SpdMax ? this.status.SpdMax : this.status.SpdCur + item.status.Spd; this.status.CriticalRateCur = this.status.CriticalRateCur + this.status.CriticalRateMax > this.status.CriticalRateMax ? this.status.CriticalRateMax : this.status.CriticalRateCur + item.status.CriticalRate; this.status.AtkSpdCur = this.status.AtkSpdCur + item.status.AtkSpd > this.status.AtkSpdMax ? this.status.AtkSpdMax : this.status.AtkSpdCur + item.status.AtkSpd; this.status.AtkRangeCur = this.status.AtkRangeCur + item.status.AtkRange > this.status.AtkRangeMax ? this.status.AtkRangeMax : this.status.AtkRangeCur + item.status.AtkRange; this.status.HitCur = this.status.HitCur + item.status.Hit > this.status.HitMax ? this.status.HitMax : this.status.HitCur + item.status.Hit; if (this.DrinkedPotion != null) this.DrinkedPotion(item); }
喝+150的药
血量补满, 血瓶数量减少
PlayerInfo
发生装备更改,喝药水,都刷新属性
private void PlayerDrinkedPotion(ItemStatus obj) { RefreshStatus(); } private void PlayerChangedEquip() { RefreshStatus(); } private void RefreshStatus() { this.m_TxtLv.text = "." + this.m_PlayerStatus.Lv.ToString(); this.m_TxtHp.text = string.Format("{0}/{1}", this.m_PlayerStatus.status.HpCur, this.m_PlayerStatus.status.HpMax); this.m_TxtMp.text = string.Format("{0}/{1}", this.m_PlayerStatus.status.MpCur, this.m_PlayerStatus.status.MpMax); this.m_SldHp.value = this.m_PlayerStatus.status.HpCur / this.m_PlayerStatus.status.HpMax; this.m_SldMp.value = this.m_PlayerStatus.status.MpCur / this.m_PlayerStatus.status.MpMax; this.m_SldExp.value = (float)(this.m_PlayerStatus.Exp / this.m_PlayerStatus.ExpMax); }
UIInventory
移除物品
移除物品逻辑是先减数量,数量为0则销毁,否则更新显示
private void PlayerDrinkedPotion(ItemStatus item) { RemoveItem(item); }public void RemoveItem(ItemStatus itemStatus) { itemStatus.Count -= 1; if (itemStatus.Count == 0) {//销毁物品 this.m_ItemList.Remove(itemStatus.ItemID); DestroyImmediate(itemStatus.gameObject); } else {//更新数量显示 itemStatus.gameObject.GetComponent<UIItem>().UpdateCount(); } RefreshPartGrid(); }
0 0
- Unity3D自学笔记——UGUI背包系统(九)装备对HP影响的逻辑及使用药品
- Unity3D自学笔记——UGUI背包系统(七)物品的装备与卸下
- Unity3D自学笔记——UGUI背包系统(二)UI设计实现及数据绑定
- Unity3D自学笔记——UGUI背包系统(六)角色换装及属性动态改变
- Unity3D自学笔记——UGUI背包系统(八)物品的分类与整理
- Unity3D自学笔记——UGUI背包系统(一)ItemData
- Unity3D自学笔记——UGUI背包系统(三)物品弹出提示框
- Unity3D自学笔记——UGUI背包系统(四)角色物品数据建立
- Unity3D自学笔记——UGUI背包系统(五)沿用Attribute设计实现物品等级
- 基于Unity3D(UGUI)的背包系统(装备系统,锻造系统,购买系统)
- Unity3D自学笔记——UGUI系统介绍
- Unity3D——UGUI实现背包系统
- Unity3d背包系统系统(二)—— 开发消耗品、装备、武器材料
- Unity3D自学笔记——UGUI前台架构
- 基于Unity3D(UGUI)的背包系统<二>
- 基于Unity3D(UGUI)的背包系统<三>
- 基于Unity3D(UGUI)的背包系统<四>完结篇
- Unity3D自学笔记——UGUI 利用遮罩显示3D人物(物体)
- 基于可靠消息的分布式事务错误处理
- 高并发性能的提升
- 错位排列的魅力
- SQL语句之CASE WHEN
- int 和 Integer 的区别
- Unity3D自学笔记——UGUI背包系统(九)装备对HP影响的逻辑及使用药品
- 【LeetCode】329. Longest Increasing Path in a Matrix (Hard)
- 【Day45】php解析xml提示Invalid byte 1 of 1-byte UTF-8 sequence错误的处理方法
- 定时执行php脚本
- 51nod 1441 士兵的数字游戏
- Intellij/AndroidStudio 类图标的含义
- php重启
- 移除 logcat 里的杂项信息
- 412. Fizz Buzz