From b3dffac09758f201c00616a750088447330a3ddd Mon Sep 17 00:00:00 2001 From: teascade Date: Sat, 8 Aug 2020 15:37:55 +0300 Subject: [PATCH] Make death a thing! --- .../GameObjects/Prefabs/UI/DeadScreen.prefab | 498 ++++++++++++++++++ .../Prefabs/UI/DeadScreen.prefab.meta | 7 + Assets/GameObjects/Scenes/TestScene.unity | 135 ++++- Assets/Scripts/Interface/DeadScreen.cs | 51 ++ Assets/Scripts/Interface/DeadScreen.cs.meta | 11 + Assets/Scripts/Networking/GameProtocol.cs | 1 + Assets/Scripts/Networking/Instances/Client.cs | 19 +- Assets/Scripts/Networking/Instances/Server.cs | 12 +- .../Scripts/Networking/Packets/SpawnPckt.cs | 22 + Assets/Scripts/Players/Player.cs | 38 +- ProjectSettings/TagManager.asset | 1 + 11 files changed, 773 insertions(+), 22 deletions(-) create mode 100644 Assets/GameObjects/Prefabs/UI/DeadScreen.prefab create mode 100644 Assets/GameObjects/Prefabs/UI/DeadScreen.prefab.meta create mode 100644 Assets/Scripts/Interface/DeadScreen.cs create mode 100644 Assets/Scripts/Interface/DeadScreen.cs.meta diff --git a/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab b/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab new file mode 100644 index 0000000..0d7ae23 --- /dev/null +++ b/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab @@ -0,0 +1,498 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &5012256108666685483 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8861545984823841015} + - component: {fileID: 5752193893751936224} + m_Layer: 5 + m_Name: DeadScreen + m_TagString: DeadScreen + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &8861545984823841015 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5012256108666685483} + 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_Children: + - {fileID: 3371112116215780634} + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &5752193893751936224 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5012256108666685483} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 36d522d609d986643aa1a648d2d61215, type: 3} + m_Name: + m_EditorClassIdentifier: + Crosshair: {fileID: 0} + Root: {fileID: 5471352474105955327} + KilledText: {fileID: 6227215403006990123} + RespawnText: {fileID: 2538438069157359999} + Open: 0 + LastUpdate: 0 + seconds: 0 +--- !u!1 &5471352474105955327 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3371112116215780634} + m_Layer: 5 + m_Name: Root + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &3371112116215780634 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 5471352474105955327} + 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_Children: + - {fileID: 2022817657939248233} + - {fileID: 9167131601190067545} + - {fileID: 7212956555095782461} + m_Father: {fileID: 8861545984823841015} + m_RootOrder: 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 &6833254667160980643 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7212956555095782461} + - component: {fileID: 2641049770738940133} + - component: {fileID: 2538438069157359999} + m_Layer: 0 + m_Name: RespawnText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &7212956555095782461 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6833254667160980643} + 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_Children: [] + m_Father: {fileID: 3371112116215780634} + m_RootOrder: 2 + 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.000011444, y: -64} + m_SizeDelta: {x: 296.40717, y: 36.626602} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &2641049770738940133 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6833254667160980643} + m_CullTransparentMesh: 0 +--- !u!114 &2538438069157359999 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6833254667160980643} + 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: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: c780c2251e690fb498319dc38127843c, type: 2} + m_sharedMaterial: {fileID: 4067991147299334843, guid: c780c2251e690fb498319dc38127843c, 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: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, 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: 25 + m_fontSizeBase: 25 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + 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!1 &8982772708179639848 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2022817657939248233} + - component: {fileID: 9153114744820804395} + - component: {fileID: 8547036058795497140} + m_Layer: 0 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &2022817657939248233 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8982772708179639848} + 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_Children: [] + m_Father: {fileID: 3371112116215780634} + m_RootOrder: 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.000011444, y: 70} + m_SizeDelta: {x: 393.74286, y: 65.87906} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &9153114744820804395 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8982772708179639848} + m_CullTransparentMesh: 0 +--- !u!114 &8547036058795497140 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8982772708179639848} + 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: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: You are Dead! + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: c780c2251e690fb498319dc38127843c, type: 2} + m_sharedMaterial: {fileID: 4067991147299334843, guid: c780c2251e690fb498319dc38127843c, 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: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, 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: 50 + m_fontSizeBase: 50 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + 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!1 &9078022159588969913 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 9167131601190067545} + - component: {fileID: 793731933260604192} + - component: {fileID: 6227215403006990123} + m_Layer: 0 + m_Name: KillerText + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &9167131601190067545 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9078022159588969913} + 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_Children: [] + m_Father: {fileID: 3371112116215780634} + m_RootOrder: 1 + 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.000019073, y: 21.455} + m_SizeDelta: {x: 226.01532, y: 31.211838} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!222 &793731933260604192 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9078022159588969913} + m_CullTransparentMesh: 0 +--- !u!114 &6227215403006990123 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 9078022159588969913} + 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: 1 + m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0} + m_Maskable: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_text: + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: c780c2251e690fb498319dc38127843c, type: 2} + m_sharedMaterial: {fileID: 4067991147299334843, guid: c780c2251e690fb498319dc38127843c, 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: 0 + m_colorMode: 3 + m_fontColorGradient: + topLeft: {r: 1, g: 1, b: 1, a: 1} + topRight: {r: 1, g: 1, b: 1, a: 1} + bottomLeft: {r: 1, g: 1, b: 1, a: 1} + bottomRight: {r: 1, g: 1, b: 1, 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: 20 + m_fontSizeBase: 20 + m_fontWeight: 400 + m_enableAutoSizing: 0 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 2 + m_VerticalAlignment: 256 + m_textAlignment: 65535 + m_characterSpacing: 0 + m_wordSpacing: 0 + m_lineSpacing: 0 + m_lineSpacingMax: 0 + m_paragraphSpacing: 0 + m_charWidthMaxAdj: 0 + m_enableWordWrapping: 1 + 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} diff --git a/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab.meta b/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab.meta new file mode 100644 index 0000000..63f4ca8 --- /dev/null +++ b/Assets/GameObjects/Prefabs/UI/DeadScreen.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 118c1cf390ce96243b1b8b147ae99885 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/GameObjects/Scenes/TestScene.unity b/Assets/GameObjects/Scenes/TestScene.unity index 7294cdb..9895b80 100644 --- a/Assets/GameObjects/Scenes/TestScene.unity +++ b/Assets/GameObjects/Scenes/TestScene.unity @@ -1365,7 +1365,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79038 + m_Name: pb_Mesh47254 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -3089,7 +3089,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78918 + m_Name: pb_Mesh47184 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -3789,7 +3789,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79150 + m_Name: pb_Mesh47338 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -4458,7 +4458,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78710 + m_Name: pb_Mesh47014 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -5977,7 +5977,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79120 + m_Name: pb_Mesh47304 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -7921,7 +7921,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79242 + m_Name: pb_Mesh47408 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -11422,7 +11422,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78650 + m_Name: pb_Mesh46974 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -12485,6 +12485,11 @@ Transform: m_Father: {fileID: 524351210} m_RootOrder: 9 m_LocalEulerAnglesHint: {x: 0, y: -180, z: 0} +--- !u!224 &1457097245 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + m_PrefabInstance: {fileID: 3448244061752814898} + m_PrefabAsset: {fileID: 0} --- !u!1 &1470235296 GameObject: m_ObjectHideFlags: 0 @@ -12990,7 +12995,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79012 + m_Name: pb_Mesh47228 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -16754,7 +16759,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78686 + m_Name: pb_Mesh47000 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -17074,7 +17079,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79070 + m_Name: pb_Mesh47282 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -17324,6 +17329,7 @@ RectTransform: m_Children: - {fileID: 629769913} - {fileID: 267525579} + - {fileID: 1457097245} m_Father: {fileID: 187747573} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -17542,7 +17548,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79178 + m_Name: pb_Mesh47366 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -17798,7 +17804,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh79190 + m_Name: pb_Mesh47378 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -18136,7 +18142,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78628 + m_Name: pb_Mesh46962 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -18300,7 +18306,7 @@ Mesh: m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_Name: pb_Mesh78844 + m_Name: pb_Mesh47126 serializedVersion: 10 m_SubMeshes: - serializedVersion: 2 @@ -18752,3 +18758,104 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1a03b85f19189674187c9966f5f557e3, type: 3} +--- !u!1001 &3448244061752814898 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1734890299} + m_Modifications: + - target: {fileID: 5012256108666685483, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_Name + value: DeadScreen + objectReference: {fileID: 0} + - target: {fileID: 5752193893751936224, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: Crosshair + value: + objectReference: {fileID: 629769914} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchoredPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_SizeDelta.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchorMin.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 8861545984823841015, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 118c1cf390ce96243b1b8b147ae99885, type: 3} diff --git a/Assets/Scripts/Interface/DeadScreen.cs b/Assets/Scripts/Interface/DeadScreen.cs new file mode 100644 index 0000000..c42e153 --- /dev/null +++ b/Assets/Scripts/Interface/DeadScreen.cs @@ -0,0 +1,51 @@ + +using UnityEngine; +using UnityEngine.UI; +using TMPro; + +namespace NeonTea.Quakeball.Interface { + public class DeadScreen : MonoBehaviour { + + public Image Crosshair; + public GameObject Root; + public TMP_Text KilledText; + public TMP_Text RespawnText; + + public bool Open = false; + + public float LastUpdate; + public int seconds; + + public void Start() { + Terminal.Singleton.RegisterCommand("dead", args => { + if (args.Length == 1) { + StartCountdown(args[0]); + return true; + } + Terminal.Singleton.Println("Need 1 argument for killer's name!"); + return false; + }, "dead - Starts the DeadScreen with given name as the killer's name."); + } + + public void Update() { + Root.gameObject.SetActive(Open); + if (Crosshair != null) { + Crosshair.enabled = !Open; + } + if (seconds > 0 && Time.time - LastUpdate > 1) { + LastUpdate = Time.time; + seconds--; + string secondsText = (seconds > 0) ? seconds.ToString() : ""; + RespawnText.text = $"Respawn in {secondsText}.."; + } + } + + public void StartCountdown(string killer) { + Open = true; + KilledText.text = $"Killed by {killer}"; + LastUpdate = Time.time; + seconds = 3; + RespawnText.text = $"Respawn in {seconds}.."; + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/Interface/DeadScreen.cs.meta b/Assets/Scripts/Interface/DeadScreen.cs.meta new file mode 100644 index 0000000..acfc14b --- /dev/null +++ b/Assets/Scripts/Interface/DeadScreen.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 36d522d609d986643aa1a648d2d61215 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Networking/GameProtocol.cs b/Assets/Scripts/Networking/GameProtocol.cs index 973d90b..1254891 100644 --- a/Assets/Scripts/Networking/GameProtocol.cs +++ b/Assets/Scripts/Networking/GameProtocol.cs @@ -27,6 +27,7 @@ namespace NeonTea.Quakeball.Networking { RegisterPacket(typeof(MultiplePlayerUpdatesPckt)); RegisterPacket(typeof(MultipleSyncsPckt)); RegisterPacket(typeof(HitPckt)); + RegisterPacket(typeof(DeadPckt)); } public override void ConnectionStatusChanged(ConnectionStatus oldStatus, ConnectionStatus newStatus, Connection conn) { diff --git a/Assets/Scripts/Networking/Instances/Client.cs b/Assets/Scripts/Networking/Instances/Client.cs index b0800cd..4728e47 100644 --- a/Assets/Scripts/Networking/Instances/Client.cs +++ b/Assets/Scripts/Networking/Instances/Client.cs @@ -95,11 +95,16 @@ namespace NeonTea.Quakeball.Networking.Instances { Player obj = Net.SpawnPlayer(spawn.Location).GetComponent(); NetPlayer player = new NetPlayer(spawn.PlayerId, obj); Players.Add(spawn.PlayerId, player); - } else { + } else if (Players[spawn.PlayerId].Controlled.IsDead) { if (Players.ContainsKey(spawn.PlayerId)) { - HandlePlayerDeath(spawn.PlayerId, spawn.Location); + HandlePlayerRespawn(spawn.PlayerId, spawn.Location); } } + } else if (packet is DeadPckt) { + DeadPckt dead = (DeadPckt)packet; + if (Players.ContainsKey(dead.DeadPlayerId)) { + HandlePlayerDeath(dead.DeadPlayerId, dead.KillerPlayerId); + } } else if (packet is MultiplePlayerUpdatesPckt) { MultiplePlayerUpdatesPckt multiple = (MultiplePlayerUpdatesPckt)packet; foreach (PlayerUpdatePckt pckt in multiple.Updates) { @@ -192,9 +197,15 @@ namespace NeonTea.Quakeball.Networking.Instances { } } - public void HandlePlayerDeath(ulong uid, Vector3 respawn) { + public void HandlePlayerDeath(ulong dead, ulong killer) { + if (Players[dead].Controlled != null) { + Players[dead].Controlled.Dead(killer); + } + } + + public void HandlePlayerRespawn(ulong uid, Vector3 respawn) { if (Players[uid].Controlled != null) { - Players[uid].Controlled.transform.position = respawn; + Players[uid].Controlled.Respawn(respawn); } } } diff --git a/Assets/Scripts/Networking/Instances/Server.cs b/Assets/Scripts/Networking/Instances/Server.cs index 29b8eb5..43cda7e 100644 --- a/Assets/Scripts/Networking/Instances/Server.cs +++ b/Assets/Scripts/Networking/Instances/Server.cs @@ -207,12 +207,18 @@ namespace NeonTea.Quakeball.Networking.Instances { SendReliableToAll(hit); } - public void HandlePlayerDeath(ulong uid) { + public void HandlePlayerDeath(ulong deadid, ulong killerid) { + Players[deadid].Controlled.Dead(killerid); + DeadPckt dead = new DeadPckt(deadid, killerid); + SendReliableToAll(dead); + } + + public void HandlePlayerRespawn(ulong uid) { Vector3 point = GameObject.FindGameObjectWithTag("Respawn").transform.position; - Player player = Players[uid].Controlled; - player.transform.position = point; + Players[uid].Controlled.Respawn(point); SpawnPckt spawn = new SpawnPckt(point, uid, false); SendReliableToAll(spawn); + } } } \ No newline at end of file diff --git a/Assets/Scripts/Networking/Packets/SpawnPckt.cs b/Assets/Scripts/Networking/Packets/SpawnPckt.cs index 18a6db6..f1cdb5c 100644 --- a/Assets/Scripts/Networking/Packets/SpawnPckt.cs +++ b/Assets/Scripts/Networking/Packets/SpawnPckt.cs @@ -29,6 +29,28 @@ namespace NeonTea.Quakeball.Networking.Packets { } } + public class DeadPckt : Packet { + + public ulong DeadPlayerId; + public ulong KillerPlayerId; + + public DeadPckt() { } + public DeadPckt(ulong deadid, ulong killerid) { + DeadPlayerId = deadid; + KillerPlayerId = killerid; + } + + public override void Read(ByteBuffer buffer) { + DeadPlayerId = buffer.ReadULong(); + KillerPlayerId = buffer.ReadULong(); + } + + public override void Write(ByteBuffer buffer) { + buffer.Write(DeadPlayerId); + buffer.Write(KillerPlayerId); + } + } + public class SelfIdentPckt : Packet { public ulong PlayerId; diff --git a/Assets/Scripts/Players/Player.cs b/Assets/Scripts/Players/Player.cs index c4ef1fe..e80adc5 100644 --- a/Assets/Scripts/Players/Player.cs +++ b/Assets/Scripts/Players/Player.cs @@ -4,6 +4,7 @@ using NeonTea.Quakeball.Util; using NeonTea.Quakeball.Networking; using NeonTea.Quakeball.Networking.Instances; using NeonTea.Quakeball.Combat; +using NeonTea.Quakeball.Interface; namespace NeonTea.Quakeball.Players { /// The central glue class for players (both local and remote). @@ -77,6 +78,9 @@ namespace NeonTea.Quakeball.Players { /// The possible networked Id of this Player instance public ulong NetId; + /// Is the player dead + public bool IsDead; + public float LatestGroundedY; [Header("Misc. technical knobs")] @@ -91,6 +95,7 @@ namespace NeonTea.Quakeball.Players { private Vector3 FeetPosition; private float LastShot; + private float TimeofDeath; /// Creates a PlayerUpdatePckt representing this Player's current status, for sending to other peers. public PlayerUpdatePckt CreateUpdatePacket(ulong id = 0) { @@ -198,7 +203,7 @@ namespace NeonTea.Quakeball.Players { public void Hit(ulong sourceUid) { if (Net.Singleton.Instance is Server) { - ((Server)Net.Singleton.Instance).HandlePlayerDeath(NetId); + ((Server)Net.Singleton.Instance).HandlePlayerDeath(NetId, sourceUid); } bool IsLocal = true; if (Net.Singleton.Instance != null) { @@ -211,6 +216,29 @@ namespace NeonTea.Quakeball.Players { } } + /// Called when this Player is dead + public void Dead(ulong killer) { + if (IsDead) { + return; + } + // Do something so the dead can not move even if they so wish. + if (Net.Singleton.Instance != null && Net.Singleton.Instance.LocalPlayer.Id == NetId) { + string name = $"Connection {killer}"; + GameObject.FindGameObjectWithTag("DeadScreen").GetComponent().StartCountdown(name); + } + TimeofDeath = Time.time; + IsDead = true; + } + + /// Called when this Player is respawned, after dying. + public void Respawn(Vector3 location) { + if (Net.Singleton.Instance != null && Net.Singleton.Instance.LocalPlayer.Id == NetId) { + GameObject.FindGameObjectWithTag("DeadScreen").GetComponent().Open = false; + } + transform.position = location; + IsDead = false; + } + public bool IsGrounded() { return CharacterController.isGrounded && Vector3.Dot(GravitationalVelocity, Vector3.down) >= 0; } @@ -224,6 +252,12 @@ namespace NeonTea.Quakeball.Players { } private void Update() { + if (Net.Singleton.Instance is Server) { + if (IsDead && (Time.time - TimeofDeath > 3)) { + ((Server)Net.Singleton.Instance).HandlePlayerRespawn(NetId); + } + } + if (MoveDirection.magnitude > 0) { BodyYaw = Vector3.SignedAngle(Vector3.forward, MoveDirection, Vector3.up); } @@ -233,7 +267,9 @@ namespace NeonTea.Quakeball.Players { float TargetLean = -Vector3.Dot(GroundVelocity / MoveStyle.TargetVelocity, CameraRoot.right) * MoveStyle.LeanDegrees; Lean = Mathf.Lerp(Lean, TargetLean, 30f * Time.deltaTime); CameraRoot.localEulerAngles = new Vector3(Pitch, Yaw, Lean); + } + private void LateUpdate() { UpdateMovement(); } diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index 7b9ead8..ac75730 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -7,6 +7,7 @@ TagManager: - Terminal - RemotePlayer - Net + - DeadScreen layers: - Default - TransparentFX