diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 7ead723c..112da2b0 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 1803017460098482366} - component: {fileID: 2136192976700920181} - component: {fileID: 2952415180134692435} + - component: {fileID: 7904266034163262073} m_Layer: 0 m_Name: Player m_TagString: Untagged @@ -212,3 +213,15 @@ PolygonCollider2D: - {x: 0.057479188, y: -0.12709153} - {x: 0.046700563, y: -0.12571843} m_UseDelaunayMesh: 0 +--- !u!114 &7904266034163262073 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1463738777561398421} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9d1d8695cfa6948278518a6a55e0b730, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab b/Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab index 4404662e..822ef877 100644 --- a/Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab +++ b/Assets/Prefabs/RoomSystem/Corridor/CorridorX7.prefab @@ -1328,6 +1328,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3022020511561805294} + - component: {fileID: 1349095506272017240} m_Layer: 0 m_Name: CorridorX7 m_TagString: Map @@ -1352,6 +1353,18 @@ Transform: - {fileID: 1238582843666978988} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1349095506272017240 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6369746937129949933} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9880ea29492da44c995f334244a5d19e, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &7452483412117750499 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/RoomSystem/Corridor/Room.prefab b/Assets/Prefabs/RoomSystem/Corridor/Room.prefab index 9852a198..7f06052a 100644 --- a/Assets/Prefabs/RoomSystem/Corridor/Room.prefab +++ b/Assets/Prefabs/RoomSystem/Corridor/Room.prefab @@ -2254,6 +2254,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 3176463435939833076} + - component: {fileID: 3498959641617480557} m_Layer: 0 m_Name: Room m_TagString: Map @@ -2278,6 +2279,18 @@ Transform: - {fileID: 8436259702988649751} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &3498959641617480557 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6459706332820108789} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9880ea29492da44c995f334244a5d19e, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &8327367539400217474 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scenes/EmptyRoom_2.unity b/Assets/Scenes/EmptyRoom_2.unity index 774490cf..711daa64 100644 --- a/Assets/Scenes/EmptyRoom_2.unity +++ b/Assets/Scenes/EmptyRoom_2.unity @@ -154,97 +154,6 @@ RectTransform: m_Children: [] m_Father: {fileID: 1250698880} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} ---- !u!114 &6611453 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6611451} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3} - m_Name: - m_EditorClassIdentifier: - m_Material: {fileID: 0} - m_Color: {r: 1, g: 1, b: 1, a: 1} - m_RaycastTarget: 1 - m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} - m_Maskable: 1 - m_OnCullStateChanged: - m_PersistentCalls: - m_Calls: [] - m_Sprite: {fileID: 0} - m_Type: 0 - m_PreserveAspect: 0 - m_FillCenter: 1 - m_FillMethod: 4 - m_FillAmount: 1 - m_FillClockwise: 1 - m_FillOrigin: 0 - m_UseSpriteMesh: 0 - m_PixelsPerUnitMultiplier: 1 ---- !u!222 &6611454 -CanvasRenderer: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 6611451} - m_CullTransparentMesh: 1 ---- !u!1 &98536830 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 98536832} - - component: {fileID: 98536831} - m_Layer: 0 - m_Name: TrapManager - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &98536831 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 98536830} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 3e906695758a3d04197ddceb298f6c86, type: 3} - m_Name: - m_EditorClassIdentifier: - trapPrefabs: - - {fileID: 6097000079642511365, guid: 127c53d14a0062f41a16963a87a85dc5, type: 3} - - {fileID: 7646078152559978388, guid: 40bc1f37707e62f4297f85bf5c7b01b4, type: 3} - - {fileID: 6762149095286452822, guid: d7c2a5ac1f23afe428f872343ed56d71, type: 3} ---- !u!4 &98536832 -Transform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 98536830} - serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: -0.21531442, y: 0.33767503, z: 0.020564094} - m_LocalScale: {x: 1, y: 1, z: 1} - m_ConstrainProportionsScale: 0 - m_Children: [] - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &166584758 stripped GameObject: m_CorrespondingSourceObject: {fileID: 2848433276931004705, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} @@ -468,6 +377,23 @@ PrefabInstance: insertIndex: -1 addedObject: {fileID: 1236749860} m_SourcePrefab: {fileID: 100100000, guid: 2359570f2fea24215ae3f989d41b590e, type: 3} +--- !u!1 &791950511 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 6459706332820108789, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} + m_PrefabInstance: {fileID: 1166055672053893236} + m_PrefabAsset: {fileID: 0} +--- !u!114 &791950512 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 791950511} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9880ea29492da44c995f334244a5d19e, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &1236749853 stripped GameObject: m_CorrespondingSourceObject: {fileID: 1463738777561398421, guid: 2359570f2fea24215ae3f989d41b590e, type: 3} @@ -493,108 +419,6 @@ Transform: m_CorrespondingSourceObject: {fileID: 6754384466861484289, guid: 2359570f2fea24215ae3f989d41b590e, type: 3} m_PrefabInstance: {fileID: 647252271} m_PrefabAsset: {fileID: 0} ---- !u!1 &1250698876 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - serializedVersion: 6 - m_Component: - - component: {fileID: 1250698880} - - component: {fileID: 1250698879} - - component: {fileID: 1250698878} - - component: {fileID: 1250698877} - m_Layer: 5 - m_Name: Canvas - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!114 &1250698877 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1250698876} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: dc42784cf147c0c48a680349fa168899, type: 3} - m_Name: - m_EditorClassIdentifier: - m_IgnoreReversedGraphics: 1 - m_BlockingObjects: 0 - m_BlockingMask: - serializedVersion: 2 - m_Bits: 4294967295 ---- !u!114 &1250698878 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1250698876} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 0cd44c1031e13a943bb63640046fad76, type: 3} - m_Name: - m_EditorClassIdentifier: - m_UiScaleMode: 0 - m_ReferencePixelsPerUnit: 100 - m_ScaleFactor: 1 - m_ReferenceResolution: {x: 800, y: 600} - m_ScreenMatchMode: 0 - m_MatchWidthOrHeight: 0 - m_PhysicalUnit: 3 - m_FallbackScreenDPI: 96 - m_DefaultSpriteDPI: 96 - m_DynamicPixelsPerUnit: 1 - m_PresetInfoIsWorld: 1 ---- !u!223 &1250698879 -Canvas: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1250698876} - m_Enabled: 1 - serializedVersion: 3 - m_RenderMode: 2 - m_Camera: {fileID: 0} - m_PlaneDistance: 100 - m_PixelPerfect: 0 - m_ReceivesEvents: 1 - m_OverrideSorting: 0 - m_OverridePixelPerfect: 0 - m_SortingBucketNormalizedSize: 0 - m_VertexColorAlwaysGammaSpace: 0 - m_AdditionalShaderChannelsFlag: 0 - m_UpdateRectTransformForStandalone: 0 - m_SortingLayerID: 0 - m_SortingOrder: 0 - m_TargetDisplay: 0 ---- !u!224 &1250698880 -RectTransform: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1250698876} - 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: - - {fileID: 6611452} - m_Father: {fileID: 0} - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} - m_AnchorMin: {x: 0.5, y: 0.5} - m_AnchorMax: {x: 0.5, y: 0.5} - m_AnchoredPosition: {x: 0, y: 0} - m_SizeDelta: {x: 100, y: 100} - m_Pivot: {x: 0.5, y: 0.5} --- !u!1 &1655521566 GameObject: m_ObjectHideFlags: 0 @@ -752,6 +576,10 @@ PrefabInstance: propertyPath: m_Enabled value: 1 objectReference: {fileID: 0} + - target: {fileID: 8327367539400217474, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} + propertyPath: m_TagString + value: Props + objectReference: {fileID: 0} - target: {fileID: 8436259702988649751, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} propertyPath: m_LocalPosition.x value: 4.5 @@ -763,7 +591,10 @@ PrefabInstance: m_RemovedComponents: [] m_RemovedGameObjects: [] m_AddedGameObjects: [] - m_AddedComponents: [] + m_AddedComponents: + - targetCorrespondingSourceObject: {fileID: 6459706332820108789, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} + insertIndex: -1 + addedObject: {fileID: 791950512} m_SourcePrefab: {fileID: 100100000, guid: 35bed5d2a54129845bcff6b3abaa746b, type: 3} --- !u!1001 &8803801296905376457 PrefabInstance: @@ -892,5 +723,4 @@ SceneRoots: - {fileID: 98536832} - {fileID: 8803801296905376457} - {fileID: 1166055672053893236} - - {fileID: 1250698880} - {fileID: 1655521569} diff --git a/Assets/Scenes/TestRoom.unity b/Assets/Scenes/TestRoom.unity index cba86288..828c1cb0 100644 --- a/Assets/Scenes/TestRoom.unity +++ b/Assets/Scenes/TestRoom.unity @@ -132,6 +132,7 @@ GameObject: m_Component: - component: {fileID: 166584760} - component: {fileID: 166584759} + - component: {fileID: 166584761} m_Layer: 0 m_Name: Grid m_TagString: Untagged @@ -170,6 +171,18 @@ Transform: - {fileID: 542654705} m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &166584761 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 166584758} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9880ea29492da44c995f334244a5d19e, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1 &371089590 GameObject: m_ObjectHideFlags: 0 @@ -184,7 +197,7 @@ GameObject: - component: {fileID: 371089592} m_Layer: 0 m_Name: Props - m_TagString: Untagged + m_TagString: Props m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 @@ -280,7 +293,7 @@ TilemapRenderer: m_LightmapParameters: {fileID: 0} m_SortingLayerID: 0 m_SortingLayer: 0 - m_SortingOrder: 2 + m_SortingOrder: 10 m_ChunkSize: {x: 32, y: 32, z: 32} m_ChunkCullingBounds: {x: 0, y: 0, z: 0} m_MaxChunkCount: 16 @@ -297,7 +310,77 @@ Tilemap: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 371089590} m_Enabled: 1 - m_Tiles: {} + m_Tiles: + - first: {x: 5, y: 4, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 16 + m_TileSpriteIndex: 16 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 6, y: 4, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 15 + m_TileSpriteIndex: 15 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 7, y: 4, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 14 + m_TileSpriteIndex: 14 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 5, y: 5, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 13 + m_TileSpriteIndex: 13 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 6, y: 5, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 12 + m_TileSpriteIndex: 12 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 7, y: 5, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 11 + m_TileSpriteIndex: 11 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 + - first: {x: 7, y: 8, z: 0} + second: + serializedVersion: 2 + m_TileIndex: 17 + m_TileSpriteIndex: 17 + m_TileMatrixIndex: 0 + m_TileColorIndex: 0 + m_TileObjectToInstantiateIndex: 65535 + dummyAlignment: 0 + m_AllTileFlags: 1073741825 m_AnimatedTiles: {} m_TileAssetArray: - m_RefCount: 0 @@ -322,20 +405,20 @@ Tilemap: m_Data: {fileID: 0} - m_RefCount: 0 m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 20a107a89fc4a45e9a6943b56316bdb8, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 4b68c7dccf4024034a0e5bbf76946e58, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 64041abb85b474ca8bc6ac42116f1a85, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 6b71a2339c12b42f4b7bd7a4b09b6034, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 51ca0b128c1864a00a6ad2934f8dd7dd, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: fb3afcb689bb1455094d893aa9ab5628, type: 2} + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: c121db5a25a0e412bb83365aa0c6f778, type: 2} m_TileSpriteArray: - m_RefCount: 0 m_Data: {fileID: 0} @@ -359,22 +442,22 @@ Tilemap: m_Data: {fileID: 0} - m_RefCount: 0 m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} + - m_RefCount: 1 + m_Data: {fileID: -1457016805, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: 1866999083, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: -2127686085, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: 2105632713, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: -1052406375, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: 1681623567, guid: ad684922a8aff654ebccc527594e7603, type: 3} + - m_RefCount: 1 + m_Data: {fileID: 1026215578, guid: ad684922a8aff654ebccc527594e7603, type: 3} m_TileMatrixArray: - - m_RefCount: 0 + - m_RefCount: 7 m_Data: e00: 1 e01: 0 @@ -393,13 +476,13 @@ Tilemap: e32: 0 e33: 1 m_TileColorArray: - - m_RefCount: 0 + - m_RefCount: 7 m_Data: {r: 1, g: 1, b: 1, a: 1} m_TileObjectToInstantiateArray: [] m_AnimationFrameRate: 1 m_Color: {r: 1, g: 1, b: 1, a: 1} m_Origin: {x: 0, y: 0, z: 0} - m_Size: {x: 9, y: 7, z: 1} + m_Size: {x: 9, y: 9, z: 1} m_TileAnchor: {x: 0.5, y: 0.5, z: 0} m_TileOrientation: 0 m_TileOrientationMatrix: @@ -988,8 +1071,8 @@ Tilemap: - first: {x: 1, y: 4, z: 0} second: serializedVersion: 2 - m_TileIndex: 16 - m_TileSpriteIndex: 15 + m_TileIndex: 15 + m_TileSpriteIndex: 16 m_TileMatrixIndex: 0 m_TileColorIndex: 0 m_TileObjectToInstantiateIndex: 65535 @@ -1457,9 +1540,9 @@ Tilemap: m_Data: {fileID: 0} - m_RefCount: 0 m_Data: {fileID: 0} - - m_RefCount: 0 - m_Data: {fileID: 0} - - m_RefCount: 40 + - m_RefCount: 1 + m_Data: {fileID: 11400000, guid: 6d8f4121c2ddc4126ab09a32de00e2a6, type: 2} + - m_RefCount: 39 m_Data: {fileID: 11400000, guid: 8b2babf76b74e4944a6bb0895e3d4647, type: 2} - m_RefCount: 41 m_Data: {fileID: 11400000, guid: dcca059947b4d724f90a78f2915a478b, type: 2} @@ -1494,10 +1577,10 @@ Tilemap: m_Data: {fileID: 0} - m_RefCount: 0 m_Data: {fileID: 0} - - m_RefCount: 40 + - m_RefCount: 39 m_Data: {fileID: 92044262, guid: 3ef9fd33020450a4c845f8e9166d5558, type: 3} - - m_RefCount: 0 - m_Data: {fileID: 0} + - m_RefCount: 1 + m_Data: {fileID: 976511200, guid: ad684922a8aff654ebccc527594e7603, type: 3} - m_RefCount: 41 m_Data: {fileID: -1574383922, guid: 3ef9fd33020450a4c845f8e9166d5558, type: 3} m_TileMatrixArray: @@ -2814,6 +2897,54 @@ Tilemap: e31: 0 e32: 0 e33: 1 +--- !u!1 &1314584499 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1314584501} + - component: {fileID: 1314584500} + m_Layer: 0 + m_Name: TrapManager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1314584500 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1314584499} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3e906695758a3d04197ddceb298f6c86, type: 3} + m_Name: + m_EditorClassIdentifier: + trapPrefabs: + - {fileID: 6097000079642511365, guid: 127c53d14a0062f41a16963a87a85dc5, type: 3} + - {fileID: 7646078152559978388, guid: 40bc1f37707e62f4297f85bf5c7b01b4, type: 3} + - {fileID: 6762149095286452822, guid: d7c2a5ac1f23afe428f872343ed56d71, type: 3} +--- !u!4 &1314584501 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1314584499} + serializedVersion: 2 + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -0.21531442, y: 0.33767503, z: 0.020564094} + m_LocalScale: {x: 1, y: 1, z: 1} + m_ConstrainProportionsScale: 0 + m_Children: [] + m_Father: {fileID: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1621253959 GameObject: m_ObjectHideFlags: 0 @@ -3460,6 +3591,7 @@ SceneRoots: m_ObjectHideFlags: 0 m_Roots: - {fileID: 519420032} + - {fileID: 1314584501} - {fileID: 619394802} - {fileID: 647252271} - {fileID: 166584760} diff --git a/Assets/Scripts/Map Control/PropsSystem.cs b/Assets/Scripts/Map Control/PropsSystem.cs new file mode 100644 index 00000000..bb7175f8 --- /dev/null +++ b/Assets/Scripts/Map Control/PropsSystem.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using UnityEngine; +using UnityEngine.Tilemaps; +using SocketIOClient; +using CandyCoded.env; + +public class PropsManager : MonoBehaviour +{ + private Tilemap propsTilemap; // Reference to the Tilemap component + private SocketIOUnity clientSocket; + private bool PropsSent = false; + + private void Start() + { + clientSocket = SocketManager.Instance.ClientSocket; + InvokeRepeating(nameof(CheckSocketAndSendProps), 0f, 5f); // Check connection every 5 seconds + } + + // Check if the socket is connected before sending props + private async void CheckSocketAndSendProps() + { + Debug.Log("Checking socket connection..."); + + if (!PropsSent && clientSocket != null && clientSocket.Connected) + { + await FindAndSendProps(); + } + else + { + Debug.LogWarning("Socket not connected, skipping props send."); + } + } + + // Find the grid and the props tilemap, then send props positions to the server + private async Task FindAndSendProps() + { + GameObject grid = GameObject.Find("Grid"); + + if (grid != null) + { + propsTilemap = grid.transform.Find("Props")?.GetComponent(); + + if (propsTilemap != null) + { + List propsPositions = GetPropsPositions(); + + if (propsPositions.Count > 0) + { + List propsPositionsString = ConvertPositionsToString(propsPositions); + await EmitPropsToServer(propsPositionsString); + + CancelInvoke(nameof(CheckSocketAndSendProps)); // Stop repeating checks after sending + } + } + else + { + Debug.LogError("Props Tilemap not found in Grid!"); + } + } + else + { + Debug.LogError("Grid object not found!"); + } + } + + // Get all positions where there are props on the Tilemap + private List GetPropsPositions() + { + BoundsInt bounds = propsTilemap.cellBounds; + List propsPositions = new List(); + + for (int x = bounds.xMin; x < bounds.xMax; x++) + { + for (int y = bounds.yMin; y < bounds.yMax; y++) + { + Vector3Int tilePosition = new Vector3Int(x, y, 0); + + if (propsTilemap.HasTile(tilePosition)) + { + propsPositions.Add(tilePosition); + } + } + } + + Debug.Log($"Total props found: {propsPositions.Count}"); + return propsPositions; + } + + // Convert Vector3 positions to strings + private List ConvertPositionsToString(List propsPositions) + { + List propsPositionsString = new List(); + + foreach (Vector3 position in propsPositions) + { + string positionString = $"{position.x}, {position.y}"; + propsPositionsString.Add(positionString); + } + + return propsPositionsString; + } + + // Emit the props positions to the server + private async Task EmitPropsToServer(List propsPositionsString) + { + try + { + Debug.Log("Emitting props to server..."); + await clientSocket.EmitAsync("rooms:create", propsPositionsString); + PropsSent = true; + Debug.Log("Props successfully sent to server."); + } + catch (Exception e) + { + Debug.LogError("Failed to emit props: " + e.Message); + } + } +} diff --git a/Assets/Scripts/Map Control/PropsSystem.cs.meta b/Assets/Scripts/Map Control/PropsSystem.cs.meta new file mode 100644 index 00000000..f3a0d26f --- /dev/null +++ b/Assets/Scripts/Map Control/PropsSystem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9880ea29492da44c995f334244a5d19e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index c2860957..fdd58f08 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -31,9 +31,7 @@ async void Start() { env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl); var uri = new Uri(socketUrl); - clientSocket = new SocketIOUnity(uri); - - await clientSocket.ConnectAsync(); + clientSocket = SocketManager.Instance.ClientSocket; animator = GetComponent(); } diff --git a/Assets/Scripts/SocketManager.cs b/Assets/Scripts/SocketManager.cs new file mode 100644 index 00000000..14eddfc6 --- /dev/null +++ b/Assets/Scripts/SocketManager.cs @@ -0,0 +1,53 @@ +using System; +using System.Threading.Tasks; +using UnityEngine; +using SocketIOClient; +using CandyCoded.env; + +public class SocketManager : MonoBehaviour +{ + private static SocketManager _instance; + public static SocketManager Instance => _instance; + + public SocketIOUnity ClientSocket { get; private set; } + + private void Awake() + { + if (_instance != null && _instance != this) + { + Destroy(this.gameObject); + } + else + { + _instance = this; + DontDestroyOnLoad(this.gameObject); // Keep the socket alive across scenes + SetupSocket().ConfigureAwait(false); // Ensure proper async handling + } + } + + private async Task SetupSocket() + { + try + { + env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl); + var uri = new Uri(socketUrl); + ClientSocket = new SocketIOUnity(uri); + + // Connect to the server + await ClientSocket.ConnectAsync(); + Debug.Log("Connected to backend via SocketManager."); + } + catch (Exception e) + { + Debug.LogError("Socket connection error: " + e.Message); + } + } + + private void OnApplicationQuit() + { + if (ClientSocket != null) + { + ClientSocket.Dispose(); // Properly close the connection + } + } +} diff --git a/Assets/Scripts/SocketManager.cs.meta b/Assets/Scripts/SocketManager.cs.meta new file mode 100644 index 00000000..7f14c6f6 --- /dev/null +++ b/Assets/Scripts/SocketManager.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9d1d8695cfa6948278518a6a55e0b730 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Trap/TrapManager.cs b/Assets/Scripts/Trap/TrapManager.cs index 32014a38..329f7df5 100644 --- a/Assets/Scripts/Trap/TrapManager.cs +++ b/Assets/Scripts/Trap/TrapManager.cs @@ -30,31 +30,13 @@ void Start() trapPrefabDictionary.Add("crossbow_side_prefab", trapPrefabs[2]); // Set up Socket.IO client - SetupSocket(); StartCoroutine(ProcessPlacementQueue()); } - async void SetupSocket() - { - try - { - env.TryParseEnvironmentVariable("SOCKET_URL", out string socketUrl); - var uri = new Uri(socketUrl); // Replace with your backend URL - clientSocket = new SocketIOUnity(uri); - - // Connect to the server - await clientSocket.ConnectAsync(); - - Debug.Log("Connected to backend and listening for trap placement events."); - } - catch (Exception e) - { - Debug.LogError("Socket connection error: " + e.Message); - } - } - public void Update() { + clientSocket = SocketManager.Instance.ClientSocket; + clientSocket.On("traps:place", response => { JArray trapDataArray = JArray.Parse(response.ToString()); diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 39c0baf1..d292537e 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -8,6 +8,7 @@ TagManager: - Wall - Enemy - Map + - Props layers: - Default - TransparentFX