Ejemplo n.º 1
0
    public void UpPressed()
    {
        if (dead || outOfTime || reachedMars)
        {
            return;
        }

        if (!game.HaveFuelLeft())
        {
            //NO FUEL
            return;
        }

        thrustersOn = true;

        if (velocity.y < maxYVelocity)
        {
            velocity.y += yThrustVelIncrease * Time.deltaTime;
        }

        downThruster.On();



        game.FuelUsed(upAndDownFuelCost * Time.deltaTime);
    }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        if (!justStarted)
        {
            justStarted = true;
            game.GiveStartBoost();
        }


        if (reachedMars)
        {
            velocity.x += 5f * Time.deltaTime;

            rightThruster.On();

            thrustersOn = true;

            forwardThrusterOn = true;

            audio.volume *= 0.99f;
        }


        if (outOfTime && !shownOutOfTimeText)
        {
            velocity.x -= 0.5f * Time.deltaTime;

            //rightThruster.On();
            thrustersOn = false;
            outOfTimer -= Time.deltaTime;

            Debug.Log("outOfTimer,j " + outOfTimer);

            if (outOfTimer < 0)
            {
                game.ShowOutOfTimeMessage();
                shownOutOfTimeText = true;

                Debug.Log("hgkgh,j");
            }
        }

        if (dead && !shownDeadMessage)
        {
            deadTimer -= Time.deltaTime;

            if (deadTimer < 0)
            {
                game.ShowDeadMessage();
                shownDeadMessage = true;
            }
        }


        if (boosterActive)
        {
            thrustersOn = true;

            forwardThrusterOn = true;

            rightThruster.On();

            float currentSpeed = game.IncreaseCSpeedTurbo();


            Vector3 newPosition = transform.position;
            newPosition.x      = Gamma.GetGamma(currentSpeed) * movementOnScreenToCFactor;
            transform.position = newPosition;
        }


        if (!forwardThrusterOn && !outOfTime)
        {
            float currentSpeed = game.DecreaseSpeed();


            Vector3 newPosition = transform.position;
            newPosition.x      = Gamma.GetGamma(currentSpeed) * movementOnScreenToCFactor;
            transform.position = newPosition;
        }

        transform.Translate(velocity * Time.deltaTime, Space.World);


        if (thrustersOn)
        {
            if (!audio.isPlaying)
            {
                audio.Play();
            }
        }
        else
        {
            audio.Stop();
        }


        if (dead || outOfTime)
        {
            return;
        }


        if (transform.position.y > 3.15)
        {
            game.OutOfBoundsTop();
        }
        else if (transform.position.y < -3.15)
        {
            game.OutOfBoundsBtm();
        }



        forwardThrusterOn = false;
        thrustersOn       = false;
    }