void Gamble() { // check has enough currency (except amount == 1) if (amount != 1 && IC.getCurrency() >= amount) { float chance = Random.Range(0f, 1f); Debug.Log(chance); if (chance < odds) { Debug.Log("win"); IC.IncreaseCurrency(amount); SC.UpdateText(); } else { Debug.Log("lose"); IC.DecreaseCurrency(amount); SC.UpdateText(); } } else if (amount == 1) { // can only do it if wait has reached 60 if (wait >= 60) { wait = 0; } else { Debug.Log("fail timer " + wait); return; } float chance = Random.Range(0f, 1f); Debug.Log(chance); if (chance < odds) { Debug.Log("win"); IC.IncreaseCurrency(amount); SC.UpdateText(); } else { Debug.Log("lose"); IC.DecreaseCurrency(amount); SC.UpdateText(); } } }
public void Unlock(int i) { // Store Unlocked marks it SU.Unlock(i); // Subtrack price from currency List <int> prices = new List <int> { 99, 499, 999, 299, 399, 109, 394, 808, 2048 }; int price = prices [i]; IC.DecreaseCurrency(price); // Decrease Currency Text SC.UpdateText(); // Destroy the upgrade in shopcontroller Destroy(UpgradeList [i]); }
void Merge() { // call RDC to check the slots int i1 = SlotOne.transform.GetChild(1).GetComponent <LabPageItemSlotClick> ().getItemID(); int i2 = SlotTwo.transform.GetChild(1).GetComponent <LabPageItemSlotClick> ().getItemID(); Debug.Log("got " + i1 + " " + i2); // Checks if it is a valid recipe int check = RDC.CheckRecipes(i1, i2); if (check != -1) { int id = check; // Checks if the recipe is already made if (!IC.CheckNewRecipe(id)) { // Not a new recipe Debug.Log("Already made recipe"); GameObject obj = Instantiate(Popup, new Vector3(), Quaternion.identity); // Popup.transform.GetChild (1).GetComponent<SpriteRenderer> ().sprite = RDC.getSprite (check); // Description obj.transform.GetChild(0).GetComponent <TextMesh> ().text = "ERROR"; obj.transform.GetChild(2).GetComponent <TextMesh> ().text = "Recipe already found"; obj.transform.GetChild(3).GetComponent <TextMesh> ().text = "You got 0 coins"; return; } else { Debug.Log("valid recipe"); // call recipe done in inventory IC.AddToRecipes(id); // valid recipe, create popup textbox of recipe GameObject obj = Instantiate(Popup, new Vector3(), Quaternion.identity); // Update with sprite obj.transform.GetChild(1).GetComponent <SpriteRenderer> ().sprite = RDC.getSprite(id); // Description obj.transform.GetChild(2).GetComponent <TextMesh> ().text = RDC.getRecipeName(id); // Currency int gain = Random.Range(75, 125); obj.transform.GetChild(3).GetComponent <TextMesh> ().text = "You got " + gain.ToString() + " coins"; // Add the currency amount IC.IncreaseCurrency(gain); // Update the Currency counter in corner SC.UpdateText(); } } else { // invalid recipe // valid recipe, create popup textbox of recipe GameObject obj = Instantiate(Popup, new Vector3(), Quaternion.identity); // Description // Title obj.transform.GetChild(0).GetComponent <TextMesh> ().text = "ERROR"; // Description obj.transform.GetChild(2).GetComponent <TextMesh> ().text = "Failed recipe"; // obj.transform.GetChild(3).GetComponent <TextMesh> ().text = "RIP"; Debug.Log("invalid recipe"); } // decrement the amounts in the inventory IC.RemoveFromInventory(i1); IC.RemoveFromInventory(i2); // Update the text on the LabInventory LC.UpdateCountText(i1); LC.UpdateCountText(i2); // Need to reset SlotOne and SlotTwo itemID SlotOne.transform.GetChild(1).GetComponent <LabPageItemSlotClick> ().ResetItemID(); SlotTwo.transform.GetChild(1).GetComponent <LabPageItemSlotClick> ().ResetItemID(); // Reset the sprites SlotOne.transform.GetChild(1).GetComponent <Image>().sprite = Locked; SlotTwo.transform.GetChild(1).GetComponent <Image>().sprite = Locked; // Reset the names SlotOne.transform.GetChild(0).GetComponent <Text>().text = "Locked"; SlotTwo.transform.GetChild(0).GetComponent <Text>().text = "Locked"; }