wangguan
2020-12-11 c0b61bfa55861463b05a332010aedb02695d2526
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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();
        }
 
        /// <summary>
        /// 设置剩余需要Hit次数
        /// </summary>
        /// <param name="count"></param>
        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);
        }
 
        /// <summary>
        /// 设置初始位置
        /// </summary>
        public void SetPos()
        {
            Camera camera = GameObject.Find("SceneCamera3D").GetComponent<Camera>();
            Vector3 screenPos = camera.WorldToScreenPoint(Target.position);
            transform.position = screenPos;
        }
    }
}