死亡细胞Boss血条扣血

本文介绍了死亡细胞游戏中,Boss血条减少的简单实现逻辑。通过比较当前血量与扣血前血量的差值,计算出扣血部分的长度,并在UI上动态创建显示。代码中未涉及血条尺寸的调整,建议使用对象池优化资源管理。实际效果可通过无伤视频查看。
摘要由CSDN通过智能技术生成

UI布局如下

代码如下,血条的默认高度和宽度感觉没必要改变就没做相应的设置

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class BossHpUI : MonoBehaviour
{
    public float bossHp;
    public float bossCurrentHp;
    public int buckleBlood;

    public Image currentHpUI;
    public Image currentHpNode;
    private float currentHPValue; 
    private RectTransform rect_currentHpUI;
    private RectTransform rect_currentHpNode;
    public GameObject DrawBloodUiEffect;

    private void Start() {
        InitBossHPUI(3000000);
        currentHPValue = GetBossHPValue();
        UpdateBossHp();
        rect_currentHpUI = currentHpUI.GetComponent<RectTransform>();
        rect_currentHpNode = currentHpNode.GetComponent<RectTransform>();
    }

    public void InitBo
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值