using System.Collections.Generic; using UnityEngine; public class GuildAtkDefBatTreasureCell : CellView { [SerializeField] GuildAtkDefBatTreasureGrid[] grids; // 绑定5个格子 /// /// 设置本行数据 /// /// 起始格子序号(从1开始) /// 总格子数 /// 是否胜利 /// 已开启的格子字典 Key=格子编号, Value=AwardID /// 播放开启动画的格子编号(0=无) public void SetData(int startIndex, int gridCount, bool isWin, Dictionary 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; bool isOpened = openedGrids != null && openedGrids.TryGetValue(gridIndex, out awardID); bool playAnim = openAnimGridIndex > 0 && gridIndex == openAnimGridIndex; grids[i].Init(gridIndex, isWin, isOpened, (ushort)awardID, playAnim); } else { grids[i].SetActive(false); } } } /// /// 获取指定位置的格子 /// public GuildAtkDefBatTreasureGrid GetGrid(int index) { if (index >= 0 && index < grids.Length) return grids[index]; return null; } }