Esempio n. 1
0
    // Update is called once per frame

    /*void Update ()
     * {
     *  //optimalGear = FindOptimalGear();
     *  if (Input.GetKeyDown("w") || Input.GetKeyDown("up"))
     *      currentGear += 1;
     *  else if(Input.GetKeyDown("s") || Input.GetKeyDown("down"))
     *      currentGear -= 1;
     *  if (currentGear > maxGear)
     *      currentGear = maxGear;
     *  else if (currentGear < minGear)
     *      currentGear = minGear;
     *
     *  if(currentGear == speed.targetGear && takingDamage)
     *  {
     *      takingDamage = false;
     *  }
     *  else if(currentGear != speed.targetGear && !takingDamage)
     *  {
     *      takingDamage = true;
     *  }
     *  UpdateGearIndicators();
     * }*/

    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space) && !gearing)
        {
            speed.ChangeSpeed(-1);
            score.generatePoints = false;
            gearing = true;
        }
        if (Input.GetKeyUp(KeyCode.Space) && gearing)
        {
            gearing = false;

            if (currentGearPoint.gameObject.transform.name.Equals("free"))
            {
                score.generatePoints = false;
                speed.ChangeSpeed(-1);
            }
            else
            {
                score.generatePoints = true;
                switch (int.Parse(currentGearPoint.gameObject.transform.name))
                {
                case 10:
                    score.scoreMultiplier = 1;
                    break;

                case 30:
                    score.scoreMultiplier = 2;
                    break;

                case 50:
                    score.scoreMultiplier = 3;
                    break;

                case 70:
                    score.scoreMultiplier = 4;
                    break;

                case 90:
                    score.scoreMultiplier = 5;
                    break;
                }

                speed.ChangeSpeed(float.Parse(currentGearPoint.gameObject.transform.name));
            }
        }
        if (gearing)
        {
            DoGearing();
        }
    }