修改天梯UI数据,及任务的UI数据的初步同步
This commit is contained in:
@@ -12,19 +12,21 @@ namespace TcgEngine.UI
|
||||
public class LeaderboardPanel : UIPanel
|
||||
{
|
||||
#region 默认排行榜
|
||||
[Header("-----默认排行榜参数------")]
|
||||
public RectTransform content;
|
||||
public RankLine line_template;
|
||||
public RankLine my_line;
|
||||
public float line_spacing = 80f;
|
||||
[Header("----------------------")]
|
||||
#endregion
|
||||
|
||||
#region 天梯排行榜
|
||||
|
||||
[Header("-----天梯排行榜参数------")]
|
||||
public RectTransform ladderContent;
|
||||
public LadderRankLine ladderLine_template;
|
||||
public LadderRankLine my_ladderLine;
|
||||
public float ladderLine_spacing = 120f;
|
||||
|
||||
[Header("----------------------")]
|
||||
#endregion
|
||||
|
||||
public Text test_text;
|
||||
@@ -35,18 +37,17 @@ namespace TcgEngine.UI
|
||||
|
||||
public List<RankLine> lines = new List<RankLine>();
|
||||
public List<LadderRankLine> ladderLines = new List<LadderRankLine>();
|
||||
|
||||
[Header("返回主页")]
|
||||
public Button returnToHome_button;
|
||||
|
||||
private const string DefaultAvatarId = "bear";
|
||||
|
||||
private static LeaderboardPanel instance;
|
||||
|
||||
#region 临时方法
|
||||
|
||||
[SerializeField] private Button defaultRankButton;
|
||||
[SerializeField] private Button ladderRankButton;
|
||||
|
||||
#endregion
|
||||
|
||||
[Header("管理指定组件")]
|
||||
public GameObject[] hideGameObject;
|
||||
private bool isHideObject = false;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
@@ -55,29 +56,34 @@ namespace TcgEngine.UI
|
||||
//lines = scroll_content.GetComponentsInChildren<RankLine>();
|
||||
|
||||
my_line.onClick += OnClickLine;
|
||||
my_ladderLine.onClick += OnClickRankLine;
|
||||
InitLines();
|
||||
|
||||
#region 临时方法
|
||||
returnToHome_button.onClick.AddListener(OnReturnToHome);
|
||||
}
|
||||
|
||||
defaultRankButton.onClick.AddListener(() =>
|
||||
/// <summary>
|
||||
/// 返回主页
|
||||
/// </summary>
|
||||
public void OnReturnToHome()
|
||||
{
|
||||
isHideObject = !isHideObject;
|
||||
if (isHideObject)
|
||||
{
|
||||
isLadderRank = false;
|
||||
RankPanelColl();
|
||||
});
|
||||
ladderRankButton.onClick.AddListener(() =>
|
||||
Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
isLadderRank = true;
|
||||
RankPanelColl();
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
Hide();
|
||||
}
|
||||
foreach (var obj in hideGameObject)
|
||||
{
|
||||
obj.SetActive(!isHideObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void InitLines()
|
||||
@@ -110,7 +116,7 @@ namespace TcgEngine.UI
|
||||
ladderLines.Add(line);
|
||||
}
|
||||
|
||||
ladderContent.sizeDelta = new Vector2(content.sizeDelta.x, ladderNlines * line_spacing + 20f);
|
||||
ladderContent.sizeDelta = new Vector2(content.sizeDelta.x, ladderNlines * ladderLine_spacing + 20f);
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -130,14 +136,14 @@ namespace TcgEngine.UI
|
||||
|
||||
private LadderRankLine LadderAddLine(LadderRankLine template, int index)
|
||||
{
|
||||
Vector2 pos = Vector2.down * ladderLine_spacing;
|
||||
Vector2 pos = Vector2.down * (ladderLine_spacing-75);
|
||||
GameObject line = Instantiate(template.gameObject, ladderContent);
|
||||
RectTransform rtrans = line.GetComponent<RectTransform>();
|
||||
LadderRankLine lrline = line.GetComponent<LadderRankLine>();
|
||||
rtrans.anchorMin = new Vector2(0.5f, 1);
|
||||
rtrans.anchorMax = new Vector2(0.5f, 1f);
|
||||
rtrans.anchoredPosition = pos + Vector2.down * index * ladderLine_spacing;
|
||||
lrline.onClick += OnClickLine;
|
||||
rtrans.anchoredPosition = pos + Vector2.down * index * (ladderLine_spacing + 15);
|
||||
lrline.onClick += OnClickRankLine;
|
||||
return lrline;
|
||||
}
|
||||
|
||||
@@ -192,7 +198,7 @@ namespace TcgEngine.UI
|
||||
|
||||
private async void RefreshLadderPanel()
|
||||
{
|
||||
my_line.Hide();
|
||||
my_ladderLine.Hide();
|
||||
foreach (LadderRankLine line in ladderLines)
|
||||
line.Hide();
|
||||
|
||||
@@ -217,8 +223,6 @@ namespace TcgEngine.UI
|
||||
int previous_rank = 0;
|
||||
int previous_index = 0;
|
||||
|
||||
|
||||
|
||||
if (users == null || users.Length == 0)
|
||||
{
|
||||
Debug.LogError("玩家数据为空");
|
||||
@@ -226,6 +230,7 @@ namespace TcgEngine.UI
|
||||
}
|
||||
|
||||
Debug.Log($"收到排行榜数据,共 {users.Length} 条");
|
||||
ladderContent.sizeDelta = new Vector2(content.sizeDelta.x, users.Length * (ladderLine_spacing + 20f));
|
||||
|
||||
foreach (LadderLeaderboardEntry rankData in sorted_users)
|
||||
{
|
||||
@@ -249,44 +254,49 @@ namespace TcgEngine.UI
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RankPanelColl()
|
||||
{
|
||||
if (isLadderRank)
|
||||
{
|
||||
ladderRank.Show();
|
||||
var lColor = ladderRankButton.image.color;
|
||||
lColor.a = 0.5f;
|
||||
ladderRankButton.image.color = lColor;
|
||||
|
||||
|
||||
defaultRank.Hide();
|
||||
var dColor = defaultRankButton.image.color;
|
||||
dColor.a = 1f;
|
||||
defaultRankButton.image.color = dColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
ladderRank.Hide();
|
||||
var lColor = ladderRankButton.image.color;
|
||||
lColor.a = 1f;
|
||||
ladderRankButton.image.color = lColor;
|
||||
|
||||
defaultRank.Show();
|
||||
var dColor = defaultRankButton.image.color;
|
||||
dColor.a = 0.5f;
|
||||
defaultRankButton.image.color = dColor;
|
||||
|
||||
}
|
||||
ladderRankButton.enabled = !isLadderRank;
|
||||
defaultRankButton.enabled = isLadderRank;
|
||||
}
|
||||
//
|
||||
// private void RankPanelColl()
|
||||
// {
|
||||
// if (isLadderRank)
|
||||
// {
|
||||
// ladderRank.Show();
|
||||
// var lColor = ladderRankButton.image.color;
|
||||
// lColor.a = 0.5f;
|
||||
// ladderRankButton.image.color = lColor;
|
||||
//
|
||||
//
|
||||
// defaultRank.Hide();
|
||||
// var dColor = defaultRankButton.image.color;
|
||||
// dColor.a = 1f;
|
||||
// defaultRankButton.image.color = dColor;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ladderRank.Hide();
|
||||
// var lColor = ladderRankButton.image.color;
|
||||
// lColor.a = 1f;
|
||||
// ladderRankButton.image.color = lColor;
|
||||
//
|
||||
// defaultRank.Show();
|
||||
// var dColor = defaultRankButton.image.color;
|
||||
// dColor.a = 0.5f;
|
||||
// defaultRankButton.image.color = dColor;
|
||||
//
|
||||
// }
|
||||
// ladderRankButton.enabled = !isLadderRank;
|
||||
// defaultRankButton.enabled = isLadderRank;
|
||||
// }
|
||||
|
||||
private void OnClickLine(string username)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnClickRankLine(string username)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
private Sprite GetAvatar(string id)
|
||||
{
|
||||
@@ -301,7 +311,6 @@ namespace TcgEngine.UI
|
||||
base.Show(instant);
|
||||
RefreshPanel();
|
||||
RefreshLadderPanel();
|
||||
RankPanelColl();
|
||||
}
|
||||
|
||||
public void OnClickBack()
|
||||
|
||||
Reference in New Issue
Block a user