예제 #1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// 设置动作裁剪模式
        /// </summary>
        /// <param name="animCullType"></param>
        public void setAnimationCullingType(AnimationCullingType animCullType)
        {
            if (_pModelRoot != null)
            {
                _pModelRoot.GetComponent <Animation>().cullingType = animCullType;
            }
        }
예제 #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;
            }
        }
예제 #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);
    }
예제 #4
0
        private void SetAnimationCullingType(AnimationCullingType animationCullingType)
        {
            if (this.animation == null)
            {
                this.animationCullingType = animationCullingType;
                return;
            }

            this.animation.cullingType = animationCullingType;
        }
예제 #5
0
 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);
     }
 }
예제 #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;
            }
        }
예제 #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
        }
    }
예제 #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;
            }
        }
예제 #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);
    }
예제 #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);
    }
예제 #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;
    }
예제 #12
0
 public virtual void SetAniCullingType(AnimationCullingType type)
 {
 }