add mockup of scoreboard manager
This commit is contained in:
parent
8c7a68cc6b
commit
e82482d996
@ -162,7 +162,7 @@ AnimatorState:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_Name: MainMenuTooltipBlinking
|
m_Name: MainMenuTooltipBlinking
|
||||||
m_Speed: 1
|
m_Speed: 0.5
|
||||||
m_CycleOffset: 0
|
m_CycleOffset: 0
|
||||||
m_Transitions: []
|
m_Transitions: []
|
||||||
m_StateMachineBehaviours: []
|
m_StateMachineBehaviours: []
|
||||||
|
229
Assets/Resources/Prefabs/Scoreboard Record.prefab
generated
Normal file
229
Assets/Resources/Prefabs/Scoreboard Record.prefab
generated
Normal file
@ -0,0 +1,229 @@
|
|||||||
|
%YAML 1.1
|
||||||
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
|
--- !u!1 &7150267414864613650
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7150267414864613651}
|
||||||
|
- component: {fileID: 7150267414864613654}
|
||||||
|
- component: {fileID: 7150267414864613653}
|
||||||
|
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 &7150267414864613651
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267414864613650}
|
||||||
|
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: 7150267415123359699}
|
||||||
|
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!222 &7150267414864613654
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267414864613650}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &7150267414864613653
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267414864613650}
|
||||||
|
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: '1. cuqmbr: 15731'
|
||||||
|
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: 55.8
|
||||||
|
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!1 &7150267415123359698
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 7150267415123359699}
|
||||||
|
- component: {fileID: 7150267415123359702}
|
||||||
|
- component: {fileID: 7150267415123359701}
|
||||||
|
- component: {fileID: 7150267415123359700}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Scoreboard Record
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &7150267415123359699
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267415123359698}
|
||||||
|
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: 7150267414864613651}
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
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: -50}
|
||||||
|
m_SizeDelta: {x: 0, y: 100}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!222 &7150267415123359702
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267415123359698}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &7150267415123359701
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267415123359698}
|
||||||
|
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.8235294, g: 0.8235294, b: 0.8235294, 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!114 &7150267415123359700
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 7150267415123359698}
|
||||||
|
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
|
7
Assets/Resources/Prefabs/Scoreboard Record.prefab.meta
generated
Normal file
7
Assets/Resources/Prefabs/Scoreboard Record.prefab.meta
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 17475f0c207c8230da0daf9725875171
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
1420
Assets/Scenes/SampleScene.unity
generated
1420
Assets/Scenes/SampleScene.unity
generated
File diff suppressed because it is too large
Load Diff
BIN
Assets/Sprites/Square.png
(Stored with Git LFS)
Normal file
BIN
Assets/Sprites/Square.png
(Stored with Git LFS)
Normal file
Binary file not shown.
160
Assets/Sprites/Square.png.meta
generated
Normal file
160
Assets/Sprites/Square.png.meta
generated
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 698ec1e99c7d691dca7b43e843782f2f
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable:
|
||||||
|
- first:
|
||||||
|
213: 7482667652216324306
|
||||||
|
second: Square
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 11
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 0
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -100
|
||||||
|
wrapU: 1
|
||||||
|
wrapV: 1
|
||||||
|
wrapW: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 2
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 256
|
||||||
|
spriteBorder: {x: 4, y: 4, z: 4, w: 4}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
spriteTessellationDetail: 0
|
||||||
|
textureType: 8
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: iPhone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Android
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites:
|
||||||
|
- serializedVersion: 2
|
||||||
|
name: Square
|
||||||
|
rect:
|
||||||
|
serializedVersion: 2
|
||||||
|
x: 0
|
||||||
|
y: 0
|
||||||
|
width: 256
|
||||||
|
height: 256
|
||||||
|
alignment: 0
|
||||||
|
pivot: {x: 0.5, y: 0.5}
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
outline: []
|
||||||
|
physicsShape: []
|
||||||
|
tessellationDetail: 0
|
||||||
|
bones: []
|
||||||
|
spriteID: 2d009a6b596c7d760800000000000000
|
||||||
|
internalID: 7482667652216324306
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
outline: []
|
||||||
|
physicsShape:
|
||||||
|
- - {x: -128, y: 128}
|
||||||
|
- {x: -128, y: -128}
|
||||||
|
- {x: 128, y: -128}
|
||||||
|
- {x: 128, y: 128}
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spritePackingTag:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
pSDShowRemoveMatteOption: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
@ -17,13 +17,13 @@ public class ScoreManager : MonoBehaviour
|
|||||||
|
|
||||||
[Header("Dependencies")]
|
[Header("Dependencies")]
|
||||||
[SerializeField] private UIManager _uiManager;
|
[SerializeField] private UIManager _uiManager;
|
||||||
|
[SerializeField] private ScoreboardManager _scoreboardManager;
|
||||||
|
|
||||||
private void Awake()
|
private void Awake()
|
||||||
{
|
{
|
||||||
PlayerEvents.OnBallTouched += AddScore;
|
PlayerEvents.OnBallTouched += AddScore;
|
||||||
PlayerEvents.OnBallTouched += AddExperience;
|
PlayerEvents.OnBallTouched += AddExperience;
|
||||||
PlayerEvents.OnWallTouched += ResetExperienceAndRewardMultiplier;
|
PlayerEvents.OnWallTouched += ResetExperienceAndRewardMultiplier;
|
||||||
PlayerEvents.OnDeath += SaveHighScore;
|
|
||||||
GameStateManager.Instance.OnGameStateChange += OnGameStateChange;
|
GameStateManager.Instance.OnGameStateChange += OnGameStateChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,10 +121,12 @@ public class ScoreManager : MonoBehaviour
|
|||||||
break;
|
break;
|
||||||
case GameState.PreGame:
|
case GameState.PreGame:
|
||||||
ResetAllValues();
|
ResetAllValues();
|
||||||
|
_scoreboardManager.SpawnScoreboardRecords();
|
||||||
break;
|
break;
|
||||||
case GameState.Game:
|
case GameState.Game:
|
||||||
break;
|
break;
|
||||||
case GameState.GameOver:
|
case GameState.GameOver:
|
||||||
|
SaveHighScore();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new ArgumentOutOfRangeException(nameof(newGameState), newGameState, null);
|
throw new ArgumentOutOfRangeException(nameof(newGameState), newGameState, null);
|
||||||
|
@ -12,7 +12,6 @@ public class PlayerCollisions : MonoBehaviour
|
|||||||
PlayerEvents.SendWallTouched();
|
PlayerEvents.SendWallTouched();
|
||||||
break;
|
break;
|
||||||
case "Floor":
|
case "Floor":
|
||||||
PlayerEvents.SendDeath();
|
|
||||||
GameStateManager.Instance.ChangeState(GameState.GameOver);
|
GameStateManager.Instance.ChangeState(GameState.GameOver);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -6,11 +6,7 @@ public class PlayerEvents
|
|||||||
|
|
||||||
public static event Action OnWallTouched;
|
public static event Action OnWallTouched;
|
||||||
|
|
||||||
public static event Action OnDeath;
|
|
||||||
|
|
||||||
public static void SendBallTouched() => OnBallTouched?.Invoke();
|
public static void SendBallTouched() => OnBallTouched?.Invoke();
|
||||||
|
|
||||||
public static void SendWallTouched() => OnWallTouched?.Invoke();
|
public static void SendWallTouched() => OnWallTouched?.Invoke();
|
||||||
|
|
||||||
public static void SendDeath() => OnDeath?.Invoke();
|
|
||||||
}
|
}
|
53
Assets/_Scripts/ScoreboardManager.cs
Normal file
53
Assets/_Scripts/ScoreboardManager.cs
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using DatabaseModels.DataTransferObjets;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ScoreboardManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
[SerializeField] private GameObject _scoreboardRecordPrefab;
|
||||||
|
|
||||||
|
[SerializeField] private Color _color1;
|
||||||
|
[SerializeField] private Color _color2;
|
||||||
|
|
||||||
|
[SerializeField] private GameObject _scrollViewContent;
|
||||||
|
|
||||||
|
public void SpawnScoreboardRecords()
|
||||||
|
{
|
||||||
|
var filteredScoreboardRecords = GetFilteredScoreboardRecords();
|
||||||
|
|
||||||
|
var rectTransform = _scrollViewContent.GetComponent<RectTransform>();
|
||||||
|
rectTransform.sizeDelta = new Vector2(0, filteredScoreboardRecords.Length * 100);
|
||||||
|
|
||||||
|
for (int i = 0; i < _scrollViewContent.transform.childCount; i++)
|
||||||
|
{
|
||||||
|
Destroy(_scrollViewContent.transform.GetChild(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < filteredScoreboardRecords.Length; i++)
|
||||||
|
{
|
||||||
|
Instantiate(_scoreboardRecordPrefab, new Vector2(225, -50 - 100 * i), Quaternion.identity, _scrollViewContent.transform);
|
||||||
|
}
|
||||||
|
|
||||||
|
ScoreboardRecordDto[] GetFilteredScoreboardRecords()
|
||||||
|
{
|
||||||
|
var localRecords = SessionStore.ScoreboardRecords.ToList();
|
||||||
|
|
||||||
|
var topUserRecord = localRecords.LastOrDefault(r => r.Score >= SessionStore.HighScore);
|
||||||
|
var topUserPlace = localRecords.IndexOf(topUserRecord) + 1;
|
||||||
|
|
||||||
|
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 - 5 ? topUserPlace - 5 : 0;
|
||||||
|
int count = localRecords.Count - currentUserPlace < localRecords.Count && localRecords.Count - currentUserPlace > 3 ? currentUserPlace + 3 - startIndex : currentUserPlace - startIndex;
|
||||||
|
|
||||||
|
if (currentUserPlace == -1)
|
||||||
|
{
|
||||||
|
count = localRecords.Count - startIndex;
|
||||||
|
}
|
||||||
|
|
||||||
|
return localRecords.GetRange(startIndex, count).ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
3
Assets/_Scripts/ScoreboardManager.cs.meta
generated
Normal file
3
Assets/_Scripts/ScoreboardManager.cs.meta
generated
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2bc38f67863847dabfe33b36efc70de6
|
||||||
|
timeCreated: 1658569500
|
@ -1,12 +1,11 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using DatabaseModels.DataTransferObjets;
|
using DatabaseModels.DataTransferObjets;
|
||||||
using JetBrains.Annotations;
|
|
||||||
|
|
||||||
public static class SessionStore
|
public static class SessionStore
|
||||||
{
|
{
|
||||||
public static string ApiUrl { get; set; }
|
public static string ApiUrl { get; set; }
|
||||||
|
|
||||||
public static UserData UserData { get; private set; }
|
public static UserData UserData { get; set; }
|
||||||
public static int HighScore { get; set; }
|
public static int HighScore { get; set; }
|
||||||
|
|
||||||
public static ScoreboardRecordDto[] ScoreboardRecords;
|
public static ScoreboardRecordDto[] ScoreboardRecords;
|
||||||
@ -23,6 +22,11 @@ public static class SessionStore
|
|||||||
HighScore = await SaveSystem.LoadFromBinaryAsync<int>("HighScore.bin");
|
HighScore = await SaveSystem.LoadFromBinaryAsync<int>("HighScore.bin");
|
||||||
|
|
||||||
ScoreboardRecords = await HttpClient.Get<ScoreboardRecordDto[]>($"{ApiUrl}/scoreboard");
|
ScoreboardRecords = await HttpClient.Get<ScoreboardRecordDto[]>($"{ApiUrl}/scoreboard");
|
||||||
|
|
||||||
|
if (UserData == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int? dbHighScore = ScoreboardRecords?.FirstOrDefault(sbr => sbr.User.Username == UserData.Username)?.Score;
|
int? dbHighScore = ScoreboardRecords?.FirstOrDefault(sbr => sbr.User.Username == UserData.Username)?.Score;
|
||||||
if (dbHighScore != null && dbHighScore > HighScore)
|
if (dbHighScore != null && dbHighScore > HighScore)
|
||||||
|
Loading…
Reference in New Issue
Block a user