Esempio n. 1
0
    public void RegisterInput(string dir)
    {
        selectedDirection = (directions)System.Enum.Parse(typeof(directions), dir);

        if (selectedDirection == crashDirection && crashDirection != directions.None)         // this means the player is trying to go into a wall. This is bad
        {
            return;
        }

        if (direction != selectedDirection)
        {
            if (GetDirectionAsVector2() != -GetDirectionAsVector2(selectedDirection))
            {
                if (direction != directions.None)
                {
                    speed_TEST += speedIncrease;

                    // NORMAL WAY OF DOING IT
                    // speed += speedIncrease; // normal
                    // speed += speedIncrease * (1 - GetSpeedPercentage()); // decreases speedIncrease
                    // speed += Mathf.Clamp(speedIncrease * (1.2f - GetSpeedPercentage()), speedIncreaseMin, speedIncrease); // levels out speedIncrease
                    // UNSURE (0.05 is too shallow. Trying 0.3f speedIncreaseMin. I like there being a curve, but can't be too shallow
                    // Debug.Log("Current Speed is: " + speed + " instead of: " + speed_TEST);

                    speed += speedIncreaseTurn;
                    // Debug.Log("Current Speed is: " + speed + " instead of: " + speed_TEST);

                    // ColorController.IncreaseSpeed(0.02f);
                    ColorController.UpdateSpeed(GetSpeedPercentage());

                    audioController.PlayerTurn();
                }
                else
                {
                    audioController.StartLevelAudio();
                    playerGraphics.MoveSprite();
                    timerScript.UnpauseTimer();
                }
            }
            else
            {
                SlowDown();
            }
        }

        direction      = selectedDirection;
        crashDirection = directions.None;
        playerGraphics.FaceDirection(GetDirectionAsVector2());
    }