Files
ft/Client/Assets/Scripts/SandDig/model/Data/GridPropData.cs
2026-06-29 21:18:33 +08:00

102 lines
2.5 KiB
C#

using System.Collections.Generic;
using asap.core;
using cfg;
using Script.RuntimeScript.GameLogic;
namespace Script.RuntimeScript.model.Data
{
public class GridPropData
{
public int PropId = 0;
public int PropDirection = 0;
public int PropRows = 2; // 行数
public int PropColumns = 2; // 列数
public int[] PropArr;
public int[,] TempArr;
/// <summary>
/// 道具配置
/// </summary>
public DiggingItemList Config = null;
/// <summary>
/// 父Grid
/// </summary>
public GridData ParentGird { get; set; }
/// <summary>
/// 需要开启的Grid
/// </summary>
private List<GridData> _needOpenGrids = new List<GridData>();
/// <summary>
/// 目标
/// </summary>
private PropItem _targetPropItem;
/// <summary>
/// 是否已经被开启
/// </summary>
public bool AlreadyOpen { get; set; } = false;
public PropItem TargetPropItem
{
get { return _targetPropItem; }
}
public void Init(int propid)
{
PropId = propid;
Config = GContext.container.Resolve<DiggingGameManager>().TableData.TbDiggingItemList.Get(PropId);
TempArr = GetArray();
}
public void AddGrid(GridData grid)
{
if (_needOpenGrids.IndexOf(grid) >= 0)
{
return;
}
DiggingGameManager.LogWarning("AddGridX::" + grid.Row + " AddGridY::" + grid.Col);
_needOpenGrids.Add(grid);
}
public void SetTargetPropItem(PropItem propItem)
{
_targetPropItem = propItem;
}
public bool IsCanOpen()
{
bool canOpen = true;
for (int i = 0; i < _needOpenGrids.Count; i++)
{
if (!_needOpenGrids[i].IsOpen)
{
canOpen = false;
AlreadyOpen = canOpen;
return canOpen;
}
}
AlreadyOpen = canOpen;
return canOpen;
}
public int[,] GetArray()
{
var arr = new int[PropRows, PropColumns];
for (int i = 0; i < PropRows; i++)
{
for (int j = 0; j < PropColumns; j++)
{
arr[i, j] = PropArr[i * PropColumns + j];
}
}
return arr;
}
}
}