예제 #1
0
    public override void Stop()
    {
        _BehaviourState = AnimationBehaviourState.STOPPED;
        if (this.IsInterleaved)
        {
            if ((_Opposite as StayInPoseBehaviour)._BehaviourState != AnimationBehaviourState.STOPPED)
            {
                _Opposite.Stop();
            }
        }
        //this.LerpRoundTripEnd -= LerpBehaviour_LerpRoundTripEnd;

        animator.speed  = 1;
        stayInPoseState = StayInPoseState.Resting;
        animator.SetInteger(AnimatorParams.Movement, (int)Movement.Iddle);
    }
예제 #2
0
    override public void RunWeb(BehaviourParams stayInParams)
    {
        animator.Play(animator.GetCurrentAnimatorStateInfo(0).fullPathHash, 0, 0);
        endRepTime = null;

        Debug.Log("Tirando RunWebWithParams");
        if (this.IsInterleaved)
        {
            this._Opposite.SetBehaviourState(AnimationBehaviourState.RUNNING_WITH_PARAMS);
        }

        this._BehaviourState = AnimationBehaviourState.RUNNING_WITH_PARAMS;


        this._RealParams    = stayInParams;
        stayInPoseState     = StayInPoseState.GoingTo;
        this.animator.speed = this._RealParams.ForwardSpeed;
    }
예제 #3
0
    override public void RunWeb(BehaviourParams stayInParams)
    {
        animator.Play(animator.GetCurrentAnimatorStateInfo(0).fullPathHash, 0, 0);
        endRepTime = null;

        Debug.Log("Tirando RunWebWithParams");
        if (this.IsInterleaved)
        {
            this._Opposite.SetBehaviourState(AnimationBehaviourState.RUNNING_WITH_PARAMS);
        }

        this._BehaviourState = AnimationBehaviourState.RUNNING_WITH_PARAMS;
	

        this._RealParams = stayInParams;
        stayInPoseState = StayInPoseState.GoingTo;
        this.animator.speed = this._RealParams.ForwardSpeed;
    }
예제 #4
0
    public override void Stop()
    {
        _BehaviourState = AnimationBehaviourState.STOPPED;
        if (this.IsInterleaved)
        {
            if ((_Opposite as StayInPoseBehaviour)._BehaviourState != AnimationBehaviourState.STOPPED)
                _Opposite.Stop();
        }
        //this.LerpRoundTripEnd -= LerpBehaviour_LerpRoundTripEnd;

        animator.speed = 1;
        stayInPoseState = StayInPoseState.Resting;
        animator.SetInteger(AnimatorParams.Movement, (int)Movement.Iddle);
    }
예제 #5
0
	override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timeSinceCapture += Time.deltaTime;
        if (this._BehaviourState == AnimationBehaviourState.INITIAL_POSE)//Testear si esto funciona en este behaviour.
        {
            if (!animator.IsInTransition(0))
                animator.speed = 0;
            return;
        }

        
        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS && timeSinceCapture > INTERVAL)
        {
            timeSinceCapture = timeSinceCapture - INTERVAL;
            /*
            if (exerciseDataGenerator == null)
                exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
            if (this.exerciseDataGenerator != null)
                this.exerciseDataGenerator.CaptureData();*/
        }
        float DELTA = 0.05f;
        DateTime temp = DateTime.Now;
        if (_BehaviourState != AnimationBehaviourState.STOPPED && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }

            if (stayInPoseState == StayInPoseState.GoingTo &&  stateInfo.normalizedTime + DELTA >= 1)
            {
                animator.speed = 0;
                startHoldTime = Time.time;
                stayInPoseState = StayInPoseState.HoldingOn;
                //Esperar
            }

            //Si ya pasó el tiempo en el ángulo máximo
            else if(stayInPoseState == StayInPoseState.HoldingOn && Time.time - startHoldTime >= _RealParams.SecondsInPose)
            {
                animator.StartRecording(0);
                animator.speed = -this._RealParams.BackwardSpeed;
                animator.StopRecording();
                stayInPoseState = StayInPoseState.Leaving;
            }

            else if (stayInPoseState == StayInPoseState.Leaving && stateInfo.normalizedTime - DELTA <= 0 && haCambiadoDeEstado)
            {
                BeginRep = false;
                animator.speed = 0;
                stayInPoseState = StayInPoseState.Resting;
                startRestTime = Time.time;

                if (((!this.IsWeb) && (!this.IsInInstruction)) && _BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && (!IsInterleaved || (IsInterleaved && limb == Limb.Right)))
                    this.PauseAnimation();
                if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    haCambiadoDeEstado = false;
                    animator.SetTrigger("ChangeLimb");
                }
                OnRepetitionEnd();
                if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                    this.Stop();

            }

            else if (stayInPoseState == StayInPoseState.Resting && Time.time - startRestTime>= _realParams.SecondsBetweenRepetitions)
            {
                this.animator.speed = this._realParams.ForwardSpeed;
                stayInPoseState = StayInPoseState.GoingTo;

            }
        }
        
    }
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (_BehaviourState == AnimationBehaviourState.INITIAL_POSE)
        {
            if (!animator.IsInTransition(0))
            {
                animator.speed = 0;
            }
            return;
        }

        DateTime temp = DateTime.Now;

        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
        {
            animator.speed  = 0;
            stayInPoseState = StayInPoseState.Resting;
            BeginRep        = false;
            this.Stop();
            OnRepetitionEnd();
        }

        else if (_BehaviourState != AnimationBehaviourState.STOPPED && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep        = true;
                animator.speed  = this._RealParams.ForwardSpeed;
                startHoldTime   = Time.time;
                stayInPoseState = StayInPoseState.HoldingOn;
            }

            //Si ya pasó el tiempo indicado realizando el movimiento
            if (stayInPoseState == StayInPoseState.HoldingOn && (Time.time - startHoldTime) >= this._RealParams.SecondsInPose)
            {
                DebugLifeware.Log("Tiempo en pose maxima = " + (Time.time - startHoldTime).ToString(), DebugLifeware.Developer.Alfredo_Gallardo);
                animator.speed = 0;
                //startHoldTime = 0;
                stayInPoseState = StayInPoseState.Resting;
                BeginRep        = false;
                if ((!this.IsWeb) && (!this.IsInInstruction) && this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS)
                {
                    this.PauseAnimation();
                }
                else if ((this.IsWeb) || (this.IsInInstruction) && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    endRepTime = DateTime.Now;
                }

                /*
                 * if(this._BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                 * {
                 *  this.Stop();
                 * }*/
                OnRepetitionEnd();
            }


//            //Si ya pasó el tiempo en el ángulo máximo
//            else if(stayInPoseState == StayInPoseState.HoldingOn && Time.time - startHoldTime >= _realLerpParams.SecondsInPose)
//            {
//                //DebugLifeware.Log("Para atrás", DebugLifeware.Developer.Marco_Rojas);
//                animator.StartRecording(0);
//                animator.speed = -1;
//                animator.StopRecording();
//                stayInPoseState = StayInPoseState.Leaving;
//            }

//            else if (stayInPoseState == StayInPoseState.Leaving && Math.Abs(stateInfo.normalizedTime - 0) <= DELTA && haCambiadoDeEstado)
//            {
//                beginRep = false;
//                animator.speed = 0;
//                stayInPoseState = StayInPoseState.Resting;
//                startRestTime = Time.time;

//                if (!this.isWeb && _behaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && (!IsInterleaved || (IsInterleaved && limb == Limb.Right)))
//                    this.PauseAnimation();
//                if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
//                {
//                    //DebugLifeware.Log("cambiando limb", DebugLifeware.Developer.Marco_Rojas);
//                    haCambiadoDeEstado = false;
//                    animator.SetTrigger("ChangeLimb");
//                }
//                OnRepetitionEnd();

//                if (_behaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
//                    _behaviourState = AnimationBehaviourState.STOPPED;

//            }

//            else if (stayInPoseState == StayInPoseState.Resting && Time.time - startRestTime>= _realLerpParams.SecondsBetweenRepetitions)
//            {
//                //DebugLifeware.Log("descansando", DebugLifeware.Developer.Marco_Rojas);
//                animator.speed = 1;
//                stayInPoseState = StayInPoseState.GoingTo;

//            }
//            //DebugLifeware.Log("termino", DebugLifeware.Developer.Marco_Rojas);
        }
    }
예제 #7
0
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        timeSinceCapture += Time.deltaTime;
        if (this._BehaviourState == AnimationBehaviourState.INITIAL_POSE)//Testear si esto funciona en este behaviour.
        {
            if (!animator.IsInTransition(0))
            {
                animator.speed = 0;
            }
            return;
        }


        if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS && timeSinceCapture > INTERVAL)
        {
            timeSinceCapture = timeSinceCapture - INTERVAL;

            /*
             * if (exerciseDataGenerator == null)
             *  exerciseDataGenerator = GameObject.FindObjectOfType<Detector.ExerciseDataGenerator>();
             * if (this.exerciseDataGenerator != null)
             *  this.exerciseDataGenerator.CaptureData();*/
        }
        float    DELTA = 0.05f;
        DateTime temp  = DateTime.Now;

        if (_BehaviourState != AnimationBehaviourState.STOPPED && (endRepTime == null || new TimeSpan(0, 0, (int)_RealParams.SecondsBetweenRepetitions) <= temp - endRepTime))
        {
            if (!BeginRep && (!IsInterleaved || (IsInterleaved && limb == Limb.Left)) &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WEB &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS &&
                this._BehaviourState != AnimationBehaviourState.PREPARING_DEFAULT)
            {
                OnRepetitionReallyStart();
                BeginRep = true;
            }

            if (stayInPoseState == StayInPoseState.GoingTo && stateInfo.normalizedTime + DELTA >= 1)
            {
                animator.speed  = 0;
                startHoldTime   = Time.time;
                stayInPoseState = StayInPoseState.HoldingOn;
                //Esperar
            }

            //Si ya pasó el tiempo en el ángulo máximo
            else if (stayInPoseState == StayInPoseState.HoldingOn && Time.time - startHoldTime >= _RealParams.SecondsInPose)
            {
                animator.StartRecording(0);
                animator.speed = -this._RealParams.BackwardSpeed;
                animator.StopRecording();
                stayInPoseState = StayInPoseState.Leaving;
            }

            else if (stayInPoseState == StayInPoseState.Leaving && stateInfo.normalizedTime - DELTA <= 0 && haCambiadoDeEstado)
            {
                BeginRep        = false;
                animator.speed  = 0;
                stayInPoseState = StayInPoseState.Resting;
                startRestTime   = Time.time;

                if (((!this.IsWeb) && (!this.IsInInstruction)) && _BehaviourState != AnimationBehaviourState.PREPARING_WITH_PARAMS && (!IsInterleaved || (IsInterleaved && limb == Limb.Right)))
                {
                    this.PauseAnimation();
                }
                if (IsInterleaved && this._BehaviourState == AnimationBehaviourState.RUNNING_WITH_PARAMS)
                {
                    haCambiadoDeEstado = false;
                    animator.SetTrigger("ChangeLimb");
                }
                OnRepetitionEnd();
                if (_BehaviourState == AnimationBehaviourState.PREPARING_WITH_PARAMS)
                {
                    this.Stop();
                }
            }

            else if (stayInPoseState == StayInPoseState.Resting && Time.time - startRestTime >= _realParams.SecondsBetweenRepetitions)
            {
                this.animator.speed = this._realParams.ForwardSpeed;
                stayInPoseState     = StayInPoseState.GoingTo;
            }
        }
    }