void OnTriggerEnter2D(Collider2D other) { if (other.tag == "StartAntigravy") { rb.gravityScale = -1 * Mathf.Abs(rb.gravityScale); } else if (other.tag == "EndAntigravy") { rb.gravityScale = Mathf.Abs(rb.gravityScale); } if ((other.tag == "Obstacle") && (!isDeathPlayer)) { if (!OnceFuncDeathCall) { DeathFunc(); } } if ((other.tag == "JumpButt") && (isDeathPlayer)) { RebirthFunc(); } if (other.tag == "Coin") { other.gameObject.SetActive(false); money = SPlayerPrefs.GetInt("Money"); money += 5; SPlayerPrefs.SetInt("Money", money); } }
private void Awake() { // PLAYER PREFS INIT BEGIN if (SPlayerPrefs.HasKey("Count")) { lvlCount = SPlayerPrefs.GetInt("Count"); } else { SPlayerPrefs.SetInt("Count", 0); } if (SPlayerPrefs.HasKey("Money")) { money = SPlayerPrefs.GetInt("Money"); } else { SPlayerPrefs.SetInt("Money", 0); } if (SPlayerPrefs.HasKey("TotalJumps")) { TotalJumps = SPlayerPrefs.GetInt("TotalJumps"); } else { SPlayerPrefs.SetInt("TotalJumps", 0); } if (SPlayerPrefs.HasKey("Attempts_" + lvlCount)) { lvlAttempts = SPlayerPrefs.GetInt("Attempts_" + lvlCount); } else { SPlayerPrefs.SetInt("Attempts_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Jumps_" + lvlCount)) { lvlJumps = SPlayerPrefs.GetInt("Jumps_" + lvlCount); } else { SPlayerPrefs.SetInt("Jumps_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Completed_" + lvlCount)) { lvlCompleted = SPlayerPrefs.GetInt("Completed_" + lvlCount); } else { SPlayerPrefs.SetInt("Completed_" + lvlCount, 0); } // PLAYER PREFS INIT END }
private void SaveData() { SPlayerPrefs.SetInt("Attempts_" + lvlCount, lvlAttempts); SPlayerPrefs.SetInt("Money", money); SPlayerPrefs.SetInt("TotalJumps", TotalJumps); SPlayerPrefs.SetInt("Jumps_" + lvlCount, lvlJumps); SPlayerPrefs.Save(); }
private void Win() { CameraShake.Shake(5f, 0.35f, CameraShake.ShakeMode.XY); Interface.SetActive(false); FinalMenu.SetActive(true); SPlayerPrefs.SetInt("Completed_" + lvlCount, 1); SaveData(); GameObject.Find("attempts").GetComponent <Text>().text = "Attempts: " + lvlAttempts; GameObject.Find("jumps").GetComponent <Text>().text = "Jumps: " + lvlJumps; }
void Start() { if (SPlayerPrefs.HasKey("Money")) { money = SPlayerPrefs.GetInt("Money"); } else { SPlayerPrefs.SetInt("Money", 0); } }
void Start() { jumps = GameObject.Find("Jumps"); attempts = GameObject.Find("Attempts"); percent = GameObject.Find("Percentage"); playOrBuy = GameObject.Find("PlayOrBuy"); //Min amount of jumps to complete the lvl lvlCount = SPlayerPrefs.GetInt("Count"); //Первые две карты изначально открыты SPlayerPrefs.SetInt("Buyed_0", 1); SPlayerPrefs.SetInt("Buyed_1", 1); SPlayerPrefs.Save(); if (SPlayerPrefs.HasKey("Jumps_" + lvlCount)) { lvlJumps = SPlayerPrefs.GetInt("Jumps_" + lvlCount); } else { SPlayerPrefs.SetInt("Jumps_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Attempts_" + lvlCount)) { lvlAttempts = SPlayerPrefs.GetInt("Attempts_" + lvlCount); } else { SPlayerPrefs.SetInt("Attempts_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Progress_" + lvlCount)) { progress = SPlayerPrefs.GetFloat("Progress_" + lvlCount); } else { SPlayerPrefs.SetFloat("Progress_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Buyed_" + lvlCount)) { lvlBuyed = SPlayerPrefs.GetInt("Buyed_" + lvlCount); } else { SPlayerPrefs.SetInt("Buyed_" + lvlCount, 0); } if (SPlayerPrefs.HasKey("Money")) { money = SPlayerPrefs.GetInt("Money"); } else { SPlayerPrefs.SetInt("Money", 0); } }
public static void BuyLevel(int cnt) { if (money >= priceLvl[cnt]) { money -= priceLvl[cnt]; SPlayerPrefs.SetInt("Money", money); SPlayerPrefs.SetInt("Buyed_" + lvlCount, 1); lvlBuyed = 1; SPlayerPrefs.Save(); } }
private void OnMouseUpAsButton() { string state; if (gameObject == tnt) { state = SPlayerPrefs.GetString(STATEITEM + direct); if (state == "Buy") { Debug.Log("pez " + direct); money = SPlayerPrefs.GetInt("Money"); if (money >= priceItem[direct]) { money -= priceItem[direct]; SPlayerPrefs.SetInt("Money", money); SPlayerPrefs.SetString(STATEITEM + direct, "Buyed"); SPlayerPrefs.Save(); textButton.GetComponent <Text>().text = "Buyed"; } } } else { //gameObject.GetComponent<Image>().color = Color.red; direct = itemCount; state = SPlayerPrefs.GetString(STATEITEM + itemCount); Debug.Log(state); if (state == "Buyed") { for (int i = 0; i < priceItem.Length; i++) { if (SPlayerPrefs.GetString(STATEITEM + i) == "Selected") { SPlayerPrefs.SetString(STATEITEM + i, "Buyed"); break; } } SPlayerPrefs.SetString(STATEITEM + itemCount, "Selected"); SPlayerPrefs.SetInt("DigitStateItemIsSelected", itemCount); SPlayerPrefs.Save(); textButton.GetComponent <Text>().text = "Selected"; } else if (state == "Selected") { textButton.GetComponent <Text>().text = "Selected"; } else if (state == "Buy") { textButton.GetComponent <Text>().text = "Buy " + priceItem[itemCount]; } Debug.Log("post" + state); } }
void Start() { rb = gameObject.GetComponentInParent <Rigidbody2D>(); if (!SPlayerPrefs.HasKey("DigitStateItemIsSelected")) { SPlayerPrefs.SetInt("DigitStateItemIsSelected", 0); } cnt = SPlayerPrefs.GetInt("DigitStateItemIsSelected"); for (int i = 0; i < skins.Length; i++) { skins[i] = Resources.Load <Sprite>("Sprites/skins/skin" + i); } //cnt = 17; gameObject.GetComponent <SpriteRenderer>().sprite = skins[cnt]; }
//private string state = "init"; void Start() { textButton = GameObject.Find("TextButton"); tnt = GameObject.Find("TntButton"); if (!SPlayerPrefs.HasKey("Money")) { SPlayerPrefs.SetInt("Money", 0); } money = SPlayerPrefs.GetInt("Money"); //SPlayerPrefs.SetString(STATEITEM + "1", "Buy"); if (gameObject != tnt) { visualStateSelected = transform.GetChild(1).gameObject; visualStateLock = transform.GetChild(2).gameObject; itemCount = 0; while (gameObject.name != ("Item" + itemCount)) { if (itemCount++ > 31) { break; } } if (flagOnceInitFirstItem) { flagOnceInitFirstItem = false; if (!SPlayerPrefs.HasKey(STATEITEM + "0")) { SPlayerPrefs.SetString(STATEITEM + "0", "Selected"); SPlayerPrefs.Save(); } } if (!SPlayerPrefs.HasKey(STATEITEM + itemCount)) { SPlayerPrefs.SetString(STATEITEM + itemCount, "Buy"); } if (itemCount == 10) { gameObject.GetComponent <Image>().color = Color.yellow; } } }
void Start() { if (SPlayerPrefs.HasKey("Count")) { lvlCount = SPlayerPrefs.GetInt("Count"); } else { SPlayerPrefs.SetInt("Count", 0); } if (SPlayerPrefs.HasKey("Progress_" + lvlCount)) { progress = SPlayerPrefs.GetFloat("Progress_" + lvlCount); } else { SPlayerPrefs.SetFloat("Progress_" + lvlCount, 0); } player = GameObject.Find("Player").transform; }
private void HandleShowResult(ShowResult result) { if (result == ShowResult.Finished) { Debug.Log("Video completed - Offer a reward to the player"); vendorText.GetComponent <Text>().text = vendorSuccessText; SPlayerPrefs.SetInt("Money", SPlayerPrefs.GetInt("Money") + Random.Range(10, 90)); SPlayerPrefs.Save(); } else if (result == ShowResult.Skipped) { Debug.LogWarning("Video was skipped - Do NOT reward the player"); vendorText.GetComponent <Text>().text = vendorErrorText; } else if (result == ShowResult.Failed) { Debug.LogError("Video failed to show"); vendorText.GetComponent <Text>().text = vendorErrorText; } }
void Start() { if (SPlayerPrefs.HasKey("Count")) { lvlCount = SPlayerPrefs.GetInt("Count"); } else { SPlayerPrefs.SetInt("Count", 0); } if (SPlayerPrefs.HasKey("Attempts_" + lvlCount)) { Attempts = SPlayerPrefs.GetInt("Attempts_" + lvlCount); } else { SPlayerPrefs.SetInt("Attempts_" + lvlCount, 0); } GetComponent <Text>().text = "Attempt " + SPlayerPrefs.GetInt("Attempts_" + lvlCount).ToString(); }
private void EditCount(int value) { SPlayerPrefs.SetInt("Count", value); SPlayerPrefs.Save(); }