lcy
2026-06-12 4e5820f0f8aab02b990a4edfd2477749a9f07eba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections.Generic;
using UnityEngine;
 
public class GuildAtkDefBatTreasureCell : CellView
{
    [SerializeField] GuildAtkDefBatTreasureGrid[] grids; // 绑定5个格子
 
    /// <summary>
    /// 设置本行数据
    /// </summary>
    /// <param name="startIndex">起始格子序号(从1开始)</param>
    /// <param name="gridCount">总格子数</param>
    /// <param name="isWin">是否胜利</param>
    /// <param name="openedGrids">已开启的格子字典 Key=格子编号, Value=开启记录</param>
    /// <param name="openAnimGridIndex">播放开启动画的格子编号(0=无)</param>
    public void SetData(int startIndex, int gridCount, bool isWin, Dictionary<int, GuildAtkDefBatTreasureRecord> openedGrids, int openAnimGridIndex = 0)
    {
        for (int i = 0; i < grids.Length; i++)
        {
            int gridIndex = startIndex + i;
            if (gridIndex <= gridCount)
            {
                grids[i].SetActive(true);
                int awardID = 0;
                string playerName = string.Empty;
                GuildAtkDefBatTreasureRecord treasureRecord = null;
                bool isOpened = openedGrids != null && openedGrids.TryGetValue(gridIndex, out treasureRecord);
                if (isOpened && treasureRecord != null)
                {
                    awardID = treasureRecord.AwardID;
                    playerName = treasureRecord.PlayerName;
                }
                bool playAnim = openAnimGridIndex > 0 && gridIndex == openAnimGridIndex;
                grids[i].Init(gridIndex, isWin, isOpened, (ushort)awardID, playerName, playAnim);
            }
            else
            {
                grids[i].SetActive(false);
            }
        }
    }
 
    /// <summary>
    /// 获取指定位置的格子
    /// </summary>
    public GuildAtkDefBatTreasureGrid GetGrid(int index)
    {
        if (index >= 0 && index < grids.Length)
            return grids[index];
        return null;
    }
}