private void FixedUpdate()
    {
        /* Determines the speed of sprite change.
         * If next is set true, will change the next Sprite.
         * Otherwise will call for idleStep.
         */

        timer += 0.1f;

        if (timer >= 2.5f)
        {
            timer = 0f;

            if (next)
            {
                stepCycle.nextStep();
                stepper.MovePosition(position);
                next = false;
            }
            else
            {
                stepCycle.idleStep();
            }
        }
    }
Ejemplo n.º 2
0
    void FixedUpdate()
    {
        /* If Freeze has been set as in "true", will further code execute.
         *
         * StepTimers will start taking time.
         *
         * if round has been executed, will steps wait a bit and execute idle step twice, before proceeding for new round.
         * else executes new round -
         *      - if there´s round left, change to next Sprite.
         *      - else activate roundBreak.
         *
         * If Freeze is not activated, check if puzzle has been finished.
         *      - If finished, - reset Sprites and destroy port and it´s wall collider. Activate opened port that will let player trough.
         */

        if (freeze)
        {
            stepTimer += 0.1f;
            nextStep  += 0.1f;

            if (roundBreak)
            {
                if (nextStep >= 15f)
                {
                    roundBreak = false;
                }
                else if (stepTimer >= 4f)
                {
                    stepCycle.idleStep();
                    stepTimer = 0f;
                }
            }
            else
            {
                if (round < size)
                {
                    if (nextStep >= 5f)
                    {
                        stepCycle.nextStep();
                        nextStep = 0f;
                        round   += 1;
                    }
                }
                else
                {
                    roundBreak = true;
                    round      = 0;
                    stepCycle  = new FootStepCycleScript(steps);
                }
            }
        }
        else if (finished)
        {
            stepCycle.resetSprites(0);
            Destroy(coll);
        }
    }