Files
JJBB/Assets/Project/Script/GUI/FactionChallenge/FactionAdvanceRankItem.cs
2024-08-23 15:49:34 +08:00

64 lines
1.9 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class FactionAdvanceRankItem : UIItemBase {
public GameObject _RankIconPanel;
public List<Image> _RankIconList;
public Text _Rank;
public Text _RoleName;
public Text _RoleLevel;
public Text _RolePassedTime;
public struct FactionAdvanceRankInfoStruct
{
public int _rank;
public string _roleName;
public string _roleLevel;
public int _rolePassedTime;
public FactionAdvanceRankInfoStruct(int rank, string roleName, string roleLevel, int rolePassedTime)
{
_rank = rank;
_roleName = roleName;
_roleLevel = roleLevel;
_rolePassedTime = rolePassedTime;
}
}
public override void Show(Hashtable hash)
{
base.Show(hash);
FactionAdvanceRankInfoStruct info = (FactionAdvanceRankInfoStruct)hash["InitObj"];
if(info._rank <= 3)
{
_Rank.gameObject.SetActive(false);
_RankIconPanel.SetActive(true);
for (int index = 0; index < _RankIconList.Count; index++)
{
_RankIconList[index].gameObject.SetActive(index == info._rank - 1);
}
}
else
{
_RankIconPanel.SetActive(false);
_Rank.gameObject.SetActive(true);
_Rank.text = info._rank.ToString();
}
_RoleName.text = info._roleName;
_RoleLevel.text = info._roleLevel;
_RolePassedTime.text = GetTimeString(info._rolePassedTime);
}
public string GetTimeString(int time)
{
//DateTime passedTime = new System.DateTime(1970, 1, 1).AddSeconds(time).ToLocalTime();
return (time / 60).ToString().PadLeft(2, '0') + ":" + (time % 60).ToString().PadLeft(2, '0');
}
}