From 6de70f68f9ab36b7477d91fa5f4ee83e45466909 Mon Sep 17 00:00:00 2001 From: cuqmbr Date: Tue, 26 Jul 2022 23:08:31 +0300 Subject: [PATCH] feat: add raw integration with an api --- Assets/Scenes/SampleScene.unity | 702 +++++++++++++++++- Assets/SharedModels.dll | Bin 7680 -> 6144 bytes Assets/_Scripts/Managers/ScoreManager.cs | 24 +- Assets/_Scripts/Managers/UIManager.cs | 6 +- Assets/_Scripts/ScoreboardManager.cs | 32 +- .../_Scripts/Systems/SaveSystem/UserData.cs | 8 + Assets/_Scripts/Utilities/HttpClient.cs | 11 +- 7 files changed, 742 insertions(+), 41 deletions(-) diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 8379227..98eebae 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -394,7 +394,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 2669b7102c53f757b82f593178e49647, type: 3} m_Name: m_EditorClassIdentifier: - _initialRewardMultiplier: 500 + _initialRewardMultiplier: 15 _maxRewardMultiplier: 128 _initialMaxExperience: 3 _uiManager: {fileID: 1676064789} @@ -906,6 +906,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 427094482} m_CullTransparentMesh: 1 +--- !u!1 &428573333 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 428573334} + - component: {fileID: 428573336} + - component: {fileID: 428573335} + m_Layer: 5 + m_Name: 'Num. Username: Score Text (TMP)' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &428573334 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428573333} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.99968, y: 0.99968, z: 0.99968} + m_Children: [] + m_Father: {fileID: 696254166} + 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: -40, y: -20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &428573335 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428573333} + 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: '725. Lollex: 178' + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: c3e5b53da86c32731943004a1b8b590e, type: 2} + m_sharedMaterial: {fileID: -8174794354313175153, guid: c3e5b53da86c32731943004a1b8b590e, 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: 60.1 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + 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: 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: 0 + 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 &428573336 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 428573333} + m_CullTransparentMesh: 1 --- !u!1 &477184383 GameObject: m_ObjectHideFlags: 0 @@ -1082,6 +1216,112 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 488822477} m_CullTransparentMesh: 1 +--- !u!1001 &564126100 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1299477820} + m_Modifications: + - target: {fileID: 7150267415123359698, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Name + value: Scoreboard Record (1) + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359698, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_SizeDelta.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchoredPosition.y + value: -250 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 17475f0c207c8230da0daf9725875171, type: 3} +--- !u!224 &564126101 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + m_PrefabInstance: {fileID: 564126100} + m_PrefabAsset: {fileID: 0} --- !u!1 &565597289 GameObject: m_ObjectHideFlags: 0 @@ -1225,7 +1465,7 @@ RectTransform: 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: 450, y: 500} + m_SizeDelta: {x: 450, y: 520} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &624579874 MonoBehaviour: @@ -1489,6 +1729,99 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 675090501} m_CullTransparentMesh: 1 +--- !u!1 &696254165 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 696254166} + - component: {fileID: 696254169} + - component: {fileID: 696254168} + - component: {fileID: 696254167} + m_Layer: 5 + m_Name: Scoreboard Record (2) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &696254166 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 696254165} + 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: 428573334} + m_Father: {fileID: 1299477820} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -350} + m_SizeDelta: {x: 0, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &696254167 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 696254165} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97bc2ebab6563400c95b036136d26ea6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Inverse: 0 + m_MaskInteraction: 85 + m_UseStencil: 1 + m_RaycastFilter: 0 +--- !u!114 &696254168 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 696254165} + 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: 0.74509805, g: 0.74509805, b: 0.74509805, 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: 7482667652216324306, guid: 698ec1e99c7d691dca7b43e843782f2f, 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!222 &696254169 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 696254165} + m_CullTransparentMesh: 1 --- !u!1 &710340420 GameObject: m_ObjectHideFlags: 0 @@ -1536,6 +1869,112 @@ Transform: m_Father: {fileID: 1037654666} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1001 &862922468 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 1299477820} + m_Modifications: + - target: {fileID: 7150267415123359698, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Name + value: Scoreboard Record (3) + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359698, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_IsActive + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Pivot.x + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_Pivot.y + value: 0.5 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_RootOrder + value: 4 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMax.x + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMax.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMin.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchorMin.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_SizeDelta.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_SizeDelta.y + value: 100 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchoredPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_AnchoredPosition.y + value: -450 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 17475f0c207c8230da0daf9725875171, type: 3} +--- !u!224 &862922469 stripped +RectTransform: + m_CorrespondingSourceObject: {fileID: 7150267415123359699, guid: 17475f0c207c8230da0daf9725875171, type: 3} + m_PrefabInstance: {fileID: 862922468} + m_PrefabAsset: {fileID: 0} --- !u!1 &867350546 GameObject: m_ObjectHideFlags: 0 @@ -2356,6 +2795,99 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 8 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &1092054271 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1092054272} + - component: {fileID: 1092054275} + - component: {fileID: 1092054274} + - component: {fileID: 1092054273} + m_Layer: 5 + m_Name: Scoreboard Record (4) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1092054272 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1092054271} + 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: 1811835082} + m_Father: {fileID: 1299477820} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 1} + m_AnchorMax: {x: 1, y: 1} + m_AnchoredPosition: {x: 0, y: -550} + m_SizeDelta: {x: 0, y: 100} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1092054273 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1092054271} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 97bc2ebab6563400c95b036136d26ea6, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Inverse: 0 + m_MaskInteraction: 85 + m_UseStencil: 1 + m_RaycastFilter: 0 +--- !u!114 &1092054274 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1092054271} + 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: 0.74509805, g: 0.74509805, b: 0.74509805, 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: 7482667652216324306, guid: 698ec1e99c7d691dca7b43e843782f2f, 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!222 &1092054275 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1092054271} + m_CullTransparentMesh: 1 --- !u!1 &1114100290 GameObject: m_ObjectHideFlags: 0 @@ -2651,13 +3183,17 @@ RectTransform: m_Children: - {fileID: 1911471411} - {fileID: 340008050} + - {fileID: 564126101} + - {fileID: 696254166} + - {fileID: 862922469} + - {fileID: 1092054272} m_Father: {fileID: 1022150241} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 1} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: 0, y: -0.00022219129} - m_SizeDelta: {x: 0, y: 523.19} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 0, y: 1} --- !u!1 &1457871091 GameObject: @@ -3024,7 +3560,7 @@ MonoBehaviour: _rewardMultiplierText: {fileID: 1114100292} _experienceSlider: {fileID: 2325626163454522012} _sliderSmoothTime: 0.1 - _scoreboardScrollViewContent: {fileID: 1299477819} + _scoreboardScrollViewContent: {fileID: 1299477820} _scoreboardRecordPrefab: {fileID: 7150267415123359698, guid: 17475f0c207c8230da0daf9725875171, type: 3} _scoreboardRecordColor1: {r: 0.82363623, g: 0.82363623, b: 0.82363623, a: 1} _scoreboardRecordColor2: {r: 0.74499124, g: 0.74499124, b: 0.74499124, a: 1} @@ -3125,6 +3661,140 @@ CanvasRenderer: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 1763820599} m_CullTransparentMesh: 1 +--- !u!1 &1811835081 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1811835082} + - component: {fileID: 1811835084} + - component: {fileID: 1811835083} + m_Layer: 5 + m_Name: 'Num. Username: Score Text (TMP)' + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1811835082 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1811835081} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0.99968, y: 0.99968, z: 0.99968} + m_Children: [] + m_Father: {fileID: 1092054272} + 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: -40, y: -20} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1811835083 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1811835081} + 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: '725. Lollex: 178' + m_isRightToLeft: 0 + m_fontAsset: {fileID: 11400000, guid: c3e5b53da86c32731943004a1b8b590e, type: 2} + m_sharedMaterial: {fileID: -8174794354313175153, guid: c3e5b53da86c32731943004a1b8b590e, 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: 60.1 + m_fontSizeBase: 36 + m_fontWeight: 400 + m_enableAutoSizing: 1 + m_fontSizeMin: 18 + m_fontSizeMax: 72 + m_fontStyle: 0 + m_HorizontalAlignment: 1 + 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: 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: 0 + 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 &1811835084 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1811835081} + m_CullTransparentMesh: 1 --- !u!1 &1827232687 GameObject: m_ObjectHideFlags: 0 @@ -3680,7 +4350,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 1, y: 1} - m_AnchoredPosition: {x: -1.0399933, y: 0.5799866} + m_AnchoredPosition: {x: -1.0399933, y: 0.5800781} m_SizeDelta: {x: -18.63, y: -20.74} m_Pivot: {x: 0.5, y: 0.5} --- !u!114 &2024342364 @@ -3697,10 +4367,10 @@ MonoBehaviour: m_EditorClassIdentifier: m_Content: {fileID: 1299477820} m_Horizontal: 0 - m_Vertical: 0 - m_MovementType: 1 + m_Vertical: 1 + m_MovementType: 2 m_Elasticity: 0.1 - m_Inertia: 1 + m_Inertia: 0 m_DecelerationRate: 0.135 m_ScrollSensitivity: 1 m_Viewport: {fileID: 1022150241} @@ -3712,7 +4382,19 @@ MonoBehaviour: m_VerticalScrollbarSpacing: -3 m_OnValueChanged: m_PersistentCalls: - m_Calls: [] + m_Calls: + - m_Target: {fileID: 2024342364} + m_TargetAssemblyTypeName: UnityEngine.UI.ScrollRect, UnityEngine.UI + m_MethodName: set_vertical + m_Mode: 6 + 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 &2024342365 MonoBehaviour: m_ObjectHideFlags: 0 diff --git a/Assets/SharedModels.dll b/Assets/SharedModels.dll index 649664c6550ef281a2148fee927f1c73eb1f8c15..365a0d817d4a005a29164caf82ddd40675fc4260 100644 GIT binary patch delta 2127 zcmaKtTWnNS6o%K{`^uai489rON=owpgfWIpazJ+s1%eC12KlgaP#u-HM>|}JjwoM{r@^= z?aQn=GcbRkX8)_D^S1nTf$VjWO1&IWLllPL&zOJ2hmNld9g7n!Ge#{@gBmJ{=5`Y0 zLZ7H6dQz9j>AGE%1@DGnc^F~+x~LMa{zR0CLj9vCop=rv%(VzZl8;uG5Ott}&_jif z=oabX?rxbV+u;y7m8DYc4V zE1k*(XYo*M7uJt$9YEz+TWV|1=8b)3NoUOy_>8S+qwf%#-N%|%G&kV$Ds)PJ?v$ln zr~ro9^%M*w$ZYpf4D+5k!XVYr=Rk7K10D4SV=A*L5$+9?9gtb6J_>KG+CH-aV2 zLhQf^(*`lB>PX?+F>05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P0AmFIr=;v9}6Pf<-lOrt?JfdC6%Gc?>beQOvZ5(b-sKGqXG0hI9N0C>R8Po4>Q>X#WI^ L>eC^7#0>lwmj=ZX diff --git a/Assets/_Scripts/Managers/ScoreManager.cs b/Assets/_Scripts/Managers/ScoreManager.cs index 4c1ef56..479fc9c 100644 --- a/Assets/_Scripts/Managers/ScoreManager.cs +++ b/Assets/_Scripts/Managers/ScoreManager.cs @@ -1,4 +1,6 @@ using System; +using System.Threading.Tasks; +using DatabaseModels.DataTransferObjets; using UnityEngine; public class ScoreManager : MonoBehaviour @@ -24,7 +26,7 @@ public class ScoreManager : MonoBehaviour PlayerEvents.OnBallTouched += AddScore; PlayerEvents.OnBallTouched += AddExperience; PlayerEvents.OnWallTouched += ResetExperienceAndRewardMultiplier; - GameStateManager.Instance.OnGameStateChange += OnGameStateChange; + GameStateManager.Instance.OnGameStateChange += async (s) => await OnGameStateChange(s); } private void Start() @@ -82,7 +84,7 @@ public class ScoreManager : MonoBehaviour _currentMaxExperience = _initialMaxExperience; _previousMaxExperience = 0; - _uiManager.SetRewardMultiplierText(1); + _uiManager.SetRewardMultiplierText(_currentRewardMultiplier); _uiManager.SetExperienceSliderValue(0); _uiManager.SetExperienceSliderMaxValue(_currentMaxExperience); } @@ -90,20 +92,28 @@ public class ScoreManager : MonoBehaviour private void ResetAllValues() { _currentScore = 0; - _uiManager.SetScoreText(0); + _uiManager.SetScoreText(_currentScore); ResetExperienceAndRewardMultiplier(); } - private void SaveHighScore() + private async Task SaveHighScore() { - if (_currentScore < _highScore) + if (_currentScore <= _highScore) { return; } _highScore = _currentScore; SessionStore.HighScore = _highScore; + + await HttpClient.Post( + $"{SessionStore.ApiUrl}/scoreboard", + new ScoreboardRecordDto + { + PostTime = DateTime.UtcNow, Score = SessionStore.HighScore, + User = SessionStore.UserData.ToDto() + }); } private void LoadHighScore() @@ -111,7 +121,7 @@ public class ScoreManager : MonoBehaviour _highScore = SessionStore.HighScore; } - private void OnGameStateChange(GameState newGameState) + private async Task OnGameStateChange(GameState newGameState) { switch (newGameState) { @@ -125,7 +135,7 @@ public class ScoreManager : MonoBehaviour case GameState.Game: break; case GameState.GameOver: - SaveHighScore(); + await SaveHighScore(); _scoreboardManager.SpawnScoreboardRecords(); break; default: diff --git a/Assets/_Scripts/Managers/UIManager.cs b/Assets/_Scripts/Managers/UIManager.cs index 7073f85..46c1630 100644 --- a/Assets/_Scripts/Managers/UIManager.cs +++ b/Assets/_Scripts/Managers/UIManager.cs @@ -20,7 +20,7 @@ public class UIManager : MonoBehaviour private float _sliderVelocity; [Header("Scoreboard")] - [SerializeField] private GameObject _scoreboardScrollViewContent; + [SerializeField] private RectTransform _scoreboardScrollViewContent; [SerializeField] private GameObject _scoreboardRecordPrefab; [SerializeField] private Color _scoreboardRecordColor1; [SerializeField] private Color _scoreboardRecordColor2; @@ -65,8 +65,8 @@ public class UIManager : MonoBehaviour public void InstantiateScoreboardRecords(ScoreboardRecordDto[] records) { - var rectTransform = _scoreboardScrollViewContent.GetComponent(); - rectTransform.sizeDelta = new Vector2(0, records.Length * 100); + _scoreboardScrollViewContent.sizeDelta = new Vector2(0, records.Length * 100); + _scoreboardScrollViewContent.localPosition = new Vector3(0, _scoreboardScrollViewContent.sizeDelta.y / records.Length * 2f); for (int i = 0; i < records.Length; i++) { diff --git a/Assets/_Scripts/ScoreboardManager.cs b/Assets/_Scripts/ScoreboardManager.cs index d2cc7c2..31d9c3e 100644 --- a/Assets/_Scripts/ScoreboardManager.cs +++ b/Assets/_Scripts/ScoreboardManager.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq; +using System.Threading.Tasks; using DatabaseModels.DataTransferObjets; using TMPro; using UnityEngine; @@ -9,7 +11,7 @@ public class ScoreboardManager : MonoBehaviour { [SerializeField] private UIManager _uiManager; - public void SpawnScoreboardRecords() + public async void SpawnScoreboardRecords() { if (SessionStore.UserData == null) { @@ -18,32 +20,22 @@ public class ScoreboardManager : MonoBehaviour return; } - // TODO: POST new HighScore to the database - - var filteredScoreboardRecords = GetFilteredScoreboardRecords(); + var filteredScoreboardRecords = await GetFilteredScoreboardRecords(); _uiManager.DestroyAllScoreboardRecords(); _uiManager.InstantiateScoreboardRecords(filteredScoreboardRecords); - ScoreboardRecordDto[] GetFilteredScoreboardRecords() + async Task GetFilteredScoreboardRecords() { - var localRecords = SessionStore.ScoreboardRecords.ToList(); + var localRecords = await HttpClient.Get>($"{SessionStore.ApiUrl}/scoreboard"); + var currentUserRecord = localRecords.First(r => r.User.Username == SessionStore.UserData.Username); - var topUserRecord = localRecords.LastOrDefault(r => r.Score >= SessionStore.HighScore); - var topUserPlace = localRecords.IndexOf(topUserRecord) + 1; + var filteredRecords = localRecords + .SkipWhile(r => Math.Abs(localRecords.IndexOf(r) - localRecords.IndexOf(currentUserRecord)) >= 5) + .TakeWhile(r => Math.Abs(localRecords.IndexOf(r) - localRecords.IndexOf(currentUserRecord)) <= 5) + .ToArray(); - var currentUserRecord = localRecords.FirstOrDefault(r => r.User.Username == SessionStore.UserData.Username); - var currentUserPlace = localRecords.IndexOf(currentUserRecord) != -1 ? localRecords.IndexOf(currentUserRecord) + 1 : -1; - - var startIndex = localRecords.Count - topUserPlace < localRecords.Count - 6 ? topUserPlace - 6 : 0; - int count = localRecords.Count - currentUserPlace < localRecords.Count && localRecords.Count - currentUserPlace > 6 ? currentUserPlace + 6 - startIndex : currentUserPlace - startIndex; - - if (currentUserPlace == -1) - { - count = localRecords.Count - startIndex; - } - - return localRecords.GetRange(startIndex, count).ToArray(); + return filteredRecords.ToArray(); } } } \ No newline at end of file diff --git a/Assets/_Scripts/Systems/SaveSystem/UserData.cs b/Assets/_Scripts/Systems/SaveSystem/UserData.cs index 75b04bb..a725765 100644 --- a/Assets/_Scripts/Systems/SaveSystem/UserData.cs +++ b/Assets/_Scripts/Systems/SaveSystem/UserData.cs @@ -1,5 +1,13 @@ +using DatabaseModels.DataTransferObjets; + public class UserData { + public int Id { get; set; } public string Username { get; set; } public string Password { get; set; } + + public UserDto ToDto() + { + return new UserDto { Id = Id, Username = Username }; + } } \ No newline at end of file diff --git a/Assets/_Scripts/Utilities/HttpClient.cs b/Assets/_Scripts/Utilities/HttpClient.cs index de430c7..8cfc8d2 100644 --- a/Assets/_Scripts/Utilities/HttpClient.cs +++ b/Assets/_Scripts/Utilities/HttpClient.cs @@ -38,6 +38,11 @@ public static class HttpClient await Task.Delay(10); } + while (!postRequest.downloadHandler.isDone) + { + await Task.Delay(10); + } + return JsonConvert.DeserializeObject(postRequest.downloadHandler.text); } @@ -58,7 +63,11 @@ public static class HttpClient request.downloadHandler = new DownloadHandlerBuffer(); request.SetRequestHeader("Content-Type", "application/json"); - request.SetRequestHeader("Authorization", $"Bearer {_jwt}"); + + if (_jwt != null) + { + request.SetRequestHeader("Authorization", $"Bearer {_jwt}"); + } request.certificateHandler = new CertificateWhore();