Exemplo n.º 1
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            AgentActor agent = this.Agent;

            if (Object.op_Equality((Object)agent.CurrentPoint, (Object)null))
            {
                agent.CurrentPoint = agent.TargetInSightActionPoint;
            }
            agent.DeactivateNavMeshAgent();
            PoseKeyPair comaId = Singleton <Resources> .Instance.AgentProfile.PoseIDTable.ComaID;
            PlayState   info   = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[comaId.postureID][comaId.poseID];

            agent.Animation.LoadEventKeyTable(comaId.postureID, comaId.poseID);
            agent.Animation.InitializeStates(info);
            agent.LoadActionFlag(comaId.postureID, comaId.poseID);
            ActorAnimInfo actorAnimInfo1 = new ActorAnimInfo()
            {
                layer             = info.Layer,
                inEnableBlend     = info.MainStateInfo.InStateInfo.EnableFade,
                inBlendSec        = info.MainStateInfo.InStateInfo.FadeSecond,
                outEnableBlend    = info.MainStateInfo.OutStateInfo.EnableFade,
                outBlendSec       = info.MainStateInfo.OutStateInfo.FadeSecond,
                directionType     = info.DirectionType,
                endEnableBlend    = info.EndEnableBlend,
                endBlendSec       = info.EndBlendRate,
                isLoop            = info.MainStateInfo.IsLoop,
                loopMinTime       = info.MainStateInfo.LoopMin,
                loopMaxTime       = info.MainStateInfo.LoopMax,
                hasAction         = info.ActionInfo.hasAction,
                loopStateName     = info.MainStateInfo.InStateInfo.StateInfos.GetElement <PlayState.Info>(info.MainStateInfo.InStateInfo.StateInfos.Length - 1).stateName,
                randomCount       = info.ActionInfo.randomCount,
                oldNormalizedTime = 0.0f
            };

            agent.Animation.AnimInfo = actorAnimInfo1;
            ActorAnimInfo actorAnimInfo2 = actorAnimInfo1;

            agent.Animation.PlayInAnimation(actorAnimInfo2.inEnableBlend, actorAnimInfo2.inBlendSec, actorAnimInfo2.inFadeOutTime, actorAnimInfo2.layer);
            ActionPointInfo outInfo;

            agent.CurrentPoint.TryGetAgentActionPointInfo(EventType.Sleep, out outInfo);
            Transform  t    = ((Component)agent.CurrentPoint).get_transform().FindLoop(outInfo.baseNullName)?.get_transform() ?? ((Component)agent.CurrentPoint).get_transform();
            GameObject loop = ((Component)agent.CurrentPoint).get_transform().FindLoop(outInfo.recoveryNullName);

            agent.Animation.RecoveryPoint = loop?.get_transform();
            agent.CurrentPoint.SetSlot((Actor)agent);
            agent.SetStand(t, info.MainStateInfo.InStateInfo.EnableFade, info.MainStateInfo.InStateInfo.FadeSecond, info.DirectionType);
            agent.SetCurrentSchedule(true, outInfo.actionName, 175, 185, false, false);
            if (!agent.AgentData.ScheduleEnabled)
            {
                return;
            }
            Actor.BehaviorSchedule schedule = agent.Schedule;
            schedule.enabled                = agent.AgentData.ScheduleEnabled;
            schedule.elapsedTime            = agent.AgentData.ScheduleElapsedTime;
            schedule.duration               = agent.AgentData.ScheduleDuration;
            agent.Schedule                  = schedule;
            agent.AgentData.ScheduleEnabled = false;
        }
Exemplo n.º 2
0
        public void SetCurrentSchedule(
            bool scheduled,
            string name_,
            int minMin,
            int maxMin,
            bool gestures,
            bool useGameTime)
        {
            this._scheduleThreshold = new ValueTuple <int, int>(minMin, maxMin);
            int num = minMin == maxMin ? minMin : Random.Range(minMin, maxMin + 1);

            this._schedule             = new Actor.BehaviorSchedule(scheduled, name_, (float)num);
            this._schedule.useGameTime = useGameTime;
            TimeSpan timeSpan = TimeSpan.FromMinutes((double)(num / 2));

            this._gestureTimeLimit = new ValueTuple <bool, TimeSpan>(gestures, timeSpan);
        }
Exemplo n.º 3
0
        public virtual void OnStart()
        {
            AgentActor agent = this.Agent;

            agent.EventKey     = EventType.Sleep;
            agent.CurrentPoint = agent.TargetInSightActionPoint;
            agent.SetActiveOnEquipedItem(false);
            agent.ChaControl.setAllLayerWeight(0.0f);
            agent.ElectNextPoint();
            agent.CurrentPoint.SetActiveMapItemObjs(false);
            ActionPointInfo actionPointInfo1 = agent.TargetInSightActionPoint.GetActionPointInfo(agent);

            agent.Animation.ActionPointInfo = actionPointInfo1;
            ActionPointInfo actionPointInfo2 = actionPointInfo1;
            Transform       t    = ((Component)agent.CurrentPoint).get_transform().FindLoop(actionPointInfo2.baseNullName)?.get_transform() ?? ((Component)agent.CurrentPoint).get_transform();
            GameObject      loop = ((Component)agent.CurrentPoint).get_transform().FindLoop(actionPointInfo2.recoveryNullName);

            agent.Animation.RecoveryPoint = loop?.get_transform();
            int eventId = actionPointInfo2.eventID;

            agent.ActionID = eventId;
            int index  = eventId;
            int poseId = actionPointInfo2.poseID;

            agent.PoseID = poseId;
            int       poseID = poseId;
            PlayState info   = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[index][poseID];

            agent.CurrentPoint.DestroyByproduct(index, poseID);
            ActorAnimInfo animInfo = agent.Animation.LoadActionState(index, poseID, info);

            agent.LoadActionFlag(index, poseID);
            agent.DeactivateNavMeshAgent();
            agent.Animation.StopAllAnimCoroutine();
            agent.Animation.PlayInAnimation(animInfo.inEnableBlend, animInfo.inBlendSec, animInfo.inFadeOutTime, animInfo.layer);
            this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>((IObservable <M0>)agent.AnimationAgent.OnEndActionAsObservable(), 1), (System.Action <M0>)(_ =>
            {
                agent.Animation.StopAllAnimCoroutine();
                agent.Animation.PlayOutAnimation(animInfo.outEnableBlend, animInfo.outBlendSec, animInfo.layer);
            }));
            if (animInfo.hasAction)
            {
                this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnActionPlayAsObservable(), (System.Action <M0>)(_ => agent.Animation.PlayActionAnimation(animInfo.layer)));
            }
            this._onCompleteActionDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnCompleteActionAsObservable(), (System.Action <M0>)(_ => this.Complete()));
            agent.CurrentPoint.SetSlot((Actor)agent);
            agent.SetStand(t, info.MainStateInfo.InStateInfo.EnableFade, info.MainStateInfo.InStateInfo.FadeSecond, info.DirectionType);
            if (animInfo.isLoop)
            {
                agent.SetCurrentSchedule(animInfo.isLoop, actionPointInfo2.actionName, 100, 200, animInfo.hasAction, true);
                if (agent.AgentData.ScheduleEnabled)
                {
                    Actor.BehaviorSchedule schedule = agent.Schedule;
                    schedule.enabled                = agent.AgentData.ScheduleEnabled;
                    schedule.elapsedTime            = agent.AgentData.ScheduleElapsedTime;
                    schedule.duration               = agent.AgentData.ScheduleDuration;
                    agent.Schedule                  = schedule;
                    agent.AgentData.ScheduleEnabled = false;
                }
            }
            MapUIContainer.AddSystemLog(string.Format("{0}が寝ました", (object)MapUIContainer.CharaNameColor((Actor)agent)), true);
        }
Exemplo n.º 4
0
        public virtual void OnStart()
        {
            ((Task)this).OnStart();
            AgentActor agent = this.Agent;

            agent.EventKey     = EventType.Sleep;
            agent.CurrentPoint = agent.TargetInSightActionPoint;
            agent.SetActiveOnEquipedItem(false);
            agent.ChaControl.setAllLayerWeight(0.0f);
            agent.ElectNextPoint();
            agent.CurrentPoint.SetActiveMapItemObjs(false);
            ActionPointInfo actionPointInfo1 = agent.TargetInSightActionPoint.GetActionPointInfo(agent);

            agent.Animation.ActionPointInfo = actionPointInfo1;
            ActionPointInfo actionPointInfo2 = actionPointInfo1;
            Transform       t    = ((Component)agent.CurrentPoint).get_transform().FindLoop(actionPointInfo2.baseNullName)?.get_transform() ?? ((Component)agent.CurrentPoint).get_transform();
            GameObject      loop = ((Component)agent.CurrentPoint).get_transform().FindLoop(actionPointInfo2.recoveryNullName);

            agent.Animation.RecoveryPoint = loop?.get_transform();
            int eventId = actionPointInfo2.eventID;

            agent.ActionID = eventId;
            int index  = eventId;
            int poseId = actionPointInfo2.poseID;

            agent.PoseID = poseId;
            int       poseID = poseId;
            PlayState info   = Singleton <Resources> .Instance.Animation.AgentActionAnimTable[index][poseID];
            ValueTuple <int, string> valueTuple;

            if (AIProject.Definitions.Action.NameTable.TryGetValue(agent.EventKey, out valueTuple) && (int)valueTuple.Item1 != agent.ActionID)
            {
                return;
            }
            ActorAnimInfo animInfo = agent.Animation.LoadActionState(index, poseID, info);

            agent.LoadActionFlag(index, poseID);
            agent.DeactivateNavMeshAgent();
            agent.Animation.StopAllAnimCoroutine();
            agent.Animation.PlayInAnimation(animInfo.inEnableBlend, animInfo.inBlendSec, info.MainStateInfo.FadeOutTime, animInfo.layer);
            this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>(Observable.Take <Unit>((IObservable <M0>)agent.AnimationAgent.OnEndActionAsObservable(), 1), (System.Action <M0>)(_ =>
            {
                agent.Animation.StopAllAnimCoroutine();
                agent.Animation.PlayOutAnimation(animInfo.outEnableBlend, animInfo.outBlendSec, animInfo.layer);
            }));
            if (animInfo.hasAction)
            {
                this._onActionPlayDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnActionPlayAsObservable(), (System.Action <M0>)(_ => agent.Animation.PlayActionAnimation(animInfo.layer)));
            }
            this._onCompleteActionDisposable = ObservableExtensions.Subscribe <Unit>((IObservable <M0>)agent.AnimationAgent.OnCompleteActionAsObservable(), (System.Action <M0>)(_ => this.Complete()));
            agent.CurrentPoint.SetSlot((Actor)agent);
            agent.SetStand(t, info.MainStateInfo.InStateInfo.EnableFade, info.MainStateInfo.InStateInfo.FadeSecond, info.DirectionType);
            if (!animInfo.isLoop)
            {
                return;
            }
            ThresholdInt sleepDurationMinMax = Singleton <Resources> .Instance.AgentProfile.SecondSleepDurationMinMax;

            agent.SetCurrentSchedule(animInfo.isLoop, actionPointInfo2.actionName, sleepDurationMinMax.min, sleepDurationMinMax.max, animInfo.hasAction, true);
            if (!agent.AgentData.ScheduleEnabled)
            {
                return;
            }
            Actor.BehaviorSchedule schedule = agent.Schedule;
            schedule.enabled                = agent.AgentData.ScheduleEnabled;
            schedule.elapsedTime            = agent.AgentData.ScheduleElapsedTime;
            schedule.duration               = agent.AgentData.ScheduleDuration;
            agent.Schedule                  = schedule;
            agent.AgentData.ScheduleEnabled = false;
        }