From e6ff740f0e664ea6bd16c3718e2114d35ec39ece Mon Sep 17 00:00:00 2001 From: Hazim Bin Ijaz Date: Mon, 2 Dec 2024 13:20:49 +0500 Subject: [PATCH] Added Swap Confirmation UI Panel --- Assets/Scenes/BossRoom.unity | 830 +++++++++++++++++- .../Character/ServerCharacter.cs | 55 +- .../Scripts/Gameplay/SwapConfirmationPanel.cs | 41 + .../Gameplay/SwapConfirmationPanel.cs.meta | 11 + .../Gameplay/UserInput/ClientInputSender.cs | 45 +- 5 files changed, 932 insertions(+), 50 deletions(-) create mode 100644 Assets/Scripts/Gameplay/SwapConfirmationPanel.cs create mode 100644 Assets/Scripts/Gameplay/SwapConfirmationPanel.cs.meta diff --git a/Assets/Scenes/BossRoom.unity b/Assets/Scenes/BossRoom.unity index 32db342..a1f1e18 100644 --- a/Assets/Scenes/BossRoom.unity +++ b/Assets/Scenes/BossRoom.unity @@ -238,6 +238,140 @@ Transform: m_Children: [] m_Father: {fileID: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &171268272 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 171268273} + - component: {fileID: 171268275} + - component: {fileID: 171268274} + m_Layer: 5 + m_Name: Text (TMP) (1) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &171268273 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 171268272} + 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: 4916910949679961597} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 1} + m_AnchorMax: {x: 0.5, y: 1} + m_AnchoredPosition: {x: 0, y: -164} + m_SizeDelta: {x: 764.1801, y: 238.8062} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &171268274 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 171268272} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Do you wish to swap platforms? + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_sharedMaterial: {fileID: -466885322316925189, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 1 + m_colorMode: 2 + m_fontColorGradient: + topLeft: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + topRight: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + bottomLeft: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + bottomRight: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 45 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 36 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 0 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 1 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &171268275 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 171268272} + m_CullTransparentMesh: 1 --- !u!1001 &222782633 PrefabInstance: m_ObjectHideFlags: 0 @@ -262,6 +396,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 103977269980398714, guid: 523332e67f2466e4f818161850bfb207, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 103977269980398718, guid: 523332e67f2466e4f818161850bfb207, type: 3} propertyPath: m_PlayerAvatars value: @@ -498,6 +636,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 5277713031123338911, guid: 523332e67f2466e4f818161850bfb207, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 5277713031198912409, guid: 523332e67f2466e4f818161850bfb207, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -522,6 +664,10 @@ PrefabInstance: propertyPath: m_AnchoredPosition.y value: 0 objectReference: {fileID: 0} + - target: {fileID: 5277713031219212455, guid: 523332e67f2466e4f818161850bfb207, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 5277713031684110771, guid: 523332e67f2466e4f818161850bfb207, type: 3} propertyPath: m_Name value: BossRoomHudCanvas @@ -802,6 +948,10 @@ PrefabInstance: propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName value: Unity.BossRoom.DebugCheats.DebugCheatsManager, Unity.BossRoom.DebugCheats objectReference: {fileID: 0} + - target: {fileID: 7649295862146065024, guid: 523332e67f2466e4f818161850bfb207, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} - target: {fileID: 7751809698112596105, guid: 523332e67f2466e4f818161850bfb207, type: 3} propertyPath: m_AnchorMax.y value: 0 @@ -904,7 +1054,10 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] - m_AddedGameObjects: [] + m_AddedGameObjects: + - targetCorrespondingSourceObject: {fileID: 5277713031684110775, guid: 523332e67f2466e4f818161850bfb207, type: 3} + insertIndex: 5 + addedObject: {fileID: 4916910949679961597} m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 523332e67f2466e4f818161850bfb207, type: 3} --- !u!1 &222782634 stripped @@ -912,6 +1065,11 @@ GameObject: m_CorrespondingSourceObject: {fileID: 7649295862146065024, guid: 523332e67f2466e4f818161850bfb207, type: 3} m_PrefabInstance: {fileID: 222782633} m_PrefabAsset: {fileID: 0} +--- !u!224 &222782635 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 5277713031684110775, guid: 523332e67f2466e4f818161850bfb207, type: 3} + m_PrefabInstance: {fileID: 222782633} + m_PrefabAsset: {fileID: 0} --- !u!1 &222782636 stripped GameObject: m_CorrespondingSourceObject: {fileID: 5277713031684110771, guid: 523332e67f2466e4f818161850bfb207, type: 3} @@ -8108,6 +8266,139 @@ Transform: m_CorrespondingSourceObject: {fileID: 5655447013084909147, guid: 8b9c63e7d70c5ff48a03aad51e17103c, type: 3} m_PrefabInstance: {fileID: 828804356} m_PrefabAsset: {fileID: 0} +--- !u!1 &863331223 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 863331224} + - component: {fileID: 863331227} + - component: {fileID: 863331226} + - component: {fileID: 863331225} + m_Layer: 5 + m_Name: No + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &863331224 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863331223} + 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: 1411799577} + m_Father: {fileID: 4916910949679961597} + 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: -98} + m_SizeDelta: {x: 300, y: 90} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &863331225 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863331223} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 863331226} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1486746209} + m_TargetAssemblyTypeName: SwapConfirmationPanel, Unity.BossRoom.Gameplay + m_MethodName: OnDeclineButtonPressed + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &863331226 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863331223} + 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: 21300000, guid: 41948b4cc6087644b983dce55b466d50, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &863331227 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 863331223} + m_CullTransparentMesh: 1 --- !u!1001 &1019511270 PrefabInstance: m_ObjectHideFlags: 0 @@ -8240,11 +8531,11 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.w - value: 0.85294455 + value: 0.8529446 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.x - value: 0.3943448 + value: 0.39434478 objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.y @@ -8252,7 +8543,7 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 1676734515771252668, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_LocalRotation.z - value: -0.14352979 + value: -0.14352977 objectReference: {fileID: 0} - target: {fileID: 1676734516302391364, guid: 0193228de87741d40a42e561901c9083, type: 3} propertyPath: m_UpdateMethod @@ -8401,15 +8692,15 @@ PrefabInstance: objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.x - value: 0.39434484 + value: 0.3943448 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.y - value: 0.3104465 + value: 0.31044644 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalRotation.z - value: -0.1435298 + value: -0.14352976 objectReference: {fileID: 0} - target: {fileID: 203267159508449512, guid: 36b3ee75677a1544191c0ddaaadd8140, type: 3} propertyPath: m_LocalEulerAnglesHint.x @@ -8714,6 +9005,185 @@ Transform: m_CorrespondingSourceObject: {fileID: 5691911501814053476, guid: 288fedacccf30e44eacf97f6a9f330c2, type: 3} m_PrefabInstance: {fileID: 1183029603} m_PrefabAsset: {fileID: 0} +--- !u!1 &1411799576 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1411799577} + - component: {fileID: 1411799579} + - component: {fileID: 1411799578} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1411799577 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1411799576} + 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: 863331224} + 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: 256, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1411799578 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1411799576} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: No + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_sharedMaterial: {fileID: -466885322316925189, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 1 + m_colorMode: 2 + m_fontColorGradient: + topLeft: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + topRight: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + bottomLeft: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + bottomRight: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 45 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 36 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 0 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 1 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1411799579 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1411799576} + m_CullTransparentMesh: 1 +--- !u!1 &1486746208 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1486746210} + - component: {fileID: 1486746209} + m_Layer: 0 + m_Name: Swap Confirmation Manager + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1486746209 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1486746208} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: e799529efab1c9d4ab780bfd693439d1, type: 3} + m_Name: + m_EditorClassIdentifier: + confirmationPanel: {fileID: 125665959027215112} +--- !u!4 &1486746210 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1486746208} + 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: 0} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &1531756835 PrefabInstance: m_ObjectHideFlags: 0 @@ -9611,6 +10081,321 @@ Transform: m_CorrespondingSourceObject: {fileID: 5739904768397314189, guid: 0cfb7e9298a474f49861ac0cc9601866, type: 3} m_PrefabInstance: {fileID: 2118781098} m_PrefabAsset: {fileID: 0} +--- !u!1 &125665959027215112 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4916910949679961597} + - component: {fileID: 4153664187659608246} + - component: {fileID: 758037865541746031} + m_Layer: 5 + m_Name: Swap Confirmation Panel + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!114 &758037865541746031 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 125665959027215112} + 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: 21300000, guid: 222f76e9081efb6428be38c0e10f7bde, type: 3} + 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!114 &1097733522617768012 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733522617768018} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_RaycastTarget: 0 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: Yes + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_sharedMaterial: {fileID: -466885322316925189, guid: 1a8c97d4cbe5134499b26527f8609c7e, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4294967295 + m_fontColor: {r: 1, g: 1, b: 1, a: 1} + m_enableVertexGradient: 1 + m_colorMode: 2 + m_fontColorGradient: + topLeft: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + topRight: {r: 0.92156863, g: 1, b: 0.17254902, a: 1} + bottomLeft: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + bottomRight: {r: 1, g: 0.668189, b: 0.07924521, a: 1} + m_fontColorGradientPreset: {fileID: 0} + m_spriteAsset: {fileID: 0} + m_tintAllSprites: 0 + m_StyleSheet: {fileID: 0} + m_TextStyleHashCode: -1183493901 + m_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_fontSize: 36 + m_fontSizeBase: 45 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 36 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 512 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 0 + m_wordWrappingRatios: 0.4 + m_overflowMode: 0 + m_linkedTextComponent: {fileID: 0} + parentLinkedComponent: {fileID: 0} + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_IsTextObjectScaleStatic: 0 + m_VertexBufferAutoSizeReduction: 1 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_hasFontAssetChanged: 0 + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &1097733522617768013 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733522617768018} + m_CullTransparentMesh: 1 +--- !u!1 &1097733522617768018 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1097733522617768019} + - component: {fileID: 1097733522617768013} + - component: {fileID: 1097733522617768012} + m_Layer: 5 + m_Name: Text (TMP) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1097733522617768019 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733522617768018} + 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: 1097733523035723444} + 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: 256, y: 80} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!224 &1097733523035723444 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733523035723451} + 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: 1097733522617768019} + m_Father: {fileID: 4916910949679961597} + 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: 300, y: 90} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1097733523035723445 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733523035723451} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Navigation: + m_Mode: 3 + m_WrapAround: 0 + m_SelectOnUp: {fileID: 0} + m_SelectOnDown: {fileID: 0} + m_SelectOnLeft: {fileID: 0} + m_SelectOnRight: {fileID: 0} + m_Transition: 1 + m_Colors: + m_NormalColor: {r: 1, g: 1, b: 1, a: 1} + m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1} + m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1} + m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608} + m_ColorMultiplier: 1 + m_FadeDuration: 0.1 + m_SpriteState: + m_HighlightedSprite: {fileID: 0} + m_PressedSprite: {fileID: 0} + m_SelectedSprite: {fileID: 0} + m_DisabledSprite: {fileID: 0} + m_AnimationTriggers: + m_NormalTrigger: Normal + m_HighlightedTrigger: Highlighted + m_PressedTrigger: Pressed + m_SelectedTrigger: Selected + m_DisabledTrigger: Disabled + m_Interactable: 1 + m_TargetGraphic: {fileID: 1097733523035723446} + m_OnClick: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1486746209} + m_TargetAssemblyTypeName: SwapConfirmationPanel, Unity.BossRoom.Gameplay + m_MethodName: OnAcceptButtonPressed + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 2 +--- !u!114 &1097733523035723446 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733523035723451} + 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: 21300000, guid: 41948b4cc6087644b983dce55b466d50, type: 3} + m_Type: 0 + m_PreserveAspect: 1 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 + m_PixelsPerUnitMultiplier: 1 +--- !u!222 &1097733523035723447 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1097733523035723451} + m_CullTransparentMesh: 1 +--- !u!1 &1097733523035723451 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1097733523035723444} + - component: {fileID: 1097733523035723447} + - component: {fileID: 1097733523035723446} + - component: {fileID: 1097733523035723445} + m_Layer: 5 + m_Name: Yes + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 --- !u!4 &3605442766607006888 Transform: m_ObjectHideFlags: 0 @@ -9763,6 +10548,36 @@ PrefabInstance: m_AddedGameObjects: [] m_AddedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: cc55d0a8a5047dc48905945e6431a5ec, type: 3} +--- !u!222 &4153664187659608246 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 125665959027215112} + m_CullTransparentMesh: 1 +--- !u!224 &4916910949679961597 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 125665959027215112} + 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: 171268273} + - {fileID: 1097733523035723444} + - {fileID: 863331224} + m_Father: {fileID: 222782635} + 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: -80} + m_SizeDelta: {x: 1250, y: 780} + m_Pivot: {x: 0.5, y: 0.5} --- !u!1660057539 &9223372036854775807 SceneRoots: m_ObjectHideFlags: 0 @@ -9786,3 +10601,4 @@ SceneRoots: - {fileID: 791609700} - {fileID: 1716415238} - {fileID: 1690610726} + - {fileID: 1486746210} diff --git a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs index 3b559ec..a90dbbb 100644 --- a/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs +++ b/Assets/Scripts/Gameplay/GameplayObjects/Character/ServerCharacter.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Collections.Generic; using Unity.BossRoom.ConnectionManagement; using Unity.BossRoom.Gameplay.Actions; using Unity.BossRoom.Gameplay.Configuration; @@ -151,17 +152,65 @@ namespace Unity.BossRoom.Gameplay.GameplayObjects.Character NetHealthState = GetComponent(); m_State = GetComponent(); } + [Rpc(SendTo.Everyone)] + private void ShowSwapConfirmationPanelClientRpc() + { + if (NetworkManager.Singleton.LocalClientId == OwnerClientId) + { + // Show the confirmation panel for the specific player + var panel = FindObjectOfType(); + if (panel != null) + { + panel.ShowPanel(this); // Pass the current ServerCharacter reference + } + else + { + Debug.LogError("SwapConfirmationPanel not found in the scene!"); + } + } + } + [Rpc(SendTo.Server, RequireOwnership = false)] public void NotifySwapRequestRpc(ulong initiatingPlayerId) { PendingSwapRequest = initiatingPlayerId; - Debug.Log($"Swap request received from Player {initiatingPlayerId}. Press 'L' to confirm."); + + // Notify all clients except the server, filtered by target + ShowSwapConfirmationPanelClientRpc(); + + Debug.Log($"Swap request received from Player {initiatingPlayerId}. Waiting for confirmation."); } + [Rpc(SendTo.Server, RequireOwnership = false)] - public void NotifySwapConfirmedRpc(ulong targetPlayerId) + public void NotifySwapDecisionRpc(bool isAccepted) { - Debug.Log($"Swap request confirmed by Player {targetPlayerId}."); + if (!PendingSwapRequest.HasValue) return; + + ulong initiatingPlayerId = PendingSwapRequest.Value; + + if (isAccepted) + { + if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(initiatingPlayerId, out var initiatingPlayerObj) && + initiatingPlayerObj.TryGetComponent(out ServerCharacter initiatingPlayer)) + { + Vector3 initiatingPlayerPosition = initiatingPlayer.physicsWrapper.Transform.position; + Vector3 targetPlayerPosition = this.physicsWrapper.Transform.position; + + // Execute the swap + initiatingPlayer.ServerSendCharacterInputRpc(targetPlayerPosition); + this.ServerSendCharacterInputRpc(initiatingPlayerPosition); + + Debug.Log($"Swap confirmed: {initiatingPlayer.name} swapped with {this.name}."); + } + } + else + { + Debug.Log($"Swap request denied by {this.name}."); + } + + // Clear pending request + PendingSwapRequest = null; } diff --git a/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs b/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs new file mode 100644 index 0000000..deecc40 --- /dev/null +++ b/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs @@ -0,0 +1,41 @@ +using System.Collections; +using System.Collections.Generic; +using Unity.BossRoom.Gameplay.GameplayObjects.Character; +using Unity.Netcode; +using UnityEngine; +using UnityEngine.UI; + +public class SwapConfirmationPanel : MonoBehaviour +{ + [SerializeField] private GameObject confirmationPanel; + private ServerCharacter associatedCharacter; // Reference to the correct ServerCharacter instance + + public void ShowPanel(ServerCharacter character) + { + associatedCharacter = character; // Set the associated character + confirmationPanel.SetActive(true); + } + + public void OnAcceptButtonPressed() + { + SendDecisionToServer(true); + } + + public void OnDeclineButtonPressed() + { + SendDecisionToServer(false); + } + + private void SendDecisionToServer(bool isAccepted) + { + if (associatedCharacter != null) + { + associatedCharacter.NotifySwapDecisionRpc(isAccepted); + } + else + { + Debug.LogError("No associated ServerCharacter found for this swap decision!"); + } + confirmationPanel.SetActive(false); + } +} diff --git a/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs.meta b/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs.meta new file mode 100644 index 0000000..5853e2d --- /dev/null +++ b/Assets/Scripts/Gameplay/SwapConfirmationPanel.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e799529efab1c9d4ab780bfd693439d1 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs index 52f0920..5e424c3 100644 --- a/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs +++ b/Assets/Scripts/Gameplay/UserInput/ClientInputSender.cs @@ -514,41 +514,6 @@ namespace Unity.BossRoom.Gameplay.UserInput { RequestAction(GameDataSource.Instance.Emote4ActionPrototype.ActionID, SkillTriggerStyle.Keyboard); } - if (Input.GetKeyDown(KeyCode.L)) // Press L to confirm the swap - { - if (m_ServerCharacter.PendingSwapRequest.HasValue) - { - ulong initiatingPlayerId = m_ServerCharacter.PendingSwapRequest.Value; - - if (NetworkManager.Singleton.SpawnManager.SpawnedObjects.TryGetValue(initiatingPlayerId, out var initiatingPlayerObject) && - initiatingPlayerObject.TryGetComponent(out ServerCharacter initiatingPlayer)) - { - // Store positions of both players - Vector3 initiatingPlayerPosition = initiatingPlayer.physicsWrapper.Transform.position; - Vector3 targetPlayerPosition = m_ServerCharacter.physicsWrapper.Transform.position; - - // Execute the swap - initiatingPlayer.ServerSendCharacterInputRpc(targetPlayerPosition); - m_ServerCharacter.ServerSendCharacterInputRpc(initiatingPlayerPosition); - - Debug.Log($"Swap confirmed: {initiatingPlayer.name} swapped with {m_ServerCharacter.name}."); - - // Clear the pending request - m_ServerCharacter.PendingSwapRequest = null; - - // Notify initiating player about confirmation (optional for UI feedback) - initiatingPlayer.NotifySwapConfirmedRpc(m_ServerCharacter.NetworkObjectId); - } - else - { - Debug.LogError("Swap confirmation failed: Initiating player not found."); - } - } - else - { - Debug.Log("No pending swap request to confirm."); - } - } if (!EventSystem.current.IsPointerOverGameObject() && m_CurrentSkillInput == null) { @@ -560,7 +525,7 @@ namespace Unity.BossRoom.Gameplay.UserInput RequestAction(CharacterClass.Skill1.ActionID, SkillTriggerStyle.MouseClick); } - if (Input.GetMouseButtonDown(0)) // Left-click triggers the SwapAction request + if (Input.GetMouseButtonDown(0)) // Left-click to request swap { var ray = m_MainCamera.ScreenPointToRay(UnityEngine.Input.mousePosition); int hits = Physics.RaycastNonAlloc(ray, k_CachedHit, k_MouseInputRaycastDistance, m_ActionLayerMask); @@ -572,22 +537,22 @@ namespace Unity.BossRoom.Gameplay.UserInput if (k_CachedHit[i].transform.TryGetComponent(out NetworkObject targetNetObj) && targetNetObj != m_ServerCharacter.NetworkObject) { - // Retrieve the target character + // Check if the target is a valid ServerCharacter if (!targetNetObj.TryGetComponent(out ServerCharacter targetCharacter)) { Debug.LogError("SwapAction failed: Target is not a valid ServerCharacter!"); return; } - // Notify the target player (send confirmation request) + // Notify the target player about the swap request targetCharacter.NotifySwapRequestRpc(m_ServerCharacter.NetworkObjectId); - - Debug.Log($"SwapAction requested: Waiting for {targetCharacter.name} to confirm."); + Debug.Log($"Swap request sent to {targetCharacter.name}."); return; // Exit loop after sending the request } } } } + else if(Input.GetMouseButtonDown(0)) {