111 lines
2.8 KiB
C#
111 lines
2.8 KiB
C#
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;
|
|
|
|
/// <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;
|
|
|
|
#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<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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|
|
} |