religion/Assets/Scripts/抽象/HPRecorder.cs

23 lines
520 B
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// HP记录员,用来在关卡间记录玩家剩余血量等信息
/// </summary>
public class HPRecorder : MonoBehaviour
{
private MyPlayer player;
public float HPLeft;
void Start(){
if(FindObjectsOfType<HPRecorder>().Length > 1) Destroy(gameObject);
DontDestroyOnLoad(gameObject);
player = FindObjectOfType<MyPlayer>();
}
void Update(){
HPLeft = player.HPLeft;
}
}