You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
932 B
39 lines
932 B
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class PointsBar : MonoBehaviour
|
|
{
|
|
//导入血条和韧性条
|
|
public Image points;
|
|
public Image effect;
|
|
float ratio;
|
|
public float recoverRate = 0.4f;
|
|
public float damageRate = 0.3f;
|
|
void Update()
|
|
{
|
|
if(points.fillAmount < ratio)
|
|
{
|
|
if(points.fillAmount + recoverRate < ratio)
|
|
points.fillAmount += recoverRate * Time.deltaTime;
|
|
else
|
|
points.fillAmount = ratio;
|
|
}
|
|
else
|
|
points.fillAmount = ratio;
|
|
if(effect.fillAmount > points.fillAmount)
|
|
{
|
|
effect.fillAmount -= damageRate * Time.deltaTime;
|
|
}
|
|
else
|
|
effect.fillAmount = points.fillAmount;
|
|
}
|
|
|
|
public void ChangeUI(float newRatio)
|
|
{
|
|
ratio = newRatio;
|
|
}
|
|
}
|