备份CatanBuilding瘦身独立工程
This commit is contained in:
83
Assets/Scripts/UI/Social/SocialFriendItem.cs
Normal file
83
Assets/Scripts/UI/Social/SocialFriendItem.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
using asap.core;
|
||||
using game;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class SocialFriendItem : PanelItemBase<SocialFriendItemData>
|
||||
{
|
||||
public GameObject bg_myself;
|
||||
List<GameObject> rank = new List<GameObject>();
|
||||
public TMP_Text text_rank;
|
||||
public TMP_Text text_name;
|
||||
public Head head;
|
||||
public TMP_Text lv_text_count;
|
||||
public TMP_Text infiniteBuildingLevel_text_count;
|
||||
public GameObject icon_skyscraper;
|
||||
string playFabId;
|
||||
bool isInit;
|
||||
void InitPanel()
|
||||
{
|
||||
bg_myself = transform.Find("bg_myself").gameObject;
|
||||
text_rank = transform.Find("rank/rank/text_rank").GetComponent<TMP_Text>();
|
||||
text_name = transform.Find("text_name").GetComponent<TMP_Text>();
|
||||
head = transform.Find("btn_head").GetComponent<Head>();
|
||||
//reward_panel = transform.Find("reward_panel").gameObject;
|
||||
lv_text_count = transform.Find("icon_rank/text_num").GetComponent<TMP_Text>();
|
||||
infiniteBuildingLevel_text_count = transform.Find("icon_skyscraper/text_num").GetComponent<TMP_Text>();
|
||||
icon_skyscraper = transform.Find("icon_skyscraper").gameObject;
|
||||
Transform rank_panel = transform.Find("rank");
|
||||
rank.Clear();
|
||||
for (int i = 0; i < rank_panel.childCount; i++)
|
||||
{
|
||||
rank.Add(rank_panel.GetChild(i).gameObject);
|
||||
}
|
||||
isInit = true;
|
||||
}
|
||||
public override void OnInit()
|
||||
{
|
||||
if (!isInit)
|
||||
{
|
||||
InitPanel();
|
||||
}
|
||||
IUserService userService = GContext.container.Resolve<IUserService>();
|
||||
playFabId = data.playFabId;
|
||||
bg_myself.SetActive(data.playFabId == userService.UserId);
|
||||
for (int i = 0; i < rank.Count - 1; i++)
|
||||
{
|
||||
rank[i].SetActive(data.rank == i + 1);
|
||||
}
|
||||
rank[^1].SetActive(data.rank >= rank.Count);
|
||||
text_rank.text = data.rank.ToString();
|
||||
|
||||
lv_text_count.text = data.lv.ToString();
|
||||
infiniteBuildingLevel_text_count.text = data.infiniteBuildingLevel.ToString();
|
||||
|
||||
if (data.infiniteBuildingLevel > 0)
|
||||
{
|
||||
if (icon_skyscraper != null)
|
||||
{
|
||||
icon_skyscraper.SetActive(true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (icon_skyscraper != null)
|
||||
{
|
||||
icon_skyscraper.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
text_name.text = data.displayName;
|
||||
head.SetData(data.avatarUrl);
|
||||
}
|
||||
}
|
||||
public class SocialFriendItemData
|
||||
{
|
||||
public int rank;
|
||||
public int lv = 1;
|
||||
public int infiniteBuildingLevel = 0;
|
||||
public string playFabId;
|
||||
public string displayName;
|
||||
public string avatarUrl;
|
||||
}
|
||||
Reference in New Issue
Block a user