Пример #1
0
 void PlayAttackSkill(int type)
 {
     m_AnimatorManager.SkillCtrl(0, type);
 }
Пример #2
0
    /// <summary>
    /// 释放技能
    /// </summary>
    public void DoSkill(int skillId)
    {
        if (!mSkillDic.ContainsKey(skillId))
        {
            return;
        }

        Skill skill = mSkillDic[skillId];

        // 检测技能释放条件
        if (!skill.Do())
        {
            return;
        }

        // 目标超过视野范围,设置目标为空,重新寻找新的目标
        if (mTarget != null && UtilTools.Vec2Distance(mTarget, mObj) > skill.mSkillRange)
        {
            mTarget = null;
        }

        if (mTarget == null)
        {
            List <IObject> objList  = RangeTools.GetEnemyByAOI(mObj, SkillRangeType.SkillRangeType_SelfRound, mDirectionRange, 0.0f);
            int            objCount = objList.Count;

            float   distance       = float.MaxValue;
            IObject minDistanceObj = null;

            // 检测距离最近的攻击目标,调整朝向
            for (int i = 0; i < objCount; ++i)
            {
                IObject enemy = objList[i];
                if (enemy == null)
                {
                    continue;
                }

                float tempDistance = UtilTools.Vec2Distance(mObj, enemy);
                if (tempDistance < distance)
                {
                    distance       = tempDistance;
                    minDistanceObj = enemy;
                }
            }

            mTarget = minDistanceObj;
        }

        if (mTarget != null)
        {
            Vector3 dir = UtilTools.Vec3Direction(mTarget, mObj);
            mAnimatorManager.SetRotation(dir);
        }

        int type = skill.mSkillProperty.mAnimatorSkillProperty.mySkillAction;

        if (type == 0)
        {
            DoAttack();
        }
        else
        {
            mAnimatorManager.SkillCtrl(skillId, type);
        }
    }