Exemple #1
0
 private void TurretLookAtEnemy()
 {
     if (null != mEnemyList[0])
     {
         CastleUtility.LookAtTarget(mTurret, mEnemyList[0].transform);
     }
 }
Exemple #2
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 #3
0
 private void MoveToTarget()
 {
     if (IsTargetAlive(mHero))
     {
         CastleUtility.LookAtTarget(transform, mHero);
         transform.Translate(Vector3.forward * mSpeed * Time.fixedDeltaTime);
     }
     else
     {
         mEnemyState = ENEMY_STATE.IDLE;
     }
 }
Exemple #4
0
        private void StateMoveToCastleWork()
        {
            mAnimator.SetBool(DataConfigure.IS_RUN_ID, true);

            if (mWayPointsTransformList.Count <= mNextWayPointIndex)
            {
                mEnemyState = ENEMY_STATE.IDLE;
            }
            else
            {
                Vector3 nextWayPointPosition            = mWayPointsTransformList[mNextWayPointIndex].position;
                Vector3 nextWayPointPositionIgnoreYAxis = new Vector3(nextWayPointPosition.x, 0, nextWayPointPosition.z);
                Vector3 currentPositionIgnoreYAxis      = new Vector3(transform.position.x, 0, transform.position.z);
                float   distanceOfNextPoint             = Vector3.Distance(currentPositionIgnoreYAxis, nextWayPointPositionIgnoreYAxis);
                if (distanceOfNextPoint < 0.1f)
                {
                    ++mNextWayPointIndex;
                }

                CastleUtility.LookAtTarget(transform, mWayPointsTransformList[mNextWayPointIndex]);
                transform.Translate(Vector3.forward * mSpeed * Time.deltaTime);
            }
        }