示例#1
0
    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);
        }
    }
示例#2
0
    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
    }
示例#3
0
 private void SaveData()
 {
     SPlayerPrefs.SetInt("Attempts_" + lvlCount, lvlAttempts);
     SPlayerPrefs.SetInt("Money", money);
     SPlayerPrefs.SetInt("TotalJumps", TotalJumps);
     SPlayerPrefs.SetInt("Jumps_" + lvlCount, lvlJumps);
     SPlayerPrefs.Save();
 }
示例#4
0
 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;
 }
示例#5
0
 private void OnDisable()
 {
     Debug.Log("Save in disable");
     if (progress > SPlayerPrefs.GetFloat("Progress_" + lvlCount))
     {
         Debug.Log("Save " + progress);
         SPlayerPrefs.SetFloat("Progress_" + lvlCount, progress);
         SPlayerPrefs.Save();
     }
 }
示例#6
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();
     }
 }
示例#7
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);
        }
    }
示例#8
0
 void Start()
 {
     if (SPlayerPrefs.HasKey("Money"))
     {
         money = SPlayerPrefs.GetInt("Money");
     }
     else
     {
         SPlayerPrefs.SetInt("Money", 0);
     }
 }
示例#9
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);
        }
    }
示例#10
0
 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];
 }
示例#11
0
    //Логика уничтожения объектов на сцене
    public void destroyScene()
    {
        StartCoroutine(createPlayerExplosion(gameObject));

        //Запись лучшего счета
        if (SPlayerPrefs.GetFloat("Score") < GameObject.Find("Score").GetComponent <ScoreCounter>().score)
        {
            SPlayerPrefs.SetFloat("Score", GameObject.Find("Score").GetComponent <ScoreCounter>().score);
            SPlayerPrefs.Save();
        }

        Destroy(gameObject);

        GameObject[] heads       = GameObject.FindGameObjectsWithTag("EnemyHead");
        GameObject[] headSprites = GameObject.FindGameObjectsWithTag("HeadSprite");
        GameObject[] backs       = GameObject.FindGameObjectsWithTag("Back");
        GameObject[] tails       = GameObject.FindGameObjectsWithTag("Tail");

        foreach (GameObject head in heads)
        {
            StartCoroutine(createExplosion(head));
            Destroy(head);
        }

        foreach (GameObject headSprite in headSprites)
        {
            Destroy(headSprite);
        }

        foreach (GameObject back in backs)
        {
            StartCoroutine(createExplosion(back));
            Destroy(back);
        }

        foreach (GameObject tail in tails)
        {
            StartCoroutine(createExplosion(tail));
            Destroy(tail);
        }

        EnemyHead.speed = 0;

        GameStatus.gameStatus = "GameOver";
    }
示例#12
0
    //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;
            }
        }
    }
示例#13
0
 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;
 }
示例#14
0
 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;
     }
 }
示例#15
0
    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();
    }
示例#16
0
    private void Update()
    {
        if (gameObject != tnt)
        {
            string state = SPlayerPrefs.GetString(STATEITEM + itemCount);
            switch (state)
            {
            case "Selected":
                visualStateLock.SetActive(false);
                visualStateSelected.SetActive(true);
                break;

            case "Buyed":
                visualStateLock.SetActive(false);
                visualStateSelected.SetActive(false);
                break;

            case "Buy":
                visualStateSelected.SetActive(false);
                visualStateLock.SetActive(true);
                break;
            }
        }
    }
示例#17
0
 void OnMouseUp()
 {
     content = "My record in Cut and Dodge " + System.Math.Round(SPlayerPrefs.GetFloat("Score")) + ".\n Try to beat my score\n https://play.google.com/store/apps/details?id=com.abadek.cutanddodge";
     CallShare(title, "", content);
 }
示例#18
0
 void FixedUpdate()
 {
     GetComponent <Text>().text = SPlayerPrefs.GetInt("Money").ToString();
 }
示例#19
0
 void Update()
 {
     if (GameStatus.gameStatus == "GameOver" && tempScore < (float)System.Math.Round(SPlayerPrefs.GetFloat("Score")))
     {
         if (!isCourStarted)
         {
             StartCoroutine(showText());
         }
     }
 }
示例#20
0
    void Start()
    {
        isCourStarted = false;

        tempScore = (float)System.Math.Round(SPlayerPrefs.GetFloat("Score"));
    }
示例#21
0
 void FixedUpdate()
 {
     GetComponent <Text>().text = "Attempt " + SPlayerPrefs.GetInt("Attempts_" + lvlCount).ToString();
 }
示例#22
0
 private void EditCount(int value)
 {
     SPlayerPrefs.SetInt("Count", value);
     SPlayerPrefs.Save();
 }
示例#23
0
    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;
        }
    }
示例#24
0
 void Start()
 {
     gameObject.GetComponent <Text> ().text = (float)System.Math.Round(SPlayerPrefs.GetFloat("Score")) + "";
 }