Merge branch 'master' of https://github.com/playmaker1210/PuzzleColorBall
This commit is contained in:
@@ -2,28 +2,49 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
public class CoinCounter : MonoBehaviour
|
||||
{
|
||||
public ulong coin = 0; //szedje le db-bol a playerhez a coint
|
||||
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 dd;
|
||||
private void Awake() {
|
||||
path = Application.persistentDataPath + "/coins.txt";
|
||||
|
||||
//get player coin at startup based on username
|
||||
private void Awake() {
|
||||
dd = FindObjectOfType<DatabaseData>();
|
||||
if(!File.Exists(path)){ //ha nincs meg ilyen fajl hozza letre
|
||||
writer = new StreamWriter(path, false, Encoding.Default);
|
||||
writer.Write(0);
|
||||
writer.Close();
|
||||
}
|
||||
|
||||
//dd.GetCoinData("Playmaker1210");
|
||||
reader = new StreamReader(path);
|
||||
coin = ulong.Parse(reader.ReadLine());
|
||||
reader.Close();
|
||||
Debug.Log("Coins at start: " + coin);
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public class GroundController : MonoBehaviour
|
||||
|
||||
private void Awake() {
|
||||
//cs = FindObjectOfType<CollectibleSpawner>();
|
||||
|
||||
//Loading modules
|
||||
loadFrom = LoadPrefabs("Prefabs/Modulok");
|
||||
sideObjects = LoadPrefabs("Models/World Objects/World 1");
|
||||
@@ -37,11 +38,11 @@ public class GroundController : MonoBehaviour
|
||||
}
|
||||
|
||||
//uj ground letrehozas
|
||||
if(ground[ground.Length-1].transform.position.z <= 80){
|
||||
if(ground[ground.Length-1].transform.position.z <= 120){
|
||||
CreateNewGround();
|
||||
}
|
||||
|
||||
//ellenorzi hogy torolheto e az object
|
||||
//ellenorzi hogy torolheto e az object || mar nem szukseges mert van egy trigger box
|
||||
/*foreach (var item in ground){
|
||||
if(CheckGroundToDestroy(item)){
|
||||
Destroy(item);
|
||||
@@ -82,7 +83,7 @@ public class GroundController : MonoBehaviour
|
||||
|
||||
private void CreateNewGround(){
|
||||
int random = UnityEngine.Random.Range(0, loadFrom.Length);
|
||||
//ketto modullal elobb tolt be, annak az iranyanak megfeleloen, +80 a ket modull hossza
|
||||
//egy modullal elobb tolt be, annak az iranyanak megfeleloen, +80 a ket modull hossza
|
||||
Instantiate(loadFrom[random], new Vector3(0,0, ground[ground.Length-1].transform.position.z + 40), ground[ground.Length-1].transform.rotation);
|
||||
}
|
||||
}
|
||||
20
Assets/Scripts/Score.cs
Normal file
20
Assets/Scripts/Score.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class Score : MonoBehaviour
|
||||
{
|
||||
public ulong score;
|
||||
public TMP_Text scoreUI;
|
||||
|
||||
private void Awake() {
|
||||
score = 0;
|
||||
scoreUI.text = "Score: " + score.ToString();
|
||||
}
|
||||
|
||||
public void addScore(ulong number){
|
||||
score += number;
|
||||
scoreUI.text = "Score: " + score.ToString();
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Score.cs.meta
Normal file
11
Assets/Scripts/Score.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d858282f94188744f80e5d0e2883a3a1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/ScoreTrigger.cs
Normal file
17
Assets/Scripts/ScoreTrigger.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class ScoreTrigger : MonoBehaviour
|
||||
{
|
||||
private Score score;
|
||||
private void Awake() {
|
||||
score = FindObjectOfType<Score>();
|
||||
}
|
||||
private void OnTriggerEnter(Collider other) {
|
||||
Debug.Log("score triggered");
|
||||
if(other.gameObject.tag == "Player"){
|
||||
score.addScore(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ScoreTrigger.cs.meta
Normal file
11
Assets/Scripts/ScoreTrigger.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a50eb662440e8354e8a596fbc79887a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user