示例#1
0
 protected void Chase()
 {
     if (movementHandler.PathEmpty() || pathRefreshTimer <= 0)
     {
         PathRequestManager.RequestPath(enemy.transform.position, enemy.Player.Get2DPosition(), enemy.gameObject, enemy.UnwalkableLayer, OnPathFound);
         pathRefreshTimer = GameManager.Instance.pathFindingRate;
     }
     else
     {
         pathRefreshTimer -= Time.deltaTime;
     }
     FlipIfNeeded();
     if (enemy.GetAnimationState() != EnemyStateHandler.MyAnimationState.Walk)
     {
         enemy.Anim.SetBool(enemy.WalkingAnimationBool, true);
     }
     movementHandler.MoveAlongPath();
 }
示例#2
0
        // todo : random next patrol point
        protected void Patrol()
        {
            if (movementHandler.PathEmpty())
            {
                PathRequestManager.RequestPath(enemy.transform.position, enemy.PatrolWayPoints[nextWaypointIndex].Get2DPosition(), enemy.gameObject, enemy.UnwalkableLayer, OnPathFound);
            }
            if (patrolWaitTimer > 0)
            {
                patrolWaitTimer -= Time.deltaTime;
                return;
            }

            FlipIfNeeded();
            enemy.Anim.SetBool(enemy.WalkingAnimationBool, true);
            movementHandler.MoveAlongPath();
            if (DirectionAndDistanceCalculator.CalculateDistance(enemy.transform.Get2DPosition(), enemy.PatrolWayPoints[nextWaypointIndex].Get2DPosition()) < GameManager.Instance.aiReachingPrecision)
            {
                nextWaypointIndex = (nextWaypointIndex + 1) % enemy.PatrolWayPoints.Length;
                PathRequestManager.RequestPath(enemy.transform.position, enemy.PatrolWayPoints[nextWaypointIndex].Get2DPosition(), enemy.gameObject, enemy.UnwalkableLayer, OnPathFound);
                patrolWaitTimer = enemy.PatrolDelay;
                enemy.Anim.SetBool(enemy.WalkingAnimationBool, false);
            }
        }