예제 #1
0
    public override void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateExit(animator, stateInfo, layerIndex);

        var smao = new StateMachineActionObject()
        {
            Animator = animator, PathHash = stateInfo.fullPathHash
        };

        foreach (var action in Actions)
        {
            action.Execute(smao);
        }
    }
예제 #2
0
    public override void OnStateMachineExit(Animator animator, int stateMachinePathHash)
    {
        base.OnStateMachineExit(animator, stateMachinePathHash);

        var smao = new StateMachineActionObject()
        {
            Animator = animator, PathHash = stateMachinePathHash
        };

        foreach (var action in Actions)
        {
            action.Execute(smao);
        }
    }
예제 #3
0
    public override void Execute(StateMachineActionObject smao)
    {
        if (IsRandom == true)
        {
            State = Random.Range(0, ChildStates);
        }
        else
        {
            State += 1;
            if (State > ChildStates)
            {
                State = 0;
            }
        }

        smao.Animator.SetInteger(ParameterHash, State);
    }
    public override void OnStateIK(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        base.OnStateIK(animator, stateInfo, layerIndex);

        if (animator.GetLayerWeight(layerIndex) <= 0f && layerIndex > 0 && !IgnoreWeight)
        {
            return;
        }

        var smao = new StateMachineActionObject()
        {
            Animator = animator, PathHash = stateInfo.fullPathHash, StateInfo = stateInfo, LayerIndex = layerIndex, State = AnimatorState.IK
        };

        foreach (var action in Actions)
        {
            action.Execute(smao);
        }
    }
예제 #5
0
    public override void Execute(StateMachineActionObject smao)
    {
        audioBehaviour = smao.Animator.GetComponent <AudioBehaviour>();
        if (audioBehaviour != null)
        {
            eventName = new NativeString64(audioBehaviour.AudioPrefix + EventName + audioBehaviour.AudioSuffix);
        }
        else
        {
            eventName = new NativeString64(EventName);
        }
        var gao    = smao.Animator.GetComponent <GameObjectEntity>();
        var target = gao != null ? gao.Entity : Entity.Null;

        EventSystem.PublishData(new AudioEvent()
        {
            EventName = eventName, Options = Options, Target = target
        });
    }
    public override void Execute(StateMachineActionObject smao)
    {
        for (var i = 0; i < LayerWeights.Count; i++)
        {
            var index = i;
            if (LayerWeights[index] < 0)
            {
                continue;
            }

            //HACK tweening those to remove jitters
            //smao.Animator.SetLayerWeight(index, LayerWeights[index]);
            var target = LayerWeights [index];
            DOTween.To
            (
                () => smao.Animator.GetLayerWeight(index),
                x => smao.Animator.SetLayerWeight(index, x),
                target,
                blendTime
            ).OnComplete(() => smao.Animator.SetLayerWeight(index, target));
        }
    }
예제 #7
0
 public virtual void Execute(StateMachineActionObject smao)
 {
 }
예제 #8
0
 public override void Execute(StateMachineActionObject smao)
 {
     smao.Animator.SetBool(ParameterHash, Value);
 }
예제 #9
0
 public override void Execute(StateMachineActionObject smao)
 {
     Debug.Log(Message);
 }
 public override void Execute(StateMachineActionObject smao)
 {
     Action.Execute(smao);
 }
    public override void Execute(StateMachineActionObject smao)
    {
        base.Execute(smao);

        if (Parameters.Count <= 0)
        {
            return;
        }

        var keys = ParameterTable.Keys.ToList();

        foreach (var key in keys)
        {
            ParameterTable[key] = smao.Animator.GetInteger(key);
        }

        var scoreGrouping  = ParameterTable.GroupBy(kvp => kvp.Value).OrderByDescending(grouping => grouping.Key);
        var highScores     = scoreGrouping.First();
        var parameterValue = highScores.Key;

        var selectedParameter = 0;

        foreach (var kvp in highScores)
        {
            smao.Animator.SetInteger(kvp.Key, 0);

            if (PreviousParameters.Contains(kvp.Key))
            {
                continue;
            }
            else
            {
                selectedParameter = kvp.Key;
                break;
            }
        }

        if (selectedParameter == 0)
        {
            PreviousParameters.Clear();
            selectedParameter = highScores.First().Key;
        }

        PreviousParameters.Add(selectedParameter);

        if (WaitForExit != null)
        {
            WaitForExit.Dispose();
        }

        WaitForExit = Observable.EveryUpdate().Where(_ => smao.Animator.State(smao.LayerIndex) == smao.PathHash).FirstOrDefault()
                      .SelectMany(Observable.EveryUpdate().Where(_ => smao.Animator.State(smao.LayerIndex) != smao.PathHash)).FirstOrDefault()
                      .Subscribe(_ =>
        {
            foreach (var kvp in highScores)
            {
                //only reset if the value is still zero
                var currentParameterValue = smao.Animator.GetInteger(kvp.Key);
                if (currentParameterValue == 0 || currentParameterValue == parameterValue + 1)
                {
                    smao.Animator.SetInteger(kvp.Key, parameterValue);
                }
            }
        }).AddTo(smao.Animator);
        smao.Animator.SetInteger(selectedParameter, parameterValue + 1);
    }
    public override void Execute(StateMachineActionObject smao)
    {
        base.Execute(smao);

        ScriptableAction.Execute(smao);
    }
예제 #13
0
    public override void Execute(StateMachineActionObject smao)
    {
        var value = Random.Range(RangedValue.MinValue, RangedValue.MaxValue);

        smao.Animator.SetInteger(ParameterHash, value);
    }
예제 #14
0
 public override void Execute(StateMachineActionObject smao)
 {
     Debug.Break();
 }