基础生成跟排序,开始处理遮罩图

This commit is contained in:
SD-20250415ABSO\Administrator 2025-04-24 21:04:43 +08:00
parent 65507bbb4c
commit 11e94dd99b
5 changed files with 114 additions and 63 deletions

File diff suppressed because one or more lines are too long

View File

@ -1311,8 +1311,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 540, y: -54.83155} m_AnchoredPosition: {x: 540, y: -54.5}
m_SizeDelta: {x: 1080, y: 109.6631} m_SizeDelta: {x: 1080, y: 109}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &3182275938344351334 --- !u!1 &3182275938344351334
GameObject: GameObject:

View File

@ -7,9 +7,26 @@ namespace GameLogic
{ {
public class ActorHItem : UIWidget public class ActorHItem : UIWidget
{ {
public int m_Index;
private long m_AllScore;
protected override void OnCreate() protected override void OnCreate()
{ {
base.OnCreate(); base.OnCreate();
} }
public void OnInit(int i)
{
m_Index = i;
m_AllScore = 100 * i;
}
public long GetAllPower()
{
return m_AllScore;
}
} }
} }

View File

@ -295,7 +295,6 @@ namespace GameLogic
Dictionary<string, string> dis = new Dictionary<string, string>(); Dictionary<string, string> dis = new Dictionary<string, string>();
dis.Add("type", "hb"); dis.Add("type", "hb");
dis.Add("data", "ping"); dis.Add("data", "ping");
Log.Debug("心跳包{0}", dis.ToJson());
m_WebSocket.SendAsync(dis.ToJson()); m_WebSocket.SendAsync(dis.ToJson());
} }
}, 5, true); }, 5, true);

View File

@ -62,23 +62,22 @@ namespace GameLogic
DataGameSceneManager.Instance.SetGameState(true); DataGameSceneManager.Instance.SetGameState(true);
//// 设置顶部条 // 刷新
////m_img_topTitle.sprite = EventConts.gameStateType == GameStateType.个人赛 ? GameModule.Resource.LoadAsset<Sprite>("Z_jfc_box") : UpdateGameTiemr();
//// GameModule.Resource.LoadAsset<Sprite>("Z_jfc_box_2"); UpdateGameScoreValue();
//m_text_TopTitle.text = EventConts.gameStateType == GameStateType.个人赛 ? "发送加入即可参与" : "发送加入+数字或者加入+姓氏即可参与";
//// 设置礼物UI(不同平台)
//m_img_GiftImg.sprite = GameModule.Resource.LoadAsset<Sprite>("Z_LW_gift_" + (int)EventConts.PlatformType);
//// 刷新
//UpdateGameTiemr();
//UpdateGameScoreValue();
//RestHItemFunc(); //RestHItemFunc();
// 创建横板列表 // 创建横板列表
for (int i = 0; i < DataGameSceneManager.Instance.m_Strs.Count; i++) for (int i = 0; i < DataGameSceneManager.Instance.m_Strs.Count; i++)
{ {
ActorHItem actorHItem = CreateWidgetByPrefab<ActorHItem>(m_itemActorHItem, m_rectHPanel); ActorHItem actorHItem = CreateWidgetByPrefab<ActorHItem>(m_itemActorHItem, m_rectHPanel);
var r = actorHItem.gameObject.GetComponent<RectTransform>();
// 计算位置
r.anchorMin = new Vector2(0.5f, 0.5f);
r.anchorMax = new Vector2(0.5f, 0.5f);
r.anchoredPosition = new Vector2(0, 478 - i * (109 - 5f));
r.localPosition = new Vector3(r.localPosition.x, r.localPosition.y, 0);
actorHItem.OnInit(i);
DataGameSceneManager.Instance.m_TeamSortList.Add(actorHItem); DataGameSceneManager.Instance.m_TeamSortList.Add(actorHItem);
} }
@ -267,42 +266,51 @@ namespace GameLogic
/// </summary> /// </summary>
private void UpdateHItem() private void UpdateHItem()
{ {
//// Create a list to hold the HItemActors and their scores // Create a list to hold the HItemActors and their scores
//List<(HItemActor actor, long score)> hItemActors = new List<(HItemActor, long)>(); List<(ActorHItem actor, long score)> hItemActors = new List<(ActorHItem, long)>();
//// Populate the list with HItemActors and their scores // Populate the list with HItemActors and their scores
//for (int i = 0; i < m_rect_List.childCount; i++) for (int i = 0; i < m_rectHPanel.childCount; i++)
//{ {
// var child = m_rect_List.GetChild(i); // var child = m_rectHPanel.GetChild(i);
// if (child != null) // if (child != null)
// { // {
// var hItemActor = child.GetComponent<HItemActor>(); // var hItemActor = child.GetComponent<ActorHItem>();
// long score = hItemActor.GetAllPower(); // Assume GetScore() returns the score of the actor // long score = hItemActor.GetAllPower(); // Assume GetScore() returns the score of the actor
// hItemActors.Add((hItemActor, score)); // hItemActors.Add((hItemActor, score));
// } // }
//}
//// Sort the list based on scores in descending order if (i < DataGameSceneManager.Instance.m_TeamSortList.Count)
//hItemActors.Sort((a, b) => b.score.CompareTo(a.score)); {
var hItemActor = DataGameSceneManager.Instance.m_TeamSortList[i];
long score = hItemActor.GetAllPower(); // Assume GetScore() returns the score of the actor
hItemActors.Add((hItemActor, score));
}
//// Set the target positions for the HItemActors based on their new order
//for (int i = 0; i < hItemActors.Count; i++)
//{
// var hItemActor = hItemActors[i].actor;
// hItemActor.m_Index = i + 1;
// var rectTransform = hItemActor.GetComponent<RectTransform>();
// Vector2 targetPosition = new Vector2(0, 151 - i * 50.5945f);
// targetPositions[rectTransform] = targetPosition;
//}
//if (hItemActors.Count > 0) }
//{
// UpdateTopActorTest(hItemActors[0].actor.m_Actor); // Sort the list based on scores in descending order
//} hItemActors.Sort((a, b) => b.score.CompareTo(a.score));
//else
//{ // Set the target positions for the HItemActors based on their new order
// UpdateTopActorTest(null); for (int i = 0; i < hItemActors.Count; i++)
//} {
var hItemActor = hItemActors[i].actor;
hItemActor.m_Index = i + 1;
var rectTransform = hItemActor.gameObject.GetComponent<RectTransform>();
Vector2 targetPosition = new Vector2(0, 478 - i * (109 - 5f));
targetPositions[rectTransform] = targetPosition;
}
// if (hItemActors.Count > 0)
// {
// UpdateTopActorTest(hItemActors[0].actor.m_Actor);
// }
// else
// {
// UpdateTopActorTest(null);
// }
} }
private void CreateHItem(string oid) private void CreateHItem(string oid)