From b368c78f9e3baab4ed8fce128ec3b170b37e9e6a Mon Sep 17 00:00:00 2001 From: Joshua Reason Date: Tue, 30 Apr 2019 21:17:31 +1000 Subject: [PATCH] Added leader score; Returned to lobby after disconnect Added round count --- Assets/Data/GameModes/ColorCollide.asset | 4 +- .../Client/Realtime/LocalClient.asset | 4 +- .../Server/Realtime/ClientList.asset | 4 +- .../GameMode Scenes/ColorGameMode.unity | 774 ++++++++++++++++-- Assets/Scripts/Components.meta | 8 + .../GameMode/ColorGameMode/ColorGameMode.cs | 7 +- .../GameMode/ColorGameMode/RoundsLeft.cs | 81 ++ .../GameMode/ColorGameMode/RoundsLeft.cs.meta | 11 + .../GameMode/ColorGameMode/ScoreDisplay.cs | 4 +- Assets/Scripts/GameMode/GameMode.cs | 2 +- Assets/Scripts/Managers/GameManager.cs | 16 +- .../Scripts/Networking/Client/ClientObject.cs | 10 +- .../Scripts/Networking/Server/ClientList.cs | 13 +- Assets/Scripts/PortalSetup.cs | 2 +- Assets/Scripts/UI/LeadPlayerUI.cs | 45 + Assets/Scripts/UI/LeadPlayerUI.cs.meta | 11 + Assets/Scripts/Utility/ExtensionMethods.cs | 17 +- Assets/Scripts/Utility/Utility.cs | 1 - Assets/Scripts/portalTesting.cs | 16 +- ProjectSettings/EditorBuildSettings.asset | 4 +- 20 files changed, 934 insertions(+), 100 deletions(-) create mode 100644 Assets/Scripts/Components.meta create mode 100644 Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs create mode 100644 Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs.meta create mode 100644 Assets/Scripts/UI/LeadPlayerUI.cs create mode 100644 Assets/Scripts/UI/LeadPlayerUI.cs.meta diff --git a/Assets/Data/GameModes/ColorCollide.asset b/Assets/Data/GameModes/ColorCollide.asset index 72d5518..ac156ab 100644 --- a/Assets/Data/GameModes/ColorCollide.asset +++ b/Assets/Data/GameModes/ColorCollide.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d59afbd5fad650186ec888cd6b5635c0f553e009beb53447dd21738b679b2d7b -size 519 +oid sha256:e9ac3ad2b1266807e868377fa1c148c766f34904a0d06c0fcb93b523bb4e8298 +size 532 diff --git a/Assets/Data/Networking/Client/Realtime/LocalClient.asset b/Assets/Data/Networking/Client/Realtime/LocalClient.asset index 2d051cf..f55f8ae 100644 --- a/Assets/Data/Networking/Client/Realtime/LocalClient.asset +++ b/Assets/Data/Networking/Client/Realtime/LocalClient.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:39ffe7b520afa4ed1e7c046a996fc7de8c0153e2edc00844b6278a18cbb65917 -size 576 +oid sha256:9e95c47ee245273f574075cf296e80d083a1401111c78ecb2025c2ebb78c6f49 +size 607 diff --git a/Assets/Data/Networking/Server/Realtime/ClientList.asset b/Assets/Data/Networking/Server/Realtime/ClientList.asset index c1c610e..9f307b9 100644 --- a/Assets/Data/Networking/Server/Realtime/ClientList.asset +++ b/Assets/Data/Networking/Server/Realtime/ClientList.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:8e6359959a0fc5fb970e62b753280e5073dc33689d0da037c365927f9a63435d -size 708 +oid sha256:3841da06902843ac539419eada2ceba17e04e66d858edf200e41da10dd6ed967 +size 585 diff --git a/Assets/Scenes/GameMode Scenes/ColorGameMode.unity b/Assets/Scenes/GameMode Scenes/ColorGameMode.unity index c52961c..ed78e87 100644 --- a/Assets/Scenes/GameMode Scenes/ColorGameMode.unity +++ b/Assets/Scenes/GameMode Scenes/ColorGameMode.unity @@ -38,7 +38,7 @@ RenderSettings: m_ReflectionIntensity: 1 m_CustomReflection: {fileID: 0} m_Sun: {fileID: 0} - m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} + m_IndirectSpecularColor: {r: 0.37311953, g: 0.38074014, b: 0.3587274, a: 1} m_UseRadianceAmbientProbe: 0 --- !u!157 &3 LightmapSettings: @@ -112,7 +112,7 @@ NavMeshSettings: debug: m_Flags: 0 m_NavMeshData: {fileID: 0} ---- !u!1 &1169593764 +--- !u!1 &679401385 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -120,68 +120,523 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1169593766} - - component: {fileID: 1169593765} - m_Layer: 0 - m_Name: Directional Light + - component: {fileID: 679401386} + - component: {fileID: 679401389} + - component: {fileID: 679401388} + - component: {fileID: 679401387} + m_Layer: 5 + m_Name: Rounds Left m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!108 &1169593765 -Light: +--- !u!224 &679401386 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 679401385} + 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: 794451241} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0.5} + m_AnchorMax: {x: 1, y: 0.5} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 50} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &679401387 +MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1169593764} + m_GameObject: {fileID: 679401385} m_Enabled: 1 - serializedVersion: 8 - m_Type: 1 - m_Color: {r: 1, g: 0.95686275, b: 0.8392157, a: 1} - m_Intensity: 1 - m_Range: 10 - m_SpotAngle: 30 - m_CookieSize: 10 - m_Shadows: - m_Type: 2 - m_Resolution: -1 - m_CustomResolution: -1 - m_Strength: 1 - m_Bias: 0.05 - m_NormalBias: 0.4 - m_NearPlane: 0.2 - m_Cookie: {fileID: 0} - m_DrawHalo: 0 - m_Flare: {fileID: 0} - m_RenderMode: 0 - m_CullingMask: + 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_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_text: 5 Rounds Left + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: serializedVersion: 2 - m_Bits: 4294967295 - m_Lightmapping: 4 - m_LightShadowCasterMode: 0 - m_AreaSize: {x: 1, y: 1} - m_BounceIntensity: 1 - m_ColorTemperature: 6570 - m_UseColorTemperature: 0 - m_ShadowRadius: 0 - m_ShadowAngle: 0 ---- !u!4 &1169593766 -Transform: + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, 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_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 44.75 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_textAlignment: 514 + m_isAlignmentEnumConverted: 1 + 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_firstOverflowCharacterIndex: -1 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 679401387} + characterCount: 13 + spriteCount: 0 + spaceCount: 2 + wordCount: 3 + linkCount: 0 + lineCount: 1 + pageCount: 1 + materialCount: 1 + m_havePropertiesChanged: 0 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_isInputParsingRequired: 0 + m_inputSource: 0 + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!114 &679401388 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 679401385} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b55250a2e96d30142930c9b9f39ce325, type: 3} + m_Name: + m_EditorClassIdentifier: + reference: {fileID: 11400000, guid: be8c78868a86aad448fd14e46bd40e51, type: 2} + DisplayTime: 2 + AnimationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: 0 + value: 0 + inSlope: 2.9510615 + outSlope: 2.9510615 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0.04155844 + - serializedVersion: 3 + time: 0.50122774 + value: 0.5000305 + inSlope: 0.15756728 + outSlope: 0.15756728 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.33333334 + outWeight: 0.23969139 + - serializedVersion: 3 + time: 1 + value: 1 + inSlope: 2.951057 + outSlope: 2.951057 + tangentMode: 0 + weightedMode: 0 + inWeight: 0.05194813 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 +--- !u!222 &679401389 +CanvasRenderer: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1169593764} - m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261} - m_LocalPosition: {x: 0, y: 3, z: 0} + m_GameObject: {fileID: 679401385} + m_CullTransparentMesh: 0 +--- !u!1 &712573699 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 712573700} + - component: {fileID: 712573702} + - component: {fileID: 712573701} + m_Layer: 5 + m_Name: Score + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &712573700 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 712573699} + 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: 1489658592} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -24.56, y: -17.400024} + m_SizeDelta: {x: 48.39, y: 20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &712573701 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 712573699} + 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_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_text: 100 + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} + m_fontSharedMaterials: [] + m_fontMaterial: {fileID: 0} + m_fontMaterials: [] + m_fontColor32: + serializedVersion: 2 + rgba: 4278190080 + m_fontColor: {r: 0, g: 0, b: 0, 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_overrideHtmlColors: 0 + m_faceColor: + serializedVersion: 2 + rgba: 4294967295 + m_outlineColor: + serializedVersion: 2 + rgba: 4278190080 + m_fontSize: 18 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_textAlignment: 513 + m_isAlignmentEnumConverted: 1 + 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_firstOverflowCharacterIndex: 0 + m_linkedTextComponent: {fileID: 0} + m_isLinkedTextComponent: 0 + m_isTextTruncated: 0 + m_enableKerning: 1 + m_enableExtraPadding: 0 + checkPaddingRequired: 0 + m_isRichText: 1 + m_parseCtrlCharacters: 1 + m_isOrthographic: 1 + m_isCullingEnabled: 0 + m_ignoreRectMaskCulling: 0 + m_ignoreCulling: 1 + m_horizontalMapping: 0 + m_verticalMapping: 0 + m_uvLineOffset: 0 + m_geometrySortingOrder: 0 + m_firstVisibleCharacter: 0 + m_useMaxVisibleDescender: 1 + m_pageToDisplay: 1 + m_margin: {x: 0, y: 0, z: 0, w: 0} + m_textInfo: + textComponent: {fileID: 712573701} + characterCount: 3 + spriteCount: 0 + spaceCount: 0 + wordCount: 1 + linkCount: 0 + lineCount: 1 + pageCount: 1 + materialCount: 1 + m_havePropertiesChanged: 0 + m_isUsingLegacyAnimationComponent: 0 + m_isVolumetricText: 0 + m_spriteAnimator: {fileID: 0} + m_isInputParsingRequired: 0 + m_inputSource: 0 + m_hasFontAssetChanged: 0 + m_subTextObjects: + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + - {fileID: 0} + m_baseMaterial: {fileID: 0} + m_maskOffset: {x: 0, y: 0, z: 0, w: 0} +--- !u!222 &712573702 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 712573699} + m_CullTransparentMesh: 0 +--- !u!1 &794451236 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 794451241} + - component: {fileID: 794451240} + - component: {fileID: 794451239} + - component: {fileID: 794451238} + - component: {fileID: 794451237} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &794451237 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 794451236} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 96bf274f514b09741a0ff748fef480f0, type: 3} + m_Name: + m_EditorClassIdentifier: + Reference: {fileID: 11400000, guid: be8c78868a86aad448fd14e46bd40e51, type: 2} + OnRoundStart: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 679401388} + m_MethodName: StartAnimation + 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 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + OnPlayersMoved: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1489658593} + m_MethodName: UpdateScore + 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 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + OnRoundEnd: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null + OnGameOver: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine.CoreModule, Version=0.0.0.0, + Culture=neutral, PublicKeyToken=null +--- !u!114 &794451238 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 794451236} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &794451239 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 794451236} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 1 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 1080, y: 1920} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &794451240 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 794451236} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 0 + m_Camera: {fileID: 0} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 25 + m_SortingLayerID: 0 + m_SortingOrder: 0 + m_TargetDisplay: 0 +--- !u!224 &794451241 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 794451236} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1489658592} + - {fileID: 679401386} m_Father: {fileID: 0} m_RootOrder: 1 - m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} ---- !u!1 &1819061323 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} +--- !u!1 &1026770877 GameObject: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -189,35 +644,109 @@ GameObject: m_PrefabAsset: {fileID: 0} serializedVersion: 6 m_Component: - - component: {fileID: 1819061326} - - component: {fileID: 1819061325} - - component: {fileID: 1819061324} - m_Layer: 0 - m_Name: Main Camera - m_TagString: MainCamera + - component: {fileID: 1026770878} + - component: {fileID: 1026770880} + - component: {fileID: 1026770879} + m_Layer: 5 + m_Name: Color + m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 m_IsActive: 1 ---- !u!81 &1819061324 +--- !u!224 &1026770878 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1026770877} + 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: 1489658592} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 1, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: -61.3, y: -17.400024} + m_SizeDelta: {x: 21.87, y: 21.87} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1026770879 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1026770877} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -765806418, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.9339623, g: 0.066082224, b: 0.066082224, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0} + m_Type: 1 + m_PreserveAspect: 0 + m_FillCenter: 1 + m_FillMethod: 4 + m_FillAmount: 1 + m_FillClockwise: 1 + m_FillOrigin: 0 + m_UseSpriteMesh: 0 +--- !u!222 &1026770880 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1026770877} + m_CullTransparentMesh: 0 +--- !u!1 &1403693168 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1403693171} + - component: {fileID: 1403693170} + - component: {fileID: 1403693169} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 0 +--- !u!81 &1403693169 AudioListener: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819061323} + m_GameObject: {fileID: 1403693168} m_Enabled: 1 ---- !u!20 &1819061325 +--- !u!20 &1403693170 Camera: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819061323} + m_GameObject: {fileID: 1403693168} m_Enabled: 1 serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.6132076, g: 0.6132076, b: 0.6132076, a: 0} m_projectionMatrixMode: 1 m_SensorSize: {x: 36, y: 24} m_LensShift: {x: 0, y: 0} @@ -232,12 +761,12 @@ Camera: near clip plane: 0.3 far clip plane: 1000 field of view: 60 - orthographic: 0 + orthographic: 1 orthographic size: 5 - m_Depth: -1 + m_Depth: 0 m_CullingMask: serializedVersion: 2 - m_Bits: 4294967295 + m_Bits: 32 m_RenderingPath: -1 m_TargetTexture: {fileID: 0} m_TargetDisplay: 0 @@ -249,17 +778,136 @@ Camera: m_OcclusionCulling: 1 m_StereoConvergence: 10 m_StereoSeparation: 0.022 ---- !u!4 &1819061326 +--- !u!4 &1403693171 Transform: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} m_PrefabInstance: {fileID: 0} m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 1819061323} + m_GameObject: {fileID: 1403693168} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0, y: 1, z: -10} + m_LocalPosition: {x: 1016.24725, y: 536.27026, z: 2.963501} m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1489658591 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1489658592} + - component: {fileID: 1489658593} + m_Layer: 5 + m_Name: Lead Score + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1489658592 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1489658591} + 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: 712573700} + - {fileID: 1026770878} + m_Father: {fileID: 794451241} + 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: 503.92, y: 288.46} + m_SizeDelta: {x: -1007.74, y: -576.91} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1489658593 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1489658591} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 31fc92ee5488ea248920b8b2a2ac7b66, type: 3} + m_Name: + m_EditorClassIdentifier: + Clients: {fileID: 11400000, guid: ded0b21c3ef1e7049a1128c12e9401fe, type: 2} + ScoreText: {fileID: 712573701} + ColorImage: {fileID: 1026770879} +--- !u!1 &1620170124 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1620170127} + - component: {fileID: 1620170126} + - component: {fileID: 1620170125} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1620170125 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1620170124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1620170126 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1620170124} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1620170127 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1620170124} + 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: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/Components.meta b/Assets/Scripts/Components.meta new file mode 100644 index 0000000..5a95b09 --- /dev/null +++ b/Assets/Scripts/Components.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d7394d70ec233849a60a26da5f23b75 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs b/Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs index 3fddbd7..806f911 100644 --- a/Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs +++ b/Assets/Scripts/GameMode/ColorGameMode/ColorGameMode.cs @@ -13,7 +13,7 @@ public class ColorGameMode : GameMode public Material OverlayMaterial; - private int RoundCount = 0; + public int RoundCount { get; private set; } private Dictionary> BlocksOwned; /// @@ -87,9 +87,9 @@ public class ColorGameMode : GameMode foreach (PlayerData player in allPlayers) { if (BlocksOwned.ContainsKey(player.client)) - player.client.collected = BlocksOwned[player.client].Count; + player.client.SceneScore = BlocksOwned[player.client].Count; else - player.client.collected = 0; + player.client.SceneScore = 0; } } @@ -133,5 +133,6 @@ public class ColorGameMode : GameMode protected override void OnGameStart(PlayerData[] allPlayers) { BlocksOwned = new Dictionary>(); + RoundCount = 0; } } diff --git a/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs b/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs new file mode 100644 index 0000000..72e0d0e --- /dev/null +++ b/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs @@ -0,0 +1,81 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using TMPro; + +[RequireComponent(typeof(TextMeshProUGUI))] +public class RoundsLeft : MonoBehaviour +{ + + [SerializeField] + private GameModeReference reference; + + + [SerializeField] + private float DisplayTime; + + [SerializeField] + private AnimationCurve AnimationCurve; + + + private ColorGameMode gameMode; + private TextMeshProUGUI Text; + + private void Awake() + { + Text = GetComponent(); + gameMode = reference.Value as ColorGameMode; + + Text.enabled = false; + } + + + [ContextMenu("Do Animation")] + public void StartAnimation() + { + UpdateText(); + + + Vector3 startPosition = new Vector3(Screen.width * 2, 0, 0); + Vector3 endPosition = new Vector3(-Screen.width * 2, 0 , 0); + StartCoroutine(AnimationRoutine(startPosition, endPosition)); + } + + private void UpdateText() + { + if (gameMode == null) { + Text.text = "New Round"; + return; + } + + int RoundsLeft = gameMode.MaxRound - gameMode.RoundCount; + if (RoundsLeft == 1) + Text.text = "Last Round"; + else + Text.text = RoundsLeft + " Rounds Left"; + } + + public IEnumerator AnimationRoutine(Vector3 startPos, Vector3 endPos) + { + RectTransform rt = transform as RectTransform; + Text.enabled = true; + + float ratio; + float elapsedTime = 0; + while (elapsedTime < DisplayTime) + { + ratio = AnimationCurve.Evaluate(elapsedTime/DisplayTime); + rt.anchoredPosition = Vector3.Lerp(startPos, endPos, ratio); + + yield return new WaitForEndOfFrame(); + elapsedTime += Time.deltaTime; + } + + ratio = AnimationCurve.Evaluate(1); + rt.anchoredPosition = Vector3.Lerp(startPos, endPos, ratio); + + Text.enabled = false; + } + + +} diff --git a/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs.meta b/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs.meta new file mode 100644 index 0000000..0a2bfd1 --- /dev/null +++ b/Assets/Scripts/GameMode/ColorGameMode/RoundsLeft.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b55250a2e96d30142930c9b9f39ce325 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/GameMode/ColorGameMode/ScoreDisplay.cs b/Assets/Scripts/GameMode/ColorGameMode/ScoreDisplay.cs index e84e611..bbf355d 100644 --- a/Assets/Scripts/GameMode/ColorGameMode/ScoreDisplay.cs +++ b/Assets/Scripts/GameMode/ColorGameMode/ScoreDisplay.cs @@ -21,12 +21,12 @@ public class ScoreDisplay : MonoBehaviour public void levelComplete(ClientList clientDataList) { ConnectedClients = clientDataList.ConnectedClients; - ConnectedClients.Sort((a, b) => b.collected.CompareTo(a.collected)); + ConnectedClients.Sort((a, b) => b.SceneScore.CompareTo(a.SceneScore)); for (int i = 0; i < ConnectedClients.Count; i++) { players[i].GetComponent().text = ConnectedClients[i].Name; - scores[i].GetComponent().text = ConnectedClients[i].collected.ToString(); + scores[i].GetComponent().text = ConnectedClients[i].SceneScore.ToString(); } StartCoroutine(displayforSeconds(levelScoreboard, 10.0f)); } diff --git a/Assets/Scripts/GameMode/GameMode.cs b/Assets/Scripts/GameMode/GameMode.cs index 3b04623..76babfc 100644 --- a/Assets/Scripts/GameMode/GameMode.cs +++ b/Assets/Scripts/GameMode/GameMode.cs @@ -48,7 +48,7 @@ public abstract class GameMode : ScriptableObject public void GameStart(PlayerData[] allPlayers) { if (!String.IsNullOrEmpty(GameModeScene)) - UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(GameModeScene); + UnityEngine.SceneManagement.SceneManager.LoadScene(GameModeScene,UnityEngine.SceneManagement.LoadSceneMode.Additive); OnGameStart(allPlayers); } diff --git a/Assets/Scripts/Managers/GameManager.cs b/Assets/Scripts/Managers/GameManager.cs index 5090a50..7e130ce 100644 --- a/Assets/Scripts/Managers/GameManager.cs +++ b/Assets/Scripts/Managers/GameManager.cs @@ -48,6 +48,13 @@ public class GameManager : MonoBehaviour gamemode.GameStart(playerArray.ToArray()); ClientList.ForEach(p => p.ChangeScene("ClientScene")); + gamemode.GameStart(playerArray.ToArray()); + } + + private void Start() + { + gamemode.GameStart(playerArray.ToArray()); + StartRound(); } private void Update() @@ -67,15 +74,19 @@ public class GameManager : MonoBehaviour playerData[msg.conn.connectionId].recievedList = true; if (playerData.All(p => p.Value.recievedList)) - StartRound(); + DoRoundRoutine(); } - private void StartRound() + private void DoRoundRoutine() { Debug.Log("Starting Round"); StartCoroutine(RoundRoutine()); } + private void StartRound() + { + gamemode.RoundStart(playerArray.ToArray()); + } private IEnumerator RoundRoutine() { @@ -118,6 +129,7 @@ public class GameManager : MonoBehaviour ClientList.ForEach(p => p.SendInventory()); ClientList.ForEach(p => p.ChangeScene("ClientScene")); Debug.Log("Finished Moving"); + StartRound(); } diff --git a/Assets/Scripts/Networking/Client/ClientObject.cs b/Assets/Scripts/Networking/Client/ClientObject.cs index e7a54c2..a2464fb 100644 --- a/Assets/Scripts/Networking/Client/ClientObject.cs +++ b/Assets/Scripts/Networking/Client/ClientObject.cs @@ -19,6 +19,10 @@ namespace Networking.Client [Tooltip("Port to connect on")] private int Port; + [SerializeField] + [Tooltip("Scene to return to if disconnected from server")] + private string DisconnectScene; + [Header("Player Settings")] [SerializeField] [Tooltip("Player Name")] @@ -55,6 +59,7 @@ namespace Networking.Client client.RegisterHandler(LogicProtocols.SendInventory, RecieveInventory); client.RegisterHandler(LoginProtocols.SceneChange, RecieveSceneChange); + client.RegisterHandler(MsgType.Disconnect, OnDisconnect); } public void Stop() @@ -91,7 +96,10 @@ namespace Networking.Client UnityEngine.SceneManagement.SceneManager.LoadScene(sceneMsg.Scene, mode); } - + public void OnDisconnect(NetworkMessage msg) + { + UnityEngine.SceneManagement.SceneManager.LoadScene(DisconnectScene); + } } } diff --git a/Assets/Scripts/Networking/Server/ClientList.cs b/Assets/Scripts/Networking/Server/ClientList.cs index 11b3b59..9ed14e2 100644 --- a/Assets/Scripts/Networking/Server/ClientList.cs +++ b/Assets/Scripts/Networking/Server/ClientList.cs @@ -173,10 +173,10 @@ namespace Networking.Server /// public string characterAnimal = "Bear"; - /// - /// Clients number of collected items - for colelction level - /// - public int collected; + /// + /// Clients number of collected items - for colelction level + /// + public int SceneScore; /// /// Network connection ID @@ -193,8 +193,6 @@ namespace Networking.Server /// public Inventory Inventory; - - public void SendInventory() { Debug.Log("Sending inventory"); @@ -205,8 +203,5 @@ namespace Networking.Server { conn.Send(LoginProtocols.SceneChange, new LoginProtocols.SceneMsg(scene,Additive)); } - - - } } diff --git a/Assets/Scripts/PortalSetup.cs b/Assets/Scripts/PortalSetup.cs index 11b185e..6219927 100644 --- a/Assets/Scripts/PortalSetup.cs +++ b/Assets/Scripts/PortalSetup.cs @@ -51,7 +51,7 @@ public class PortalSetup : MonoBehaviour void Update() { - if (!collectedFive && (ConnectedClients[0].collected >= collectAmount || ConnectedClients[1].collected >= collectAmount || ConnectedClients[2].collected >= collectAmount || ConnectedClients[3].collected >= collectAmount)){ + if (!collectedFive && (ConnectedClients[0].SceneScore >= collectAmount || ConnectedClients[1].SceneScore >= collectAmount || ConnectedClients[2].SceneScore >= collectAmount || ConnectedClients[3].SceneScore >= collectAmount)){ collectedFive = true; StartCoroutine (ColorChange ()); } diff --git a/Assets/Scripts/UI/LeadPlayerUI.cs b/Assets/Scripts/UI/LeadPlayerUI.cs new file mode 100644 index 0000000..713f9f2 --- /dev/null +++ b/Assets/Scripts/UI/LeadPlayerUI.cs @@ -0,0 +1,45 @@ +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine; +using UnityEngine.UI; +using Networking.Server; + +public class LeadPlayerUI : MonoBehaviour +{ + [SerializeField] + private ClientList Clients; + + [SerializeField] + private TMPro.TextMeshProUGUI ScoreText; + + [SerializeField] + private Image ColorImage; + + private void Awake() + { + UpdateScore(); + } + + public void UpdateScore() + { + if (Clients.Count() == 0) + { + ScoreText.gameObject.SetActive(false); + ColorImage.gameObject.SetActive(false); + return; + } + else + { + ScoreText.gameObject.SetActive(true); + ColorImage.gameObject.SetActive(true); + } + + ClientData lead = Clients.maxBy(p => p.SceneScore); + ScoreText.text = lead.SceneScore.ToString(); + ColorImage.color = lead.Color; + } + + + +} diff --git a/Assets/Scripts/UI/LeadPlayerUI.cs.meta b/Assets/Scripts/UI/LeadPlayerUI.cs.meta new file mode 100644 index 0000000..d06977a --- /dev/null +++ b/Assets/Scripts/UI/LeadPlayerUI.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 31fc92ee5488ea248920b8b2a2ac7b66 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Utility/ExtensionMethods.cs b/Assets/Scripts/Utility/ExtensionMethods.cs index 645ba46..25c424a 100644 --- a/Assets/Scripts/Utility/ExtensionMethods.cs +++ b/Assets/Scripts/Utility/ExtensionMethods.cs @@ -1,5 +1,7 @@ -using System.Collections; +using System; +using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; /// @@ -80,6 +82,19 @@ public static class ExtensionMethods foreach (T item in enumeration) action(item); } + + public static T maxBy(this IEnumerable values, Func predicate) + { + //Define smallest value as first + T max = values.First(); + + //compare all other values + foreach (T item in values) + if (predicate(item).CompareTo(predicate(max)) > 0) + max = item; + + return max; + } } diff --git a/Assets/Scripts/Utility/Utility.cs b/Assets/Scripts/Utility/Utility.cs index 693ba0d..2b3d485 100644 --- a/Assets/Scripts/Utility/Utility.cs +++ b/Assets/Scripts/Utility/Utility.cs @@ -34,5 +34,4 @@ public static class Utility //return return min; } - } diff --git a/Assets/Scripts/portalTesting.cs b/Assets/Scripts/portalTesting.cs index 2bf1e32..cfe6879 100644 --- a/Assets/Scripts/portalTesting.cs +++ b/Assets/Scripts/portalTesting.cs @@ -19,26 +19,26 @@ public class portalTesting : MonoBehaviour void Update() { if(Input.GetKeyDown(KeyCode.A)){ - ConnectedClients[0].collected++; - if(ConnectedClients[0].collected >= 5){ + ConnectedClients[0].SceneScore++; + if(ConnectedClients[0].SceneScore >= 5){ ps.validIndex.Add(0); } } if(Input.GetKeyDown(KeyCode.B)){ - ConnectedClients[1].collected++; - if(ConnectedClients[1].collected >= 5){ + ConnectedClients[1].SceneScore++; + if(ConnectedClients[1].SceneScore >= 5){ ps.validIndex.Add(1); } } if(Input.GetKeyDown(KeyCode.C)){ - ConnectedClients[2].collected++; - if(ConnectedClients[2].collected >= 5){ + ConnectedClients[2].SceneScore++; + if(ConnectedClients[2].SceneScore >= 5){ ps.validIndex.Add(2); } } if(Input.GetKeyDown(KeyCode.D)){ - ConnectedClients[3].collected++; - if(ConnectedClients[3].collected >= 5){ + ConnectedClients[3].SceneScore++; + if(ConnectedClients[3].SceneScore >= 5){ ps.validIndex.Add(3); } } diff --git a/ProjectSettings/EditorBuildSettings.asset b/ProjectSettings/EditorBuildSettings.asset index 130e882..dd5c6f1 100644 --- a/ProjectSettings/EditorBuildSettings.asset +++ b/ProjectSettings/EditorBuildSettings.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:3d923cbd2ad4e5d16251c73d41f14240e9040e46c3adb2ea24c5fe9907a591e2 -size 1428 +oid sha256:bd4d395cb9e19688d6fc571157ae8ff28afcd911ab9e63e2af8cec8a67868e51 +size 1546