unity实现DNF阿拉德之怒的血条扣除效果

如果血条显示不出来就是你选择的血条颜色透明度没有设置

 

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_EDITOR
using UnityEditor;
#endif
//作者:小也在编程
//时间:2023年7月15日
//QQ:277381119
namespace TopGame.UI
{public class CustomHP : Image{struct DamageData{public float damage;/// /// 当前血条百分比(0到1),例如从50%掉到20%,那么这就是0.5f/// public float startValue;/// /// 受伤前,当前血量/// public float curHP;public float time;/// /// 剩余百分比(0到1),例如剩余20%血量,就是0.2f/// public float endValue;/// /// 绘制的顶点偏移/// public float vertexOffsetY;public Color color;/// /// 绘制矩形的长度/// public float rectLength{get{return Mathf.Clamp(endValue - startValue, 0, 1);}}/// /// 插值的进度 0到1/// public float lerpPer;public bool IsShow{get{return (Time.time - time) < 0.5f;}}}[Range(0f, 1f)]public float slider = 1f;public bool bReverse = false;public float m_offsetX;//x轴偏移public float m_offsetY;//y轴偏移public List m_ColorList;public float Max;public float Cur;public float CurLerpValue;public float SingleValue;public int ColorIndex;/// /// 总的血条数量/// public int MaxHPCount;/// /// 当前血条数量/// public int CurHPCount;public bool bInit = false;public float FlashingTime = 0.5f;/// /// 每次攻击伤害数据/// DamageData damageData = new DamageData();List m_vRecords = new List();private bool m_bVertexChange;protected override void Start(){base.Start();}//------------------------------------------------------void Update(){VertexLerp();ColorLerp();if (m_bVertexChange){m_bVertexChange = false;SetVerticesDirty();}if (!bInit || CurLerpValue <= Cur){return;}CurLerpValue = Mathf.Lerp(CurLerpValue, Cur, 0.5f);RefreshSlider(CurLerpValue);}//------------------------------------------------------public void Test(){float value = Random.Range(0, 100);Debug.Log("Random value:" + value);//SetLerpValue(Cur- value);SetValue(Cur - value);}//---------------


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部