Exemplo n.º 1
0
        public static int AnimatorIntPopupBase(Animator _animator, int _selected, string _title = "")
        {
            if (_animator == null || _animator.runtimeAnimatorController == null)
            {
                return(-1);
            }


            AnimationClip[] _clips = AnimationTools.GetAnimationClips(_animator);

            string[] _animation_names = new string[_clips.Length];         //_animator.runtimeAnimatorController.animationClips.Length ];
            int[]    _animation_index = new int[_clips.Length];            //_animator.runtimeAnimatorController.animationClips.Length ];

            int i = 0;

            foreach (AnimationClip _clip in _clips)             // _animator.runtimeAnimatorController.animationClips )
            {
                _animation_index[i] = i;
                _animation_names[i] = _clip.name;

                i++;
            }

            if (_title == "")
            {
                _title = "Animation";
            }

            _selected = (int)EditorGUILayout.IntPopup(_title, _selected, _animation_names, _animation_index);

            _selected = (int)ICEEditorLayout.PlusMinusGroup(_selected, 1, ICEEditorStyle.CMDButtonDouble);

            if (_selected < 0)
            {
                _selected = 0;
            }
            else if (_selected >= _clips.Length - 1)
            {
                _selected = _clips.Length - 1;
            }

            return(_selected);
        }
        public static bool WizardAnimation(ICECreatureControl _control, BehaviourModeObject _behaviour)
        {
            if (_behaviour == null)
            {
                return(false);
            }

            _behaviour.NextRule();
            if (_behaviour.Rule == null)
            {
                return(false);
            }

            if (_behaviour.Key == "RUN" || _behaviour.Key == "TRAVEL" || _behaviour.Key == "JOURNEY" || _behaviour.Key == "HUNT" || _behaviour.Key == "ESCAPE" || _behaviour.Key == "FLEE")
            {
                _behaviour.Rule.Move.Enabled                  = true;
                _behaviour.Rule.Move.Motion.Velocity.z        = _control.Creature.Essentials.DefaultRunningSpeed;
                _behaviour.Rule.Move.Motion.AngularVelocity.y = _control.Creature.Essentials.DefaultTurningSpeed;
            }
            else if (_behaviour.Key == "WALK" || _behaviour.Key == "LEISURE" || _behaviour.Key == "AVOID")
            {
                _behaviour.Rule.Move.Enabled                  = true;
                _behaviour.Rule.Move.Motion.Velocity.z        = _control.Creature.Essentials.DefaultWalkingSpeed;
                _behaviour.Rule.Move.Motion.AngularVelocity.y = _control.Creature.Essentials.DefaultTurningSpeed;
            }
            else
            {
                _behaviour.Rule.Move.Enabled                  = false;
                _behaviour.Rule.Move.Motion.Velocity.z        = 0;
                _behaviour.Rule.Move.Motion.AngularVelocity.y = 0;
            }

            if (_control.GetComponent <Animator>() != null && _control.GetComponent <Animator>().runtimeAnimatorController != null)
            {
                AnimationClip[] _clips = AnimationTools.GetAnimationClips(_control.GetComponent <Animator>());
                int             _index = 0;
                foreach (AnimationClip _clip in _clips)
                {
                    if (AnimationIsSuitable(_behaviour.Key, _clip.name))
                    {
                        _behaviour.Rule.Animation.InterfaceType  = AnimationInterfaceType.MECANIM;
                        _behaviour.Rule.Animation.Animator.Type  = AnimatorControlType.DIRECT;
                        _behaviour.Rule.Animation.Animator.Name  = _clip.name;
                        _behaviour.Rule.Animation.Animator.Index = _index;
                        break;
                    }

                    _index++;
                }
            }
            else if (_control.GetComponentInChildren <Animation>() != null)
            {
                Animation _animation = _control.GetComponentInChildren <Animation>();
                int       _index     = 0;
                foreach (AnimationState _state in _animation)
                {
                    if (AnimationIsSuitable(_behaviour.Key, _state.name))
                    {
                        _behaviour.Rule.Animation.InterfaceType   = AnimationInterfaceType.LEGACY;
                        _behaviour.Rule.Animation.Animation.Name  = _state.name;
                        _behaviour.Rule.Animation.Animation.Index = _index;
                    }

                    _index++;
                }
            }

            return(true);
        }