Scoreboard implementation part 1
Get scores from server Submit score to server Basic scoreboard scene
This commit is contained in:
@@ -508,7 +508,9 @@ MonoBehaviour:
|
|||||||
playerHealthLabel: {fileID: 1307309473}
|
playerHealthLabel: {fileID: 1307309473}
|
||||||
gameOverLabel: {fileID: 733797117}
|
gameOverLabel: {fileID: 733797117}
|
||||||
scoreLabel: {fileID: 71873946}
|
scoreLabel: {fileID: 71873946}
|
||||||
|
waveLabel: {fileID: 0}
|
||||||
restartButton: {fileID: 145060169}
|
restartButton: {fileID: 145060169}
|
||||||
|
scoreboardButton: {fileID: 1214927756}
|
||||||
--- !u!4 &286668900
|
--- !u!4 &286668900
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -581,6 +583,141 @@ PrefabInstance:
|
|||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents: []
|
m_RemovedComponents: []
|
||||||
m_SourcePrefab: {fileID: 100100000, guid: aa520f25e9cc9644fad9fb11be3f9d25, type: 3}
|
m_SourcePrefab: {fileID: 100100000, guid: aa520f25e9cc9644fad9fb11be3f9d25, type: 3}
|
||||||
|
--- !u!1 &415646752
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 415646753}
|
||||||
|
- component: {fileID: 415646755}
|
||||||
|
- component: {fileID: 415646754}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Text (TMP)
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &415646753
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 415646752}
|
||||||
|
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_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 1214927755}
|
||||||
|
m_RootOrder: 0
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
|
m_AnchorMax: {x: 1, y: 1}
|
||||||
|
m_AnchoredPosition: {x: 0, y: 0}
|
||||||
|
m_SizeDelta: {x: 0, y: 0}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &415646754
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 415646752}
|
||||||
|
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: Scoreboard
|
||||||
|
m_isRightToLeft: 0
|
||||||
|
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
|
||||||
|
m_fontSharedMaterials: []
|
||||||
|
m_fontMaterial: {fileID: 0}
|
||||||
|
m_fontMaterials: []
|
||||||
|
m_fontColor32:
|
||||||
|
serializedVersion: 2
|
||||||
|
rgba: 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: 24
|
||||||
|
m_fontSizeBase: 24
|
||||||
|
m_fontWeight: 400
|
||||||
|
m_enableAutoSizing: 0
|
||||||
|
m_fontSizeMin: 18
|
||||||
|
m_fontSizeMax: 72
|
||||||
|
m_fontStyle: 0
|
||||||
|
m_HorizontalAlignment: 2
|
||||||
|
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 &415646755
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 415646752}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &464214021
|
--- !u!1 &464214021
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -1104,6 +1241,7 @@ RectTransform:
|
|||||||
- {fileID: 733797116}
|
- {fileID: 733797116}
|
||||||
- {fileID: 145060168}
|
- {fileID: 145060168}
|
||||||
- {fileID: 71873945}
|
- {fileID: 71873945}
|
||||||
|
- {fileID: 1214927755}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 7
|
m_RootOrder: 7
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
@@ -6222,6 +6360,140 @@ Transform:
|
|||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 4
|
m_RootOrder: 4
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &1214927754
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1214927755}
|
||||||
|
- component: {fileID: 1214927758}
|
||||||
|
- component: {fileID: 1214927757}
|
||||||
|
- component: {fileID: 1214927756}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: Scoreboard Butt
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 0
|
||||||
|
--- !u!224 &1214927755
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1214927754}
|
||||||
|
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_ConstrainProportionsScale: 0
|
||||||
|
m_Children:
|
||||||
|
- {fileID: 415646753}
|
||||||
|
m_Father: {fileID: 920563117}
|
||||||
|
m_RootOrder: 4
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -105}
|
||||||
|
m_SizeDelta: {x: 160, y: 30}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1214927756
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1214927754}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Navigation:
|
||||||
|
m_Mode: 3
|
||||||
|
m_WrapAround: 0
|
||||||
|
m_SelectOnUp: {fileID: 0}
|
||||||
|
m_SelectOnDown: {fileID: 0}
|
||||||
|
m_SelectOnLeft: {fileID: 0}
|
||||||
|
m_SelectOnRight: {fileID: 0}
|
||||||
|
m_Transition: 1
|
||||||
|
m_Colors:
|
||||||
|
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||||
|
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||||
|
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||||
|
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||||
|
m_ColorMultiplier: 1
|
||||||
|
m_FadeDuration: 0.1
|
||||||
|
m_SpriteState:
|
||||||
|
m_HighlightedSprite: {fileID: 0}
|
||||||
|
m_PressedSprite: {fileID: 0}
|
||||||
|
m_SelectedSprite: {fileID: 0}
|
||||||
|
m_DisabledSprite: {fileID: 0}
|
||||||
|
m_AnimationTriggers:
|
||||||
|
m_NormalTrigger: Normal
|
||||||
|
m_HighlightedTrigger: Highlighted
|
||||||
|
m_PressedTrigger: Pressed
|
||||||
|
m_SelectedTrigger: Selected
|
||||||
|
m_DisabledTrigger: Disabled
|
||||||
|
m_Interactable: 1
|
||||||
|
m_TargetGraphic: {fileID: 1214927757}
|
||||||
|
m_OnClick:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls:
|
||||||
|
- m_Target: {fileID: 2036477789}
|
||||||
|
m_TargetAssemblyTypeName: GameManager, Assembly-CSharp
|
||||||
|
m_MethodName: OpenScoreboard
|
||||||
|
m_Mode: 1
|
||||||
|
m_Arguments:
|
||||||
|
m_ObjectArgument: {fileID: 0}
|
||||||
|
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
|
||||||
|
m_IntArgument: 0
|
||||||
|
m_FloatArgument: 0
|
||||||
|
m_StringArgument:
|
||||||
|
m_BoolArgument: 0
|
||||||
|
m_CallState: 2
|
||||||
|
--- !u!114 &1214927757
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1214927754}
|
||||||
|
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, g: 0.35631594, b: 0.7264151, 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: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||||
|
m_Type: 1
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1214927758
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1214927754}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
--- !u!1 &1307309471
|
--- !u!1 &1307309471
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -6589,6 +6861,8 @@ MonoBehaviour:
|
|||||||
pickups: []
|
pickups: []
|
||||||
pickupDelay: 0
|
pickupDelay: 0
|
||||||
scoreMultiplier: 1.2
|
scoreMultiplier: 1.2
|
||||||
|
waves: []
|
||||||
|
enemyHolder: {fileID: 0}
|
||||||
--- !u!4 &2036477790
|
--- !u!4 &2036477790
|
||||||
Transform:
|
Transform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
1733
Assets/Scenes/Menu.unity
Normal file
1733
Assets/Scenes/Menu.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/Menu.unity.meta
Normal file
7
Assets/Scenes/Menu.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 05af818c75f387843a7be919cc692218
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
2467
Assets/Scenes/Scoreboard.unity
Normal file
2467
Assets/Scenes/Scoreboard.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
Assets/Scenes/Scoreboard.unity.meta
Normal file
7
Assets/Scenes/Scoreboard.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bfeadc32d3e85b04bba07093ce68e69c
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -34,6 +34,8 @@ public class GameManager : MonoBehaviour
|
|||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
//dont destroy on load
|
||||||
|
DontDestroyOnLoad(this.gameObject);
|
||||||
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
|
||||||
|
|
||||||
StartWave();
|
StartWave();
|
||||||
@@ -111,4 +113,9 @@ public class GameManager : MonoBehaviour
|
|||||||
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OpenScoreboard()
|
||||||
|
{
|
||||||
|
SceneManager.LoadScene("Scoreboard");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
28
Assets/Scripts/Core/MenuManager.cs
Normal file
28
Assets/Scripts/Core/MenuManager.cs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class MenuManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartGame()
|
||||||
|
{
|
||||||
|
UnityEngine.SceneManagement.SceneManager.LoadScene("Main");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void QuitGame()
|
||||||
|
{
|
||||||
|
Application.Quit();
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Core/MenuManager.cs.meta
Normal file
11
Assets/Scripts/Core/MenuManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 53ecff72f2724144d9a7cf7267fe1679
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
117
Assets/Scripts/Core/ScoreboardManager.cs
Normal file
117
Assets/Scripts/Core/ScoreboardManager.cs
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.Networking;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class ScoreboardManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public string username;
|
||||||
|
public Button btnSubmit;
|
||||||
|
public TMPro.TextMeshProUGUI currentScore;
|
||||||
|
|
||||||
|
[Header("Global Scores")]
|
||||||
|
public TMPro.TextMeshProUGUI globalNames;
|
||||||
|
public TMPro.TextMeshProUGUI globalScores;
|
||||||
|
|
||||||
|
private int playerScore = 0;
|
||||||
|
private bool submitted = false;
|
||||||
|
|
||||||
|
[System.Serializable]
|
||||||
|
public class Score
|
||||||
|
{
|
||||||
|
public string username;
|
||||||
|
public int score;
|
||||||
|
}
|
||||||
|
[System.Serializable]
|
||||||
|
public class Scores
|
||||||
|
{
|
||||||
|
public Score[] scores;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start is called before the first frame update
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
StartCoroutine(GetScores());
|
||||||
|
//find gamemanager
|
||||||
|
GameManager gm = GameObject.Find("GameManager").GetComponent<GameManager>();
|
||||||
|
//set current score
|
||||||
|
currentScore.text = gm.score.ToString();
|
||||||
|
playerScore = gm.score;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
btnSubmit.interactable = username.Length > 0 && !submitted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdateUsername(string _username)
|
||||||
|
{
|
||||||
|
username = _username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SubmitScore()
|
||||||
|
{
|
||||||
|
btnSubmit.interactable = false;
|
||||||
|
StartCoroutine(SendScoreToServer());
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator SendScoreToServer()
|
||||||
|
{
|
||||||
|
string additional_data = "{}";
|
||||||
|
WWWForm form = new WWWForm();
|
||||||
|
form.AddField("username", username);
|
||||||
|
form.AddField("score", playerScore);
|
||||||
|
form.AddField("additional_data", additional_data);
|
||||||
|
using (UnityWebRequest www = UnityWebRequest.Post("http://vps5.minzkraut.com:3030/scores", form))
|
||||||
|
{
|
||||||
|
yield return www.SendWebRequest();
|
||||||
|
|
||||||
|
if (www.result != UnityWebRequest.Result.Success)
|
||||||
|
{
|
||||||
|
Debug.Log(www.error);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Log("Score submitted");
|
||||||
|
btnSubmit.GetComponentInChildren<TMPro.TextMeshProUGUI>().text = "Submitted!";
|
||||||
|
submitted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IEnumerator GetScores()
|
||||||
|
{
|
||||||
|
using (UnityWebRequest webRequest = UnityWebRequest.Get("http://vps5.minzkraut.com:3030/scores"))
|
||||||
|
{
|
||||||
|
// Request and wait for the desired page.
|
||||||
|
yield return webRequest.SendWebRequest();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
switch (webRequest.result)
|
||||||
|
{
|
||||||
|
case UnityWebRequest.Result.ConnectionError:
|
||||||
|
case UnityWebRequest.Result.DataProcessingError:
|
||||||
|
Debug.LogError("Error: " + webRequest.error);
|
||||||
|
break;
|
||||||
|
case UnityWebRequest.Result.ProtocolError:
|
||||||
|
Debug.LogError("HTTP Error: " + webRequest.error);
|
||||||
|
break;
|
||||||
|
case UnityWebRequest.Result.Success:
|
||||||
|
Debug.Log("Received: " + webRequest.downloadHandler.text);
|
||||||
|
Scores scores = JsonUtility.FromJson<Scores>("{\"scores\":" + webRequest.downloadHandler.text + "}");
|
||||||
|
globalNames.text = "";
|
||||||
|
globalScores.text = "";
|
||||||
|
foreach (Score score in scores.scores)
|
||||||
|
{
|
||||||
|
globalNames.text += score.username + "\n";
|
||||||
|
globalScores.text += score.score + "\n";
|
||||||
|
Debug.Log(score.username + ": " + score.score);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/Core/ScoreboardManager.cs.meta
Normal file
11
Assets/Scripts/Core/ScoreboardManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2aa5c6310c7a2b145b3c495581360ebc
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -12,6 +12,7 @@ public class UIManager : MonoBehaviour
|
|||||||
public TextMeshProUGUI waveLabel;
|
public TextMeshProUGUI waveLabel;
|
||||||
|
|
||||||
public Button restartButton;
|
public Button restartButton;
|
||||||
|
public Button scoreboardButton;
|
||||||
private GameManager gameManager;
|
private GameManager gameManager;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
@@ -34,6 +35,7 @@ public class UIManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
gameOverLabel.gameObject.SetActive(true);
|
gameOverLabel.gameObject.SetActive(true);
|
||||||
restartButton.gameObject.SetActive(true);
|
restartButton.gameObject.SetActive(true);
|
||||||
|
scoreboardButton.gameObject.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ public class Slowmotion : Pickup
|
|||||||
Time.timeScale = Time.timeScale * slowFactor;
|
Time.timeScale = Time.timeScale * slowFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,15 @@
|
|||||||
EditorBuildSettings:
|
EditorBuildSettings:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
m_Scenes: []
|
m_Scenes:
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/Scenes/Menu.unity
|
||||||
|
guid: 05af818c75f387843a7be919cc692218
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/Scenes/Main.unity
|
||||||
|
guid: bdd98952a528da747ae4648180cc9cfb
|
||||||
|
- enabled: 1
|
||||||
|
path: Assets/Scenes/Scoreboard.unity
|
||||||
|
guid: bfeadc32d3e85b04bba07093ce68e69c
|
||||||
m_configObjects:
|
m_configObjects:
|
||||||
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
|
com.unity.input.settings: {fileID: 11400000, guid: 9e7be553448fa2546aea5752021cbcf7, type: 2}
|
||||||
|
|||||||
Reference in New Issue
Block a user