コード例 #1
0
        public void UpdateState()
        {
            this.CalcAnimSpeed();
            MerchantActor     actor             = this._actor as MerchantActor;
            NavMeshAgent      navMeshAgent      = actor.NavMeshAgent;
            LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile;
            AgentProfile      agentProfile      = Singleton <Resources> .Instance.AgentProfile;

            if (actor.CurrentMode == Merchant.ActionType.GotoLesbianSpotFollow)
            {
                if (((Behaviour)navMeshAgent).get_isActiveAndEnabled() && !navMeshAgent.get_pathPending())
                {
                    if (!actor.IsRunning && (double)agentProfile.RunDistance < (double)navMeshAgent.get_remainingDistance())
                    {
                        actor.IsRunning = true;
                    }
                    float num;
                    if (actor.IsRunning)
                    {
                        this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.runSpeed);
                        num = locomotionProfile.MerchantSpeed.runSpeed;
                    }
                    else
                    {
                        this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed);
                        num = locomotionProfile.MerchantSpeed.walkSpeed;
                    }
                    navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed));
                }
                else
                {
                    this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed);
                }
            }
            else if (this.MovePoseID == 0)
            {
                this.AnimState.moveDirection   = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.MerchantSpeed.walkSpeed);
                this.AnimState.setMediumOnWalk = true;
                this.AnimState.medVelocity     = locomotionProfile.MerchantSpeed.walkSpeed;
                this.AnimState.maxVelocity     = locomotionProfile.MerchantSpeed.runSpeed;
            }
            else
            {
                this.AnimState.moveDirection   = Vector3.get_zero();
                this.AnimState.setMediumOnWalk = false;
                this.AnimState.maxVelocity     = locomotionProfile.MerchantSpeed.walkSpeed;
            }
            this.CharacterAnimation.UpdateState(this.AnimState);
        }
コード例 #2
0
        public void UpdateState(Actor.InputInfo state, ActorLocomotion.UpdateType updateType)
        {
            this._actor.StateInfo = state;
            this.Look(updateType);
            this.GroundCheck();
            AgentProfile      agentProfile      = Singleton <Resources> .Instance.AgentProfile;
            LocomotionProfile locomotionProfile = Singleton <Resources> .Instance.LocomotionProfile;
            PlayerActor       actor             = this._actor as PlayerActor;
            NavMeshAgent      navMeshAgent      = this._actor.NavMeshAgent;

            if (actor.PlayerController.State is Follow)
            {
                Actor.InputInfo     stateInfo  = this._actor.StateInfo;
                ref Actor.InputInfo local      = ref stateInfo;
                Vector3             vector3    = Vector3.Scale(this._actor.NavMeshAgent.get_velocity(), new Vector3(1f, 0.0f, 1f));
                Vector3             normalized = ((Vector3) ref vector3).get_normalized();
                local.move            = normalized;
                this._actor.StateInfo = stateInfo;
                if ((double)navMeshAgent.get_remainingDistance() > (double)agentProfile.RunDistance && !actor.IsRunning)
                {
                    actor.IsRunning = true;
                }
                this.AnimState.setMediumOnWalk = true;
                this.AnimState.medVelocity     = locomotionProfile.AgentSpeed.walkSpeed;
                this.AnimState.maxVelocity     = locomotionProfile.AgentSpeed.runSpeed;
                float num;
                if (actor.IsRunning)
                {
                    this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.runSpeed);
                    num = locomotionProfile.AgentSpeed.followRunSpeed;
                }
                else
                {
                    this.AnimState.moveDirection = Vector3.op_Multiply(this.MoveDirection, locomotionProfile.AgentSpeed.walkSpeed);
                    num = locomotionProfile.AgentSpeed.walkSpeed;
                }
                navMeshAgent.set_speed(Mathf.Lerp(navMeshAgent.get_speed(), num, locomotionProfile.LerpSpeed));
            }
コード例 #3
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);
        }