コード例 #1
0
    public void showScores()
    {
        StaticLevelState.changeState(3);

        if (!System.IO.File.Exists(Application.persistentDataPath + "/scores"))
        {
            scores = new Scores();
        }
        else
        {
            scores = FileManager.ReadFromBinaryFile <Scores> (Application.persistentDataPath + "/scores");
        }

        scoresPanel.SetActive(true);

        for (int i = 0; i < scores.getScores().Count; i++)
        {
            namesText.text += scores.getScores() [i].Key + "\r\n";
        }

        for (int i = 0; i < scores.getScores().Count; i++)
        {
            scoresText.text += scores.getScores()[i].Value.ToString("0.00") + "m" + "\r\n";
        }

        FileManager.WriteToBinaryFile(Application.persistentDataPath + "/scores", scores);
    }
コード例 #2
0
    public void killPlayer()
    {
        Health             = 0;
        isDead             = true;
        playerCurrentSpeed = 0f;

        setPlayerHorizontalSpeed(0);

        anim.SetTrigger("dead");
        //Debug.Log("die");

        SoundController.instance.stopMusic();
        SoundController.instance.playMusic(music.player_death, false);
        // play dead animation

        StaticLevelState.changeState(2);
    }
コード例 #3
0
 // Update is called once per frame
 void Update()
 {
     if (StaticLevelState.getState() == 0)
     {
         menu.SetActive(true);
         gameOverMenu.SetActive(false);
         scoresPanel.SetActive(false);
         for (int i = 0; i < UI.Count; i++)
         {
             UI [i].SetActive(false);
         }
     }
     else if (StaticLevelState.getState() == 1)
     {
         menu.SetActive(false);
         gameOverMenu.SetActive(false);
         scoresPanel.SetActive(false);
         for (int i = 0; i < UI.Count; i++)
         {
             UI [i].SetActive(true);
         }
     }
     else if (StaticLevelState.getState() == 2)
     {
         menu.SetActive(false);
         gameOverMenu.SetActive(true);
         scoresPanel.SetActive(false);
         for (int i = 0; i < UI.Count; i++)
         {
             UI [i].SetActive(true);
         }
     }
     else
     {
         menu.SetActive(false);
         gameOverMenu.SetActive(false);
         for (int i = 0; i < UI.Count; i++)
         {
             UI [i].SetActive(false);
         }
     }
 }
コード例 #4
0
    // Update is called once per frame
    void Update()
    {
        if (lastPositionBackground.x < GameController.instance.player.transform.position.x + backgroundHorizontalLength / 2 - 10)
        {
            rotateBackgroundQueuePlataform();
        }

        if (lastPositionFirstFloor.x < GameController.instance.player.transform.position.x + firstFloorgroundHorizontalLenght * numPlataformsInAdvance)
        {
            rotateFirstQueuePlataform();
        }

        if (lastPositionSecondFloor.x < GameController.instance.player.transform.position.x + secondFloorgroundHorizontalLenght * numPlataformsInAdvance)
        {
            rotateSecondQueuePlataform();
        }

        destroyObjects();

        if (StaticLevelState.getState() == 1)
        {
            if (!GameController.instance.player.isPlayerDead())
            {
                timerLeftToSpwan -= Time.deltaTime;
                timerTimeToInc   -= Time.deltaTime;
                if (timerLeftToSpwan <= 0f)
                {
                    creatObjects();
                }
                if (timerTimeToInc <= 0f && smallerTimeToSpawn > minTimeToSpawn)
                {
                    timerTimeToInc = Random.Range(downTimeToIncreaseSpawn, topTimeToIncreaseSpawn);
                    float smallerTime = smallerTimeToSpawn - Random.Range(0.2f, 0.6f);
                    smallerTimeToSpawn = smallerTime > minTimeToSpawn ? smallerTime : minTimeToSpawn;
                    biggestTimeToSpawn = smallerTimeToSpawn + 0.5f;

                    //Debug.Log("decrease time to spawn " + smallerTimeToSpawn + " -> " + biggestTimeToSpawn);
                }
            }
        }
    }
コード例 #5
0
 public void showMenuWithoutRestart()
 {
     StaticLevelState.changeState(0);
 }
コード例 #6
0
 public void showMenu()
 {
     StaticLevelState.changeState(0);
     SceneManager.LoadScene("ImpossibleFeupPrototype");
 }
コード例 #7
0
 public void startGame()
 {
     StaticLevelState.changeState(1);
     SoundController.instance.playMusic(music.bossfight_commando_steve, true);
 }
コード例 #8
0
 public void restartGame()
 {
     StaticLevelState.changeState(1);
     SceneManager.LoadScene("ImpossibleFeupPrototype");
 }
コード例 #9
0
    // Update is called once per
    void Update()
    {
        if (!isDead)
        {
            if (haveColideWithOtherStudent)
            {
                timerLeftSlowDown -= Time.deltaTime;
                if (timerLeftSlowDown < 0)
                {
                    haveColideWithOtherStudent = false;
                }
            }

            // secondFloor colider is importante to make the double jump to the secound floor only
            isGrounded = Physics2D.IsTouchingLayers(playerColider, firstFloor);              //|| Physics2D.IsTouchingLayers(playerColider, otherObject);
            if (isGrounded)
            {
                doubleJump = false;
            }
            setPlayerHorizontalSpeed(!haveColideWithOtherStudent ? playerCurrentSpeed : (playerCurrentSpeed / 2.0f));
            if (StaticLevelState.getState() == 1)
            {
                if (Input.GetMouseButtonDown(0) && !haveColideWithOtherStudent)
                {
                    if (isGrounded)
                    {
                        playerRgBody.velocity = new Vector2(playerRgBody.velocity.x, jumpSpeed);
                        SoundController.instance.playEffect(effect.jump);
                    }
                    else if (!doubleJump)
                    {
                        playerRgBody.velocity = new Vector2(playerRgBody.velocity.x, jumpSpeed);
                        SoundController.instance.playEffect(effect.jump);
                        doubleJump = true;
                    }
                }

                // gui update
                timePlayed += Time.deltaTime;

                meters         += (playerCurrentSpeed * Time.deltaTime) / 2f;
                metersText.text = meters.ToString("0.00 ") + "m";

                // speed up level
                timerLeftToIncrease -= Time.deltaTime;
                if (timerLeftToIncrease <= 0f && playerCurrentSpeed < playerMaxSpeed)
                {
                    timerLeftToIncrease = Random.Range(downTimeToIncreaseSpeed, topTimeToIncreaseSpeed);
                    float speed = playerCurrentSpeed + Random.Range(1.0f, 2f);
                    playerCurrentSpeed = speed < playerMaxSpeed ? speed : playerMaxSpeed;
                    //Debug.Log("acelarate " + playerCurrentSpeed);
                }


                // jump animation
                anim.SetFloat("jump", playerRgBody.velocity.y);


                if (Health <= 0)
                {
                    killPlayer();
                }
            }
        }

        if (haveColideWithOtherStudent)
        {
            cantJump.SetActive(true);
        }
        else
        {
            cantJump.SetActive(false);
        }

        if (isOnSecondFloor())
        {
            boost.SetActive(true);
        }
        else
        {
            boost.SetActive(false);
        }
    }