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.
58 lines
1.9 KiB
58 lines
1.9 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using TMPro;
|
|
public class CharacterUIManager : MonoBehaviour
|
|
{
|
|
PointsBar healthBar;
|
|
PointsBar poiseBar;
|
|
MovementBar movementBar;
|
|
public GameObject healthDamageAmountPrefab;
|
|
public GameObject poiseDamageAmountPrefab;
|
|
public GameObject outOfMovementPrefab;
|
|
private void Start()
|
|
{
|
|
healthBar = transform.GetChild(0).GetComponent<PointsBar>();
|
|
poiseBar = transform.GetChild(1).GetComponent<PointsBar>();
|
|
movementBar = transform.GetChild(2).GetComponent<MovementBar>();
|
|
}
|
|
public void ChangePoints(int amount, float ratio, int type)
|
|
{
|
|
PointsBar pointsBar = null;
|
|
float deltaY = 0;
|
|
if(type == 0)
|
|
{
|
|
pointsBar = healthBar;
|
|
deltaY = 0.5f;
|
|
}
|
|
else if(type == 1)
|
|
{
|
|
pointsBar = poiseBar;
|
|
deltaY = 0.3f;
|
|
}
|
|
else return;
|
|
pointsBar.ChangeUI(ratio); //根据血条或韧性条改变UI显示
|
|
if(amount <= 0)
|
|
{
|
|
Vector2 position = transform.position;
|
|
position.x += 0.5f;
|
|
position.y += deltaY;
|
|
FloatingDigit(amount,healthDamageAmountPrefab,position);
|
|
}
|
|
}
|
|
public void OutOfMovement()
|
|
{
|
|
Vector2 position = transform.position;
|
|
position.x -= 0.5f;
|
|
position.y += 0.4f;
|
|
GameObject instance = Instantiate(outOfMovementPrefab, position, Quaternion.identity);
|
|
GameObject text = instance.transform.GetChild(0).gameObject;
|
|
}
|
|
void FloatingDigit(int amount, GameObject digitPrefab, Vector2 position) //显示漂浮的数字
|
|
{
|
|
GameObject instance = Instantiate(digitPrefab,position,Quaternion.identity);
|
|
GameObject text = instance.transform.GetChild(0).gameObject;
|
|
text.GetComponent<TMP_Text>().text = amount.ToString();
|
|
}
|
|
}
|