coin backend start

This commit is contained in:
2023-03-07 13:55:45 +01:00
parent e1b689f6c5
commit 927ea1f885
4 changed files with 53 additions and 24 deletions

View File

@@ -4,7 +4,7 @@ using UnityEngine;
public class CoinCounter : MonoBehaviour
{
public ulong coin = 0;
public ulong coin = 0; //szedje le db-bol a playerhez a coint
public void AddCoin(ulong number){
coin += number;

View File

@@ -87,6 +87,29 @@ public class DatabaseData : MonoBehaviour
}
}
private IEnumerator IGetPlayerCoins(string username){
string uri = "http://localhost:3000/coinget";
var uwr = new UnityWebRequest(uri, "POST");
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+username+"}"); //palya id megadasa
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend); //felkuldi a palya id-t
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
uwr.SetRequestHeader("Content-Type", "application/json");
yield return uwr.SendWebRequest();
if (uwr.isNetworkError) {
Debug.Log(uwr.error);
} else {
Debug.Log(uwr.downloadHandler.text);
}
}
private IEnumerator IPostNewPlayerData() {
input.text = "loading...";

View File

@@ -1,13 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class WallCollision : MonoBehaviour
{
private void OnTriggerEnter(Collider other) {
if(other.gameObject.tag == "Player"){
Debug.Log("neki ment a falnak");
Application.Quit();
#if UNITY_EDITOR
EditorApplication.isPlaying = false;
#else
Application.Quit();
#endif
}
}
}