예제 #1
0
 public void buyYellow()
 {
     if (SkinStore.balances[0] >= 80)
     {
         SkinStore.balances[0]   -= 80;
         SkinStore.isYellowBought = true;
         SkinStore.updateBankAccount(0, true, 80, 4);
         curBalance -= 80;
     }
 }
예제 #2
0
 public void buyGreen()
 {
     if (SkinStore.balances[0] >= 40)
     {
         SkinStore.balances[0]  -= 40;
         SkinStore.isGreenBought = true;
         SkinStore.updateBankAccount(0, true, 40, 3);
         curBalance -= 40;
     }
 }
예제 #3
0
 public void buyBlue()
 {
     if (SkinStore.balances[0] >= 20)
     {
         SkinStore.balances[0] -= 20;
         SkinStore.isBlueBought = true;
         SkinStore.updateBankAccount(0, true, 20, 1);
         curBalance -= 20;
     }
 }
예제 #4
0
 public void buyRed()
 {
     if (SkinStore.balances[0] >= 10)
     {
         SkinStore.balances[0] -= 10;
         SkinStore.isRedBought  = true;
         SkinStore.updateBankAccount(0, true, 10, 2);
         curBalance -= 10;
     }
 }
예제 #5
0
    // Update is called once per frame
    void Update()
    {
        inGameTimer += Time.deltaTime;


        if (Input.GetKeyDown(KeyCode.Escape) && isPaused)
        {
            SceneManager.UnloadSceneAsync(2);
            isPaused = false;
        }

        else if (Input.GetKeyDown(KeyCode.Escape))
        {
            SceneManager.LoadScene(2, LoadSceneMode.Additive);
            isPaused = true;
        }

        float displayedScore = maxDist + score;

        scoreText.text = "Score :" + displayedScore;

        if (isDead)
        {
            timer += Time.deltaTime;
            if (timer % 60 >= 2)
            {
                timer  = 0.0f;
                isDead = false;
                LeaderBoard.updateLeaderBoard((int)displayedScore, id, isSpeedMode);
                LifeTimeStats.upateLifeTimeStats((int)displayedScore, coinsCollected, clocksCollected, (int)maxDist, deathByEnviro, deathByCar, logsRidden, turtlesRidden, inGameTimer);
                SkinStore.updateBankAccount((int)coinsCollected, false, 0, 0);
                id = "";
                SceneManager.LoadScene(0);
            }
        }
        if (transform.localPosition.y < -0.21f && !isDead)
        {
            // super hacky way
            Vector3 spawnPos  = new Vector3(transform.position.x - 1, transform.position.y, transform.position.z - 1);
            Vector3 spawnPos2 = new Vector3(transform.position.x - 1, transform.position.y + 0.5f, transform.position.z - 1);
            Instantiate(fragmentedCubes, spawnPos, transform.rotation);
            Instantiate(fragmentedCubes, spawnPos2, transform.rotation);
            transform.GetComponent <MeshRenderer>().enabled = false;
            deathByEnviro++;
            isDead = true;
        }

        // forward
        if (Input.GetKeyDown(KeyCode.UpArrow) && !isHopping && !isDead)
        {
            maxDist = Mathf.Max(maxDist, transform.position.x + 2);
            float zDiff = 0;
            // make sure we are in a grid space not inbetween
            if (transform.position.z % 1 != 0)
            {
                zDiff = Mathf.Round(transform.position.z) - transform.position.z;
            }
            MovePlayer(new Vector3(1, 0, zDiff));
        }
        // left
        else if (Input.GetKeyDown(KeyCode.LeftArrow) && !isHopping && !isDead)
        {
            MovePlayer(new Vector3(0, 0, 1));
        }
        // right
        else if (Input.GetKeyDown(KeyCode.RightArrow) && !isHopping && !isDead)
        {
            MovePlayer(new Vector3(0, 0, -1));
        }
        // down
        else if (Input.GetKeyDown(KeyCode.DownArrow) && !isHopping && maxDist - transform.position.x <= 3 && !isDead)
        {
            float zDiff = 0;

            if (transform.position.z % 1 != 0)
            {
                zDiff = Mathf.Round(transform.position.z) - transform.position.z;
            }
            MovePlayer(new Vector3(-1, 0, zDiff));
        }
        currDist = transform.position.x;
    }