Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        if (world.doUpdate)
        {

            switch (state)
            {

                case barbedTrapState.WAITING:


                    if (Time.time >= timeToJump)
                    {
                        state = barbedTrapState.JUMPING;
                    }

                    break;

                case barbedTrapState.JUMPING:

                    currentLerpTime += world.lag;
                    float lerpPercentage = currentLerpTime / lerpTime;
                    if (lerpPercentage > 1.0f)
                    {
                        timeToDeactivate = Time.time + timeTrapWaitsInDeactivation;
                        state = barbedTrapState.ACTIVE;
                    }

                    transform.position = Vector3.Lerp(startPosition, endPosition, lerpPercentage);


                    break;

                case barbedTrapState.ACTIVE:

                    if (Time.time >= timeToDeactivate)
                    {
                        currentLerpTime = 0.0f;
                        state = barbedTrapState.HIDING;
                    }

                    break;

                case barbedTrapState.HIDING:

                    currentLerpTime += world.lag;
                    float lerpPercentageO = currentLerpTime / lerpTime;
                    if (lerpPercentageO > 1.0f)
                    {
                        currentLerpTime = 1.0f;
                        state = barbedTrapState.RESTING;
                    }

                    transform.position = Vector3.Lerp(endPosition, startPosition, lerpPercentageO);

                    break;

            }
        }
    }
Ejemplo n.º 2
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player") && state == barbedTrapState.RESTING)
     {
         timeToJump      = Time.time + timeTrapWaitsInActivation;
         currentLerpTime = 0.0f;
         state           = barbedTrapState.WAITING;
     }
 }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (world.doUpdate)
        {
            switch (state)
            {
            case barbedTrapState.WAITING:


                if (Time.time >= timeToJump)
                {
                    state = barbedTrapState.JUMPING;
                }

                break;

            case barbedTrapState.JUMPING:

                currentLerpTime += world.lag;
                float lerpPercentage = currentLerpTime / lerpTime;
                if (lerpPercentage > 1.0f)
                {
                    timeToDeactivate = Time.time + timeTrapWaitsInDeactivation;
                    state            = barbedTrapState.ACTIVE;
                }

                transform.position = Vector3.Lerp(startPosition, endPosition, lerpPercentage);


                break;

            case barbedTrapState.ACTIVE:

                if (Time.time >= timeToDeactivate)
                {
                    currentLerpTime = 0.0f;
                    state           = barbedTrapState.HIDING;
                }

                break;

            case barbedTrapState.HIDING:

                currentLerpTime += world.lag;
                float lerpPercentageO = currentLerpTime / lerpTime;
                if (lerpPercentageO > 1.0f)
                {
                    currentLerpTime = 1.0f;
                    state           = barbedTrapState.RESTING;
                }

                transform.position = Vector3.Lerp(endPosition, startPosition, lerpPercentageO);

                break;
            }
        }
    }
Ejemplo n.º 4
0
 void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag("Player") && state == barbedTrapState.RESTING)
     {
         timeToJump = Time.time + timeTrapWaitsInActivation;
         currentLerpTime = 0.0f;
         state = barbedTrapState.WAITING;
     }
 }