Files
PuzzleColorBall/Assets/Scripts/CoinCounter.cs
bance 62354dc7b9 Squashed commit of the following:
commit 1e4ffae4f6
Author: bance <90307762+bance23@users.noreply.github.com>
Date:   Sat May 13 14:23:47 2023 +0200

    proba athozas

    veszelyes

commit 0297a2cb78
Merge: 604088e 31b9214
Author: bance <90307762+bance23@users.noreply.github.com>
Date:   Sat May 13 14:09:48 2023 +0200

    Merge branch 'master' of https://github.com/playmaker1210/PuzzleColorBall

commit 31b9214f35
Merge: 184d2e8 89976bb
Author: Playmaker1210 <hatvanitamas09@gmail.com>
Date:   Mon May 8 14:42:34 2023 +0200

    Merge https://github.com/playmaker1210/PuzzleColorBall

commit 184d2e84da
Author: Playmaker1210 <hatvanitamas09@gmail.com>
Date:   Mon May 8 14:41:59 2023 +0200

    server mukodik

commit 89976bbcf8
Author: playmaker1210 <75033623+playmaker1210@users.noreply.github.com>
Date:   Fri May 5 12:49:28 2023 +0200

    Update README.md

commit 250cc0ffee
Author: playmaker1210 <75033623+playmaker1210@users.noreply.github.com>
Date:   Fri May 5 12:49:01 2023 +0200

    Create README.md

commit 2f0ae77e35
Author: playmaker1210 <hatvanitamas09@gmail.com>
Date:   Thu May 4 12:56:56 2023 +0200

    update

commit b94c80b293
Author: Playmaker1210 <hatvanitamas09@gmail.com>
Date:   Tue May 2 13:46:38 2023 +0200

    coin db working

commit 25d792e0fd
Author: playmaker1210 <hatvanitamas09@gmail.com>
Date:   Sat Apr 29 17:07:23 2023 +0200

    update
2023-05-13 15:09:38 +02:00

67 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
using System.IO;
using System.Text;
public class CoinCounter : MonoBehaviour
{
public ulong coin; //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 UsernameHandler usernameHandler;
private void Awake() {
db = FindObjectOfType<DatabaseData>();
usernameHandler = FindObjectOfType<UsernameHandler>();
/*path = Application.persistentDataPath + "/coins.txt";
if(!File.Exists(path)){ //ha nincs meg ilyen fajl hozza letre
writer = new StreamWriter(path, false, Encoding.Default);
writer.Write(0);
writer.Close();
}
reader = new StreamReader(path);
coin = ulong.Parse(reader.ReadLine());
reader.Close();
Debug.Log("Coins at start: " + coin);*/
/*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 SetCoin(ulong number){
coin = number;
coinCounterUI.text = "Coins: " + coin.ToString();
}
public void AddCoin(ulong number){
coin += number;
coinCounterUI.text = "Coins: " + coin.ToString();
/*writer = new StreamWriter(path, false, Encoding.Default);
writer.Write(coin);
writer.Close();*/
}
public void RemoveCoin(ulong number){
coin -= number;
coinCounterUI.text = "Coins: " + coin.ToString();
/*writer = new StreamWriter(path, false, Encoding.Default);
writer.Write(coin);
writer.Close();*/
}
}