Ejemplo n.º 1
0
        public override void UpdateState(ActorLocomotion.AnimationState state)
        {
            if (Mathf.Approximately(Time.get_deltaTime(), 0.0f) || Object.op_Equality((Object)this.Animator, (Object)null))
            {
                return;
            }
            AnimatorStateInfo animatorStateInfo = this.Animator.GetCurrentAnimatorStateInfo(0);

            this.IsLocomotionState = ((AnimatorStateInfo) ref animatorStateInfo).IsName("Locomotion") || ((AnimatorStateInfo) ref animatorStateInfo).IsName("Grounded Strafe");
            float num1 = -this.GetAngleFromForward(this._lastForward);

            this._lastForward = ((Component)this).get_transform().get_forward();
            float  num2                = num1 * (this._turnSensitivity * 0.01f);
            string forwardMove         = Singleton <Resources> .Instance.DefinePack.AnimatorParameter.ForwardMove;
            string heightParameterName = Singleton <Resources> .Instance.DefinePack.AnimatorParameter.HeightParameterName;
            float  num3                = !state.setMediumOnWalk ? Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z) : (state.moveDirection.z < (double)state.medVelocity || Mathf.Approximately((float)state.moveDirection.z, state.medVelocity) ? Mathf.Lerp(0.0f, 0.5f, Mathf.InverseLerp(0.0f, Mathf.InverseLerp(0.0f, state.maxVelocity, state.medVelocity), Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z))) : Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z));
            float  num4                = Mathf.Lerp(this.Animator.GetFloat(forwardMove), num3, Time.get_deltaTime() * Singleton <Resources> .Instance.LocomotionProfile.LerpSpeed);

            this.Animator.SetFloat(forwardMove, num4);
            PlayerActor actor = this.Actor as PlayerActor;

            if (Object.op_Inequality((Object)actor, (Object)null) && Object.op_Inequality((Object)actor.Partner, (Object)null) && actor.Partner.IsSlave)
            {
                actor.Partner.Animation.Animator.SetFloat(forwardMove, num4);
                float shapeBodyValue = actor.Partner.ChaControl.GetShapeBodyValue(0);
                this.Animator.SetFloat(heightParameterName, shapeBodyValue);
            }
            this.Animator.set_speed(!state.onGround || state.moveDirection.z <= 0.0 ? 1f : this._animSpeedMultiplier);
        }
        public void UpdateState(ActorLocomotion.AnimationState state)
        {
            if (Mathf.Approximately(Time.get_deltaTime(), 0.0f) || Object.op_Equality((Object)this.Animator, (Object)null) || !((Behaviour)this.Animator).get_isActiveAndEnabled())
            {
                return;
            }
            DefinePack definePack             = Singleton <Resources> .Instance.DefinePack;
            string     directionParameterName = definePack.AnimatorParameter.DirectionParameterName;
            string     forwardMove            = definePack.AnimatorParameter.ForwardMove;
            string     heightParameterName    = definePack.AnimatorParameter.HeightParameterName;
            float      num1 = !state.setMediumOnWalk ? Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z) : (state.moveDirection.z <= (double)state.medVelocity || Mathf.Approximately((float)state.moveDirection.z, state.medVelocity) ? Mathf.Lerp(0.0f, 0.5f, Mathf.InverseLerp(0.0f, Mathf.InverseLerp(0.0f, state.maxVelocity, state.medVelocity), Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z))) : Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z));

            foreach (AnimatorControllerParameter parameter in this.Animator.get_parameters())
            {
                if (!this.Actor.IsSlave && parameter.get_name() == forwardMove && parameter.get_type() == 1)
                {
                    float num2 = Mathf.Lerp(this.Animator.GetFloat(forwardMove), num1, Time.get_deltaTime() * Singleton <Resources> .Instance.LocomotionProfile.LerpSpeed);
                    this.Animator.SetFloat(forwardMove, num2);
                }
                if (parameter.get_name() == heightParameterName && parameter.get_type() == 1)
                {
                    float shapeBodyValue = this.Actor.ChaControl.GetShapeBodyValue(0);
                    this.Animator.SetFloat(heightParameterName, shapeBodyValue);
                }
            }
        }
Ejemplo n.º 3
0
        public void UpdateState(ActorLocomotion.AnimationState state)
        {
            if (Mathf.Approximately(Time.get_deltaTime(), 0.0f) || Object.op_Equality((Object)this.Animator, (Object)null))
            {
                return;
            }
            AnimatorStateInfo animatorStateInfo = this.Animator.GetCurrentAnimatorStateInfo(0);

            this.IsLocomotionState = ((AnimatorStateInfo) ref animatorStateInfo).IsName("Locomotion");
            DefinePack definePack             = Singleton <Resources> .Instance.DefinePack;
            string     directionParameterName = definePack.AnimatorParameter.DirectionParameterName;
            string     forwardMove            = definePack.AnimatorParameter.ForwardMove;
            string     heightParameterName    = definePack.AnimatorParameter.HeightParameterName;
            float      num1 = !state.setMediumOnWalk ? Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z) : (state.moveDirection.z < (double)state.medVelocity || Mathf.Approximately((float)state.moveDirection.z, state.medVelocity) ? Mathf.Lerp(0.0f, 0.5f, Mathf.InverseLerp(0.0f, Mathf.InverseLerp(0.0f, state.maxVelocity, state.medVelocity), Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z))) : Mathf.InverseLerp(0.0f, state.maxVelocity, (float)state.moveDirection.z));

            if (!this.Actor.IsSlave)
            {
                float num2 = Mathf.Lerp(this.Animator.GetFloat(forwardMove), num1, Time.get_deltaTime() * Singleton <Resources> .Instance.LocomotionProfile.LerpSpeed);
                this.Animator.SetFloat(forwardMove, num2);
            }
            float shapeBodyValue = this.Actor.ChaControl.GetShapeBodyValue(0);

            this.Animator.SetFloat(heightParameterName, shapeBodyValue);
        }
Ejemplo n.º 4
0
        public void UpdateState()
        {
            this.CalcAnimSpeed();
            this.Look();
            this.GroundCheck();
            AgentProfile      agentProfile      = Singleton <Resources> .Instance.AgentProfile;
            LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile;
            AgentActor        actor             = this._actor as AgentActor;
            StuffItem         carryingItem      = actor.AgentData.CarryingItem;
            int caseID;

            if (carryingItem != null && !agentProfile.CanStandEatItems.Exists <ItemIDKeyPair>((Predicate <ItemIDKeyPair>)(pair => pair.categoryID == carryingItem.CategoryID && pair.itemID == carryingItem.ID)))
            {
                caseID = 0;
            }
            else
            {
                int     id      = actor.AgentData.SickState.ID;
                Weather weather = Singleton <Manager.Map> .Instance.Simulator.Weather;
                switch (id)
                {
                case 3:
                    caseID = 1;
                    break;

                case 4:
                    caseID = 0;
                    break;

                default:
                    StuffItem equipedUmbrellaItem           = actor.AgentData.EquipedUmbrellaItem;
                    CommonDefine.ItemIDDefines itemIdDefine = Singleton <Resources> .Instance.CommonDefine.ItemIDDefine;
                    if (equipedUmbrellaItem != null && equipedUmbrellaItem.CategoryID == itemIdDefine.UmbrellaID.categoryID && equipedUmbrellaItem.ID == itemIdDefine.UmbrellaID.itemID)
                    {
                        if (weather == Weather.Rain || weather == Weather.Storm)
                        {
                            caseID = 0;
                            break;
                        }
                        this.SetLocomotionInfo(actor, weather, out caseID);
                        break;
                    }
                    this.SetLocomotionInfo(actor, weather, out caseID);
                    break;
                }
            }
            ActorLocomotion.AnimationState animState = this.AnimState;
            NavMeshAgent navMeshAgent = this._actor.NavMeshAgent;

            if (actor.Mode == Desire.ActionType.Date)
            {
                if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending())
                {
                    if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance && !actor.IsRunning)
                    {
                        actor.IsRunning = true;
                    }
                    float num;
                    if (actor.IsRunning)
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.followRunSpeed);
                        num = locomotionProfile.AgentSpeed.followRunSpeed;
                    }
                    else
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                        num = locomotionProfile.AgentSpeed.walkSpeed;
                    }
                    animState.setMediumOnWalk = true;
                    animState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                    navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed));
                }
                else
                {
                    animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                }
            }
            else if (actor.Mode == Desire.ActionType.TakeHPoint || actor.Mode == Desire.ActionType.ChaseYobai || actor.Mode == Desire.ActionType.ComeSleepTogether)
            {
                if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending())
                {
                    navMeshAgent.set_speed(locomotionProfile.AgentSpeed.runSpeed);
                }
                animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed);
                animState.setMediumOnWalk = true;
                animState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
            }
            else if (actor.Mode == Desire.ActionType.WalkWithAgentFollow || actor.BehaviorResources.Mode == Desire.ActionType.WalkWithAgentFollow)
            {
                if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending())
                {
                    float num;
                    if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance)
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed);
                        num = locomotionProfile.AgentSpeed.runSpeed;
                    }
                    else
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                        num = locomotionProfile.AgentSpeed.walkSpeed;
                    }
                    animState.setMediumOnWalk = true;
                    animState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                    navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed));
                }
                else
                {
                    animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.followRunSpeed);
                }
            }
            else if (this._actor.Mode == Desire.ActionType.Escape)
            {
                if (((Behaviour)navMeshAgent).get_enabled() && !navMeshAgent.get_pathPending())
                {
                    float escapeSpeed = locomotionProfile.AgentSpeed.escapeSpeed;
                    animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, escapeSpeed);
                    navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), escapeSpeed, locomotionProfile.LerpSpeed));
                }
            }
            else
            {
                if (actor.TutorialMode)
                {
                    switch (Manager.Map.GetTutorialProgress())
                    {
                    case 14:
                    case 15:
                        caseID = actor.TutorialLocomoCaseID;
                        break;
                    }
                }
                switch (caseID)
                {
                case 0:
                    animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                    animState.setMediumOnWalk = false;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                    break;

                case 1:
                    animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                    animState.setMediumOnWalk = true;
                    animState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                    break;

                case 2:
                    animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed);
                    animState.setMediumOnWalk = false;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                    break;

                case 100:
                    animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.tutorialWalkSpeed);
                    animState.setMediumOnWalk = true;
                    animState.medVelocity     = locomotionProfile.AgentSpeed.tutorialWalkSpeed;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.tutorialRunSpeed;
                    break;

                case 101:
                    animState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.tutorialRunSpeed);
                    animState.setMediumOnWalk = false;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.tutorialRunSpeed;
                    break;

                default:
                    float num        = actor.AgentData.StatsTable[5] * agentProfile.MustRunMotivationPercent;
                    int   desireKey  = Desire.GetDesireKey(actor.RequestedDesire);
                    float?motivation = actor.GetMotivation(desireKey);
                    if (motivation.HasValue && (double)motivation.Value < (double)num)
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed);
                    }
                    else if (Object.op_Inequality((Object)actor.MapArea, (Object)null))
                    {
                        int areaId = actor.MapArea.AreaID;
                        animState.moveDirection = !Object.op_Inequality((Object)actor.TargetInSightActionPoint, (Object)null) ? (!Object.op_Inequality((Object)actor.DestWaypoint, (Object)null) ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed) : (actor.DestWaypoint.OwnerArea.AreaID != areaId ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed) : Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed))) : (actor.TargetInSightActionPoint.OwnerArea.AreaID != areaId ? Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed) : Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed));
                    }
                    else
                    {
                        animState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                    }
                    animState.setMediumOnWalk = true;
                    animState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                    animState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                    animState.onGround        = this._actor.IsOnGround;
                    break;
                }
                actor.UpdateLocomotionSpeed(actor.DestWaypoint);
            }
            this.AnimState = animState;
            this.CharacterAnimation.UpdateState(animState);
        }
 public virtual void UpdateState(ActorLocomotion.AnimationState state)
 {
 }