Ejemplo n.º 1
0
    /// <summary>
    /// 播放动画.
    /// </summary>
    public static void PlayAnimation(BattleUnit owner, string aniName, bool loop = false, ClientBehaviourIdContainer cont = null)
    {
        if (cont != null && cont.roleAnimationHashCode != 0)
        {
            owner.GetStateController().FinishCurrentState(cont.roleAnimationHashCode);
            cont.roleAnimationHashCode = 0;
        }

        if (!string.IsNullOrEmpty(aniName))
        {
            string animationName = owner.CombineAnimname(aniName);
            int    hashCode      = 0;
            if (owner.GetStateController().AnimSet != null)
            {
                hashCode = owner.GetStateController().AnimSet.GetStateHash(animationName);
            }

            if (hashCode != 0)
            {
                AnimActionUseSkill skillAction = AnimActionFactory.Create(AnimActionFactory.E_Type.UseSkill) as AnimActionUseSkill;
                skillAction.AnimName = animationName;

                skillAction.loop = loop;
                owner.GetStateController().DoAction(skillAction);

                // 动作无论循环与否, 都保存ID.
                if (cont != null)
                {
                    cont.roleAnimationHashCode = hashCode;
                }
            }
        }
    }
Ejemplo n.º 2
0
    private void PlayMoveAnim(bool force)
    {
        BattleUnit battleUnit = Owner as BattleUnit;

        if (battleUnit == null)
        {
            Release();
            return;
        }
        bool lowerMove = Owner.GetMovingType() == MovingType.MoveType_Lowwer;

        // 能不能移动
        if (!battleUnit.IsCanMove() || !battleUnit.IsMoveing())
        {
            if (lowerMove)
            {
                StopMove();
                return;//这里处在下半身移动层。。
            }

            Release();
            return;
        }


        if (lowerMove)
        {
            //更新状态

            Speed     = battleUnit.GetSpeed();
            Direction = Owner.GetAnimAngle();
            MoveState = (float)Owner.GetMoveState();
        }
        else
        {
            string statename = battleUnit.CombineAnimname(AnimationNameDef.PrefixPao);

            SetTransition(statename);
            //SwitchState(statename, (int)AnimationLayer.BaseLayer);
        }
    }