using AdamSync;
using System.Collections.Generic;
using UnityEngine;
///
/// 重点保护目标
///
public class HighPriorityTarget : MonoBehaviour
{
///
/// 重点保护目标集合
///
public static List HighPriorityTargets = new List();
///
/// 重点设备完整度
///
public static float EquipmentIntegrity = 1;
///
/// 编号
///
public string Number;
#region 单体保护目标属性
///
/// 单体保护目标属性血量
///
public float HP = 100;
#endregion
///
/// 重点目标UI看向摄像机
///
public Transform KeyObjectiveUI;
///
/// 爆炸预制体
///
public GameObject explodePrefab;
///
/// 完整模型
///
public GameObject ModerFull;
///
/// 损坏模型
///
public GameObject ModerDamage;
// 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);
}
///
/// 被攻击
///
/// 被攻击时触发点位置
/// 是否向外发送同步消息
public void BeAssaulted(Vector3 Pos, bool isSend, int hp = 0)
{
if (isSend)
{
HP -= 10;
GameObject Bao = Instantiate(explodePrefab, transform);
Bao.transform.localPosition = Pos;
Bao.transform.SetParent(null);
Bao.SetActive(true);
string nowData = GetSyncDis(Pos);
Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
}
else
{
HP = hp;
}
if (HP < 50)
{
ModerFull.SetActive(false);
ModerDamage.SetActive(true);
}
}
protected string GetSyncDis(Vector3 pos)
{
return string.Format("{0},{1},{2},{3},{4},{5}", "KeyTarget", Number, HP, pos.x, pos.y, pos.z);
}
}