using System.Collections; using System.Collections.Generic; using UnityEngine; using TowerDefense.Agents; using TMPro; /** * 泡泡炸弹血条脚本 * @Author: chenxin * @Date: 2020-12-09 16:06:26 */ namespace KTGMGemClient { public class BubbleBombBlood : MonoBehaviour { [SerializeField] private TextMeshProUGUI bloodText; public BubbleBombAgent Target { get; set; } // Update is called once per frame private void Update() { if (Target != null) SetPos(); } /// /// 设置剩余需要Hit次数 /// /// public void SetRemainHitCount(int count) { if (count < 0) count = 0; bloodText.text = $"{count}"; } public void ShowBlood() { gameObject.SetActive(true); } public void HideBlood() { gameObject.SetActive(false); } /// /// 设置初始位置 /// public void SetPos() { Camera camera = GameObject.Find("SceneCamera3D").GetComponent(); Vector3 screenPos = camera.WorldToScreenPoint(Target.position); transform.position = screenPos; } } }