初版石头功能可用

This commit is contained in:
2026-02-04 23:53:16 +08:00
parent b054e2ee86
commit 1d1ea4488c
38 changed files with 1421 additions and 2687 deletions
@@ -15,7 +15,7 @@ MonoBehaviour:
m_DefaultGroup: 09546aca93a801441859af2a811fe53b
m_currentHash:
serializedVersion: 2
Hash: b53f304e2338ce70db1045411843d66c
Hash: 23f8c5ccd7cce25d443750000db64bc9
m_OptimizeCatalogSize: 0
m_BuildRemoteCatalog: 0
m_BundleLocalCatalog: 0
@@ -72,6 +72,11 @@ MonoBehaviour:
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
- m_GUID: 0519c41f06740d64390437a889eee2d9
m_Address: "BlockPuzzle/\u6309\u94AE\u7F29\u7565\u56FE"
m_ReadOnly: 0
m_SerializedLabels: []
FlaggedDuringContentUpdateRestriction: 0
m_ReadOnly: 0
m_Settings: {fileID: 11400000, guid: 77169ce22e430f64fb36c771815a4a7b, type: 2}
m_SchemaSet:
@@ -6,14 +6,26 @@ namespace AibisDream.SystemEditor
[CustomEditor(typeof(GridVisualizer))]
public class GridVisualizerEditor : Editor
{
private SerializedProperty sortingLayerProperty;
private SerializedProperty sortingOrderProperty;
private void OnEnable()
{
sortingLayerProperty = serializedObject.FindProperty("sortingLayer");
sortingOrderProperty = serializedObject.FindProperty("sortingOrder");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var example = (GridVisualizer)target;
serializedObject.Update();
EditorGUILayout.LabelField("层级设置", EditorStyles.boldLabel);
example.sortingLayer = EditorKit.SortingLayerField("目标层级", example.sortingLayer);
example.sortingOrder = EditorGUILayout.IntField("层级顺序", example.sortingOrder);
EditorKit.SortingLayerField(new GUIContent("目标层级"), sortingLayerProperty);
EditorGUILayout.PropertyField(sortingOrderProperty, new GUIContent("层级顺序"));
serializedObject.ApplyModifiedProperties();
}
}
}
+1 -13
View File
@@ -13,7 +13,6 @@ GameObject:
- component: {fileID: 1224845219232276460}
- component: {fileID: 4646419983055809048}
- component: {fileID: 4283988294842430357}
- component: {fileID: 8308584449185143604}
m_Layer: 0
m_Name: BlockShape
m_TagString: Untagged
@@ -68,6 +67,7 @@ MonoBehaviour:
shapeDescription:
states: []
buttonImagePath:
detailImagePath:
--- !u!60 &1224845219232276460
PolygonCollider2D:
m_ObjectHideFlags: 0
@@ -179,15 +179,3 @@ MonoBehaviour:
dragLayerOrder: 25
idleLayerId: 1134468525
idleLayerOrder: 11
--- !u!210 &8308584449185143604
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1355800832498282156}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 0
m_SortAtRoot: 0
@@ -93,6 +93,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8033066979870906055}
- component: {fileID: 3407210902441740410}
m_Layer: 0
m_Name: "\u5171\u9E23\u8154"
m_TagString: Untagged
@@ -118,6 +119,18 @@ Transform:
- {fileID: 2777847432519987012}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &3407210902441740410
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5189088947080543749}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &6516789740179254263
GameObject:
m_ObjectHideFlags: 0
@@ -429,6 +429,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 1219879511032645539}
- component: {fileID: 4679671145176646940}
m_Layer: 0
m_Name: "\u52A8\u5E73\u8861\u98DE\u8F6E\u7EC4"
m_TagString: Untagged
@@ -461,6 +462,18 @@ Transform:
- {fileID: 3972042556459422518}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &4679671145176646940
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6540296062082269002}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &6726549844697620442
GameObject:
m_ObjectHideFlags: 0
@@ -1,6 +1,6 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &8798820299727595205
--- !u!1 &1444101771948321629
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
@@ -8,37 +8,37 @@ GameObject:
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1333018235521955266}
- component: {fileID: 6942524670884740071}
- component: {fileID: 3013593665482770009}
- component: {fileID: 3486306133740348940}
m_Layer: 0
m_Name: "\u60EF\u6027\u7A33\u538B\u5668"
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1333018235521955266
--- !u!4 &3013593665482770009
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798820299727595205}
m_GameObject: {fileID: 1444101771948321629}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.585, y: 0.585, z: 0}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_Father: {fileID: 1333018235521955266}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6942524670884740071
--- !u!212 &3486306133740348940
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798820299727595205}
m_GameObject: {fileID: 1444101771948321629}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
@@ -84,3 +84,48 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &8798820299727595205
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1333018235521955266}
- component: {fileID: 4889412042225234040}
m_Layer: 0
m_Name: "\u60EF\u6027\u7A33\u538B\u5668"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1333018235521955266
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798820299727595205}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0.585, y: 0.585, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 3013593665482770009}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &4889412042225234040
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8798820299727595205}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
@@ -9,7 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 3103684059536612534}
- component: {fileID: 7891746101094893876}
- component: {fileID: 8023670165185557050}
m_Layer: 0
m_Name: "\u6563\u70ED\u6761"
m_TagString: Untagged
@@ -29,17 +29,62 @@ Transform:
m_LocalPosition: {x: 1.755, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 5891729032255803302}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &7891746101094893876
SpriteRenderer:
--- !u!210 &8023670165185557050
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2459254411633306081}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &6837666022557684452
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 5891729032255803302}
- component: {fileID: 3190295386551606174}
m_Layer: 0
m_Name: "\u6563\u70ED\u6761"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &5891729032255803302
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6837666022557684452}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 3103684059536612534}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &3190295386551606174
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6837666022557684452}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@@ -9,7 +9,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 4003383592530614652}
- component: {fileID: 4540708111873067341}
- component: {fileID: 4034973304588068555}
m_Layer: 0
m_Name: "\u6563\u70ED\u7CFB\u7EDF"
m_TagString: Untagged
@@ -29,17 +29,62 @@ Transform:
m_LocalPosition: {x: 1.17, y: 0.585, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Children:
- {fileID: 566472679620608657}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &4540708111873067341
SpriteRenderer:
--- !u!210 &4034973304588068555
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 172036340797654731}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &7018008495298836964
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 566472679620608657}
- component: {fileID: 6750360120797687883}
m_Layer: 0
m_Name: "\u6563\u70ED\u7CFB\u7EDF"
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &566472679620608657
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7018008495298836964}
serializedVersion: 2
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 4003383592530614652}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &6750360120797687883
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7018008495298836964}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
@@ -93,6 +93,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8950552191398444585}
- component: {fileID: 7213596409072140752}
m_Layer: 0
m_Name: "\u65B0\u52A8\u529B\u6838\u5FC3"
m_TagString: Untagged
@@ -117,6 +118,18 @@ Transform:
- {fileID: 1373797842777019686}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &7213596409072140752
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4905377015707044745}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &8583653343740636636
GameObject:
m_ObjectHideFlags: 0
@@ -93,6 +93,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 6944742323572982583}
- component: {fileID: 7505792561260385530}
m_Layer: 0
m_Name: "\u65E7\u52A8\u529B\u6838\u5FC3"
m_TagString: Untagged
@@ -118,6 +119,18 @@ Transform:
- {fileID: 32864910298448052}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &7505792561260385530
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4507972502512266135}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &4899262883552945804
GameObject:
m_ObjectHideFlags: 0
@@ -177,6 +177,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 9127022540097516158}
- component: {fileID: 9127173804116326207}
m_Layer: 0
m_Name: "\u8F85\u52A9\u6DA1\u8F6E"
m_TagString: Untagged
@@ -201,3 +202,15 @@ Transform:
- {fileID: 194806414261741644}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &9127173804116326207
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6137923525990552215}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
@@ -177,6 +177,7 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 8164154881897081106}
- component: {fileID: 6326437728626410913}
m_Layer: 0
m_Name: "\u8FDB\u6C14\u7CFB\u7EDF"
m_TagString: Untagged
@@ -202,6 +203,18 @@ Transform:
- {fileID: 8626455257342477063}
m_Father: {fileID: 0}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!210 &6326437728626410913
SortingGroup:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7198766400001509568}
m_Enabled: 1
m_SortingLayerID: 1134468525
m_SortingLayer: 10
m_SortingOrder: 10
m_SortAtRoot: 0
--- !u!1 &8726264211696304123
GameObject:
m_ObjectHideFlags: 0
File diff suppressed because it is too large Load Diff
@@ -183,7 +183,7 @@ ScriptedImporter:
tessellationDetail: 0
uvTransform: {x: 199, y: 429}
spritePosition: {x: 379, y: 81}
- name: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B"
- name: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B\u60AC\u505C"
originalName:
pivot: {x: 0.5, y: 0.5}
alignment: 0
@@ -194,7 +194,7 @@ ScriptedImporter:
y: 419
width: 23
height: 18
spriteID: 66ce627837168c747b628b4086a2afda
spriteID: 0db20e613f3782a41a2c7c5ac574ef61
spriteBone: []
spriteOutline: []
vertices: []
@@ -204,7 +204,7 @@ ScriptedImporter:
tessellationDetail: 0
uvTransform: {x: 168, y: 419}
spritePosition: {x: 238, y: 80}
- name: "\u63D0\u4EA4\u6309\u94AE\u672A\u6FC0\u6D3B\u60AC\u505C"
- name: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B"
originalName:
pivot: {x: 0.5, y: 0.5}
alignment: 0
@@ -215,7 +215,7 @@ ScriptedImporter:
y: 445
width: 23
height: 18
spriteID: 39de5653cf6d8e445bef16c06ae5ff96
spriteID: 66ce627837168c747b628b4086a2afda
spriteBone: []
spriteOutline: []
vertices: []
@@ -225,7 +225,7 @@ ScriptedImporter:
tessellationDetail: 0
uvTransform: {x: 168, y: 445}
spritePosition: {x: 238, y: 80}
- name: "\u63D0\u4EA4\u6309\u94AE\u672A\u6FC0\u6D3B"
- name: "\u63D0\u4EA4\u6309\u94AE\u672A\u6FC0\u6D3B\u60AC\u505C"
originalName:
pivot: {x: 0.5, y: 0.5}
alignment: 0
@@ -236,7 +236,7 @@ ScriptedImporter:
y: 471
width: 23
height: 18
spriteID: 448ae6aa4a49ee948a6624d9101affdc
spriteID: 39de5653cf6d8e445bef16c06ae5ff96
spriteBone: []
spriteOutline: []
vertices: []
@@ -246,6 +246,27 @@ ScriptedImporter:
tessellationDetail: 0
uvTransform: {x: 168, y: 471}
spritePosition: {x: 238, y: 80}
- name: "\u63D0\u4EA4\u6309\u94AE\u672A\u6FC0\u6D3B"
originalName:
pivot: {x: 0.5, y: 0.5}
alignment: 0
border: {x: 0, y: 0, z: 0, w: 0}
rect:
serializedVersion: 2
x: 209
y: 366
width: 23
height: 18
spriteID: 448ae6aa4a49ee948a6624d9101affdc
spriteBone: []
spriteOutline: []
vertices: []
spritePhysicsOutline: []
indices:
edges: []
tessellationDetail: 0
uvTransform: {x: 209, y: 366}
spritePosition: {x: 238, y: 80}
- name: "\u76EE\u6807\u5C4F\u5E55"
originalName:
pivot: {x: 0.5, y: 0.5}
@@ -317,7 +338,7 @@ ScriptedImporter:
rect:
serializedVersion: 2
x: 209
y: 394
y: 420
width: 15
height: 15
spriteID: df8609dcdcec37d41919b4b955817cb9
@@ -328,7 +349,7 @@ ScriptedImporter:
indices:
edges: []
tessellationDetail: 0
uvTransform: {x: 209, y: 394}
uvTransform: {x: 209, y: 420}
spritePosition: {x: 249, y: 43}
- name: "\u9009\u62E9\u5C4F\u5E55"
originalName:
@@ -401,7 +422,7 @@ ScriptedImporter:
rect:
serializedVersion: 2
x: 209
y: 366
y: 392
width: 19
height: 20
spriteID: f0ee7b155b20bed48b29cf33463953c6
@@ -412,7 +433,7 @@ ScriptedImporter:
indices:
edges: []
tessellationDetail: 0
uvTransform: {x: 209, y: 366}
uvTransform: {x: 209, y: 392}
spritePosition: {x: 283, y: 37}
- name: "\u5E95\u56FE"
originalName:
@@ -781,22 +802,22 @@ ScriptedImporter:
isImported: 1
isVisible: 1
- name: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B\u60AC\u505C"
spriteName:
spriteName: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B\u60AC\u505C"
isGroup: 0
parentIndex: 1
spriteID: 0db20e613f3782a41a2c7c5ac574ef61
layerID: 30
mosaicPosition: {x: 0, y: 0}
mosaicPosition: {x: 168, y: 419}
flatten: 0
isImported: 0
isVisible: 0
isImported: 1
isVisible: 1
- name: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B"
spriteName: "\u63D0\u4EA4\u6309\u94AE\u6FC0\u6D3B"
isGroup: 0
parentIndex: 1
spriteID: 66ce627837168c747b628b4086a2afda
layerID: 29
mosaicPosition: {x: 168, y: 419}
mosaicPosition: {x: 168, y: 445}
flatten: 0
isImported: 1
isVisible: 1
@@ -806,7 +827,7 @@ ScriptedImporter:
parentIndex: 1
spriteID: 39de5653cf6d8e445bef16c06ae5ff96
layerID: 28
mosaicPosition: {x: 168, y: 445}
mosaicPosition: {x: 168, y: 471}
flatten: 0
isImported: 1
isVisible: 1
@@ -816,7 +837,7 @@ ScriptedImporter:
parentIndex: 1
spriteID: 448ae6aa4a49ee948a6624d9101affdc
layerID: 27
mosaicPosition: {x: 168, y: 471}
mosaicPosition: {x: 209, y: 366}
flatten: 0
isImported: 1
isVisible: 1
@@ -876,7 +897,7 @@ ScriptedImporter:
parentIndex: 13
spriteID: df8609dcdcec37d41919b4b955817cb9
layerID: 20
mosaicPosition: {x: 209, y: 394}
mosaicPosition: {x: 209, y: 420}
flatten: 0
isImported: 1
isVisible: 1
@@ -916,7 +937,7 @@ ScriptedImporter:
parentIndex: 13
spriteID: f0ee7b155b20bed48b29cf33463953c6
layerID: 42
mosaicPosition: {x: 209, y: 366}
mosaicPosition: {x: 209, y: 392}
flatten: 0
isImported: 1
isVisible: 1
File diff suppressed because it is too large Load Diff
@@ -14,15 +14,14 @@ MonoBehaviour:
m_EditorClassIdentifier:
baseConditions:
- name: "\u52A8\u529B"
property: PWR
range: {x: 155, y: 155}
isOutRange: 0
paramType: 0
comparisonType: 2
threshold: 100
- name: "\u6563\u70ED"
property: HEAT
range: {x: 100, y: 155}
isOutRange: 0
extraConditions:
paramType: 2
comparisonType: 3
threshold: 100
- name: "\u566A\u97F3"
property: NOISE
range: {x: 10, y: 150}
isOutRange: 0
paramType: 1
comparisonType: 3
threshold: 100
@@ -16,16 +16,29 @@ namespace AibisDream.FixSystem
// ------------------------ 进度条 -------------------------
// [Header("进度条")]
// [SerializeField] private ProgressBar _powerProgressBar;
// [SerializeField] private ProgressBar _noiseProgressBar;
// [SerializeField] private ProgressBar _heatProgressBar;
[SerializeField] private SpriteProgressBar powerProgressBar;
[SerializeField] private SpriteProgressBar noiseProgressBar;
[SerializeField] private SpriteProgressBar heatProgressBar;
public void OnProgressChanged(BlockPuzzleParamValue paramValue)
/// <summary>
/// 设置进度条最大值
/// </summary>
/// <param name="paramValue"></param>
public void SetProgressMaxValue(BlockPuzzleParamValue paramValue)
{
powerProgressBar.MaxValue = paramValue.power;
noiseProgressBar.MaxValue = paramValue.noise;
heatProgressBar.MaxValue = paramValue.heat;
}
public void OnProgressChanged(ValidateResult validateResult)
{
var paramValue = validateResult.propValue;
// 更新进度条
// _powerProgressBar.CurrentValue = paramValue.power;
// _noiseProgressBar.CurrentValue = paramValue.noise;
// _heatProgressBar.CurrentValue = paramValue.heat;
powerProgressBar.CurrentValue = paramValue.power;
noiseProgressBar.CurrentValue = paramValue.noise;
heatProgressBar.CurrentValue = paramValue.heat;
// TODO 更新通过情况
@@ -42,11 +55,17 @@ namespace AibisDream.FixSystem
[SerializeField] private RectTransform _deviceButtonRoot;
[SerializeField] private GameObject _deviceItemPrefab;
private BlockShapeData[] deviceButtonDatas;
public BlockShapeData[] DeviceButtonDatas { set => deviceButtonDatas = value; }
public event Action<BlockShapeInfo> OnDeviceSelected;
private void InitDeviceList()
{
// TODO: 初始化器件列表
foreach (var data in deviceButtonDatas)
{
AddDeviceButton(data.blockShapeInfo);
}
}
public void OnDeviceRecycle(BlockShape blockShape)
@@ -54,13 +73,6 @@ namespace AibisDream.FixSystem
AddDeviceButton(blockShape.BlockShapeData.blockShapeInfo);
}
public void OnDeviceRemove(BlockShape blockShape)
{
// 从传送带获取器件时移除面板上的器件信息
Destroy(blockShape.gameObject);
RemoveDeviceButton(blockShape.BlockShapeData.shapeName);
}
private void AddDeviceButton(BlockShapeInfo blockShapeInfo)
{
var button = Instantiate(_deviceItemPrefab, _deviceButtonRoot).GetComponent<ShapeCreateButton>();
@@ -84,6 +96,11 @@ namespace AibisDream.FixSystem
public Button LockButton => lockButton;
public Button PopUpButton => popUpButton;
public void SetVaildState(ValidateResult validateResult)
{
lockButton.GetComponent<BlockSubmitHander>().SetValidState(validateResult.isPass);
}
// ------------------------ 面板收放 -------------------------
public void Init()
{
@@ -10,7 +10,6 @@ namespace AibisDream.FixSystem
public class UniversalScreen : MonoBehaviour, ILineView
{
[Header("是否为对话容器")]
[SerializeField] private bool IsLineView = false;
[SerializeField] private TerminalText logText;
[Header("其他字段")]
@@ -15,7 +15,6 @@ namespace AibisDream
[SerializeField] public int width = 10;
[SerializeField] public int height = 10;
[SerializeField] public float cellSize = 1f;
[SerializeField] private bool showCellStates = true;
private GridCellState[,] _grid;
private GridCellState[,] _previewGrid;
@@ -30,8 +29,6 @@ namespace AibisDream
public GridVisualizer GridVisualizer { get; private set; }
public Dictionary<BlockShape, GridShapeData> ShapeDict { get; private set; }
public event Action OnShapePlaced;
/// <summary>
/// 初始化编辑器预览
/// </summary>
@@ -269,11 +266,6 @@ namespace AibisDream
{
return ShapeDict.Keys.ToList();
}
private void OnDestroy()
{
OnShapePlaced = null;
}
}
}
@@ -100,6 +100,74 @@ namespace AibisDream
}
}
/// <summary>
/// 批量从文件加载 BlockShapeData
/// </summary>
/// <param name="keys">要加载的数据键数组</param>
/// <param name="path">文件路径,如果为空则使用默认路径</param>
/// <returns>成功加载的数据列表</returns>
public static Dictionary<string, BlockShapeData> LoadBlockShapeDataBatch(string[] keys, string path = null)
{
var result = new Dictionary<string, BlockShapeData>();
if (keys == null || keys.Length == 0)
{
return result;
}
if (string.IsNullOrEmpty(path))
{
path = ConstRef.BlockShapeDataPath;
}
try
{
if (!File.Exists(path))
{
Debug.LogWarning($"BlockShapeData 文件不存在: {path}");
return result;
}
var dict = JsonUtil.ReadBeanDict<BlockShapeData>(path);
var infoDict = JsonUtil.ReadBeanDict<BlockShapeInfo>(ConstRef.BlockShapeInfoPath);
if (dict == null)
{
Debug.LogWarning($"读取 BlockShapeData 字典失败: {path}");
return result;
}
foreach (string key in keys)
{
if (string.IsNullOrEmpty(key))
continue;
if (dict.ContainsKey(key))
{
BlockShapeData data = dict[key];
// 尝试加载对应的 BlockShapeInfo
if (infoDict != null && infoDict.ContainsKey(key))
{
data.blockShapeInfo = infoDict[key];
}
result.Add(key, data);
}
else
{
Debug.LogWarning($"未找到键为 '{key}' 的 BlockShapeData");
}
}
}
catch (Exception e)
{
Debug.LogError($"批量加载 BlockShapeData 失败: {e.Message}");
}
return result;
}
/// <summary>
/// 从文件加载单个 BlockPuzzleData
/// </summary>
@@ -1,7 +1,5 @@
using UnityEngine;
using AibisDream.FixSystem;
using System;
using UnityEngine.Events;
namespace AibisDream
{
@@ -12,6 +10,14 @@ namespace AibisDream
[SerializeField] private UniversalScreen blockPuzzleScreen;
[SerializeField] private BlockPuzzlePart blockPuzzlePart;
// ---------------------- 基本功能 ----------------------
public void SwitchToLogScreen()
{
logScreen.gameObject.SetActive(true);
blockPuzzleScreen.gameObject.SetActive(false);
}
// ---------------------- 维修部分 ----------------------
public BlockPuzzlePart Panel => blockPuzzlePart;
@@ -26,11 +32,21 @@ namespace AibisDream
blockPuzzleScreen.SetText("设备名称", shape.shapeName);
blockPuzzleScreen.SetText("设备描述", shape.shapeDescription);
blockPuzzleScreen.SetText("PWR", shape.paramValue.power.ToString());
blockPuzzleScreen.SetText("NOISE", shape.paramValue.noise.ToString());
blockPuzzleScreen.SetText("HEAT", shape.paramValue.heat.ToString());
blockPuzzleScreen.SetText("PWR", $"PWR\n{shape.paramValue.power.ToString("+0;-0;+0")}");
blockPuzzleScreen.SetText("NOISE", $"NOISE\n{shape.paramValue.noise.ToString("+0;-0;+0")}");
blockPuzzleScreen.SetText("HEAT", $"HEAT\n{shape.paramValue.heat.ToString("+0;-0;+0")}");
// TODO: 设备状态后面实现
for (int i = 1; i <= 3; i++)
{
if (i <= shape.states.Length)
{
blockPuzzleScreen.SetText($"设备状态{i}", shape.states[i-1]);
}
else
{
blockPuzzleScreen.SetText($"设备状态{i}", "");
}
}
}
public void ClearShapeInScreen()
@@ -43,6 +59,11 @@ namespace AibisDream
blockPuzzleScreen.SetText("PWR", "0");
blockPuzzleScreen.SetText("NOISE", "0");
blockPuzzleScreen.SetText("HEAT", "0");
for (int i = 1; i <= 3; i++)
{
blockPuzzleScreen.SetText($"设备状态{i}", "");
}
}
// ---------------------- 对话功能 ----------------------
@@ -60,12 +81,12 @@ namespace AibisDream
private void OnEnable()
{
DialogUIManager.Instance.RegisterScreenView(DialogViewType.Log, this);
DialogUIManager.Instance?.RegisterScreenView(DialogViewType.Log, this);
}
private void OnDisable()
{
DialogUIManager.Instance.UnRegisterScreenView(DialogViewType.Log);
DialogUIManager.Instance?.UnRegisterScreenView(DialogViewType.Log);
}
}
}
@@ -1,10 +1,11 @@
using System;
using UnityEngine;
using Cinemachine;
using AibisDream.Kit;
using AibisDream.Utility;
using System.Linq;
using AibisDream.Framework;
using System;
using UnityEngine.EventSystems;
namespace AibisDream
{
@@ -24,6 +25,9 @@ namespace AibisDream
private BlockPuzzleValidator validator;
private ShapeFactory shapeFactory;
// 锁定状态
public bool IsLocked { get; private set; }
private void Start()
{
if (initializeOnStart)
@@ -48,53 +52,113 @@ namespace AibisDream
public void Initialize()
{
float startTime = Time.realtimeSinceStartup;
// 初始化网格
grid.Initialize(puzzleData.gridWidth, puzzleData.gridHeight, puzzleData.cellSize);
// 批量预加载所有需要的BlockShapeData,避免循环中重复读取JSON文件
var shapeKeys = puzzleData.gridShapeDataInfos.Select(s => s.shapeKey).Distinct().ToArray();
var shapeDataDict = BlockPuzzleKit.LoadBlockShapeDataBatch(shapeKeys);
// 初始化网格上图形
shapeFactory = new ShapeFactory(shapeRoot);
foreach (var shapeData in puzzleData.gridShapeDataInfos)
{
var shape = shapeFactory.CreateBlockShape(shapeData.shapeKey);
shape.Rotate(shapeData.rotationAngle);
grid.TrySnapToGrid(shape, shapeData.rootCell);
shape.GetComponent<ShapeDragger>().IsDraggable = shapeData.isDraggable;
// 使用预加载的数据创建形状,避免重复读取JSON
if (shapeDataDict.TryGetValue(shapeData.shapeKey, out var blockShapeData))
{
var shape = shapeFactory.CreateBlockShape(blockShapeData);
shape.Rotate(shapeData.rotationAngle);
grid.TrySnapToGrid(shape, shapeData.rootCell);
shape.ShapeDragger.IsDraggable = shapeData.isDraggable;
}
}
grid.GridVisualizer.UpdateAllCellsVisual();
// 加载验证器
validator = ResourceKit.LoadAssetSync<BlockPuzzleValidator>(puzzleData.validatorName);
blockPuzzlePanel.Panel.SetProgressMaxValue(validator.CollectThresholds());
// 初始化侧边栏
var deviceDatas = BlockPuzzleKit.LoadBlockShapeDataBatch(puzzleData.shapeInRack);
blockPuzzlePanel.Panel.DeviceButtonDatas = deviceDatas.Values.ToArray();
// 组装事件逻辑
AssembleEventLogic();
Debug.Log("网格系统初始化完成");
}
// 初始化时验证一次
validator.Validate(grid.GetShapes());
private void PreCheckGameState()
{
var shapes = grid.GetShapes();
var validateResult = validator.Validate(shapes);
// 确保交互状态正确
UpdateInteractionState();
}
private void SubmitGameResult()
{
var shapes = grid.GetShapes();
var validateResult = validator.Validate(shapes);
// 检查系统是否锁定
if (IsLocked)
{
return;
}
var validateResult = validator.Validate(grid.GetShapes());
// 如果验证通过, 则设置变量并弹出对话
if (validateResult.isPass)
{
StorageSystem.Instance.SetValue("$block_puzzle_pass", true);
DialogController.Instance.StartDialogNode("方块拼图完成");
// StorageSystem.Instance.SetValue("$block_puzzle_pass", true);
// DialogController.Instance.StartDialogNode("方块拼图完成");
Debug.Log("方块拼图完成");
}
}
public void ClearGame()
{
grid.Clear();
// shapeRack.Clear();
shapeRoot.DestroyAllChildren();
// 重置锁定状态
SetLocked(false);
}
// --------------------- 锁定状态管理 -------------------
/// <summary>
/// 设置系统锁定状态
/// </summary>
/// <param name="locked">是否锁定</param>
public void SetLocked(bool locked)
{
IsLocked = locked;
UpdateInteractionState();
}
/// <summary>
/// 更新所有交互组件的状态
/// </summary>
private void UpdateInteractionState()
{
// 更新所有形状的拖拽状态
if (shapeFactory != null)
{
shapeFactory.SetAllShapesDraggable(!IsLocked);
}
// 更新按钮的交互状态
if (blockPuzzlePanel != null && blockPuzzlePanel.Panel != null)
{
var panel = blockPuzzlePanel.Panel;
if (panel.LockButton != null)
{
panel.LockButton.interactable = !IsLocked;
}
if (panel.PopUpButton != null)
{
panel.PopUpButton.interactable = !IsLocked;
}
}
}
// --------------------- 维修面板同步 -------------------
@@ -111,13 +175,14 @@ namespace AibisDream
blockPuzzlePanel.Panel.OnSubmit.AddListener(SubmitGameResult);
blockPuzzlePanel.Panel.OnPopUp.AddListener(PopUpShape);
// 由网格触发
grid.OnShapePlaced += PreCheckGameState;
// 由Shape触发
shapeFactory.OnDragStart += OnShapeDragStart;
shapeFactory.OnDragEnd += OnShapeDragEnd;
shapeFactory.OnDragUpdate += OnShapeDragUpdate;
// 由系统触发
validator.OnValidate.AddListener(blockPuzzlePanel.Panel.SetVaildState);
validator.OnValidate.AddListener(blockPuzzlePanel.Panel.OnProgressChanged);
}
private void OnPanelShapeSelected(BlockShapeInfo shapeData)
@@ -127,28 +192,31 @@ namespace AibisDream
blockPuzzlePanel.ShowShapeInScreen(shapeData);
}
public void OnValidateResult(ValidateResult validateResult)
{
// 先更新进度条
// 再更新校验结果,包括锁定按钮等UI
}
public void OnShapeDragStart(IBlockShape blockShape)
{
// 更新选中图形
// 显示Info
if (blockShape is BlockShape shape && shape.BlockShapeData.blockShapeInfo.shapeName != null)
{
blockPuzzlePanel.ShowShapeInScreen(shape.BlockShapeData.blockShapeInfo);
EventSystem.current.SetSelectedGameObject(null);
selectedShapeName = null;
}
// 回收抽屉高亮,半开
shapeRecycleSlot.PreRecycle();
shapeRecycleSlot.SetRecycleAvaliable(true);
// 每次拿起时也要校验
validator.Validate(grid.GetShapes());
}
public void OnShapeDragEnd(IBlockShape blockShape, bool isPlaced)
{
//
// TODO: 如果吸附到回收处,应该播放动画,并提示回收成功
// 如果放置成功,则预先检查一次
if (isPlaced)
{
validator.Validate(grid.GetShapes());
}
}
public void OnShapeDragUpdate(IBlockShape blockShape)
@@ -159,6 +227,12 @@ namespace AibisDream
public void PopUpShape()
{
// 检查系统是否锁定
if (IsLocked)
{
return;
}
if (selectedShapeName == null)
{
return;
@@ -172,7 +246,6 @@ namespace AibisDream
// 删除按钮
blockPuzzlePanel.Panel.RemoveDeviceButton(selectedShapeName);
selectedShapeName = null;
blockPuzzlePanel.ClearShapeInScreen();
}
// --------------------- 吸附校验 ---------------------
@@ -183,7 +256,10 @@ namespace AibisDream
if (shapeRecycleSlot.CurrentState == PositionState.Open)
{
shapeRecycleSlot.RecycleShape(blockShape);
// TODO: 向面板添加回收的形状
// 清空屏幕并切换回LogScreen
blockPuzzlePanel.ClearShapeInScreen();
blockPuzzlePanel.SwitchToLogScreen();
// 向面板添加回收的形状
blockPuzzlePanel.Panel.OnDeviceRecycle(blockShape);
// 延时后进行销毁
ActionKit.Delay(1.0f, () => {
@@ -1,6 +1,6 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
namespace AibisDream
{
@@ -10,6 +10,8 @@ namespace AibisDream
[Tooltip("基础条件, 不满足无法提交")]
public ValidateItem[] baseConditions;
public UnityEvent<ValidateResult> OnValidate = new();
/// <summary>
/// 验证是否可以完成拼图
/// </summary>
@@ -49,6 +51,7 @@ namespace AibisDream
result.isPass = result.isPass && itemResult;
}
OnValidate.Invoke(result);
return result;
}
@@ -69,6 +72,49 @@ namespace AibisDream
};
}
/// <summary>
/// 收集Power, Noise, Heat的阈值,并以BlockPuzzleParamValue的形式返回
/// </summary>
/// <returns>包含各参数阈值的BlockPuzzleParamValue结构</returns>
public BlockPuzzleParamValue CollectThresholds()
{
var thresholds = new BlockPuzzleParamValue();
if (baseConditions == null)
return thresholds;
// 遍历所有条件,收集每个参数类型的阈值
// 如果同一参数类型有多个条件,取第一个匹配的阈值
bool powerFound = false;
bool noiseFound = false;
bool heatFound = false;
foreach (var condition in baseConditions)
{
if (!powerFound && condition.paramType == ParamType.Power)
{
thresholds.power = condition.threshold;
powerFound = true;
}
else if (!noiseFound && condition.paramType == ParamType.Noise)
{
thresholds.noise = condition.threshold;
noiseFound = true;
}
else if (!heatFound && condition.paramType == ParamType.Heat)
{
thresholds.heat = condition.threshold;
heatFound = true;
}
// 如果所有参数类型都已找到,可以提前退出
if (powerFound && noiseFound && heatFound)
break;
}
return thresholds;
}
[System.Serializable]
public struct ValidateItem
{
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using AibisDream.Utility;
using UnityEngine;
@@ -58,7 +57,6 @@ namespace AibisDream
ShapeDragger = GetComponent<ShapeDragger>();
_blockShapeData = blockShapeData;
gameObject.name = blockShapeData.shapeName;
// 加载视觉Prefab
LoadVisualPrefab();
// 更新碰撞体
UpdatePolygonCollider();
@@ -28,8 +28,8 @@ namespace AibisDream
[SerializeField] private Sprite cellSprite;
[SerializeField] private Material cellMaterial;
[HideInInspector] public int sortingLayer;
[HideInInspector] public int sortingOrder;
[SerializeField] private int sortingLayer;
[SerializeField] private int sortingOrder;
// 单元格可视化对象池
private Dictionary<(int x, int y), GameObject> _cellObjects = new Dictionary<(int x, int y), GameObject>();
@@ -126,6 +126,9 @@ namespace AibisDream
lineObj.transform.localPosition = Vector3.zero;
LineRenderer lineRenderer = lineObj.AddComponent<LineRenderer>();
lineRenderer.sortingLayerID = sortingLayer;
lineRenderer.sortingOrder = sortingOrder;
lineRenderer.useWorldSpace = true;
lineRenderer.positionCount = 2;
lineRenderer.SetPosition(0, start);
@@ -135,7 +138,8 @@ namespace AibisDream
lineRenderer.material = new Material(Shader.Find("Sprites/Default"));
lineRenderer.startColor = color;
lineRenderer.endColor = color;
lineRenderer.sortingOrder = 0;
lineRenderer.sortingLayerID = sortingLayer;
lineRenderer.sortingOrder = sortingOrder;
}
/// <summary>
@@ -166,6 +170,8 @@ namespace AibisDream
cellObj.transform.position = _grid.GridToWorld(x, y);
SpriteRenderer spriteRenderer = cellObj.AddComponent<SpriteRenderer>();
spriteRenderer.sortingLayerID = sortingLayer;
spriteRenderer.sortingOrder = sortingOrder;
// 如果没有指定Sprite,创建一个简单的白色Sprite
if (cellSprite == null)
@@ -175,7 +181,8 @@ namespace AibisDream
spriteRenderer.sprite = cellSprite;
spriteRenderer.color = emptyCellColor;
spriteRenderer.sortingOrder = 1;
spriteRenderer.sortingLayerID = sortingLayer;
spriteRenderer.sortingOrder = sortingOrder;
// 设置大小
float spriteSize = _grid.CellSize * 0.9f; // 稍微小一点,留出网格线空间
@@ -183,6 +183,17 @@ namespace AibisDream
public float distance; // 到网格单元格的距离
public Vector2Int[] gridPositions; // 吸附后
public Vector2Int RootCell => new Vector2Int(gridX, gridY); // 吸附后的根网格坐标
}
public static SnapResult RecycleResult => new()
{
canSnap = false,
snapPosition = Vector3.zero,
gridX = -10,
gridY = -10,
distance = float.MaxValue,
gridPositions = new Vector2Int[0]
};
};
}
@@ -116,6 +116,8 @@ namespace AibisDream
if (recycled)
{
CurrentState = DragState.Idle;
_snapResult = SnapResult.RecycleResult;
TargetGrid.ShowSnapPreview(_snapResult);
return;
}
@@ -75,5 +75,20 @@ namespace AibisDream
_blockShapeList.Remove(blockShape);
UnityEngine.Object.Destroy(blockShape.gameObject);
}
/// <summary>
/// 批量设置所有形状的可拖拽状态
/// </summary>
/// <param name="draggable">是否可拖拽</param>
public void SetAllShapesDraggable(bool draggable)
{
foreach (var shape in _blockShapeList)
{
if (shape != null && shape.ShapeDragger != null)
{
shape.ShapeDragger.IsDraggable = draggable;
}
}
}
}
}
@@ -4,11 +4,11 @@ namespace AibisDream
{
public class ShapeRecycleSlot : MonoBehaviour
{
public PositionState CurrentState => mover.GetCurrentState();
[SerializeField] private ThreeStatePositionMover mover;
[SerializeField] private BoxArea halfArea;
[SerializeField] private BoxArea openArea;
[SerializeField] private Transform attachPoint; // 吸附点,如果为空则吸附到(0,0)
// ----------------------- 回收逻辑 -----------------------
public void PreRecycle()
@@ -87,12 +87,23 @@ namespace AibisDream
}
}
}
private void PutShapeInSlot(BlockShape shape)
{
shape.transform.SetParent(mover.transform);
Vector3 centerPosition = shape.GetCenterPosition();
shape.transform.localPosition = -centerPosition;
// 如果有配置吸附点,则吸附到吸附点;否则吸附到(0,0)
if (attachPoint != null)
{
// 吸附点挂在mover下面,直接使用本地坐标
shape.transform.localPosition = attachPoint.localPosition - centerPosition;
}
else
{
// 默认行为:吸附到(0,0)
shape.transform.localPosition = -centerPosition;
}
}
}
}
@@ -0,0 +1,53 @@
using UnityEngine;
using AibisDream.UI;
using UnityEngine.Events;
using UnityEngine.UI;
namespace AibisDream
{
public class BlockSubmitHander : MonoBehaviour
{
[Header("图片索引")]
[SerializeField] private SpriteTint validAsset;
[SerializeField] private SpriteTint invalidAsset;
private bool _validState = false;
private BaseButton submitButton;
private Image submitButtonImage;
public UnityEvent OnClick => submitButton.onClick;
private void Awake()
{
submitButtonImage = GetComponent<Image>();
submitButton = GetComponent<BaseButton>();
submitButton.onStateTransition.AddListener(OnStateTransition);
}
private void OnStateTransition(SelectionType stateTransition, bool instant)
{
switch (stateTransition)
{
case SelectionType.Normal:
submitButtonImage.sprite = _validState ? validAsset.normalSprite : invalidAsset.normalSprite;
break;
case SelectionType.Highlighted:
submitButtonImage.sprite = _validState ? validAsset.highlightedSprite : invalidAsset.highlightedSprite;
break;
case SelectionType.Pressed:
submitButtonImage.sprite = _validState ? validAsset.pressedSprite : invalidAsset.pressedSprite;
break;
case SelectionType.Selected:
submitButtonImage.sprite = _validState ? validAsset.selectedSprite : invalidAsset.selectedSprite;
break;
case SelectionType.Disabled:
submitButtonImage.sprite = _validState ? validAsset.disabledSprite : invalidAsset.disabledSprite;
break;
}
}
public void SetValidState(bool valid)
{
_validState = valid;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: df5a7683c04d2a04b84b5fc5f02d2306
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+10
View File
@@ -12,4 +12,14 @@ namespace AibisDream.UI
public Color selectedColor;
public Color disabledColor;
}
[Serializable]
public struct SpriteTint
{
public Sprite normalSprite;
public Sprite highlightedSprite;
public Sprite pressedSprite;
public Sprite selectedSprite;
public Sprite disabledSprite;
}
}
+27 -5
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -13,6 +13,21 @@ namespace AibisDream.Utility
{
public const string JsonSuffix = ".json";
// 缓存的 JsonSerializerSettings,优化性能
private static readonly JsonSerializerSettings _defaultSettings = new JsonSerializerSettings
{
// 禁用类型名称处理,提升性能
TypeNameHandling = TypeNameHandling.None,
// 使用默认的日期格式处理
DateFormatHandling = DateFormatHandling.IsoDateFormat,
// 忽略循环引用
ReferenceLoopHandling = ReferenceLoopHandling.Ignore
// 注意:不设置 NullValueHandling,保持默认行为(Include),避免改变现有功能
};
// 缓存的 JsonSerializer 实例,用于字典反序列化优化
private static readonly JsonSerializer _cachedSerializer = JsonSerializer.Create(_defaultSettings);
/// <summary>
/// 根据平台读取文件内容
/// </summary>
@@ -95,7 +110,7 @@ namespace AibisDream.Utility
public static T ReadBean<T>(string path)
{
string json = ReadFileText(path);
return JsonConvert.DeserializeObject<T>(json);
return JsonConvert.DeserializeObject<T>(json, _defaultSettings);
}
public static T ReadBeanByText<T>(string text)
@@ -104,7 +119,7 @@ namespace AibisDream.Utility
{
text = "{" + text + "}";
}
return JsonConvert.DeserializeObject<T>(text);
return JsonConvert.DeserializeObject<T>(text, _defaultSettings);
}
/// <summary>
@@ -116,7 +131,7 @@ namespace AibisDream.Utility
public static T[] ReadBeanArray<T>(string path)
{
string json = ReadFileText(path);
return JsonConvert.DeserializeObject<T[]>(json);
return JsonConvert.DeserializeObject<T[]>(json, _defaultSettings);
}
/// <summary>
@@ -128,7 +143,14 @@ namespace AibisDream.Utility
public static Dictionary<string, T> ReadBeanDict<T>(string path)
{
string json = ReadFileText(path);
return JsonConvert.DeserializeObject<Dictionary<string, T>>(json);
// 使用缓存的 JsonSerializerSettings 和 StringReader 优化性能
using (var reader = new StringReader(json))
using (var jsonReader = new JsonTextReader(reader))
{
var result = _cachedSerializer.Deserialize<Dictionary<string, T>>(jsonReader);
return result;
}
}
/// <summary>
@@ -1,22 +1,25 @@
{
{
"共鸣腔": {
"shapeName": "共鸣腔",
"shapeDescription": "共鸣腔描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 50,
"noise": 10,
"heat": 10
},
"states": ["正常", "故障"],
"states": [
"正常",
"故障"
],
"buttonImagePath": "BlockPuzzle/按钮缩略图[共鸣腔]"
},
"动平衡飞轮组": {
"shapeName": "动平衡飞轮组",
"shapeDescription": "动平衡飞轮组描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": [
"正常",
@@ -28,20 +31,23 @@
"shapeName": "惯性稳压器",
"shapeDescription": "惯性稳压器描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": ["正常", "故障"],
"states": [
"正常",
"故障"
],
"buttonImagePath": "BlockPuzzle/按钮缩略图[惯性稳压器]"
},
"进气系统": {
"shapeName": "进气系统",
"shapeDescription": "进气系统描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": [
"正常",
@@ -53,9 +59,9 @@
"shapeName": "辅助涡轮",
"shapeDescription": "辅助涡轮描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": [
"正常",
@@ -67,9 +73,9 @@
"shapeName": "散热条",
"shapeDescription": "散热条描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": [
"正常",
@@ -81,33 +87,42 @@
"shapeName": "散热系统",
"shapeDescription": "散热系统描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": ["正常", "故障"],
"states": [
"正常",
"故障"
],
"buttonImagePath": "BlockPuzzle/按钮缩略图[散热系统]"
},
"旧动力核心": {
"shapeName": "旧动力核心",
"shapeDescription": "旧动力核心描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": ["正常", "故障"],
"states": [
"正常",
"故障"
],
"buttonImagePath": "BlockPuzzle/按钮缩略图[旧动力核心]"
},
"新动力核心": {
"shapeName": "新动力核心",
"shapeDescription": "新动力核心描述",
"paramValue": {
"power": 100,
"noise": 100,
"heat": 100
"power": 10,
"noise": 10,
"heat": 10
},
"states": ["正常", "故障"],
"states": [
"正常",
"故障"
],
"buttonImagePath": "BlockPuzzle/按钮缩略图[新动力核心]"
}
}