Exemple #1
0
 public LState(IAnim i, string name, float frame, bool l = false, bool m = false)
 {
     ia       = i;
     animName = name;
     hashName = Animator.StringToHash("Base Layer." + animName);
     time     = frame / 30;
     isLoop   = l;
     canMove  = m;
     tris     = new List <LStateTrigger>();
 }
    public void ExecuteAbility(int index)
    {
        IAbility   ability   = (IAbility)this.abilities [index];
        ICharacter character = gameObject.GetComponentInParent <ICharacter> ();

        if (ability.GetType() == typeof(BasicAttack) && ability.Cooldown())
        {
            IAnim proj = gameObject.GetComponentInChildren <ProjectileAnim> ();
            proj.Animate(ability, character);
        }
        else if (ability.GetType() == typeof(Rush) && ability.Cooldown())
        {
            IAnim rush = gameObject.GetComponentInChildren <RushAnim> ();
            rush.Animate(ability, character);
            ability.ApplyAbility(character);
        }
        else if (ability.GetType() == typeof(BurstJump) && ability.Cooldown())
        {
            IAnim jump = gameObject.GetComponentInChildren <BurstJumpAnim> ();
            jump.Animate(new BasicAttack("Projectile", 2.5f, 2.5f, 2.5f, 2.5f, 0.5f), character);
            ability.ApplyAbility(character);
        }
        else if (ability.GetType() == typeof(GrenadeToss) && ability.Cooldown())
        {
            IAnim toss = gameObject.GetComponentInChildren <GrenadeTossAnim> ();
            toss.Animate(ability, character);
        }
        else if (ability.GetType() == typeof(DeathLazer) && ability.Cooldown())
        {
            IAnim lazer = gameObject.GetComponentInChildren <DeathLazerAnim> ();
            lazer.Animate(ability, character);
        }
        else if (ability.GetType() == typeof(MeleeAttack) && ability.Cooldown())
        {
            IAnim melee = gameObject.GetComponentInChildren <MeleeAnim> ();
            melee.Animate(ability, character);
        }
        else
        {
            if (ability != null)
            {
                if (ability.Cooldown())
                {
                    ability.ApplyAbility(character);
                }
            }
        }
    }
Exemple #3
0
    public void ResetAllTrigger(IAnim anim)
    {
        Animator animator = anim.GetAnimator();

        AnimManager.Instance.ResetAllTrigger(animator);
    }
Exemple #4
0
    public float GetAnimtionClipLength(IAnim anim, string name)
    {
        Animator animator = anim.GetAnimator();

        return(AnimManager.Instance.GetAnimtionClip(animator, 0, name).length);
    }
Exemple #5
0
    public bool GetStateBool(IAnim anim, string name)
    {
        Animator animator = anim.GetAnimator();

        return(AnimManager.Instance.GetAnimtorBoolParam(animator, name));
    }
Exemple #6
0
    public bool IsInTransforming(IAnim anim, string name)
    {
        Animator animator = anim.GetAnimator();

        return(AnimManager.Instance.IsInTransforming(animator, 0, name));
    }
Exemple #7
0
    public float GetAnimCurrentRuningTime(IAnim anim)
    {
        Animator animator = anim.GetAnimator();

        return(AnimManager.Instance.GetCurrentNormalizeTime(animator, 0));
    }
Exemple #8
0
    /// <summary>
    /// 是否正在运行指定动画
    /// </summary>
    /// <param name="animName"></param>
    /// <param name="anim"></param>
    /// <returns></returns>
    public bool IsInStateAnim(string animName, IAnim anim)
    {
        Animator animator = anim.GetAnimator();

        return(AnimManager.Instance.IsInThisAnimState(animator, 0, animName));
    }
Exemple #9
0
    /// <summary>
    /// 注册指定实体的所有动画回调
    /// </summary>
    /// <param name="data"></param>
    private void RigisterAnimCallback(EventData data)
    {
        IAnim anim = data.Sender.GetComponent <IAnim>();

        AnimManager.Instance.BindAnimCallBack(anim);
    }
Exemple #10
0
        /// <summary>
        /// 依据游戏角色物体和回调控制器(mono)实现动态动画绑定
        /// note:由于发布后,动画片段在内存重新加载时就会重置,所以不能用角色类型来判断是否绑定过
        /// note:直接在动画片段上查找是否有绑定函数,没有再绑定
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="target"></param>
        public void BindAnimCallBack(IAnim target)
        {
            //绑定动画回调函数
            //获得动画状态机中的所有动画片段引用
            AnimationClip[]           clips    = target.GetAnimator().runtimeAnimatorController.animationClips;
            List <AnimCallBackEntity> entities = target.GetCallBacks();

            foreach (var e in entities)
            {
                for (int i = 0; i < clips.Length; i++)
                {
                    AnimationClip clip = clips[i];
                    if (clip.name.Equals(e.AnimName))//当动画片段的名称相同,这是需要绑定的目标
                    {
                        //这里要加一步判断,判断是否该动画片段中已经绑定了同名方法,有则不再重复绑定
                        AnimationEvent[] events  = clip.events;
                        bool             isExits = false;
                        for (int j = 0; j < events.Length; j++)
                        {
                            //查找该片段的所有事件中,是否有同名事件了。
                            if (events[j].functionName.Equals(e.FunName))
                            {
                                isExits = true;
                                break;
                            }
                        }
                        if (isExits)//若存在相同的同名事件方法
                        {
                            break;
                        }
                        AnimationEvent ae = new AnimationEvent();
                        ae.time         = clips[i].length * e.NormalizeTime; //用单位比例时间获得实际时间
                        ae.functionName = e.FunName;
                        switch (e.Type)
                        {
                        case AnimEventParamType.Int:
                            ae.intParameter = e.IntParam;
                            break;

                        case AnimEventParamType.Float:
                            ae.floatParameter = e.FloatParam;
                            break;

                        case AnimEventParamType.Object:
                            ae.objectReferenceParameter = e.ObjectParam;
                            break;

                        case AnimEventParamType.String:
                            ae.stringParameter = e.StringParam;
                            break;

                        case AnimEventParamType.Null:
                            break;
                        }
                        //给动画片段添加事件,只在运行时有效果
                        clips[i].AddEvent(ae);
                        break;
                    }
                }
            }
        }