void OnTriggerEnter(Collider other) { if (other.tag == Constants._PlayerTag) { // AllPlayerPrefs.piece += piece; GlobalManager.Ui.TakeCoin(); GetComponent <CapsuleCollider>().enabled = false; Debug.Log(GetComponent <MeshRenderer>().material.name); if (GetComponent <MeshRenderer>().material.name == "Piece (Instance)") { AllPlayerPrefs.SetIntValue(Constants.Coin, 1); } else { AllPlayerPrefs.SetIntValue(Constants.Coin, 5); } GlobalManager.Ui.MoneyPoints.text = "" + AllPlayerPrefs.GetIntValue(Constants.Coin); transform.DOLocalRotate(new Vector3(0, 2000, 0), 1f, RotateMode.FastBeyond360); Destroy(this.gameObject, 1f); } }
// achete ou confirme un item public void BuyItem( ) { string getCons = Constants.ItemBought + currItemSeled.CatName; Dictionary <string, ItemModif> getAllBuy = allConfirm; if (AllPlayerPrefs.GetBoolValue(getCons + currItemSeled.ItemName)) { AllPlayerPrefs.SetStringValue(getCons + currItemSeled.ItemName, "Confirm"); ItemModif getThis; if (getAllBuy.TryGetValue(getCons, out getThis)) { AllPlayerPrefs.SetStringValue(getCons + getThis.ItemName, "ok"); if (getThis.UseOtherSprite) { getThis.GetComponent <Image> ( ).sprite = currItemSeled.BoughtSpriteUnselected; } else { getThis.GetComponent <Image> ( ).sprite = currItemSeled.SpriteUnselected; } if (getThis.UseColor) { if (getThis.UseOtherColor) { getThis.GetComponent <Image> ( ).color = currItemSeled.BoughtColorUnSelected; } else { getThis.GetComponent <Image> ( ).color = currItemSeled.ColorUnSelected; } } getAllBuy.Remove(getCons); } getThis = currItemSeled; getThis.GetComponent <Image> ( ).sprite = getThis.SpriteConfirm; if (getThis.UseColor) { getThis.GetComponent <Image> ( ).color = getThis.ColorConfirm; } getAllBuy.Add(getCons, getThis); } else { bool checkProg = false; ItemModif currIT = currItemSeled; if (currCatSeled.Progression) { if (currIT.UpItem.ItemBought || currIT.DownItem.ItemBought || currIT.LeftItem.ItemBought || currIT.RightItem.ItemBought) { checkProg = true; } } else { checkProg = true; } if (checkProg && AllPlayerPrefs.GetIntValue(Constants.Coin) > currIT.Price) { Debug.Log("buy"); AllPlayerPrefs.SetIntValue(Constants.Coin, -currIT.Price); if (currCatSeled.BuyForLife) { getAllBuy.Add(getCons, currItemSeled); AllPlayerPrefs.SetStringValue(getCons + currIT.ItemName); } else { allTempItem.Add(currItemSeled); } } } moneyNumberPlayer.text = "" + AllPlayerPrefs.GetIntValue(Constants.Coin); }