备份CatanBuilding瘦身独立工程
This commit is contained in:
11
Assets/Scripts/SandDig/model/Data/BroadData.cs
Normal file
11
Assets/Scripts/SandDig/model/Data/BroadData.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class BroadData
|
||||
{
|
||||
public int ID = 201;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/BroadData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/BroadData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75757a48f91646249ebf60d91fe6b665
|
||||
timeCreated: 1723866522
|
||||
104
Assets/Scripts/SandDig/model/Data/DinggingSceneData.cs
Normal file
104
Assets/Scripts/SandDig/model/Data/DinggingSceneData.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
using Random = System.Random;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class DinggingSceneData
|
||||
{
|
||||
public string BoxPositionJson;
|
||||
public string AllBroadJson;
|
||||
public string AllPropJson;
|
||||
public string AllCubeJson;
|
||||
public string AllTempJson;
|
||||
|
||||
private BroadData[] _allBroadData;
|
||||
private GridData[] _allGridData;
|
||||
private PropData[] _allPropData;
|
||||
private List<List<PropTempData>> _allPropTempData;
|
||||
//任务目标宝箱位置
|
||||
private Vector3 _taskBoxPositon = Vector3.zero;
|
||||
|
||||
|
||||
public void AnalysisData(List<ServerGridData> serverGrid)
|
||||
{
|
||||
_taskBoxPositon = JsonConvert.DeserializeObject<Vector3>(BoxPositionJson);
|
||||
_allBroadData = JsonConvert.DeserializeObject<BroadData[]>(AllBroadJson);
|
||||
_allGridData = JsonConvert.DeserializeObject<GridData[]>(AllCubeJson);
|
||||
_allPropData = JsonConvert.DeserializeObject<PropData[]>(AllPropJson);
|
||||
_allPropTempData = JsonConvert.DeserializeObject<List<List<PropTempData>>>(AllTempJson);
|
||||
|
||||
GridData gData;
|
||||
for (int i = 0; i < _allGridData.Length; i++)
|
||||
{
|
||||
gData = _allGridData[i];
|
||||
gData.Init();
|
||||
for (int j = 0; j < serverGrid.Count; j++)
|
||||
{
|
||||
if (serverGrid[j].Row == gData.Row && serverGrid[j].Col == gData.Col)
|
||||
{
|
||||
gData.IsOpen = serverGrid[j].IsOpen == 1;
|
||||
gData.hasClickCount = serverGrid[j].hasClickCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
_allGridData = new GridData[0];
|
||||
_allPropData = new PropData[0];
|
||||
}
|
||||
public GridData GetGridData(int row, int col)
|
||||
{
|
||||
GridData gData;
|
||||
for (int i = 0; i < _allGridData.Length; i++)
|
||||
{
|
||||
gData = _allGridData[i];
|
||||
if (gData.Row == row && gData.Col == col)
|
||||
{
|
||||
return gData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Vector3 GetTaskPosPositon()
|
||||
{
|
||||
return _taskBoxPositon;
|
||||
}
|
||||
|
||||
public BroadData[] GetAllBroadData()
|
||||
{
|
||||
return _allBroadData;
|
||||
}
|
||||
public GridData[] GetAllGridData()
|
||||
{
|
||||
return _allGridData;
|
||||
}
|
||||
|
||||
public PropData[] GetAllPropData()
|
||||
{
|
||||
return _allPropData;
|
||||
}
|
||||
|
||||
public List<PropTempData> GetAllPropTempData(int index)
|
||||
{
|
||||
if (_allPropTempData == null || _allPropTempData.Count == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
if (index >= _allPropTempData.Count)
|
||||
{
|
||||
index = GetOnePropTempDataIndex();
|
||||
}
|
||||
return _allPropTempData[index];
|
||||
}
|
||||
public int GetOnePropTempDataIndex()
|
||||
{
|
||||
return UnityEngine.Random.Range(0, _allPropTempData.Count);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8aa6471ba052426b8ac286d5b4b07e84
|
||||
timeCreated: 1723806234
|
||||
39
Assets/Scripts/SandDig/model/Data/GridData.cs
Normal file
39
Assets/Scripts/SandDig/model/Data/GridData.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class GridData
|
||||
{
|
||||
public int PropId = 0;
|
||||
public bool IsBorder = false;
|
||||
public bool DoubleClick = false;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
public int ID = 1;
|
||||
public int Row = 0;
|
||||
public int Col = 0;
|
||||
public GridPropData ConfigData;
|
||||
|
||||
public bool IsOpen { get; set; } = false;
|
||||
/// <summary>
|
||||
/// 已经点击的个数
|
||||
/// </summary>
|
||||
public int hasClickCount = 0;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Row = (int)LocalPos.x;
|
||||
Col = (int)LocalPos.y;
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
ServerGridData data = new ServerGridData();
|
||||
data.Row = Row;
|
||||
data.Col = Col;
|
||||
data.IsOpen = IsOpen ? 1 : 0;
|
||||
data.hasClickCount = hasClickCount;
|
||||
return data.ToJson();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/GridData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/GridData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3fb9576d851440798d5655c115edabdd
|
||||
timeCreated: 1723805269
|
||||
111
Assets/Scripts/SandDig/model/Data/GridPropData.cs
Normal file
111
Assets/Scripts/SandDig/model/Data/GridPropData.cs
Normal file
@@ -0,0 +1,111 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/GridPropData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/GridPropData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a89fdc76de8c4de8ab60308ee52bcfda
|
||||
timeCreated: 1724209029
|
||||
14
Assets/Scripts/SandDig/model/Data/PropData.cs
Normal file
14
Assets/Scripts/SandDig/model/Data/PropData.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using Script.RuntimeScript.GameLogic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class PropData
|
||||
{
|
||||
public int PropId = 0;
|
||||
public Vector3 LocalPos = Vector3.zero;
|
||||
public bool IsOk = false;
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/PropData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/PropData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: db73383b55f74e61b1f3a02f6fb15191
|
||||
timeCreated: 1723805279
|
||||
11
Assets/Scripts/SandDig/model/Data/PropTempData.cs
Normal file
11
Assets/Scripts/SandDig/model/Data/PropTempData.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
public class PropTempData
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public int PropId;
|
||||
public GridPropData ConfigData;
|
||||
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/SandDig/model/Data/PropTempData.cs.meta
Normal file
3
Assets/Scripts/SandDig/model/Data/PropTempData.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c58dfc94ed294c468bfdc8e65e0c9952
|
||||
timeCreated: 1724226589
|
||||
72
Assets/Scripts/SandDig/model/Data/SandDigServerData.cs
Normal file
72
Assets/Scripts/SandDig/model/Data/SandDigServerData.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace Script.RuntimeScript.model.Data
|
||||
{
|
||||
[System.Serializable]
|
||||
public class SandDigServerData
|
||||
{
|
||||
public int ClampId = 0;
|
||||
public int ClickCount = 0;
|
||||
/// <summary>
|
||||
/// 已经获得的目标道具
|
||||
/// </summary>
|
||||
public List<int> PassPropIds = new List<int>();
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
PassPropIds.Clear();
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ServerGridData
|
||||
{
|
||||
public int Row = 0;
|
||||
public int Col = 0;
|
||||
public int IsOpen = 0;
|
||||
public int hasClickCount = 0;
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return JsonConvert.SerializeObject(this);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SaveDataJson
|
||||
{
|
||||
public int ActivityId = 0;
|
||||
public string SandDigServerData;
|
||||
public string AllGridJson;
|
||||
public int TempIndex = -1;
|
||||
|
||||
//public string AllGridPropsJson;
|
||||
|
||||
public SandDigServerData GetSerializableData()
|
||||
{
|
||||
return JsonConvert.DeserializeObject<SandDigServerData>(SandDigServerData);
|
||||
}
|
||||
|
||||
public ServerGridData[] GetSerializableGridData()
|
||||
{
|
||||
if (string.IsNullOrEmpty(AllGridJson))
|
||||
return new ServerGridData[0];
|
||||
return JsonConvert.DeserializeObject<ServerGridData[]>(AllGridJson);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class SaveDigCountJson
|
||||
{
|
||||
public int ActivityId = 0;
|
||||
public int DigCount = 0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c63d6ecedfd442f83e59df31144fb65
|
||||
timeCreated: 1724898766
|
||||
Reference in New Issue
Block a user