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 }
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); } }
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(); }
void FixedUpdate() { GetComponent <Text>().text = SPlayerPrefs.GetInt("Money").ToString(); }
void OnMouseUpAsButton() { switch (gameObject.name) { case "Play": //CameraShake.Shake(0.5f, 0.25f, CameraShake.ShakeMode.XY); SceneManager.LoadScene("LevelSelect", LoadSceneMode.Single); EditCount(0); break; case "Go": if (SPlayerPrefs.GetInt("Buyed_" + CurrentCanvas) == 1) { if (CurrentCanvas == 6) { SceneManager.LoadScene("LevelTest", LoadSceneMode.Single); } else { SceneManager.LoadScene("Level1_" + (CurrentCanvas + 1), LoadSceneMode.Single); } } else if (SPlayerPrefs.GetInt("Buyed_" + CurrentCanvas) == 0) { LvlSelectInfo.BuyLevel(CurrentCanvas); } break; case "Shop": SceneManager.LoadScene("Shop", LoadSceneMode.Single); break; case "BackToMenu": SceneManager.LoadScene("main", LoadSceneMode.Single); break; case "Twitter": Application.OpenURL("https://twitter.com/PionInkApps"); Debug.Log("twit"); break; case "Pause": Time.timeScale = 0; PauseMenu.SetActive(true); Interface.SetActive(false); audio.Pause(); break; case "RightArrow": if (CurrentCanvas < levels.Length - 1) { levels[CurrentCanvas].SetActive(false); CurrentCanvas++; levels[CurrentCanvas].SetActive(true); EditCount(CurrentCanvas); } break; case "LeftArrow": if (CurrentCanvas > 0) { levels[CurrentCanvas].SetActive(false); CurrentCanvas--; levels[CurrentCanvas].SetActive(true); EditCount(CurrentCanvas); } break; } }
void FixedUpdate() { GetComponent <Text>().text = "Attempt " + SPlayerPrefs.GetInt("Attempts_" + lvlCount).ToString(); }