// Update is called once per frame void Update() { if (Input.GetMouseButtonUp(0) && (EventSystem.current.currentSelectedGameObject != null)) { clicked = EventSystem.current.currentSelectedGameObject; Debug.Log(clicked); if (clicked.tag == "PlayerButtons") { has = readItemsFromFile(); if (!has.listPlayer.Contains(clicked.GetComponentInChildren <SpriteRenderer>().sharedMaterial.name)) { buyItem(); } else { wearSave(); } } else if (clicked.name == "LifePowerUps" || clicked.name == "ShieldPowerUps" || clicked.name == "MagnetPowerUps") { buyPowerUp(); } } if (Input.GetKeyDown(KeyCode.Escape)) { Application.Quit(); } }
public static void firstOpening() { string path = Application.persistentDataPath + "/saved.json"; string path2 = Application.persistentDataPath + "/whatPlayerHas.json"; if (!System.IO.File.Exists(path)) { SavePlayer newSave = new SavePlayer(); newSave.hat = null; newSave.color = "whitePlayer"; newSave.glass = null; string jsonVersion1 = JsonUtility.ToJson(newSave); System.IO.File.WriteAllText(path, jsonVersion1); } if (!System.IO.File.Exists(path2)) { whatPlayerHas newFile = new whatPlayerHas(); newFile.listPlayer = new List <string>(); newFile.listPlayer.Add("whitePlayer"); newFile.listHat = new List <string>(); newFile.listGlass = new List <string>(); string jsonVersion = JsonUtility.ToJson(newFile); System.IO.File.WriteAllText(path2, jsonVersion); } }
public void setEquipped() { foreach (Transform t in contentSlider.transform) { has = readItemsFromFile(); Debug.Log(clicked); if (has.listPlayer.Contains(findChildTechnique(t.gameObject, "mat").GetComponent <SpriteRenderer>().sharedMaterial.name)) { findChildTechnique(t.gameObject, "Untagged").SetActive(false); } } }
void Start() { ballShow = GameObject.Find("BallShow"); x = readDataFromFile(); has = readItemsFromFile(); playerColorMaterial = Resources.Load <Material>("PlayerMaterials/" + x.color); ballShow.GetComponent <SpriteRenderer>().sharedMaterial = playerColorMaterial; savePrices(); setTextsOnMarket(); updateStocks(); setEquipped(); doTick(); }
public void buyItem() { int totalCoin = PlayerPrefs.GetInt("totalCoin"); has = readItemsFromFile(); if (clicked.tag == "PlayerButtons") { if (totalCoin >= ballColorPrice && totalCoin > 0) { List <string> temp = has.listPlayer; temp.Add(clicked.GetComponentInChildren <SpriteRenderer>().sharedMaterial.name); has.listPlayer = temp; PlayerPrefs.SetInt("totalCoin", totalCoin - ballColorPrice); wearSave(); } } updateStocks(); string jsonVersion = JsonUtility.ToJson(has); writeItemToFile(jsonVersion); doTick(); setEquipped(); }