Ejemplo n.º 1
0
        // Set vars
        void SetVariables()
        {
            if (mode != AnimatorType.None)
            {
                animator = GetComponent <Animator>();

                // Get list of cached transforms
                tmList = gameObject.GetComponentsInChildren <Transform>(false).ToList();
                tmList.Remove(transform);

                // No children
                if (tmList.Count == 0)
                {
                    Debug.Log("RayFire Record: " + gameObject.name + " Mode set to " + mode.ToString() + " but object has no children. Mode set to None.", gameObject);
                    mode = AnimatorType.None;
                    return;
                }

                // Record set
                SetModeRecord();

                // Play set
                SetModePlay();
            }
        }
Ejemplo n.º 2
0
 private AnimatorDescription(AnimatorController animatorController, AnimatorOverrideController animatorOverrideController,
                             AnimatorType animatorType)
 {
     Type = animatorType;
     _animatorController         = animatorController;
     _animatorOverrideController = animatorOverrideController;
 }
Ejemplo n.º 3
0
    static string GetAnimatorName(AnimatorType type)
    {
        string name = "";

        switch (type)
        {
        case AnimatorType.Idle:
            name = "Base.Idle";
            break;

        case AnimatorType.Walk:
            name = "Base.Walking";
            break;

        case AnimatorType.Run:
            name = "Base.Running";
            break;

        case AnimatorType.IdleThrow:
            name = "Base.IdleThrow";
            break;

        case AnimatorType.RunThrow:
            name = "Base.RunThrow";
            break;

        case AnimatorType.Dead:
            name = "Base.Death";
            break;

        default:
            break;
        }
        return(name);
    }
Ejemplo n.º 4
0
    public static void AnimatorPlay(MonoBehaviour mono, Animator animator, AnimatorType type)
    {
        switch (type)
        {
        case AnimatorType.Attack:
            if (animator.GetInteger("State") == 0)
            {
                mono.StartCoroutine(WorkAfterFrame(() => { if (animator.GetInteger("State") == 1)
                                                           {
                                                               animator.SetInteger("State", 0);
                                                           }
                                                   }, 2));
            }
            animator.SetInteger("State", 1);
            break;

        case AnimatorType.Die:
            animator.SetInteger("State", 2);
            break;

        case AnimatorType.Null:
            animator.SetInteger("State", 0);
            break;

        default:
            break;
        }
    }
Ejemplo n.º 5
0
 void OnThrowAnimatorExit(Animator ani, AnimatorType type, AnimatorStateInfo stateInfo)
 {
     if (ani == animator)
     {
         if (type == AnimatorType.IdleThrow || type == AnimatorType.RunThrow)
         {
             system.PerformTransition(FSMTransition.ThrowToIdle);
         }
     }
 }
        public AnimatorCreator(FastBitmap image, BezierPolyline bezierPolyline, int canvasWidth, int canvasHeight)
        {
            _animatorType = AnimatorType.Spinning;
            _rotatorType  = RotatorType.Naive;
            _image        = image;
            //_grayImage = _GetGrayImage(_image);
            _bezierPolyline = bezierPolyline;

            _canvasWidth  = canvasWidth;
            _canvasHeight = canvasHeight;
        }
Ejemplo n.º 7
0
    public static AnimatorType GetTypeByHash(int hash)
    {
        AnimatorType animatorType = AnimatorType.Empty;

        foreach (AnimatorType type in Enum.GetValues(typeof(AnimatorType)))
        {
            if (hash == GetHashByType(type))
            {
                animatorType = type;
                break;
            }
        }

        return(animatorType);
    }
Ejemplo n.º 8
0
    public static AnimatorType GetCurrentState(Animator animator)
    {
        AnimatorType animatorType = AnimatorType.Empty;

        foreach (AnimatorType type in Enum.GetValues(typeof(AnimatorType)))
        {
            if (animator.GetCurrentAnimatorStateInfo(0).fullPathHash == GetHashByType(type))
            {
                animatorType = type;
                break;
            }
        }

        return(animatorType);
    }
 public override void OnXGUI()
 {
     _animatorType = (AnimatorType)CreateEnumSelectable("AnimatorType", _animatorType);
     switch (_animatorType)
     {
         case AnimatorType.AnimatorController:
             ShowAnimatorController();
             break;
         case AnimatorType.AnimatorModel:
             ShowAnimatorModel();
             break;
         case AnimatorType.Animator:
             ShowAnimatorInfo();
             break;
     }
 }
Ejemplo n.º 10
0
        // Play set
        void SetModePlay()
        {
            if (mode == AnimatorType.Play)
            {
                // Check for null controller
                if (controller == null)
                {
                    Debug.Log("RayFire Record: " + gameObject.name + " Mode set to " + mode.ToString() + " but controller is not defined. Mode set to None.", gameObject);
                    mode = AnimatorType.None;
                    return;
                }

                // Check for null controller
                if (animationClip == null)
                {
                    Debug.Log("RayFire Record: " + gameObject.name + " Mode set to " + mode.ToString() + " but animation clip is not defined. Mode set to None.", gameObject);
                    mode = AnimatorType.None;
                    return;
                }

                // Check for clip in controller
                bool hasClip = false;
                foreach (var anim in controller.animationClips)
                {
                    if (anim == animationClip)
                    {
                        hasClip = true;
                    }
                }
                if (hasClip == false)
                {
                    Debug.Log("RayFire Record: " + gameObject.name + " Mode set to " + mode.ToString() + " but animation clip is not defined in controller. Mode set to None.", gameObject);
                    mode = AnimatorType.None;
                    return;
                }

                // Create animator
                if (animator == null)
                {
                    animator = gameObject.AddComponent <Animator>();
                }
                animator.updateMode = AnimatorUpdateMode.AnimatePhysics;

                // Set defined controller
                animator.runtimeAnimatorController = controller;
            }
        }
Ejemplo n.º 11
0
        public override void OnXGUI()
        {
            _animatorType = (AnimatorType)CreateEnumSelectable("AnimatorType", _animatorType);
            switch (_animatorType)
            {
            case AnimatorType.AnimatorController:
                ShowAnimatorController();
                break;

            case AnimatorType.AnimatorModel:
                ShowAnimatorModel();
                break;

            case AnimatorType.Animator:
                ShowAnimatorInfo();
                break;
            }
        }
Ejemplo n.º 12
0
    void RpcNetSynAnimator(string aniName, int aniType, int isPlay)
    {
        AnimatorType aniState = (AnimatorType)aniType;

        switch (aniState)
        {
        case AnimatorType.Trigger:
        {
            mAnimator.SetTrigger(aniName);
            break;
        }

        case AnimatorType.Bool:
        {
            mAnimator.SetBool(aniName, isPlay == 0 ? false : true);
            break;
        }
        }
    }
Ejemplo n.º 13
0
    /// <summary>
    /// 同步网络动画.
    /// </summary>
    public void SynNetAnimator(string aniName, AnimatorType aniType, bool isPlay = false)
    {
        if (!IsNetControlPort || !enabled)
        {
            return;
        }

        if (Network.peerType == NetworkPeerType.Client || Network.peerType == NetworkPeerType.Server)
        {
            if (NetworkServerNet.GetInstance().mNetworkRootGame.ePlayerGameNetState == NetworkServerNet.PlayerGameNetType.GameBackMovie)
            {
                //游戏准备返回循环动画场景,无需继续同步信息!
            }
            else
            {
                mNetworkView.RPC("RpcNetSynAnimator", RPCMode.Others, aniName, (int)aniType, isPlay == false ? 0 : 1);
            }
        }
    }
Ejemplo n.º 14
0
        public AnimatorDefinition(IAnimationDefinition parent, AnimatorController animator, AnimatorType type)
        {
            bool animatorIsNull = animator == null;

            Parent   = parent;
            Animator = animator;
            Name     = animatorIsNull ? type.ToString() : animator.name;
            Type     = type;

            if (animatorIsNull)
            {
                return;
            }

            foreach (AnimatorControllerLayer animatorControllerLayer in animator.layers)
            {
                AddLayer(animatorControllerLayer);
            }
            foreach (var parameter in animator.parameters)
            {
                AddParameter(parameter);
            }
        }
Ejemplo n.º 15
0
 public AnimatorDefinition(IAnimationDefinition parent, AnimatorType type, string name = null)
 {
     Name   = name ?? type.ToString();
     Parent = parent;
 }
Ejemplo n.º 16
0
 public virtual void PlayAnimator(string paramName, AnimatorType type)
 {
     myAnimator.SetInteger(paramName, (int)type);
 }
Ejemplo n.º 17
0
 public static bool GetIsPlaying(Animator animator, AnimatorType type)
 {
     return(animator.GetCurrentAnimatorStateInfo(0).fullPathHash == GetHashByType(type));
 }
Ejemplo n.º 18
0
 public void Init(UnityEditor.Animations.AnimatorController controller)
 {
     animatorType       = AnimatorType.Controller;
     animatorController = controller;
     Refresh();
 }
Ejemplo n.º 19
0
 public static int GetHashByType(AnimatorType type)
 {
     return(Animator.StringToHash(GetAnimatorName(type)));
 }
Ejemplo n.º 20
0
 public void Init(AnimatorOverrideController controller)
 {
     animatorType = AnimatorType.Override;
     animatorOverrideController = controller;
     Refresh();
 }
Ejemplo n.º 21
0
 public TimedAnimator(TimeSpan totalDuration, TOutput startValue, AnimatorType animatorType)
 {
     TotalDuration = totalDuration;
     AnimatorType  = animatorType;
     CurrentValue  = StartValue = startValue;
 }
Ejemplo n.º 22
0
 public DelegateTimedAnimator(Func <double, T> function, TimeSpan totalDuration, T startValue, AnimatorType animatorType)
     : base(totalDuration, startValue, animatorType)
 {
     _function = function;
 }
Ejemplo n.º 23
0
 public static TimedAnimator <T> ToTimed <T>(this IAnimator <T> animator, TimeSpan totalDuration, T currentValue, AnimatorType animatorType = AnimatorType.Continue)
 => new DelegateTimedAnimator <T>(animator.Animate, totalDuration, currentValue, animatorType);
 public void SetAnimator(AnimatorType animatorType)
 {
     _animatorType = animatorType;
 }