Exemple #1
0
        protected override void Attack()
        {
            GameObject attackTarget = GetAttackTarget();

            if (null != attackTarget)
            {
                CastleUtility.LookAtTarget(transform, attackTarget.transform);

                if (CastleUtility.IsTargetInAttackRange(transform, attackTarget.transform, mAttackDistance))
                {
                    mAttack.AddTarget(attackTarget);
                    mAttack.LaunchSkill();
                    mHeroState = HERO_STATE.AUTO_ATTACK;
                }
                else
                {
                    // change hero state to  move to target
                    mHeroState = HERO_STATE.MOVE_TO_TARGET;
                }
            }
            else
            {
                mAttack.LaunchSkill();
            }
        }
Exemple #2
0
 private void StateDiscoverHeroWork()
 {
     if (CastleUtility.IsTargetInAttackRange(transform, mHero, mAttackDistance))
     {
         mAnimator.SetBool(DataConfigure.IS_RUN_ID, false);
         mEnemyState = ENEMY_STATE.ATTACK;
     }
     else
     {
         mAnimator.SetBool(DataConfigure.IS_RUN_ID, true);
         // move to hero
         MoveToTarget();
     }
 }
Exemple #3
0
 private void StateAttackWork()
 {
     if (IsTargetAlive(mHero))
     {
         if (!CastleUtility.IsTargetInAttackRange(transform, mHero, mAttackDistance))
         {
             mEnemyState = ENEMY_STATE.DISCOVER_HERO;
         }
         Attack();
     }
     else
     {
         mEnemyState = ENEMY_STATE.IDLE;
     }
 }
Exemple #4
0
        private void AutoMoveToTarget()
        {
            GameObject attackTarget = GetAttackTarget();

            if (null != attackTarget)
            {
                if (CastleUtility.IsTargetInAttackRange(transform, attackTarget.transform, mAttackDistance))
                {
                    mHeroState = HERO_STATE.AUTO_ATTACK;
                }
                else
                {
                    // move to target
                    Vector3 direction        = attackTarget.transform.position - transform.position;
                    Vector2 correctDirection = new Vector2(direction.x, direction.z);
                    Move(correctDirection);
                }
            }
        }
Exemple #5
0
 private void DetectSkillRangeEnemies()
 {
     for (int i = 0; i < mEnemyList.Count; ++i)
     {
         if (CastleUtility.IsTargetInAttackRange(transform, mEnemyList[i].transform, mSelectSkill.distance))
         {
             if (mSkill3 == mSelectSkill)
             {
                 mSelectSkill.AddTarget(mEnemyList[i]);
             }
             else
             {
                 Vector3 inversePos = transform.InverseTransformPoint(mEnemyList[i].transform.position);
                 if (0 <= inversePos.z)
                 {
                     mSelectSkill.AddTarget(mEnemyList[i]);
                 }
             }
         }
     }
 }