92 lines
2.7 KiB
C#
92 lines
2.7 KiB
C#
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using TH1_Logic.Core;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
public class UnitMono : MonoBehaviour
|
||
{
|
||
public GameObject RODebugText;
|
||
public GameObject AttackHighlight;
|
||
public GameObject SelectHighlight;
|
||
public GameObject AllyHighlight;
|
||
public SpriteRenderer SpriteRenderer;
|
||
public TextMeshProUGUI HealthText;
|
||
public TextMeshProUGUI DebugText;
|
||
//public SpriteRenderer UnitInfoBGImg;
|
||
public Image UnitInfoBG;
|
||
public Image ChessBG;
|
||
public Image ChessImg;
|
||
public GameObject UnionBG;
|
||
//可选:UnionBG 上的 Image 引用,用于改色;不拖时会通过 GetComponent 兜底
|
||
public Image UnionBGImage;
|
||
public GameObject Defense;
|
||
public GameObject SuperDefense;
|
||
public TextMeshProUGUI UnitInfoName;
|
||
public RectTransform InfoGroup;
|
||
public Image HideAround;
|
||
|
||
[Header("Damage Preview")]
|
||
[Tooltip("伤害预测面板(含背景Image)")]
|
||
public GameObject DamagePreviewPanel;
|
||
[Tooltip("伤害预测文本(挂在Panel下)")]
|
||
public TextMeshProUGUI DamagePreviewText;
|
||
|
||
[Header("Status Area")]
|
||
[Tooltip("负面状态图标的父容器")]
|
||
public Transform StatusAreaContainer;
|
||
[Tooltip("负面状态图标预制体")]
|
||
public GameObject StatusIconPrefab;
|
||
|
||
public Color UnitBGBlue;
|
||
public Color UnitBGRed;
|
||
public Color UnitBGGreen;
|
||
public Color UnitLowHealth;
|
||
|
||
//UnionBG 正常显示颜色(同盟)
|
||
public Color UnionBGNormalColor = Color.white;
|
||
//UnionBG 背盟显示颜色(刚背盟还未脱离同盟关系记录)
|
||
public Color UnionBGBetrayColor = Color.black;
|
||
|
||
void Start()
|
||
{
|
||
|
||
}
|
||
|
||
// Update is called once per frame
|
||
void Update()
|
||
{
|
||
|
||
}
|
||
|
||
public void UpdateUnitDefense(float defenseBonus)
|
||
{
|
||
if (Defense == null || SuperDefense == null || InfoGroup == null) return;
|
||
bool defense = Defense.activeSelf;
|
||
bool superdefense = SuperDefense.activeSelf;
|
||
bool noDefense = !defense && !superdefense;
|
||
bool newDefense = false;
|
||
bool newSuperDefense = false;
|
||
bool newNoDefense = false;
|
||
|
||
|
||
|
||
if (defenseBonus > 1.4f && defenseBonus < 3.9f)
|
||
newDefense = true;
|
||
if(defenseBonus < 1.01f && defenseBonus > 0.99f)
|
||
newNoDefense = true;
|
||
if (Mathf.Approximately(defenseBonus, 4.0f))
|
||
newSuperDefense = true;
|
||
|
||
if (defense != newDefense || superdefense != newSuperDefense || noDefense != newNoDefense)
|
||
{
|
||
Defense.SetActive(newDefense);
|
||
SuperDefense.SetActive(newSuperDefense);
|
||
LayoutRebuilder.ForceRebuildLayoutImmediate(InfoGroup);
|
||
}
|
||
|
||
|
||
}
|
||
}
|