using System.Collections.Generic;
using asap.core;
using cfg;
using Script.RuntimeScript.ExplosionEffect;
using Script.RuntimeScript.GameLogic;
using UnityEngine;
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;
///
/// 道具配置
///
public DiggingItemList Config = null;
///
/// 父Grid
///
public GridData ParentGird { get; set; }
///
/// 需要开启的Grid
///
private List _needOpenGrids = new List();
///
/// 目标
///
private PropItem _targetPropItem;
///
/// 是否已经被开启
///
public bool AlreadyOpen { get; set; } = false;
#region 动态赋值数据
private int Row = 0;
private int Col = 0;
#endregion
public PropItem TargetPropItem
{
get { return _targetPropItem; }
}
public void Init(int propid,int row,int col)
{
PropId = propid;
Row = row;
Col = col;
Config = GContext.container.Resolve().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;
}
private 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;
}
}
}