coin
This commit is contained in:
@@ -926,7 +926,6 @@ GameObject:
|
||||
- component: {fileID: 1201779184}
|
||||
- component: {fileID: 1201779185}
|
||||
- component: {fileID: 1201779186}
|
||||
- component: {fileID: 1201779187}
|
||||
m_Layer: 0
|
||||
m_Name: Manager
|
||||
m_TagString: Untagged
|
||||
@@ -1026,20 +1025,6 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
fpsText: {fileID: 1572233531}
|
||||
_hudRefreshRate: 1
|
||||
--- !u!114 &1201779187
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1201779180}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d858282f94188744f80e5d0e2883a3a1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
score: 0
|
||||
scoreUI: {fileID: 834582560}
|
||||
--- !u!1 &1219467652
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -11249,7 +11234,7 @@ Rigidbody:
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0
|
||||
m_UseGravity: 1
|
||||
m_UseGravity: 0
|
||||
m_IsKinematic: 0
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 112
|
||||
@@ -11263,7 +11248,7 @@ CapsuleCollider:
|
||||
m_GameObject: {fileID: 7398140401948337837}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
m_Enabled: 0
|
||||
m_Radius: 1.7212968
|
||||
m_Height: 6.3698125
|
||||
m_Direction: 1
|
||||
|
||||
@@ -7,14 +7,17 @@ using System.Text;
|
||||
|
||||
public class CoinCounter : MonoBehaviour
|
||||
{
|
||||
public ulong coin; //szedje le db-bol a playerhez a coint
|
||||
public ulong coin = ulong.MaxValue; //szedje le db-bol a playerhez a coint
|
||||
public TMP_Text coinCounterUI;
|
||||
private string path;
|
||||
private StreamWriter writer;
|
||||
private StreamReader reader;
|
||||
|
||||
private DatabaseData db;
|
||||
|
||||
private void Awake() {
|
||||
path = Application.persistentDataPath + "/coins.txt";
|
||||
db = FindObjectOfType<DatabaseData>();
|
||||
/*path = Application.persistentDataPath + "/coins.txt";
|
||||
|
||||
if(!File.Exists(path)){ //ha nincs meg ilyen fajl hozza letre
|
||||
writer = new StreamWriter(path, false, Encoding.Default);
|
||||
@@ -25,11 +28,16 @@ public class CoinCounter : MonoBehaviour
|
||||
reader = new StreamReader(path);
|
||||
coin = ulong.Parse(reader.ReadLine());
|
||||
reader.Close();
|
||||
Debug.Log("Coins at start: " + coin);
|
||||
Debug.Log("Coins at start: " + coin);*/
|
||||
|
||||
coinCounterUI.text = "Coins: " + coin.ToString();
|
||||
/*Debug.Log("coin 1: " + coin);
|
||||
coin = db.GetCoins(1);
|
||||
Debug.Log("itt van coin");
|
||||
Debug.Log("coin 2: " + coin);
|
||||
coinCounterUI.text = "Coins: " + coin.ToString();*/
|
||||
}
|
||||
|
||||
|
||||
public void AddCoin(ulong number){
|
||||
coin += number;
|
||||
coinCounterUI.text = "Coins: " + coin.ToString();
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.Networking;
|
||||
|
||||
public class DatabaseData : MonoBehaviour
|
||||
{
|
||||
public TMP_InputField input; //szoveg megjelenitese
|
||||
//public TMP_InputField input; //szoveg megjelenitese
|
||||
public PlayerList players; //jatekos adatok
|
||||
public HighScoreTableDataContainer htdc; //itt van a tomb
|
||||
public HighScoreTable hst; //high score table ui
|
||||
@@ -14,6 +14,8 @@ public class DatabaseData : MonoBehaviour
|
||||
|
||||
private CoinCounter coinc;
|
||||
|
||||
private ulong coins = 0;
|
||||
|
||||
private void Awake() {
|
||||
hst = FindObjectOfType<HighScoreTable>(); //High Score Table referencia
|
||||
htdc = new HighScoreTableDataContainer(); //High Score Table Container objektum
|
||||
@@ -22,7 +24,8 @@ public class DatabaseData : MonoBehaviour
|
||||
}
|
||||
|
||||
private void Start() {
|
||||
GetHighScoreData(2);
|
||||
//GetHighScoreData(2);
|
||||
//StartCoroutine(GetCoinData(1));
|
||||
}
|
||||
|
||||
public void jsonParser(string jsondata) { //beerkezo json adat eltarolasa
|
||||
@@ -33,6 +36,11 @@ public class DatabaseData : MonoBehaviour
|
||||
htdc = JsonUtility.FromJson<HighScoreTableDataContainer>("{\"htd\":" + jsondata + "}");
|
||||
}
|
||||
|
||||
public void jsonParserCoin(string jsondata){
|
||||
coins = ulong.Parse(jsondata.Substring(14,2));
|
||||
Debug.Log(jsondata.Substring(14,2));
|
||||
}
|
||||
|
||||
//fuggvenyek amik meghivjak a rutint
|
||||
public void GetPlayerData() => StartCoroutine(IGetPlayerData());
|
||||
public void GetHighScoreData(int palya_id) => StartCoroutine(IGetHighScoreData(palya_id));
|
||||
@@ -40,10 +48,35 @@ public class DatabaseData : MonoBehaviour
|
||||
public void PostNewScoreData() => StartCoroutine(IPostNewScoreData());
|
||||
public void PostNewPalyaData() => StartCoroutine(IPostNewPalyaData());
|
||||
|
||||
public void GetCoinData(string username) => StartCoroutine(IGetPlayerCoins(username));
|
||||
public ulong GetCoins(int userid){
|
||||
StartCoroutine(GetCoinData(userid));
|
||||
|
||||
return coins;
|
||||
}
|
||||
|
||||
private IEnumerator GetCoinData(int userid){
|
||||
string uri = "http://localhost:3000/coinget";
|
||||
|
||||
var uwr = new UnityWebRequest(uri, "GET");
|
||||
byte[] jsonToSend = new System.Text.UTF8Encoding().GetBytes("{\"bevitel1\":"+userid+"}");
|
||||
uwr.uploadHandler = (UploadHandler)new UploadHandlerRaw(jsonToSend);
|
||||
uwr.downloadHandler = (DownloadHandler)new DownloadHandlerBuffer();
|
||||
uwr.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
yield return uwr.SendWebRequest();
|
||||
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
jsondata = uwr.downloadHandler.text; //json szoveg eltarolasa
|
||||
Debug.Log(jsondata);
|
||||
jsonParserCoin(jsondata);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private IEnumerator IGetPlayerData() {
|
||||
input.text = "Loading..."; //ideiglenes szoveg amig nem jelenik meg az adat szoveg
|
||||
//input.text = "Loading..."; //ideiglenes szoveg amig nem jelenik meg az adat szoveg
|
||||
|
||||
string uri = "http://localhost:3000/player"; //backend vegpont linkje
|
||||
|
||||
@@ -51,7 +84,7 @@ public class DatabaseData : MonoBehaviour
|
||||
yield return request.SendWebRequest(); //amig be nem fejezodik az fv ide fog visszaterni
|
||||
|
||||
if(request.isNetworkError || request.isHttpError) { //ha valami hiba tortent kiirjuk a kepernyore
|
||||
input.text = request.error;
|
||||
//input.text = request.error;
|
||||
} else {
|
||||
jsondata = request.downloadHandler.text; //json szoveg eltarolasa
|
||||
jsonParser(jsondata); //json adat atalakitasa
|
||||
@@ -60,11 +93,11 @@ public class DatabaseData : MonoBehaviour
|
||||
Debug.Log("p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n");
|
||||
}
|
||||
|
||||
input.text = "";
|
||||
//input.text = "";
|
||||
foreach(var p in players.player) {
|
||||
p.ConvertDate();
|
||||
//adatok kiirasa kepernyore
|
||||
input.text += "p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n";
|
||||
//input.text += "p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,14 +118,14 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
jsondata = uwr.downloadHandler.text; //json szoveg eltarolasa
|
||||
Debug.Log("current player json: " + jsondata);
|
||||
jsonParser(jsondata); //json adat atalakitasa
|
||||
foreach(var p in players.player) {
|
||||
p.ConvertDate(); //datum eltarolasa es atalakitasa datum tipussa
|
||||
Debug.Log("p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n");
|
||||
}
|
||||
jsondata = uwr.downloadHandler.text; //json szoveg eltarolasa
|
||||
Debug.Log("current player json: " + jsondata);
|
||||
jsonParser(jsondata); //json adat atalakitasa
|
||||
foreach(var p in players.player) {
|
||||
p.ConvertDate(); //datum eltarolasa es atalakitasa datum tipussa
|
||||
Debug.Log("p_id: " + p.player_id + " username: " + p.player_name + " join date: " + p.joindate.printDate() + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator IGetHighScoreData(int palya_id){
|
||||
@@ -109,7 +142,7 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
input.text = uwr.downloadHandler.text;
|
||||
//input.text = uwr.downloadHandler.text;
|
||||
Debug.Log(uwr.downloadHandler.text);
|
||||
jsonParserHighScore(uwr.downloadHandler.text);
|
||||
hst.CreateTable(htdc.htd); //high score tabla letrehozasa
|
||||
@@ -129,7 +162,7 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
input.text = uwr.downloadHandler.text;
|
||||
//input.text = uwr.downloadHandler.text;
|
||||
Debug.Log(uwr.downloadHandler.text);
|
||||
jsonParserHighScore(uwr.downloadHandler.text);
|
||||
hst.CreateTable(htdc.htd); //high score tabla letrehozasa
|
||||
@@ -160,7 +193,7 @@ public class DatabaseData : MonoBehaviour
|
||||
|
||||
|
||||
private IEnumerator IPostNewPlayerData() {
|
||||
input.text = "loading...";
|
||||
//input.text = "loading...";
|
||||
|
||||
string uri = "http://localhost:3000/newplayer";
|
||||
|
||||
@@ -175,13 +208,13 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
input.text = uwr.downloadHandler.text; //vissza erzkezes arrol hogy sikeres a felvitel vagy nem
|
||||
//input.text = uwr.downloadHandler.text; //vissza erzkezes arrol hogy sikeres a felvitel vagy nem
|
||||
Debug.Log(uwr.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator IPostNewScoreData() {
|
||||
input.text = "loading...";
|
||||
//input.text = "loading...";
|
||||
|
||||
string uri = "http://localhost:3000/newscore";
|
||||
|
||||
@@ -197,13 +230,13 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
input.text = uwr.downloadHandler.text;
|
||||
//input.text = uwr.downloadHandler.text;
|
||||
Debug.Log(uwr.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerator IPostNewPalyaData() {
|
||||
input.text = "loading...";
|
||||
//input.text = "loading...";
|
||||
|
||||
string uri = "http://localhost:3000/newpalya";
|
||||
|
||||
@@ -218,7 +251,7 @@ public class DatabaseData : MonoBehaviour
|
||||
if (uwr.isNetworkError) {
|
||||
Debug.Log(uwr.error);
|
||||
} else {
|
||||
input.text = uwr.downloadHandler.text;
|
||||
//input.text = uwr.downloadHandler.text;
|
||||
Debug.Log(uwr.downloadHandler.text);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ public class ScoreTrigger : MonoBehaviour
|
||||
score = FindObjectOfType<Score>();
|
||||
}
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
Debug.Log("score triggered");
|
||||
//Debug.Log("score triggered");
|
||||
if(other.gameObject.tag == "Player"){
|
||||
score.addScore(1);
|
||||
}
|
||||
|
||||
@@ -43,8 +43,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 456
|
||||
height: 629
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_MinSize: {x: 202, y: 221}
|
||||
m_MaxSize: {x: 4002, y: 4021}
|
||||
m_ActualView: {fileID: 18}
|
||||
m_Panes:
|
||||
- {fileID: 18}
|
||||
@@ -145,7 +145,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 400, y: 200}
|
||||
m_MaxSize: {x: 32384, y: 16192}
|
||||
vertical: 0
|
||||
controlID: 16
|
||||
controlID: 144
|
||||
--- !u!114 &7
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -170,7 +170,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 200}
|
||||
m_MaxSize: {x: 24288, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 17
|
||||
controlID: 145
|
||||
--- !u!114 &8
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -196,7 +196,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 100}
|
||||
m_MaxSize: {x: 24288, y: 8096}
|
||||
vertical: 0
|
||||
controlID: 18
|
||||
controlID: 146
|
||||
--- !u!114 &9
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@@ -216,8 +216,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 186
|
||||
height: 629
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_MinSize: {x: 201, y: 221}
|
||||
m_MaxSize: {x: 4001, y: 4021}
|
||||
m_ActualView: {fileID: 13}
|
||||
m_Panes:
|
||||
- {fileID: 13}
|
||||
@@ -242,8 +242,8 @@ MonoBehaviour:
|
||||
y: 0
|
||||
width: 685
|
||||
height: 629
|
||||
m_MinSize: {x: 200, y: 200}
|
||||
m_MaxSize: {x: 4000, y: 4000}
|
||||
m_MinSize: {x: 202, y: 221}
|
||||
m_MaxSize: {x: 4002, y: 4021}
|
||||
m_ActualView: {fileID: 14}
|
||||
m_Panes:
|
||||
- {fileID: 14}
|
||||
@@ -335,7 +335,7 @@ MonoBehaviour:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 4c36ffffe267ffff4068ffff466effffd27fffff3080ffff3886ffffbef8ffff34fbffffa2f2000054f40000d65b0100
|
||||
m_ExpandedIDs: 34fbffff
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -617,9 +617,9 @@ MonoBehaviour:
|
||||
m_PlayAudio: 0
|
||||
m_AudioPlay: 0
|
||||
m_Position:
|
||||
m_Target: {x: 646.07245, y: 1493.4817, z: 53.950325}
|
||||
m_Target: {x: 1177.4196, y: 1628.5796, z: 85.38733}
|
||||
speed: 2
|
||||
m_Value: {x: 646.07245, y: 1493.4817, z: 53.950325}
|
||||
m_Value: {x: 1177.4196, y: 1628.5796, z: 85.38733}
|
||||
m_RenderMode: 0
|
||||
m_CameraMode:
|
||||
drawMode: 0
|
||||
@@ -668,11 +668,11 @@ MonoBehaviour:
|
||||
m_Rotation:
|
||||
m_Target: {x: 0.113753475, y: -0.00000011450476, z: 0.000000050034828, w: 0.99350965}
|
||||
speed: 2
|
||||
m_Value: {x: 0.11375341, y: -0.00000011450469, z: 0.0000000500348, w: 0.99350905}
|
||||
m_Value: {x: -0.113753475, y: 0.000000114504765, z: -0.000000050034824, w: -0.99350965}
|
||||
m_Size:
|
||||
m_Target: 1399.2793
|
||||
m_Target: 1412.7163
|
||||
speed: 2
|
||||
m_Value: 1399.2793
|
||||
m_Value: 1412.7163
|
||||
m_Ortho:
|
||||
m_Target: 0
|
||||
speed: 2
|
||||
@@ -738,22 +738,22 @@ MonoBehaviour:
|
||||
m_SkipHidden: 0
|
||||
m_SearchArea: 1
|
||||
m_Folders:
|
||||
- Assets/Scripts
|
||||
- Assets/Scripts/Network
|
||||
m_Globs: []
|
||||
m_OriginalText:
|
||||
m_ViewMode: 1
|
||||
m_StartGridSize: 64
|
||||
m_LastFolders:
|
||||
- Assets/Scripts
|
||||
- Assets/Scripts/Network
|
||||
m_LastFoldersGridSize: -1
|
||||
m_LastProjectPath: E:\dev\zarodolgozat\ColorBall
|
||||
m_LockTracker:
|
||||
m_IsLocked: 0
|
||||
m_FolderTreeState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: ba650000
|
||||
m_LastClickedID: 26042
|
||||
m_ExpandedIDs: 00000000a8650000b66500007e7d0000807d0000
|
||||
m_SelectedIDs: f6650000
|
||||
m_LastClickedID: 26102
|
||||
m_ExpandedIDs: 00000000dc650000f2650000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -781,7 +781,7 @@ MonoBehaviour:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 00000000a8650000
|
||||
m_ExpandedIDs: 00000000dc650000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@@ -808,7 +808,7 @@ MonoBehaviour:
|
||||
m_ListAreaState:
|
||||
m_SelectedInstanceIDs:
|
||||
m_LastClickedInstanceID: 0
|
||||
m_HadKeyboardFocusLastEvent: 1
|
||||
m_HadKeyboardFocusLastEvent: 0
|
||||
m_ExpandedInstanceIDs: c6230000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
|
||||
Reference in New Issue
Block a user