备份CatanBuilding瘦身独立工程

This commit is contained in:
JSD\13999
2026-05-26 16:15:54 +08:00
commit 2d0e6a61b7
12001 changed files with 2431925 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
#if UNITY_EDITOR
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "ScriptableObjects/CubeConfigData")]
[System.Serializable]
[ExecuteInEditMode]
public class CubeConfigData : ScriptableObject
{
[Tooltip("090180270左")]
[HideInInspector]
public int PropDirection = 0;
public int PropRows = 2; // 行数
public int PropColumns = 2; // 列数
public int[] PropArr;
[NonSerialized]
public int[,] TempArr;
private int _oidPropRows = 0;
private int _oidPropColumns = 0;
void OnValidate()
{
if (PropRows != _oidPropRows)
{
if(_oidPropRows != 0)
Reset();
_oidPropRows = PropRows;
}
if (PropColumns != _oidPropColumns)
{
if(_oidPropColumns != 0)
Reset();
_oidPropColumns = PropColumns;
}
}
public void InitializePropGrid()
{
PropArr = new int[PropRows * PropColumns];
}
public void Reset()
{
PropArr = null;
TempArr = null;
}
public void Serializable2DArray(int[,] array)
{
PropArr = new int[PropRows * PropColumns];
for (int i = 0; i < PropRows; i++)
{
for (int j = 0; j < PropColumns; j++)
{
PropArr[i * PropColumns + j] = array[i, j];
}
}
}
public int[,] To2DArray()
{
int[,] array = new int[PropRows, PropColumns];
for (int i = 0; i < PropRows; i++)
{
for (int j = 0; j < PropColumns; j++)
{
array[i, j] = PropArr[i * PropColumns + j];
}
}
return array;
}
public int[,] GetArray()
{
if (TempArr != null )
{
return TempArr;
}
if (PropArr == null || PropArr.Length == 0)
{
InitializePropGrid();
}
TempArr = new int[PropRows, PropColumns];
for (int i = 0; i < PropRows; i++)
{
for (int j = 0; j < PropColumns; j++)
{
TempArr[i, j] = PropArr[i * PropColumns + j];
}
}
return TempArr;
}
public CubeConfigData Copy()
{
CubeConfigData copy = ScriptableObject.CreateInstance<CubeConfigData>();
// copy.IdData.EnableId = this.IdData.EnableId;
// copy.IdData.PropId = this.IdData.PropId;
copy.PropDirection = this.PropDirection;
copy.PropRows = this.PropRows;
copy.PropColumns = this.PropColumns;
copy.PropArr = this.PropArr;
return copy;
}
public string ToJson()
{
return JsonUtility.ToJson(this);
}
}
#endif