79 lines
2.1 KiB
C#
79 lines
2.1 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// 重点保护目标
|
|
/// </summary>
|
|
public class HighPriorityTarget : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 重点保护目标集合
|
|
/// </summary>
|
|
public static List<HighPriorityTarget> HighPriorityTargets = new List<HighPriorityTarget>();
|
|
/// <summary>
|
|
/// 重点设备完整度
|
|
/// </summary>
|
|
public static float EquipmentIntegrity = 1;
|
|
|
|
|
|
#region 单体保护目标属性
|
|
/// <summary>
|
|
/// 单体保护目标属性血量
|
|
/// </summary>
|
|
public float HP = 100;
|
|
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 重点目标UI看向摄像机
|
|
/// </summary>
|
|
public Transform KeyObjectiveUI;
|
|
|
|
/// <summary>
|
|
/// 爆炸预制体
|
|
/// </summary>
|
|
public GameObject explodePrefab;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Camera.main)
|
|
KeyObjectiveUI.transform.LookAt(Camera.main.transform);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 被攻击
|
|
/// </summary>
|
|
public void BeAssaulted()
|
|
{
|
|
HP -= 10;
|
|
if (HP <= 0)
|
|
{
|
|
GameObject Bao1 = Instantiate(explodePrefab, transform);
|
|
GameObject Bao2 = Instantiate(explodePrefab, transform);
|
|
GameObject Bao3 = Instantiate(explodePrefab, transform);
|
|
Vector3 v1 = new Vector3(Random.Range(0f, 1.5f), 0, Random.Range(0f, 1.5f));
|
|
Vector3 v2 = new Vector3(Random.Range(0f, 1.5f), 0, Random.Range(0f, 1.5f));
|
|
Vector3 v3 = new Vector3(Random.Range(0f, 1.5f), 0, Random.Range(0f, 1.5f));
|
|
Bao1.transform.localPosition = Vector3.zero + v1;
|
|
Bao2.transform.localPosition = Vector3.zero + v2;
|
|
Bao3.transform.localPosition = Vector3.zero + v3;
|
|
Bao1.transform.SetParent(null);
|
|
Bao2.transform.SetParent(null);
|
|
Bao3.transform.SetParent(null);
|
|
Bao1.SetActive(true);
|
|
Bao2.SetActive(true);
|
|
Bao3.SetActive(true);
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
|
|
}
|