예제 #1
0
    void Update()           //  *   *   *   *   *   *   *   *   *   *   *   *   *   Update
    {
        if (!END)
        {
            if (controls.PausePressed()) //  .   .   .   .   .   .   .   .   .   Check if paused pressed
            {
                if (!paused)             //  .   .   .   .   .   .   .   .   .   .   .   .   Pause - freeze all rigidbodies
                {
                    Pause();
                }
            }
            else
            {
                if (paused)
                {
                    if (!helping)
                    {
                        Unpause();
                    }
                }
            }
            if (paused)
            {
                if (helping)
                {
                    PlayerControls();
                }
                playerScript.Pause();
            }
            else        //  .   .   .   .   .   .   .   .   .   .   .   .   .   .   Check if player is dead
            {
                if (playerScript.GetLives() < 0)
                {
                    if (!playerDead)
                    {
                        playerDead = true;
                        if (paused)
                        {
                            pauseBtn.GetComponent <ButtonScript>().DoMouseUp();
                            paused = false;
                        }
                        pauseBtn.SetActive(false);
                        SoundManScript.PlaySound("fail", false, false, Vector2.zero, 0.4f);
                        for (int i = 0; i < achievements.Count; i++)
                        {
                            switch (achievements[i].GetReq())
                            {
                            case "deaths":
                                achievements[i].AddValue(1);
                                break;

                            case "puff/angdead":
                                if (playerScript.GetDeath() == "puff/ang")
                                {
                                    achievements[i].AddValue(1);
                                }
                                break;
                            }
                        }
                        persistentDataScript.AddDeaths(1);
                        if (persistentDataScript.SetScore(score))
                        {
                        }
                        else
                        {
                        }
                        persistentDataScript.SetAchievements(achievements);
                    }
                    PlayerDead();
                }
                else        //  .   .   .   .   .   .   .   .   .   .   .   .   .   Activate controls after unpause
                {
                    if (unpauseTimer < unpauseTime)
                    {
                        unpauseTimer += Time.deltaTime;
                        controls.JumpPressed();
                    }
                    else
                    {
                        PlayerControls();
                        if (!helping)
                        {
                            playerScript.UpdatePlayer();
                        }
                    }
                    if ((started) && (!helping))    //  .   .   .   .   .   .   .   .   .   .   .   Count score
                    {
                        MultiplierUpdate();
                        AddScore();
                        timer       += Time.deltaTime;
                        timeTxt.text = "Time:\n" + (int)timer;
                    }
                }
            }
        }
    }