57 lines
1.4 KiB
C#
57 lines
1.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace TH1_Renderer
|
|
{
|
|
public class CityInfoHouseMono : MonoBehaviour
|
|
{
|
|
|
|
public enum CityInfoHouseStatusEnum
|
|
{
|
|
NoExp,
|
|
Exp,
|
|
LackExp
|
|
};
|
|
|
|
public Image House;
|
|
public Image People;
|
|
|
|
|
|
public Sprite BlueHouse;
|
|
public Sprite RedHouse;
|
|
public Sprite WhiteHouse;
|
|
private bool _hasPeople;
|
|
private CityInfoHouseStatusEnum _status;
|
|
|
|
public void SetContent(bool hasPeople, CityInfoHouseStatusEnum status)
|
|
{
|
|
//Step #1 保留缓存值
|
|
_hasPeople = hasPeople;
|
|
_status = status;
|
|
//Step #2 设置house的样式
|
|
House.sprite = _status switch
|
|
{
|
|
CityInfoHouseStatusEnum.Exp => BlueHouse,
|
|
CityInfoHouseStatusEnum.LackExp => RedHouse,
|
|
_ => WhiteHouse
|
|
};
|
|
|
|
|
|
//step#3 设置people的样式
|
|
People.gameObject.SetActive(hasPeople);
|
|
if(_hasPeople)
|
|
People.color = _status switch
|
|
{
|
|
CityInfoHouseStatusEnum.NoExp => Color.black,
|
|
_ => Color.white
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
} |