high score after lose

This commit is contained in:
2023-03-21 15:36:23 +01:00
parent 9d71b525c0
commit d8a4886d59
11 changed files with 598 additions and 101 deletions

View File

@@ -11,6 +11,10 @@ public class HighScoreTable : MonoBehaviour
private DatabaseData dbData; //Database osztalyhoz referencia
private HighScoreTableDataContainer htdc; //A tombot tarolo osztalyhoz referencia
private void Start() {
dbData.GetHighScoreData();
}
public void CreateTable(HighScoreTableData[] htd){
foreach(HighScoreTableData item in htd){
item.kiir(); //konzolra Debug miatt kiirja az adatokat

View File

@@ -144,7 +144,7 @@ public class DatabaseData : MonoBehaviour
private IEnumerator IGetHighScoreData(){
string uri = "http://localhost:3000/toplist";
var uwr = new UnityWebRequest(uri, "POST");
var uwr = new UnityWebRequest(uri, "GET");
//byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+palya_id+"}"); //palya id megadasa
//uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend); //felkuldi a palya id-t
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
@@ -238,7 +238,7 @@ public class DatabaseData : MonoBehaviour
var uwr = new UnityWebRequest(uri, "POST");
byte[] jsonToSend =
new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+playerid+",\"bevitel2\":400,\"bevitel3\":\"00:05:06\"}");
new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+playerid+",\"bevitel2\":"+score+",\"bevitel3\":\""+time+"\"}");
//playerid, points, time
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);

View File

@@ -68,7 +68,6 @@ public class UsernameHandler : MonoBehaviour
usernameInputCanvas.gameObject.SetActive(true);
inputBackground.SetActive(true);
input.gameObject.SetActive(true);
}
if(File.Exists(path)){

View File

@@ -22,6 +22,13 @@ public class jatekmanager : MonoBehaviour
public GameObject settingsGomb;
public GameObject shopGomb;
public GameObject goLeftButton;
public GameObject jumpButton;
public GameObject goRightButton;
public TMP_Text scoreText;
public TMP_Text timerText;
private DatabaseData db;
private UsernameHandler usernameHandler;
@@ -86,13 +93,24 @@ public class jatekmanager : MonoBehaviour
homeGomb.SetActive(true);
settingsGomb.SetActive(true);
shopGomb.SetActive(true);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
scoreText.gameObject.SetActive(false);
timerText.gameObject.SetActive(false);
}
private async void HandleHome()
{
{
//deactivate buttons
StartCoroutine(TimerHome());
GetComponent<GroundController>().enabled = false;
GetComponent<PlayerController>().enabled = false;
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
scoreText.gameObject.SetActive(false);
timerText.gameObject.SetActive(false);
garazs.SetActive(true);
}
@@ -110,6 +128,11 @@ public class jatekmanager : MonoBehaviour
private async void HandleSettings()
{
playButton.SetActive(false);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
scoreText.gameObject.SetActive(false);
timerText.gameObject.SetActive(false);
}
public void ChangeToShop()
@@ -120,6 +143,11 @@ public class jatekmanager : MonoBehaviour
private async void HandleShop()
{
playButton.SetActive(false);
goLeftButton.SetActive(false);
jumpButton.SetActive(false);
goRightButton.SetActive(false);
scoreText.gameObject.SetActive(false);
timerText.gameObject.SetActive(false);
}
public void ChangeToGame()
@@ -142,6 +170,11 @@ public class jatekmanager : MonoBehaviour
StartCoroutine(TimerGame());
GetComponent <GroundController> ().enabled = true;
GetComponent <PlayerController>().enabled = true;
goLeftButton.SetActive(true);
jumpButton.SetActive(true);
goRightButton.SetActive(true);
scoreText.gameObject.SetActive(true);
timerText.gameObject.SetActive(true);
timer.playTime.Start();
}