public void RestoreCurrentSlot() { if (this.equipped.Equals(BuyableEquipped.NOT_EQUIPPED)) { return; } string auxId = this.id; this.id = gameObject.name; this.state = BuyableState.NOT_BOUGHT; this.equipped = BuyableEquipped.NOT_EQUIPPED; GameManager.Instance.player.rocks.currentItems.Remove(auxId); PlayerPrefs.SetInt(auxId + "_Equipped", 0); PlayerPrefs.Save(); this.price = 0; this.chosedToEquipped = false; this.transform.GetChild(1).GetComponent <Image>().sprite = controller.noImage; this.transform.GetChild(1).GetComponent <Image>().color = new Color32(255, 255, 255, 128); foreach (BuyableItem item in controller.items) { item.CheckEquipped(auxId); } }
public void Set(BuyableItem item) { this.id = item.id; this.price = item.price; this.image = item.image; this.state = item.state; this.equipped = item.equipped; this.chosedToEquipped = item.chosedToEquipped; this.controller = item.controller; this.transform.GetChild(1).GetComponent <Image>().sprite = this.image; this.transform.GetChild(1).GetComponent <Image>().color = new Color32(255, 255, 255, 255); this.Init(); }
private void CheckState() { Debug.Log(gameObject.name + " >" + PlayerPrefs.GetInt(id, 0)); switch (PlayerPrefs.GetInt(id, 0)) { case 0: state = BuyableState.NOT_BOUGHT; break; case 1: state = BuyableState.BOUGHT; break; } }
public void BuyItem() { if (state.Equals(BuyableState.NOT_BOUGHT)) { if (PlayerPrefs.GetInt("level", 0) >= price)//if (100 >= price)// { GetComponent <Button>().colors = colors; GameManager.Instance.player.playerStats.LevelSpend(price); Debug.LogError("LEVEL BE LIKE WOW>" + PlayerPrefs.GetInt("level", 0)); price = 0; state = BuyableState.BOUGHT; Debug.Log("BOUGHT ID: " + id); PlayerPrefs.SetInt(id, 1); PlayerPrefs.Save(); controller.UpdateText(); GetComponentInChildren <TMP_Text>().text = "BOUGHT"; } else { GetComponent <Button>().colors = colorsInvalid; } } else { if (controller.currentSelected == null || controller.currentSelected != this) { BuyableItem aux = null; if (controller.currentSelected != null) { aux = controller.currentSelected; } chosedToEquipped = true; controller.currentSelected = this; if (controller.currentSelected != null && controller.currentSelected != this) { aux.chosedToEquipped = false; } } if (controller.HasSpace(this)) { Equip(); controller.GetFirstFreeSpace().Set(this); } } }