Merge pull request #11 from Games-Academy-Student-Work-21-22/amend-database-script
Amend database script
This commit is contained in:
commit
6c78643e7d
@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class FetchingScoresAnimation : MonoBehaviour
|
||||
{
|
||||
private Text textComponent;
|
||||
|
||||
void Start()
|
||||
{
|
||||
textComponent = GetComponent<Text>();
|
||||
AnimateText();
|
||||
}
|
||||
|
||||
private async void AnimateText()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
textComponent.text = "Fetching Scores";
|
||||
await Task.Delay(200);
|
||||
textComponent.text = "Fetching Scores.";
|
||||
await Task.Delay(200);
|
||||
textComponent.text = "Fetching Scores..";
|
||||
await Task.Delay(200);
|
||||
textComponent.text = "Fetching Scores...";
|
||||
await Task.Delay(200);
|
||||
}
|
||||
}
|
||||
}
|
11
Unity-Files/Assets/Animations/Game Over Screen/FetchingScoresAnimation.cs.meta
generated
Normal file
11
Unity-Files/Assets/Animations/Game Over Screen/FetchingScoresAnimation.cs.meta
generated
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5b53f28e9e952b644890fd1bc631a6d6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -34,6 +34,9 @@ AnimatorStateMachine:
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 8202368344915041182}
|
||||
m_Position: {x: 290, y: 110, z: 0}
|
||||
- serializedVersion: 1
|
||||
m_State: {fileID: 4072317482317692542}
|
||||
m_Position: {x: 325, y: 175, z: 0}
|
||||
m_ChildStateMachines: []
|
||||
m_AnyStateTransitions: []
|
||||
m_EntryTransitions: []
|
||||
@ -44,6 +47,32 @@ AnimatorStateMachine:
|
||||
m_ExitPosition: {x: 800, y: 120, z: 0}
|
||||
m_ParentStateMachinePosition: {x: 800, y: 20, z: 0}
|
||||
m_DefaultState: {fileID: 8202368344915041182}
|
||||
--- !u!1102 &4072317482317692542
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 1
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: FetchingScores
|
||||
m_Speed: 1
|
||||
m_CycleOffset: 0
|
||||
m_Transitions: []
|
||||
m_StateMachineBehaviours: []
|
||||
m_Position: {x: 50, y: 50, z: 0}
|
||||
m_IKOnFeet: 0
|
||||
m_WriteDefaultValues: 1
|
||||
m_Mirror: 0
|
||||
m_SpeedParameterActive: 0
|
||||
m_MirrorParameterActive: 0
|
||||
m_CycleOffsetParameterActive: 0
|
||||
m_TimeParameterActive: 0
|
||||
m_Motion: {fileID: 7400000, guid: f23142e76eace5e4ab0d5f5029975aee, type: 2}
|
||||
m_Tag:
|
||||
m_SpeedParameter:
|
||||
m_MirrorParameter:
|
||||
m_CycleOffsetParameter:
|
||||
m_TimeParameter:
|
||||
--- !u!1102 &8202368344915041182
|
||||
AnimatorState:
|
||||
serializedVersion: 6
|
||||
|
@ -241,34 +241,6 @@ AnimationClip:
|
||||
path: GameOverLabel/ScoreSubmitPanel
|
||||
classID: 1
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: Infinity
|
||||
tangentMode: 103
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 4.5
|
||||
value: 1
|
||||
inSlope: Infinity
|
||||
outSlope: Infinity
|
||||
tangentMode: 103
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_IsActive
|
||||
path: LeaderboardPanel/Return Button (1)
|
||||
classID: 1
|
||||
script: {fileID: 0}
|
||||
m_PPtrCurves: []
|
||||
m_SampleRate: 60
|
||||
m_WrapMode: 0
|
||||
@ -333,13 +305,6 @@ AnimationClip:
|
||||
typeID: 1
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
- serializedVersion: 2
|
||||
path: 2245661666
|
||||
attribute: 2086281974
|
||||
script: {fileID: 0}
|
||||
typeID: 1
|
||||
customType: 0
|
||||
isPPtrCurve: 0
|
||||
pptrCurveMapping: []
|
||||
m_AnimationClipSettings:
|
||||
serializedVersion: 2
|
||||
@ -586,34 +551,6 @@ AnimationClip:
|
||||
path: GameOverLabel/ScoreSubmitPanel
|
||||
classID: 1
|
||||
script: {fileID: 0}
|
||||
- curve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: Infinity
|
||||
outSlope: Infinity
|
||||
tangentMode: 103
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
- serializedVersion: 3
|
||||
time: 4.5
|
||||
value: 1
|
||||
inSlope: Infinity
|
||||
outSlope: Infinity
|
||||
tangentMode: 103
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
attribute: m_IsActive
|
||||
path: LeaderboardPanel/Return Button (1)
|
||||
classID: 1
|
||||
script: {fileID: 0}
|
||||
m_EulerEditorCurves: []
|
||||
m_HasGenericRootTransform: 0
|
||||
m_HasMotionFloatCurves: 0
|
||||
|
145
Unity-Files/Assets/Examples/Defender/Defender.unity
generated
145
Unity-Files/Assets/Examples/Defender/Defender.unity
generated
@ -389,7 +389,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -175}
|
||||
m_AnchoredPosition: {x: 500, y: -125}
|
||||
m_SizeDelta: {x: 0, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &204554430
|
||||
@ -516,8 +516,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -480}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_AnchoredPosition: {x: 500, y: -430}
|
||||
m_SizeDelta: {x: 81.12676, y: 80}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &222835919
|
||||
MonoBehaviour:
|
||||
@ -777,8 +777,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -100}
|
||||
m_SizeDelta: {x: 0, y: 100}
|
||||
m_AnchoredPosition: {x: 500, y: -50}
|
||||
m_SizeDelta: {x: 1000, y: 100}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &289906080
|
||||
MonoBehaviour:
|
||||
@ -856,8 +856,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -560}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_AnchoredPosition: {x: 500, y: -510}
|
||||
m_SizeDelta: {x: 81.12676, y: 80}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &303121901
|
||||
MonoBehaviour:
|
||||
@ -1643,8 +1643,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -400}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_AnchoredPosition: {x: 500, y: -350}
|
||||
m_SizeDelta: {x: 81.12676, y: 80}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &615826098
|
||||
MonoBehaviour:
|
||||
@ -1969,6 +1969,98 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 720830516}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &730755786
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 730755787}
|
||||
- component: {fileID: 730755790}
|
||||
- component: {fileID: 730755789}
|
||||
- component: {fileID: 730755788}
|
||||
m_Layer: 5
|
||||
m_Name: FetchingScores
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &730755787
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 730755786}
|
||||
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: 1911386533}
|
||||
m_RootOrder: 1
|
||||
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: 0}
|
||||
m_SizeDelta: {x: 953.13, y: 178.71}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &730755788
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 730755786}
|
||||
m_Enabled: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5b53f28e9e952b644890fd1bc631a6d6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &730755789
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 730755786}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, 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_FontData:
|
||||
m_Font: {fileID: 12800000, guid: 2fb810d2f9fc27b4eb7693fd3f9f158c, type: 3}
|
||||
m_FontSize: 100
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 102
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 1
|
||||
m_RichText: 1
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text:
|
||||
--- !u!222 &730755790
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 730755786}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &839555743
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2547,9 +2639,8 @@ RectTransform:
|
||||
- {fileID: 615826097}
|
||||
- {fileID: 222835918}
|
||||
- {fileID: 303121900}
|
||||
- {fileID: 1066252772}
|
||||
m_Father: {fileID: 1911386533}
|
||||
m_RootOrder: 1
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
@ -2573,7 +2664,7 @@ MonoBehaviour:
|
||||
m_Right: 0
|
||||
m_Top: 0
|
||||
m_Bottom: 0
|
||||
m_ChildAlignment: 4
|
||||
m_ChildAlignment: 1
|
||||
m_Spacing: 0
|
||||
m_ChildForceExpandWidth: 0
|
||||
m_ChildForceExpandHeight: 0
|
||||
@ -2604,6 +2695,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
submitUsername: {fileID: 0}
|
||||
GameOverPanel: {fileID: 0}
|
||||
FetchingScores: {fileID: 0}
|
||||
--- !u!1 &1061207721
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -2719,12 +2811,12 @@ RectTransform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1835608784}
|
||||
m_Father: {fileID: 1059183747}
|
||||
m_RootOrder: 7
|
||||
m_Father: {fileID: 1911386533}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -600}
|
||||
m_AnchoredPosition: {x: 960, y: -858}
|
||||
m_SizeDelta: {x: 260, y: 86.8201}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!95 &1066252773
|
||||
@ -3063,8 +3155,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -240}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_AnchoredPosition: {x: 500, y: -190}
|
||||
m_SizeDelta: {x: 74.88624, y: 80}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1433312461
|
||||
MonoBehaviour:
|
||||
@ -4309,6 +4401,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
submitUsername: {fileID: 839555745}
|
||||
GameOverPanel: {fileID: 1891273395}
|
||||
FetchingScores: {fileID: 730755786}
|
||||
--- !u!1 &1891273445
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -4447,7 +4540,7 @@ RectTransform:
|
||||
m_Children:
|
||||
- {fileID: 873720541}
|
||||
m_Father: {fileID: 1911386533}
|
||||
m_RootOrder: 0
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
@ -4503,6 +4596,8 @@ RectTransform:
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 1066252772}
|
||||
- {fileID: 730755787}
|
||||
- {fileID: 1911360419}
|
||||
- {fileID: 1059183747}
|
||||
m_Father: {fileID: 1911403295}
|
||||
@ -4783,8 +4878,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 1}
|
||||
m_AnchorMax: {x: 0, y: 1}
|
||||
m_AnchoredPosition: {x: 500, y: -320}
|
||||
m_SizeDelta: {x: 0, y: 80}
|
||||
m_AnchoredPosition: {x: 500, y: -270}
|
||||
m_SizeDelta: {x: 81.12676, y: 80}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &2084735052
|
||||
MonoBehaviour:
|
||||
@ -5012,6 +5107,11 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Nuke
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 1044604232950715027, guid: 35d4c3c707316d94eafa98daa3a72231,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5825771540101445476, guid: 35d4c3c707316d94eafa98daa3a72231,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
@ -5162,6 +5262,11 @@ PrefabInstance:
|
||||
propertyPath: m_Name
|
||||
value: Bomb
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2095680581380159745, guid: 437a8142fe505894fae2882aba31035b,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2095680581380159747, guid: 437a8142fe505894fae2882aba31035b,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
|
@ -4,33 +4,38 @@ using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using MySql.Data.MySqlClient;
|
||||
using System.Net;
|
||||
using System.Threading.Tasks;
|
||||
public class LeaderboardHandle : MonoBehaviour
|
||||
{
|
||||
public InputField submitUsername;
|
||||
public GameObject GameOverPanel;
|
||||
public GameObject FetchingScores;
|
||||
public float time { get; set; }
|
||||
public int finalScore { get; set; }
|
||||
|
||||
private MySqlConnectionStringBuilder mySQLConectionBuilder = new MySqlConnectionStringBuilder();
|
||||
private MySqlConnectionStringBuilder mySQLConnectionBuilder = new MySqlConnectionStringBuilder();
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
mySQLConectionBuilder.Server = "sql4.freesqldatabase.com";
|
||||
mySQLConectionBuilder.Port = 3306;
|
||||
mySQLConectionBuilder.UserID = "sql4449219";
|
||||
mySQLConectionBuilder.Password = "hsFqWLxIIF";
|
||||
mySQLConectionBuilder.Database = "sql4449219";
|
||||
mySQLConnectionBuilder.Server = "sql4.freesqldatabase.com";
|
||||
mySQLConnectionBuilder.Port = 3306;
|
||||
mySQLConnectionBuilder.UserID = "sql4449219";
|
||||
mySQLConnectionBuilder.Password = "hsFqWLxIIF";
|
||||
mySQLConnectionBuilder.Database = "sql4449219";
|
||||
|
||||
GameObject.Find("FinalScoreLabel").GetComponent<Text>().text = GameObject.Find("FinalScoreLabel").GetComponent<Text>().text.Replace("000", finalScore.ToString());
|
||||
}
|
||||
|
||||
public void SubmitScores()
|
||||
public async void SubmitScores()
|
||||
{
|
||||
SetScoreRecords(mySQLConectionBuilder.ConnectionString, submitUsername.text);
|
||||
GameObject.Find("GameOverLabel").SetActive(false);
|
||||
FetchingScores.GetComponent<FetchingScoresAnimation>().enabled = true;
|
||||
await SetScoreRecords(mySQLConnectionBuilder.ConnectionString, submitUsername.text);
|
||||
List<Score> Scores = new List<Score>(await GetScoreRecords(mySQLConnectionBuilder.ConnectionString));
|
||||
FetchingScores.GetComponent<FetchingScoresAnimation>().enabled = false;
|
||||
FetchingScores.SetActive(false);
|
||||
GameOverPanel.GetComponent<Animator>().enabled = true;
|
||||
|
||||
List<Score> Scores = new List<Score>(GetScoreRecords(mySQLConectionBuilder.ConnectionString));
|
||||
for (int i = 0; i < Scores.Count; i++)
|
||||
{
|
||||
Text scoreLabel = GameObject.Find($"ScoreText ({i + 1})").GetComponent<Text>();
|
||||
@ -39,51 +44,57 @@ public class LeaderboardHandle : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void SetScoreRecords(string connectionString, string username)
|
||||
private async Task SetScoreRecords(string connectionString, string username)
|
||||
{
|
||||
try
|
||||
await Task.Run(() =>
|
||||
{
|
||||
using (MySqlConnection connection = new MySqlConnection(connectionString))
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = $"INSERT INTO Scores VALUES ('{username.ToUpper()}', '{finalScore}', '{Mathf.FloorToInt(time)}', '{GetIPAddress()}')";
|
||||
using (MySqlCommand command = new MySqlCommand(sql, connection))
|
||||
using (MySqlConnection connection = new MySqlConnection(connectionString))
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
connection.Open();
|
||||
string sql = $"INSERT INTO Scores VALUES ('{username.ToUpper()}', '{finalScore}', '{Mathf.FloorToInt(time)}', '{GetIPAddress()}')";
|
||||
using (MySqlCommand command = new MySqlCommand(sql, connection))
|
||||
{
|
||||
command.ExecuteNonQuery();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Debug.Log(e.ToString());
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Debug.Log(e.ToString());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<Score> GetScoreRecords(string connectionString)
|
||||
private async Task<List<Score>> GetScoreRecords(string connectionString)
|
||||
{
|
||||
List<Score> records = new List<Score>();
|
||||
try
|
||||
await Task.Run(() =>
|
||||
{
|
||||
using (MySqlConnection connection = new MySqlConnection(connectionString))
|
||||
try
|
||||
{
|
||||
connection.Open();
|
||||
string sql = "SELECT Username, Score, TimeLasted FROM Scores ORDER BY Score DESC LIMIT 5";
|
||||
using (MySqlCommand command = new MySqlCommand(sql, connection))
|
||||
using (MySqlConnection connection = new MySqlConnection(connectionString))
|
||||
{
|
||||
using (MySqlDataReader reader = command.ExecuteReader())
|
||||
connection.Open();
|
||||
string sql = "SELECT Username, Score, TimeLasted FROM Scores ORDER BY Score DESC LIMIT 5";
|
||||
using (MySqlCommand command = new MySqlCommand(sql, connection))
|
||||
{
|
||||
while (reader.Read())
|
||||
using (MySqlDataReader reader = command.ExecuteReader())
|
||||
{
|
||||
records.Add(new Score(reader.GetString(0), reader.GetInt32(1), reader.GetInt32(2)));
|
||||
while (reader.Read())
|
||||
{
|
||||
records.Add(new Score(reader.GetString(0), reader.GetInt32(1), reader.GetInt32(2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Debug.Log(e.ToString());
|
||||
}
|
||||
catch (MySqlException e)
|
||||
{
|
||||
Debug.Log(e.ToString());
|
||||
}
|
||||
});
|
||||
return records;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user