using System.Collections.Generic;
|
using UnityEngine;
|
using System;
|
public class EquipRecordCell : MonoBehaviour
|
{
|
[SerializeField] EquipRecordItem fromEquip;
|
[SerializeField] EquipRecordItem toEquip;
|
[SerializeField] ImageEx imgWear;
|
[SerializeField] ImageEx imgDecompose;
|
[SerializeField] TextEx txtFightPoint;
|
[SerializeField] TextEx txtTime;
|
public void Display(int index, List<EquipRecordManager.EquipRecordData> list)
|
{
|
if (list == null || index >= list.Count || index < 0)
|
return;
|
var data = list[index];
|
int state = GetState(data);
|
if (state == 0)
|
{
|
fromEquip.SetActive(false);
|
toEquip.SetActive(false);
|
imgWear.SetActive(false);
|
imgDecompose.SetActive(false);
|
}
|
else
|
{
|
fromEquip.SetActive(state == 1 || state == 2 || state == 3);
|
toEquip.SetActive(state == 1);
|
imgDecompose.SetActive(state == 2);
|
imgWear.SetActive(state == 3);
|
fromEquip.Display(state == 1 ? data.oldEquip : data.newEquip);
|
toEquip.Display(data.newEquip);
|
}
|
txtFightPoint.text = StringUtility.Concat("+", UIHelper.ReplaceLargeNum(data.fightPower));
|
txtTime.text = GetTime(data.timestamp);
|
}
|
|
// 0-不显示 1-交换 2-分解 3-首次穿装备
|
private int GetState(EquipRecordManager.EquipRecordData data)
|
{
|
if (data == null || data.newEquip == null)
|
return 0;
|
if (data.oldEquip == null)
|
return 3;
|
if (data.recordType == (int)EquipRecordManager.EquipOPType.Equip)
|
return 1;
|
if (data.recordType == (int)EquipRecordManager.EquipOPType.Decompose)
|
return 2;
|
return 0;
|
}
|
|
private string GetTime(int timestamp)
|
{
|
DateTime dateTime = TimeUtility.GetTime((uint)timestamp);
|
return dateTime.ToString("MM-dd HH:mm:ss");
|
}
|
}
|