78 lines
2.1 KiB
C#
78 lines
2.1 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;
|
|
public GameObject Defense;
|
|
public GameObject SuperDefense;
|
|
public TextMeshProUGUI UnitInfoName;
|
|
public RectTransform InfoGroup;
|
|
public Image HideAround;
|
|
|
|
[Header("Status Area")]
|
|
[Tooltip("负面状态图标的父容器")]
|
|
public Transform StatusAreaContainer;
|
|
[Tooltip("负面状态图标预制体")]
|
|
public GameObject StatusIconPrefab;
|
|
|
|
public Color UnitBGBlue;
|
|
public Color UnitBGRed;
|
|
public Color UnitBGGreen;
|
|
public Color UnitLowHealth;
|
|
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void UpdateUnitDefense(float defenseBonus)
|
|
{
|
|
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);
|
|
}
|
|
|
|
|
|
}
|
|
}
|