feat(stats): add stats window UI and functionality for displaying game statistics

This commit is contained in:
Данил Ярош 2025-11-26 17:03:34 +03:00
parent 175287f195
commit 0718c7805b
37 changed files with 7548 additions and 816 deletions

View File

@ -309,7 +309,7 @@ MonoBehaviour:
m_Value: 0.8
intensity:
m_OverrideState: 1
m_Value: 2
m_Value: 0
scatter:
m_OverrideState: 1
m_Value: 0.7

View File

@ -12,14 +12,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 71c1514a6bd24e1e882cebbe1904ce04, type: 3}
m_Name: NexaText-Regular SDF
m_EditorClassIdentifier:
hashCode: -1971092407
material: {fileID: 4262305343556741190}
materialHashCode: 769285321
m_Version: 1.1.0
m_SourceFontFileGUID: 9282a8614e95b3747b093f73c8eeb7a9
m_SourceFontFile_EditorRef: {fileID: 12800000, guid: 9282a8614e95b3747b093f73c8eeb7a9, type: 3}
m_SourceFontFile: {fileID: 0}
m_AtlasPopulationMode: 0
m_FaceInfo:
m_FaceIndex: 0
m_FamilyName: NexaText
@ -42,6 +35,31 @@ MonoBehaviour:
m_StrikethroughOffset: 28
m_StrikethroughThickness: 7.05
m_TabWidth: 36
m_Material: {fileID: 4262305343556741190}
m_SourceFontFileGUID: 9282a8614e95b3747b093f73c8eeb7a9
m_CreationSettings:
sourceFontFileName:
sourceFontFileGUID: 9282a8614e95b3747b093f73c8eeb7a9
faceIndex: 0
pointSizeSamplingMode: 0
pointSize: 141
padding: 5
paddingMode: 0
packingMode: 4
atlasWidth: 2048
atlasHeight: 2048
characterSetSelectionMode: 6
characterSequence: 20-7E,A0-161,164-17F,192,1FC-1FF,218-21B,237,2BC,2C6-2C7,2D8-2DD,400-45F,462-463,46A-46B,472-475,490-49D,4A0-4A5,4AA-4AB,4AE-4B1,4B6-4BB,4C0-4C2,4CB-4CC,4D0-4D9,4DC-4DF,4E2-4E9,4EE-4F9
referencedFontAssetGUID:
referencedTextAssetGUID:
fontStyle: 0
fontStyleModifier: 0
renderMode: 4165
includeFontFeatures: 0
m_SourceFontFile: {fileID: 0}
m_SourceFontFilePath:
m_AtlasPopulationMode: 0
InternalDynamicOS: 0
m_GlyphTable:
- m_Index: 4
m_Metrics:
@ -8313,7 +8331,12 @@ MonoBehaviour:
- {fileID: 4028949618672951788}
m_AtlasTextureIndex: 0
m_IsMultiAtlasTexturesEnabled: 0
m_GetFontFeatures: 1
m_ClearDynamicDataOnBuild: 0
m_AtlasWidth: 2048
m_AtlasHeight: 2048
m_AtlasPadding: 5
m_AtlasRenderMode: 4165
m_UsedGlyphRects:
- m_X: 0
m_Y: 0
@ -11120,57 +11143,14 @@ MonoBehaviour:
m_Y: 1777
m_Width: 137
m_Height: 184
m_fontInfo:
Name:
PointSize: 0
Scale: 0
CharacterCount: 0
LineHeight: 0
Baseline: 0
Ascender: 0
CapHeight: 0
Descender: 0
CenterLine: 0
SuperscriptOffset: 0
SubscriptOffset: 0
SubSize: 0
Underline: 0
UnderlineThickness: 0
strikethrough: 0
strikethroughThickness: 0
TabWidth: 0
Padding: 0
AtlasWidth: 0
AtlasHeight: 0
atlas: {fileID: 0}
m_AtlasWidth: 2048
m_AtlasHeight: 2048
m_AtlasPadding: 5
m_AtlasRenderMode: 4165
m_glyphInfoList: []
m_KerningTable:
kerningPairs: []
m_FontFeatureTable:
m_MultipleSubstitutionRecords: []
m_LigatureSubstitutionRecords: []
m_GlyphPairAdjustmentRecords: []
fallbackFontAssets: []
m_MarkToBaseAdjustmentRecords: []
m_MarkToMarkAdjustmentRecords: []
m_ShouldReimportFontFeatures: 0
m_FallbackFontAssetTable: []
m_CreationSettings:
sourceFontFileName:
sourceFontFileGUID: 9282a8614e95b3747b093f73c8eeb7a9
pointSizeSamplingMode: 0
pointSize: 141
padding: 5
packingMode: 4
atlasWidth: 2048
atlasHeight: 2048
characterSetSelectionMode: 6
characterSequence: 20-7E,A0-161,164-17F,192,1FC-1FF,218-21B,237,2BC,2C6-2C7,2D8-2DD,400-45F,462-463,46A-46B,472-475,490-49D,4A0-4A5,4AA-4AB,4AE-4B1,4B6-4BB,4C0-4C2,4CB-4CC,4D0-4D9,4DC-4DF,4E2-4E9,4EE-4F9
referencedFontAssetGUID:
referencedTextAssetGUID:
fontStyle: 0
fontStyleModifier: 0
renderMode: 4165
includeFontFeatures: 0
m_FontWeightTable:
- regularTypeface: {fileID: 0}
italicTypeface: {fileID: 0}
@ -11199,6 +11179,33 @@ MonoBehaviour:
boldSpacing: 7
italicStyle: 35
tabSize: 10
m_fontInfo:
Name:
PointSize: 0
Scale: 0
CharacterCount: 0
LineHeight: 0
Baseline: 0
Ascender: 0
CapHeight: 0
Descender: 0
CenterLine: 0
SuperscriptOffset: 0
SubscriptOffset: 0
SubSize: 0
Underline: 0
UnderlineThickness: 0
strikethrough: 0
strikethroughThickness: 0
TabWidth: 0
Padding: 0
AtlasWidth: 0
AtlasHeight: 0
m_glyphInfoList: []
m_KerningTable:
kerningPairs: []
fallbackFontAssets: []
atlas: {fileID: 0}
--- !u!28 &4028949618672951788
Texture2D:
m_ObjectHideFlags: 0
@ -11209,10 +11216,8 @@ Texture2D:
m_ImageContentsHash:
serializedVersion: 2
Hash: 00000000000000000000000000000000
m_ForcedFallbackFormat: 4
m_DownscaleFallback: 0
m_IsAlphaChannelOptional: 0
serializedVersion: 2
serializedVersion: 4
m_Width: 2048
m_Height: 2048
m_CompleteImageSize: 4194304
@ -11256,7 +11261,7 @@ Material:
m_PrefabAsset: {fileID: 0}
m_Name: NexaText-Regular SDF Material
m_Shader: {fileID: 4800000, guid: 68e6db2ebdc24f95958faec2be5558d6, type: 3}
m_Parent: {fileID: 0}
m_Parent: {fileID: 2100000, guid: 7562de12ae76cfd4b9c6be07c3e2dfdb, type: 2}
m_ModifiedSerializedProperties: 0
m_ValidKeywords: []
m_InvalidKeywords: []
@ -11270,88 +11275,16 @@ Material:
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Cube:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _FaceTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 4028949618672951788}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OutlineTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Ints: []
m_Floats:
- _Ambient: 0.5
- _Bevel: 0.5
- _BevelClamp: 0
- _BevelOffset: 0
- _BevelRoundness: 0
- _BevelWidth: 0
- _BumpFace: 0
- _BumpOutline: 0
- _ColorMask: 15
- _CullMode: 0
- _Diffuse: 0.5
- _FaceDilate: 0
- _FaceUVSpeedX: 0
- _FaceUVSpeedY: 0
- _GlowInner: 0.05
- _GlowOffset: 0
- _GlowOuter: 0.05
- _GlowPower: 0.75
- _GradientScale: 6
- _LightAngle: 3.1416
- _MaskSoftnessX: 0
- _MaskSoftnessY: 0
- _OutlineSoftness: 0
- _OutlineUVSpeedX: 0
- _OutlineUVSpeedY: 0
- _OutlineWidth: 0
- _PerspectiveFilter: 0.875
- _Reflectivity: 10
- _ScaleRatioA: 0.8333333
- _ScaleRatioB: 0.6770833
- _ScaleRatioC: 0.6770833
- _ScaleX: 1
- _ScaleY: 1
- _ShaderFlags: 0
- _Sharpness: 0
- _SpecularPower: 2
- _Stencil: 0
- _StencilComp: 8
- _StencilOp: 0
- _StencilReadMask: 255
- _StencilWriteMask: 255
- _TextureHeight: 2048
- _TextureWidth: 2048
- _UnderlayDilate: 0
- _UnderlayOffsetX: 0
- _UnderlayOffsetY: 0
- _UnderlaySoftness: 0
- _VertexOffsetX: 0
- _VertexOffsetY: 0
- _WeightBold: 0.75
- _WeightNormal: 0
m_Colors:
- _ClipRect: {r: -32767, g: -32767, b: 32767, a: 32767}
- _EnvMatrixRotation: {r: 0, g: 0, b: 0, a: 0}
- _FaceColor: {r: 1, g: 1, b: 1, a: 1}
- _GlowColor: {r: 0, g: 1, b: 0, a: 0.5}
- _MaskCoord: {r: 0, g: 0, b: 32767, a: 32767}
- _OutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _ReflectFaceColor: {r: 0, g: 0, b: 0, a: 1}
- _ReflectOutlineColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecularColor: {r: 1, g: 1, b: 1, a: 1}
- _UnderlayColor: {r: 0, g: 0, b: 0, a: 0.5}
m_Colors: []
m_BuildTextureStacks: []
m_AllowLocking: 1

View File

@ -428,6 +428,15 @@
"processors": "",
"interactions": "",
"initialStateCheck": false
},
{
"name": "ShowPlayerStats",
"type": "Button",
"id": "23dd6dcc-ee3e-49c5-921e-77e21ac190b4",
"expectedControlType": "",
"processors": "",
"interactions": "",
"initialStateCheck": false
}
],
"bindings": [
@ -782,6 +791,39 @@
"action": "AddCredit",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "One Modifier",
"id": "cbdcfb53-b586-4d59-9ac5-ac9cd6db8646",
"path": "OneModifier",
"interactions": "",
"processors": "",
"groups": "",
"action": "ShowPlayerStats",
"isComposite": true,
"isPartOfComposite": false
},
{
"name": "modifier",
"id": "4dd19fe5-79b2-4815-a20a-3eb866fff733",
"path": "<Keyboard>/leftArrow",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "ShowPlayerStats",
"isComposite": false,
"isPartOfComposite": true
},
{
"name": "binding",
"id": "42b3efd2-da14-4f43-84e2-d4c3043116db",
"path": "<Keyboard>/rightArrow",
"interactions": "",
"processors": "",
"groups": ";Keyboard&Mouse",
"action": "ShowPlayerStats",
"isComposite": false,
"isPartOfComposite": true
}
]
},

View File

@ -125,17 +125,15 @@ MonoBehaviour:
suffix: "\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435!
\u042F \u0432\u044B\u0438\u0433\u0440\u0430\u043B \u0432 \u0438\u0433\u0440\u0435!
\u0416\u0434\u0443 \u0441\u0432\u043E\u0439 \u043F\u0440\u0438\u0437!"
darkColor: {x: 0, y: 0, z: 0}
lightColor: {x: 0, y: 0, z: 0}
icon: {fileID: 2800000, guid: 7f21dcd24d95ab140a4d9a7384aafc34, type: 3}
darkColor: {x: 0, y: 0, z: 1}
lightColor: {x: 1, y: 1, z: 1}
- generateQRCode: 1
linkPrefix: https://wa.me/
suffix: "\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435!
\u042F \u0432\u044B\u0438\u0433\u0440\u0430\u043B \u0432 \u0438\u0433\u0440\u0435!
\u0416\u0434\u0443 \u0441\u0432\u043E\u0439 \u043F\u0440\u0438\u0437!"
darkColor: {x: 0, y: 0, z: 0}
lightColor: {x: 0, y: 0, z: 0}
icon: {fileID: 2800000, guid: 27345aeb13a6e2b4ba0da51f57e89af0, type: 3}
darkColor: {x: 0, y: 0.5, z: 0}
lightColor: {x: 1, y: 1, z: 1}
_phoneNumberMask: +7XXXXXXXXXX
--- !u!114 &6824661392768214298
MonoBehaviour:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: c25186adb6feb6343890f43504aeab6d
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,63 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Light Profile
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile
components:
- {fileID: 3931643873142543064}
--- !u!114 &3931643873142543064
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 1
m_Value: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 152e312826c19f74eb7d0bf976101f89
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,63 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Volume Profile
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile
components:
- {fileID: 5350586350289149108}
--- !u!114 &5350586350289149108
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 1
m_Value: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 8e3333548442dec4c974424987e03ab4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: ef4d2872581fd9a47ad3ca34516c7fdb
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -5266,7 +5266,7 @@ MonoBehaviour:
priority: 0
blendDistance: 0
weight: 1
sharedProfile: {fileID: 11400000, guid: 3dae892882a893c4da58e8534a7452bb, type: 2}
sharedProfile: {fileID: 11400000, guid: 3f9215ea0144899419cfbc0957140d3f, type: 2}
--- !u!1 &395422965
GameObject:
m_ObjectHideFlags: 0

View File

@ -1,63 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Light Profile
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile
components:
- {fileID: 9167928885711641750}
--- !u!114 &9167928885711641750
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 1
m_Value: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3dae892882a893c4da58e8534a7452bb
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 54bf06b85c0d2a242ae6298259a1d7d4
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 112000000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,169 +0,0 @@
fileFormatVersion: 2
guid: 3a3c15d25031dcb4f9bd991bcfdd3719
TextureImporter:
internalIDToNameTable:
- first:
213: -6178708042526665401
second: ReflectionProbe-0_0
externalObjects: {}
serializedVersion: 13
mipmaps:
mipMapMode: 0
enableMipMap: 1
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
flipGreenChannel: 0
isReadable: 0
streamingMipmaps: 0
streamingMipmapsPriority: 0
vTOnly: 0
ignoreMipmapLimit: 0
grayScaleToAlpha: 0
generateCubemap: 6
cubemapConvolution: 1
seamlessCubemap: 1
textureFormat: 1
maxTextureSize: 2048
textureSettings:
serializedVersion: 2
filterMode: 2
aniso: 0
mipBias: 0
wrapU: 1
wrapV: 1
wrapW: 1
nPOTScale: 1
lightmap: 0
compressionQuality: 50
spriteMode: 0
spriteExtrude: 1
spriteMeshType: 1
alignment: 0
spritePivot: {x: 0.5, y: 0.5}
spritePixelsToUnits: 100
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
spriteGenerateFallbackPhysicsShape: 1
alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureShape: 2
singleChannelComponent: 0
flipbookRows: 1
flipbookColumns: 1
maxTextureSizeSet: 0
compressionQualitySet: 0
textureFormatSet: 0
ignorePngGamma: 0
applyGammaDecoding: 0
swizzle: 50462976
cookieLightType: 0
platformSettings:
- serializedVersion: 4
buildTarget: DefaultTexturePlatform
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 100
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: Standalone
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WebGL
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
- serializedVersion: 4
buildTarget: WindowsStoreApps
maxTextureSize: 2048
resizeAlgorithm: 0
textureFormat: -1
textureCompression: 1
compressionQuality: 50
crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
ignorePlatformSupport: 0
androidETC2FallbackOverride: 0
forceMaximumCompressionQuality_BC6H_BC7: 0
spriteSheet:
serializedVersion: 2
sprites:
- serializedVersion: 2
name: ReflectionProbe-0_0
rect:
serializedVersion: 2
x: 0
y: 0
width: 4
height: 4
alignment: 0
pivot: {x: 0, y: 0}
border: {x: 0, y: 0, z: 0, w: 0}
customData:
outline: []
physicsShape: []
tessellationDetail: -1
bones: []
spriteID: 745595285c1d04aa0800000000000000
internalID: -6178708042526665401
vertices: []
indices:
edges: []
weights: []
outline: []
customData:
physicsShape: []
bones: []
spriteID:
internalID: 0
vertices: []
indices:
edges: []
weights: []
secondaryTextures: []
spriteCustomMetadata:
entries: []
nameFileIdTable:
ReflectionProbe-0_0: -6178708042526665401
mipmapLimitGroupName:
pSDRemoveMatte: 0
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 3575ee66273a9c1409a144e620effe5a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: cf8426d273c96ff468f117d3b545b439
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 112000000
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 5752dd0a0ea1a004884a5354eaf47f28
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,110 +0,0 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d7fd9488000d3734a9e00ee676215985, type: 3}
m_Name: Global Volume Profile
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.VolumeProfile
components:
- {fileID: 2855469478229301362}
- {fileID: 323351530273520648}
--- !u!114 &323351530273520648
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0b2db86121404754db890f4c8dfe81b2, type: 3}
m_Name: Bloom
m_EditorClassIdentifier: Unity.RenderPipelines.Universal.Runtime::UnityEngine.Rendering.Universal.Bloom
active: 1
skipIterations:
m_OverrideState: 0
m_Value: 1
threshold:
m_OverrideState: 0
m_Value: 0.9
intensity:
m_OverrideState: 0
m_Value: 0
scatter:
m_OverrideState: 0
m_Value: 0.7
clamp:
m_OverrideState: 0
m_Value: 65472
tint:
m_OverrideState: 0
m_Value: {r: 1, g: 1, b: 1, a: 1}
highQualityFiltering:
m_OverrideState: 0
m_Value: 0
downscale:
m_OverrideState: 0
m_Value: 0
maxIterations:
m_OverrideState: 0
m_Value: 6
dirtTexture:
m_OverrideState: 0
m_Value: {fileID: 0}
dimension: 1
dirtIntensity:
m_OverrideState: 0
m_Value: 0
--- !u!114 &2855469478229301362
MonoBehaviour:
m_ObjectHideFlags: 3
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6bd486065ce11414fa40e631affc4900, type: 3}
m_Name: ProbeVolumesOptions
m_EditorClassIdentifier: Unity.RenderPipelines.Core.Runtime::UnityEngine.Rendering.ProbeVolumesOptions
active: 1
normalBias:
m_OverrideState: 0
m_Value: 0.05
viewBias:
m_OverrideState: 0
m_Value: 0.1
scaleBiasWithMinProbeDistance:
m_OverrideState: 0
m_Value: 0
samplingNoise:
m_OverrideState: 0
m_Value: 0.1
animateSamplingNoise:
m_OverrideState: 0
m_Value: 1
leakReductionMode:
m_OverrideState: 0
m_Value: 2
minValidDotProductValue:
m_OverrideState: 0
m_Value: 0.1
occlusionOnlyReflectionNormalization:
m_OverrideState: 0
m_Value: 1
intensityMultiplier:
m_OverrideState: 0
m_Value: 1
skyOcclusionIntensityMultiplier:
m_OverrideState: 0
m_Value: 1
worldOffset:
m_OverrideState: 0
m_Value: {x: 0, y: 0, z: 0}

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f4ba7f07f8f6d0b4a82ba15d4c71569f
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 11400000
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@ -29,7 +29,7 @@ namespace RR.Game2D.Behaviour
// Аниматор
private static readonly int Speed = Animator.StringToHash("Speed");
void Start()
private void Start()
{
_rb = GetComponent<Rigidbody2D>();
_col = GetComponent<Collider2D>();
@ -51,7 +51,7 @@ namespace RR.Game2D.Behaviour
health.SetMaxHealth(config.maxHealth);
}
void FixedUpdate()
private void FixedUpdate()
{
if (!_playerObj) return;
// if (rb.linearVelocity.x > 0.0001f) Debug.Log(rb.linearVelocity.x);
@ -81,24 +81,23 @@ namespace RR.Game2D.Behaviour
_animator.SetFloat(Speed, Mathf.Abs(_rb.linearVelocity.magnitude));
}
void OnCollisionEnter2D(Collision2D collision)
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.collider.CompareTag("Player"))
if (!collision.collider.CompareTag("Player")) return;
Rigidbody2D playerRb = collision.collider.GetComponent<Rigidbody2D>();
_playerObj.TryGetComponent(out PlayerController playerController);
if (playerRb == null) return;
Vector2 contactNormal = collision.GetContact(0).normal;
if (contactNormal.y < -0.5f)
{
Rigidbody2D playerRb = collision.collider.GetComponent<Rigidbody2D>();
_playerObj.TryGetComponent(out PlayerController playerController);
if (playerRb == null) return;
Vector2 contactNormal = collision.GetContact(0).normal;
if (contactNormal.y < -0.5f)
{
playerRb.linearVelocity = new Vector2(playerRb.linearVelocity.x, 35f);
TakeDamage(MaxHealth);
// TakeDamage(1);
}
else
{
playerController.TakeDamage(1f);
}
playerRb.linearVelocity = new Vector2(playerRb.linearVelocity.x, 35f);
TakeDamage(MaxHealth);
// TakeDamage(1);
}
else
{
playerController.TakeDamage(1f);
}
}
@ -129,9 +128,8 @@ namespace RR.Game2D.Behaviour
Vector2 origin = eyePos + forward.normalized * 0.05f;
RaycastHit2D hit = Physics2D.Raycast(origin, toPlayer.normalized, dist, mask);
if (hit.collider != null) return false;
return true;
return !hit.collider;
}
public void TakeDamage(float amount)
@ -166,11 +164,11 @@ namespace RR.Game2D.Behaviour
Gizmos.DrawWireSphere(origin, config.viewDistance);
Vector2 toPlayer = (Vector2)_playerObj.transform.position - origin;
if (toPlayer.magnitude <= config.viewDistance)
{
Gizmos.color = Color.red;
Gizmos.DrawLine(transform.position, _playerObj.transform.position);
}
if (!(toPlayer.magnitude <= config.viewDistance)) return;
Gizmos.color = Color.red;
Gizmos.DrawLine(transform.position, _playerObj.transform.position);
}
#endif
}

View File

@ -152,18 +152,10 @@ namespace RR.Game2D.Behaviour
rb.linearVelocity = newVelocity;
_jumpPressed = _jumpReleased = _jumpHold = false;
// Смерть
// if (transform.position.y < deathY) Die();
}
private void OnTriggerEnter2D(Collider2D collision)
{
// if (collision.CompareTag("Coin"))
// {
// GameManager.Instance.AddCoin();
// Destroy(collision.gameObject);
// }
if (collision.CompareTag("Finish"))
{
@ -173,6 +165,8 @@ namespace RR.Game2D.Behaviour
if (collision.CompareTag("Enemy"))
{
TakeDamage(1f);
// GameManager.Logger.Log(ToString(), "Took damage from enemy collision.");
// GameManager.Logger.Log(ToString(), $"Collision with: {collision.name}");
}
}

View File

@ -0,0 +1,142 @@
using System;
using System.Collections;
using RR.Common.Controls;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class AdminStatsWindowUIController : MonoBehaviour
{
[Header("Тексты статистики")]
[SerializeField] private string gamesPlayedTextPrefix = "Игр сыграно: ";
[SerializeField] private TextMeshProUGUI gamesPlayedText;
[SerializeField] private string gamesPlayedNulTextPrefix = "Игр сыграно (обнуляемый): ";
[SerializeField] private TextMeshProUGUI gamesPlayedNulText;
[SerializeField] private string prizesGivenTextPrefix = "Призов выдано: ";
[SerializeField] private TextMeshProUGUI prizesGivenText;
[SerializeField] private string prizesGivenNulTextPrefix = "Призов выдано (обнуляемый): ";
[SerializeField] private TextMeshProUGUI prizesGivenNulText;
[Header("Кнопки")]
[SerializeField] private Button resetGamesPlayedNulButton;
[SerializeField] private Button resetPrizesGivenNulButton;
[SerializeField] private Button closeButton;
[Header("UI")]
[SerializeField] private CanvasGroup canvasGroup;
[SerializeField] private float fadeDuration = 0.15f;
private string _gamesPlayedKey;
private string _gamesPlayedNulKey;
private string _prizesGivenKey;
private string _prizesGivenNulKey;
private void Awake()
{
_gamesPlayedKey = PrizeSystem.key_starts;
_gamesPlayedNulKey = PrizeSystem.key_startsNul;
_prizesGivenKey = PrizeSystem.key_prizesgiven;
_prizesGivenNulKey = PrizeSystem.key_prizesgivenNul;
if (resetGamesPlayedNulButton) resetGamesPlayedNulButton.onClick.AddListener(() => ResetPlayerPrefsStat(_gamesPlayedNulKey));
if (resetPrizesGivenNulButton) resetPrizesGivenNulButton.onClick.AddListener( () => ResetPlayerPrefsStat(_prizesGivenNulKey));
if (closeButton) closeButton.onClick.AddListener(Toggle);
gameObject.SetActive(false);
}
private void OnDestroy()
{
if (resetGamesPlayedNulButton) resetGamesPlayedNulButton.onClick.RemoveListener(() => ResetPlayerPrefsStat(_gamesPlayedNulKey));
if (resetPrizesGivenNulButton) resetPrizesGivenNulButton.onClick.RemoveListener( () => ResetPlayerPrefsStat(_prizesGivenNulKey));
if (closeButton) closeButton.onClick.RemoveListener(Toggle);
}
public void Toggle()
{
if (gameObject.activeSelf)
{
Close();
}
else
{
Open();
}
}
private void Open()
{
gameObject.SetActive(true);
UpdateText();
StopAllCoroutines();
StartCoroutine(Fade(0f, 1f, fadeDuration));
}
private void Close()
{
StopAllCoroutines();
StartCoroutine(Fade(1f, 0f, fadeDuration, () => { gameObject.SetActive(false); }));
}
private void UpdateText()
{
if (gamesPlayedText)
{
int gamesPlayed = PlayerPrefs.GetInt(_gamesPlayedKey, 0);
gamesPlayedText.text = gamesPlayedTextPrefix + gamesPlayed;
}
if (gamesPlayedNulText)
{
int gamesPlayedNul = PlayerPrefs.GetInt(_gamesPlayedNulKey, 0);
gamesPlayedNulText.text = gamesPlayedNulTextPrefix + gamesPlayedNul;
}
if (prizesGivenText)
{
int prizesGiven = PlayerPrefs.GetInt(_prizesGivenKey, 0);
prizesGivenText.text = prizesGivenTextPrefix + prizesGiven;
}
if (prizesGivenNulText)
{
int prizesGivenNul = PlayerPrefs.GetInt(_prizesGivenNulKey, 0);
prizesGivenNulText.text = prizesGivenNulTextPrefix + prizesGivenNul;
}
}
private void ResetPlayerPrefsStat(string key)
{
PlayerPrefs.SetInt(key, 0);
UpdateText();
}
/// <summary>
/// Метод для плавного перехода (затухания)
/// </summary>
/// <param name="from">Начальная прозрачность</param>
/// <param name="to">Конечная прозрачность</param>
/// <param name="time">Время перехода</param>
/// <param name="onDone">Действие при выполнении перехода</param>
private IEnumerator Fade(float from, float to, float time, System.Action onDone = null)
{
if (!canvasGroup) { onDone?.Invoke(); yield break; }
float t = 0f;
canvasGroup.alpha = from;
canvasGroup.blocksRaycasts = true;
while (t < time)
{
t += Time.unscaledDeltaTime;
canvasGroup.alpha = Mathf.Lerp(from, to, t / time);
yield return null;
}
canvasGroup.alpha = to;
canvasGroup.blocksRaycasts = to > 0.99f;
onDone?.Invoke();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: df89ed1d48bc36140864491f04301407

View File

@ -119,7 +119,7 @@ namespace RR.Common.UI
/// <param name="cg">Группа холстов</param>
/// <param name="target">Целевое значение альфа-канала</param>
/// <param name="duration">Продолжительность перехода</param>
private IEnumerator Fade(CanvasGroup cg, float target, float duration)
private static IEnumerator Fade(CanvasGroup cg, float target, float duration)
{
float start = cg.alpha;
float t = 0f;

View File

@ -26,21 +26,19 @@ namespace RR.Common.UI
}
if (_paymentManager != null) _paymentManager.OnCreditsChanged.AddListener(ChangePlayButtonInteractable);
if (SettingsManager.Instance != null)
{
SettingsManager.Instance.OnSettingsLoaded += ChangePlayButtonInteractable;
SettingsManager.Instance.OnSettingsSaved += ChangePlayButtonInteractable;
}
if (SettingsManager.Instance == null) return;
SettingsManager.Instance.OnSettingsLoaded += ChangePlayButtonInteractable;
SettingsManager.Instance.OnSettingsSaved += ChangePlayButtonInteractable;
}
private void OnDestroy()
{
if (_paymentManager != null) _paymentManager.OnCreditsChanged.RemoveListener(ChangePlayButtonInteractable);
if (SettingsManager.Instance != null)
{
SettingsManager.Instance.OnSettingsLoaded -= ChangePlayButtonInteractable;
SettingsManager.Instance.OnSettingsSaved -= ChangePlayButtonInteractable;
}
if (SettingsManager.Instance == null) return;
SettingsManager.Instance.OnSettingsLoaded -= ChangePlayButtonInteractable;
SettingsManager.Instance.OnSettingsSaved -= ChangePlayButtonInteractable;
}
/// <summary>
@ -61,7 +59,7 @@ namespace RR.Common.UI
/// <summary>
/// Метод начала новой игры
/// </summary>
private void OnNewGame()
private static void OnNewGame()
{
GameManager.Instance.NewGame();
}
@ -69,7 +67,7 @@ namespace RR.Common.UI
/// <summary>
/// Метод выхода из игры
/// </summary>
private void OnQuit()
private static void OnQuit()
{
Application.Quit();
}
@ -79,11 +77,13 @@ namespace RR.Common.UI
// Проверяем только через SettingsManager, так как PaymentManager обновляется с задержкой
if (SettingsManager.Instance.GetCurrentGameSettings().isFreeGame)
{
newGameButton.interactable = true;
newGameButton.interactable = true;
return;
}
if (newGameButton) newGameButton.interactable = credits >= 1;
if (newGameButton) newGameButton.interactable = credits >= 1;
}
private void ChangePlayButtonInteractable()

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
@ -33,7 +34,7 @@ namespace RR.Common.UI
void Update()
{
if (modalRoot == null) return;
if (!modalRoot) return;
bool isOpen = modalRoot.activeSelf;
if (isOpen && !_wasOpenLastFrame) OnModalOpened();
@ -44,21 +45,20 @@ namespace RR.Common.UI
if (isOpen && enforce) EnsureFocusInsideModal();
}
void OnDisable()
private void OnDisable()
{
if (_wasOpenLastFrame) OnModalClosed();
}
void OnModalOpened()
private void OnModalOpened()
{
// запомнить, что было выделено до открытия
_prevSelectedGlobal = EventSystem.current ? EventSystem.current.currentSelectedGameObject : null;
// выключить интерактив вне модалки
CollectOutsideSelectables();
foreach (var s in _outside)
foreach (Selectable s in _outside.Where(s => s))
{
if (!s) continue;
_outsidePrev[s] = s.interactable;
s.interactable = false;
}
@ -69,25 +69,22 @@ namespace RR.Common.UI
toSelect = firstSelected.gameObject;
else
{
var any = modalRoot.GetComponentInChildren<Selectable>(includeInactive: false);
Selectable any = modalRoot.GetComponentInChildren<Selectable>(includeInactive: false);
if (any) toSelect = any.gameObject;
}
if (toSelect && EventSystem.current)
{
EventSystem.current.SetSelectedGameObject(null);
EventSystem.current.SetSelectedGameObject(toSelect);
_lastModalSelected = toSelect.GetComponent<Selectable>();
}
if (!toSelect || !EventSystem.current) return;
EventSystem.current.SetSelectedGameObject(null);
EventSystem.current.SetSelectedGameObject(toSelect);
_lastModalSelected = toSelect.GetComponent<Selectable>();
}
void OnModalClosed()
private void OnModalClosed()
{
// Восстанавливаем интерактивность всех внешних элементов
foreach (var kv in _outsidePrev)
foreach ((Selectable selectable, bool value) in _outsidePrev)
{
var s = kv.Key;
if (s) s.interactable = kv.Value;
if (selectable) selectable.interactable = value;
}
_outsidePrev.Clear();
_outside.Clear();
@ -100,7 +97,7 @@ namespace RR.Common.UI
// Проверяем, что предыдущий элемент всё ещё активен и интерактивен
if (_prevSelectedGlobal && _prevSelectedGlobal.activeInHierarchy)
{
var selectable = _prevSelectedGlobal.GetComponent<Selectable>();
Selectable selectable = _prevSelectedGlobal.GetComponent<Selectable>();
if (selectable && selectable.interactable)
{
toSelect = _prevSelectedGlobal;
@ -108,9 +105,9 @@ namespace RR.Common.UI
}
// Если предыдущий элемент недоступен, ищем любой доступный Selectable
if (toSelect == null)
if (!toSelect)
{
var anySelectable = Object.FindAnyObjectByType<Selectable>(FindObjectsInactive.Exclude);
Selectable anySelectable = Object.FindAnyObjectByType<Selectable>(FindObjectsInactive.Exclude);
if (anySelectable && anySelectable.interactable && !IsUnderModal(anySelectable.transform))
{
toSelect = anySelectable.gameObject;
@ -124,16 +121,16 @@ namespace RR.Common.UI
_prevSelectedGlobal = null;
}
void CollectOutsideSelectables()
private void CollectOutsideSelectables()
{
_outside.Clear();
_outsidePrev.Clear();
var all = Object.FindObjectsByType<Selectable>(
Selectable[] all = Object.FindObjectsByType<Selectable>(
FindObjectsInactive.Include,
FindObjectsSortMode.None);
foreach (var s in all)
foreach (Selectable s in all)
{
if (!s || !s.gameObject.activeInHierarchy) continue;
if (!IsUnderModal(s.transform))
@ -141,32 +138,30 @@ namespace RR.Common.UI
}
}
bool IsUnderModal(Transform t)
private bool IsUnderModal(Transform t)
{
if (!modalRoot) return false;
var root = modalRoot.transform;
for (var cur = t; cur != null; cur = cur.parent)
Transform root = modalRoot.transform;
for (Transform cur = t; cur; cur = cur.parent)
if (cur == root) return true;
return false;
}
void EnsureFocusInsideModal()
private void EnsureFocusInsideModal()
{
if (!EventSystem.current) return;
var cur = EventSystem.current.currentSelectedGameObject;
if (cur == null || !IsUnderModal(cur.transform))
GameObject cur = EventSystem.current.currentSelectedGameObject;
if (!cur || !IsUnderModal(cur.transform))
{
GameObject fallback =
(_lastModalSelected && _lastModalSelected.gameObject.activeInHierarchy) ? _lastModalSelected.gameObject :
(firstSelected && firstSelected.gameObject.activeInHierarchy) ? firstSelected.gameObject :
modalRoot.GetComponentInChildren<Selectable>()?.gameObject;
if (fallback)
{
EventSystem.current.SetSelectedGameObject(fallback);
_lastModalSelected = fallback.GetComponent<Selectable>();
}
if (!fallback) return;
EventSystem.current.SetSelectedGameObject(fallback);
_lastModalSelected = fallback.GetComponent<Selectable>();
}
else
{

View File

@ -68,7 +68,7 @@ namespace RR.Common.UI
}
}
private void Open()
public void Open()
{
gameObject.SetActive(true);
StopAllCoroutines();
@ -86,7 +86,7 @@ namespace RR.Common.UI
settingsUIList.SaveSettings();
}
private void SaveAndClose()
public void SaveAndClose()
{
Save();
Close();
@ -107,7 +107,7 @@ namespace RR.Common.UI
/// Метод для плавного перехода (затухания)
/// </summary>
/// <param name="from">Начальная прозрачность</param>
/// <param name="to">Конечная прозрачнеость</param>
/// <param name="to">Конечная прозрачность</param>
/// <param name="time">Время перехода</param>
/// <param name="onDone">Действие при выполнении перехода</param>
private IEnumerator Fade(float from, float to, float time, System.Action onDone = null)

View File

@ -27,6 +27,9 @@ namespace RR.Common.UI
[SerializeField] private Slider startLivesSlider;
[SerializeField] private Slider increasedLivesSlider;
// Buttons
[SerializeField] private Button statsButton;
[Header("Текст в UI")]
// Text
[SerializeField] private TextMeshProUGUI volumePercentageText;
@ -53,6 +56,7 @@ namespace RR.Common.UI
settingsList.Add(givingPrizesToggle);
settingsList.Add(startLivesSlider);
settingsList.Add(increasedLivesSlider);
settingsList.Add(statsButton);
currentSettings = settingsManager.GetCurrentGameSettings();

View File

@ -0,0 +1,105 @@
using System;
using System.Collections;
using RR.Common.Controls;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
public class StatsWindowUIController : MonoBehaviour
{
[Header("Управление")]
[SerializeField] private InputActionReference triggerKey;
[Header("Тексты статистики")]
[SerializeField] private string gamesPlayedTextPrefix = "Игр сыграно: ";
[SerializeField] private TextMeshProUGUI gamesPlayedText;
[SerializeField] private string prizesGivenTextPrefix = "Призов выдано: ";
[SerializeField] private TextMeshProUGUI prizesGivenText;
[Header("UI")]
[SerializeField] private CanvasGroup canvasGroup;
[SerializeField] private float fadeDuration = 0.15f;
private string _gamesPlayedKey;
private string _prizesGivenKey;
private void Awake()
{
_gamesPlayedKey = PrizeSystem.key_startsNul;
_prizesGivenKey = PrizeSystem.key_prizesgivenNul;
if (triggerKey != null) triggerKey.action.performed += Toggle;
gameObject.SetActive(false);
}
private void OnDestroy()
{
if (triggerKey != null) triggerKey.action.performed -= Toggle;
}
private void Toggle(InputAction.CallbackContext ctx)
{
if (gameObject.activeSelf)
{
Close();
}
else
{
Open();
}
}
private void Open()
{
gameObject.SetActive(true);
UpdateText();
StopAllCoroutines();
StartCoroutine(Fade(0f, 1f, fadeDuration));
}
private void Close()
{
StopAllCoroutines();
StartCoroutine(Fade(1f, 0f, fadeDuration, () => { gameObject.SetActive(false); }));
}
private void UpdateText()
{
if (gamesPlayedText)
{
int gamesPlayed = PlayerPrefs.GetInt(_gamesPlayedKey, 0);
gamesPlayedText.text = gamesPlayedTextPrefix + gamesPlayed;
}
if (prizesGivenText)
{
int prizesGiven = PlayerPrefs.GetInt(_prizesGivenKey, 0);
prizesGivenText.text = prizesGivenTextPrefix + prizesGiven;
}
}
/// <summary>
/// Метод для плавного перехода (затухания)
/// </summary>
/// <param name="from">Начальная прозрачность</param>
/// <param name="to">Конечная прозрачность</param>
/// <param name="time">Время перехода</param>
/// <param name="onDone">Действие при выполнении перехода</param>
private IEnumerator Fade(float from, float to, float time, System.Action onDone = null)
{
if (!canvasGroup) { onDone?.Invoke(); yield break; }
float t = 0f;
canvasGroup.alpha = from;
canvasGroup.blocksRaycasts = true;
while (t < time)
{
t += Time.unscaledDeltaTime;
canvasGroup.alpha = Mathf.Lerp(from, to, t / time);
yield return null;
}
canvasGroup.alpha = to;
canvasGroup.blocksRaycasts = to > 0.99f;
onDone?.Invoke();
}
}

View File

@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: bd944ee3cdcf2fc429f6f82033bd32c4

View File

@ -1,6 +1,4 @@
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using QRCoder;
using UnityEngine;