Пример #1
0
        public void Init(string standAni)
        {
            _StandAnimName     = standAni;
            _AnimationComp     = gameObject.GetComponent <Animation>();
            _AnimationUnitComp = gameObject.GetComponent <AnimationUnit>();
            _AnimationInfo     = GetComponent <AnimationInfo>();
            if (_AnimationUnitComp != null && null != _AnimationInfo)
            {
                var aniState = GetAnimationStateByName(standAni);
                _StandAnimLength = aniState != null ? aniState.length : 0;

                if (null != _AnimationInfo.animationPaths)
                {
                    foreach (var v in _AnimationInfo.animationPaths)
                    {
                        if (!v.Contains("idle"))
                        {
                            continue;
                        }

                        if (_IdleAnimList == null)
                        {
                            _IdleAnimList = new List <string>();
                        }
                        var temp = v.Split('/');
                        if (0 < temp.Length)
                        {
                            var animationName = System.IO.Path.GetFileNameWithoutExtension(temp[temp.Length - 1]);
                            //GetAnimationStateByName(animationName);
                            _IdleAnimList.Add(animationName);
                        }
                    }
                }
            }
        }
Пример #2
0
        private IEnumerable PlayIdleAnimation()
        {
            //没有休闲动作则跳过 (调用入口处已经做过检查)
            // if (_AnimationUnitComp != null && _IdleAnimList != null && _IdleAnimList.Count > 0)

            while (true)
            {
                var count = Random.Range(MIN_STAND_LOOP, MAX_STAND_LOOP + 1);
                yield return(new WaitForSeconds(count * _StandAnimLength)); //等待循环n次stand_c后播放idle_c

                //若此时没有播放stand_c,继续下次循环
                if (_AnimationUnitComp.IsPlaying(_StandAnimName, AnimationUnit.GetCloneAnimationName(_StandAnimName)))
                {
                    int    animIndex          = Random.Range(0, _IdleAnimList.Count);
                    string animName           = _IdleAnimList[animIndex];
                    var    idleAnimationState = GetAnimationStateByName(animName);
                    if (idleAnimationState != null)
                    {
                        _AnimationUnitComp.PlayAnimation(animName, ANIMAITON_FADE_TIME, false, -1, false);

                        // 不再使用Queue的方式进行,因为美术资源精诚将Idle作为Loop类型的  -- added by Jerry
                        yield return(new WaitForSeconds(idleAnimationState.length - ANIMAITON_FADE_TIME));

                        if (_AnimationUnitComp.IsPlaying(animName))
                        {
                            _AnimationUnitComp.PlayAnimation(_StandAnimName, ANIMAITON_FADE_TIME, false, -1, false);
                        }
                    }
                }
            }
        }
        //private string _BackWeaponName = "";

        void Awake()
        {
            _AnimationUnitComp   = gameObject.GetComponent <AnimationUnit>();
            _HasCombatAnimation  = (_AnimationUnitComp != null && _AnimationUnitComp.HasAnimation(AnimationUnit.BATTLE_STAND));
            _HangPointHolderComp = gameObject.GetComponent <HangPointHolder>();
            _AnimationLength     = _AnimationUnitComp != null?_AnimationUnitComp.GetAniLength(AnimationUnit.UNLOAD_WEAPON) : 0f;
        }
    static int CloneAnimationState(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);

        obj.CloneAnimationState(arg0);
        return(0);
    }
    static int EnableAnimationComponent(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        bool arg0 = LuaScriptMgr.GetBoolean(L, 2);

        obj.EnableAnimationComponent(arg0);
        return(0);
    }
    static int StopPartialSkillAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);

        obj.StopPartialSkillAnimation(arg0);
        return(0);
    }
    static int StopAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);
        int    arg1 = (int)LuaScriptMgr.GetNumber(L, 3);

        obj.StopAnimation(arg0, arg1);
        return(0);
    }
    static int HasAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);
        bool   o    = obj.HasAnimation(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
    static int PlayAssignedAniClip(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);
        float  arg1 = (float)LuaScriptMgr.GetNumber(L, 3);

        obj.PlayAssignedAniClip(arg0, arg1);
        return(0);
    }
    static int GetCurAnimTimeAtLayer(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 2);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        int   arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
        float o    = obj.GetCurAnimTimeAtLayer(arg0);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
    static int PlayHurtAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        bool   arg0 = LuaScriptMgr.GetBoolean(L, 2);
        string arg1 = LuaScriptMgr.GetLuaString(L, 3);

        obj.PlayHurtAnimation(arg0, arg1);
        return(0);
    }
    static int BluntCurSkillAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 3);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        float arg0 = (float)LuaScriptMgr.GetNumber(L, 2);
        bool  arg1 = LuaScriptMgr.GetBoolean(L, 3);
        float o    = obj.BluntCurSkillAnimation(arg0, arg1);

        LuaScriptMgr.Push(L, o);
        return(1);
    }
Пример #13
0
 public void Init(int minInterval, int maxInterval, string standAnimName, GameObject host)
 {
     _MinStandLoop           = minInterval;
     _MaxStandLoop           = maxInterval;
     _HostStandAnimName      = standAnimName;
     _HostStandAnimNameClone = AnimationUnit.GetCloneAnimationName(standAnimName);
     _AnimationUnitComp      = gameObject.GetComponent <AnimationUnit>();
     if (host != null)
     {
         _HostAnimationUnitComp = host.GetComponent <AnimationUnit>();
     }
 }
    static int PlayAnimation(IntPtr L)
    {
        LuaScriptMgr.CheckArgsCount(L, 7);
        EntityComponent.AnimationUnit obj = (EntityComponent.AnimationUnit)LuaScriptMgr.GetUnityObjectSelf(L, 1, "EntityComponent.AnimationUnit");
        string arg0 = LuaScriptMgr.GetLuaString(L, 2);
        float  arg1 = (float)LuaScriptMgr.GetNumber(L, 3);
        bool   arg2 = LuaScriptMgr.GetBoolean(L, 4);
        float  arg3 = (float)LuaScriptMgr.GetNumber(L, 5);
        bool   arg4 = LuaScriptMgr.GetBoolean(L, 6);
        float  arg5 = (float)LuaScriptMgr.GetNumber(L, 7);

        obj.PlayAnimation(arg0, arg1, arg2, arg3, arg4, arg5);
        return(0);
    }
Пример #15
0
        public void OnStart(float speed)
        {
            _AnimationUnit = gameObject.GetComponent <AnimationUnit>();
            if (_AnimationUnit == null)
            {
                Destroy(this);
                return;
            }

            _Speed = speed;

            _CurAnimationState0 = _AnimationUnit.GetCurAnimationStateAtLayer(0);
            _CurAnimationState1 = _AnimationUnit.GetCurAnimationStateAtLayer(1);

            if (_CurAnimationState0 != null)
            {
                _CurAnimationState0.enabled = false;
            }

            if (_CurAnimationState1 != null)
            {
                _CurAnimationState1.enabled = false;
            }
        }