Esempio n. 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 设置动作裁剪模式
        /// </summary>
        /// <param name="animCullType"></param>
        public void setAnimationCullingType(AnimationCullingType animCullType)
        {
            if (_pModelRoot != null)
            {
                _pModelRoot.GetComponent <Animation>().cullingType = animCullType;
            }
        }
Esempio n. 2
0
        protected override void Init(AIBehaviors fsm)
        {
            goingToReload          = false;
            curAnimPosition        = 0.0f;
            previousSamplePosition = 0.0f;

            if (inheritPreviousStateMovement && fsm.previousState != null)
            {
                fsm.MoveAgent(fsm.previousState.GetNextMovement(fsm), movementSpeed, rotationSpeed);
            }
            else
            {
                fsm.MoveAgent(fsm.transform, 0.0f, rotationSpeed);
            }

            if (attackBasedOn == AttackMode.Animation)
            {
                attackAnimation = fsm.gameObject.GetComponentInChildren <Animation>();

                if (attackAnimation != null && attackAnimation[attackAnimName] != null)
                {
                    initialCullingType          = attackAnimation.cullingType;
                    attackAnimation.cullingType = AnimationCullingType.AlwaysAnimate;
                    animationLength             = attackAnimation[attackAnimName].length;
                }
                else
                {
                    animationLength = 1.0f;
                }
            }
            else
            {
                intervalAttackTime = Time.time + initialAttackTime;
            }
        }
Esempio n. 3
0
    static int IntToEnum(IntPtr L)
    {
        int arg0 = (int)LuaDLL.lua_tonumber(L, 1);
        AnimationCullingType o = (AnimationCullingType)arg0;

        LuaScriptMgr.PushEnum(L, o);
        return(1);
    }
Esempio n. 4
0
        private void SetAnimationCullingType(AnimationCullingType animationCullingType)
        {
            if (this.animation == null)
            {
                this.animationCullingType = animationCullingType;
                return;
            }

            this.animation.cullingType = animationCullingType;
        }
 public static void SetAnimationCullingMode(GameObject gameObj, AnimationCullingType cullingType)
 {
     if (null != gameObj.animation)
     {
         gameObj.animation.cullingType = cullingType;
     }
     for (int i = 0; i < gameObj.transform.childCount; i++)
     {
         NkUtil.SetAnimationCullingMode(gameObj.transform.GetChild(i).gameObject, cullingType);
     }
 }
Esempio n. 6
0
        protected virtual void SetAniCullingType(AnimationCullingType type)
        {
            mAniCullingType = type;
            if (this.ResStatus != ResStatus.OK)
            {
                return;
            }

            Animation[] anis = this.GameObject.GetComponentsInChildren <Animation>(true);
            foreach (Animation ani in anis)
            {
                ani.cullingType = type;
            }
        }
Esempio n. 7
0
    private static void CopyAnimations(GameObject source, GameObject destination)
    {
        if (source.animation == null && destination.animation != null)
        {
            //Remove animation component
            Component.DestroyImmediate(destination.animation);
        }
        else if (source.animation != null && destination.animation == null)
        {
            //Add & sync animation component
            Animation anim = destination.AddComponent <Animation>();
            anim.clip = source.animation.clip;
            foreach (AnimationState animState in source.animation)
            {
                anim.AddClip(animState.clip, animState.name);
            }
        }
        else if (source.animation != null && destination.animation != null)
        {
            AnimationClip        clip = destination.animation.clip;
            bool                 auto = destination.animation.playAutomatically;
            bool                 phys = destination.animation.animatePhysics;
            AnimationCullingType cull = destination.animation.cullingType;

            //Remove old
            foreach (AnimationState item in destination.animation)
            {
                destination.animation.RemoveClip(item.clip);
            }

            foreach (AnimationState item in source.animation)
            {
                destination.animation.AddClip(item.clip, item.name);
            }

            //Add & sync animation component
            destination.animation.clip = clip;
            destination.animation.playAutomatically = auto;
            destination.animation.animatePhysics    = phys;
            destination.animation.cullingType       = cull;
        }
        else
        {
            //source.anmation && destination.animation are null;
            //Do nothing
        }
    }
Esempio n. 8
0
        protected override void Init(AIBehaviors fsm)
        {
            //playerSystem = new PlayerSystem(this,fsm);

            this.fsm = fsm;
            fsm.SetNavMeshAgentStoppingDistance(attackRange);
            if (fsm.target != null)
            {
                target = fsm.target;
            }

            goingToReload          = false;
            curAnimPosition        = 0.0f;
            previousSamplePosition = 0.0f;

            if (inheritPreviousStateMovement && fsm.previousState != null)
            {
                fsm.MoveAgent(fsm.previousState.GetNextMovement(fsm), movementSpeed, rotationSpeed);
            }
            else
            {
                fsm.MoveAgent(fsm.transform, 0.0f, rotationSpeed);
            }

            if (attackBasedOn == AttackMode.Animation)
            {
                attackAnimation = fsm.gameObject.GetComponentInChildren <Animation>();

                if (attackAnimation != null && attackAnimation[attackAnimName] != null)
                {
                    initialCullingType          = attackAnimation.cullingType;
                    attackAnimation.cullingType = AnimationCullingType.AlwaysAnimate;
                    animationLength             = attackAnimation[attackAnimName].length;
                }
                else
                {
                    animationLength = 1.0f;
                }
            }
            else
            {
                intervalAttackTime = Time.time + initialAttackTime;
            }
        }
Esempio n. 9
0
    private static int set_cullingType(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            Animation            animation   = (Animation)obj;
            AnimationCullingType cullingType = (int)ToLua.CheckObject(L, 2, typeof(AnimationCullingType));
            animation.set_cullingType(cullingType);
            result = 0;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index cullingType on a nil value");
        }
        return(result);
    }
Esempio n. 10
0
    private static int get_cullingType(IntPtr L)
    {
        object obj = null;
        int    result;

        try
        {
            obj = ToLua.ToObject(L, 1);
            Animation            animation   = (Animation)obj;
            AnimationCullingType cullingType = animation.get_cullingType();
            ToLua.Push(L, cullingType);
            result = 1;
        }
        catch (Exception ex)
        {
            result = LuaDLL.toluaL_exception(L, ex, (obj != null) ? ex.get_Message() : "attempt to index cullingType on a nil value");
        }
        return(result);
    }
Esempio n. 11
0
    public static void EmptyAnimationStateArray(GameObject go)
    {
        if (!go.animation)
        {
            return;
        }

        WrapMode savedWrapMode = go.animation.wrapMode;
        bool     savedPlayAutomaticallyState = go.animation.playAutomatically;
        bool     savedAnimatePhysicsState    = go.animation.animatePhysics;

        AnimationCullingType savedCulType = go.animation.cullingType;

        Object.DestroyImmediate(go.GetComponent <Animation>(), true);

        Animation newAnim = (Animation)go.AddComponent(typeof(Animation));

        newAnim.wrapMode          = savedWrapMode;
        newAnim.playAutomatically = savedPlayAutomaticallyState;
        newAnim.animatePhysics    = savedAnimatePhysicsState;
        newAnim.cullingType       = savedCulType;
    }
Esempio n. 12
0
 public virtual void SetAniCullingType(AnimationCullingType type)
 {
 }