Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     playerInRange  = false;
     player         = GameManager.instance.player.gameObject;
     enemy          = GameManager.instance.enemy;
     lineOfSightEnd = player.transform;
 }
Beispiel #2
0
 public void Enter(AIPawn pawn)
 {
     if (pawn.BehaviorState.IsBTRunning == false)
     {
         Index = 0;
     }
 }
Beispiel #3
0
        // TODO: not dependent on Enemy
        public override ActionResult Execute(AIPawn pawn)
        {
            pawn.Move(pawn.BehaviorState.MoveSelection);


            return(ActionResult.Success);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            Player player = BattleController.Instance.Player;

            var pointOptions = new List <Point>();

            List <Point> pointsInRange = pawn.PointsInRange;

            foreach (Point point in pointsInRange)
            {
                if (player.IsPawnOnPoint(point))
                {
                    pointOptions.Add(point);
                }
            }

            if (pointOptions.Count <= 0)
            {
                return(ActionResult.Failure);
            }

            pawn.BehaviorState.PointOptions = pointOptions;

            return(ActionResult.Success);
        }
Beispiel #5
0
        public override ActionResult Execute(AIPawn pawn)
        {
            BehaviorState behavior = pawn.BehaviorState;

            List <Point> adjacentPoints = pawn.Position.Adjacent();

            var adjacentPointsWithEnemy = new List <Point>();

            foreach (Point adjacentPoint in adjacentPoints)
            {
                if (BattleController.Instance.Player.IsPawnOnPoint(adjacentPoint))
                {
                    adjacentPointsWithEnemy.Add(adjacentPoint);
                }
            }

            behavior.PointOptions = adjacentPointsWithEnemy;

            if (behavior.PointOptions.Count <= 0)
            {
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            List <Point> options = pawn.BehaviorState.PointOptions;

            var adjPointInRange = new List <Point>();

            foreach (Point point in options)
            {
                List <Point> adjacentPoints = point.Adjacent();

                foreach (Point adjacent in adjacentPoints)
                {
                    if (!pawn.PointsInRange.Contains(adjacent))
                    {
                        continue;
                    }
                    if (!adjPointInRange.Contains(adjacent))
                    {
                        adjPointInRange.Add(adjacent);
                    }
                }
            }

            pawn.BehaviorState.PointOptions = adjPointInRange;

            return(pawn.BehaviorState.PointOptions.Count <= 0 ?
                   ActionResult.Failure : ActionResult.Success);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            List <Point> points = pawn.BehaviorState.PointOptions;

            if (points.Count <= 0)
            {
                return(ActionResult.Failure);
            }

            Point closest          = points[0];
            int   shortestDistance = int.MaxValue;

            foreach (Point point in points)
            {
                int distance = point.Distance(pawn.Position);
                if (distance < shortestDistance)
                {
                    closest          = point;
                    shortestDistance = distance;
                }
            }

            pawn.BehaviorState.PointChoice = closest;

            return(ActionResult.Success);
        }
    // Use this for initialization
    void Start()
    {
        enemyPawn  = (AIPawn)pawn;
        playerPawn = (PlayerPawn)GetComponent <PlayerController>().pawn;

        aiTransform = enemyPawn.GetComponent <Transform>();
        target      = playerPawn.GetComponent <Transform>();
    }
        public override ActionResult Execute(AIPawn pawn)
        {
            if (BattleController.Instance.Player.IsPawnOnPoint(pawn.Engage))
            {
                return(ActionResult.Success);
            }

            return(ActionResult.Failure);
        }
 public override ActionResult Execute(AIPawn pawn)
 {
     if (pawn.IsMoving == false)
     {
         Debug.Log("DUNM ISMOVING FALSE");
     }
     return(pawn.IsMoving ?
            ActionResult.Running :
            ActionResult.Success);
 }
        public override ActionResult Execute(AIPawn pawn)
        {
            List <Point> points = pawn.BehaviorState.PointOptions;

            int rand = Random.Range(0, points.Count - 1);

            pawn.BehaviorState.PointChoice = points[rand];

            return(ActionResult.Success);
        }
Beispiel #12
0
        public override ActionResult Execute(AIPawn pawn)
        {
            if (pawn.PointsInRange.Count > 0)
            {
                if (pawn.HasEnoughAPToMove)
                {
                    return(ActionResult.Success);
                }
            }

            return(ActionResult.Failure);
        }
Beispiel #13
0
    protected virtual IEnumerator TrySpawning()
    {
        GameObject objToSpawn = SpawnPool[Random.Range(0, SpawnPool.Length)];

        AIPawn pawn = objToSpawn.GetComponent <AIPawn>();
        int    nearbyOfSameTypeFound  = 0;
        bool   invalidSpawnConditions = true;

        while (invalidSpawnConditions)
        {
            nearbyOfSameTypeFound = 0;
            Collider[] foundColliders = Physics.OverlapSphere(transform.position, maxSpawnDistance * 2);
            foreach (Collider col in foundColliders)
            {
                AIPawn foundPawn = col.GetComponent <AIPawn>();
                if (foundPawn)
                {
                    if (foundPawn.GetType() == pawn.GetType())
                    {
                        nearbyOfSameTypeFound++;
                    }
                }
            }
            //Debug.Log("Found " + nearbyOfSameTypeFound + " nearby " + pawn.GetType());

            if (nearbyOfSameTypeFound < maxNearbySpawn || maxNearbySpawn <= 0)
            {
                invalidSpawnConditions = false;
            }
            else
            {
                Debug.Log("Invalid spawn conditions");
                yield return(null);
            }

            //Debug.Log("invalidSpawnConditions: " + invalidSpawnConditions);
        }

        int numberToSpawn = Random.Range(1, maxGroupSize);

        if (numberToSpawn + nearbyOfSameTypeFound > maxNearbySpawn && maxNearbySpawn > 0)
        {
            numberToSpawn = maxNearbySpawn - nearbyOfSameTypeFound;
        }
        //Debug.Log("Spawning " + numberToSpawn + " " + objToSpawn.name);
        for (int count = 0; count < numberToSpawn; count++)
        {
            SpawnEntity(objToSpawn);
        }

        SpawnCoroutine = null;
    }
Beispiel #14
0
 public override ActionResult Execute(AIPawn pawn)
 {
     Enter(pawn);
     while (Index < Children.Count)
     {
         ActionResult result = Children[Index].Execute(pawn);
         if (result != ActionResult.Success)
         {
             return(result);
         }
         ++Index;
     }
     return(ActionResult.Success);
 }
        public override ActionResult Execute(AIPawn pawn)
        {
            pawn.BehaviorState.PointOptions = pawn.PointsInRange;

            if (pawn.BehaviorState.PointOptions == null)
            {
                return(ActionResult.Failure);
            }
            if (pawn.BehaviorState.PointOptions.Count == 0)
            {
                return(ActionResult.Failure);
            }

            return(ActionResult.Success);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            BehaviorState behavior = pawn.BehaviorState;

            if (behavior.PointChoice == null)
            {
                return(ActionResult.Failure);
            }
            if (pawn.Position.Distance(behavior.PointChoice) != 1)
            {
                return(ActionResult.Failure);
            }

            behavior.FacingSelection = pawn.Position.GetDirection(behavior.PointChoice);

            return(ActionResult.Success);
        }
Beispiel #17
0
        public override ActionResult Execute(AIPawn pawn)
        {
            BehaviorState behavior = pawn.BehaviorState;

            if (behavior.PointChoice == null)
            {
                return(ActionResult.Failure);
            }
            if (!pawn.PointsInRange.Contains(behavior.PointChoice))
            {
                return(ActionResult.Failure);
            }

            behavior.MoveSelection = behavior.PointChoice;

            return(ActionResult.Success);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            var InRange = new List <Point>();

            foreach (Point point in pawn.BehaviorState.PointOptions)
            {
                if (pawn.PointsInRange.Contains(point))
                {
                    InRange.Add(point);
                }
            }

            pawn.BehaviorState.PointOptions = InRange;

            return(pawn.BehaviorState.PointOptions.Count <= 0 ?
                   ActionResult.Failure :
                   ActionResult.Success);
        }
Beispiel #19
0
        public override ActionResult Execute(AIPawn pawn)
        {
            if (!pawn.BehaviorState.IsBTRunning)
            {
                Reset();
            }
            //pawn.BehaviorState.IsBTRunning = true;

            var result = Child.Execute(pawn);

            pawn.BehaviorState.IsBTRunning = result == ActionResult.Running;

            if (pawn.BehaviorState.IsBTRunning == false)
            {
                Debug.Log("IsRunning FALSE");
            }

            return(result);
        }
        public override ActionResult Execute(AIPawn pawn)
        {
            var adjacentToEnemy = new List <Point>();

            foreach (Pawn enemy in BattleController.Instance.Player.Pawns)
            {
                List <Point> adjacent = enemy.Position.Adjacent();
                foreach (Point point in adjacent)
                {
                    if (!adjacentToEnemy.Contains(point))
                    {
                        adjacentToEnemy.Add(point);
                    }
                }
            }

            pawn.BehaviorState.PointOptions = adjacentToEnemy;

            return(pawn.BehaviorState.PointOptions.Count <= 0 ?
                   ActionResult.Failure : ActionResult.Success);
        }
Beispiel #21
0
        public override ActionResult Execute(AIPawn pawn)
        {
            List <Point> points = pawn.PointsInRange;

            int pointCount = points.Count;

            if (pointCount <= 0)
            {
                return(ActionResult.Failure);
            }

            int   rand      = Random.Range(0, pointCount - 1);
            Point randPoint = points[rand];

            pawn.Move(randPoint);

            StartCoroutine(WaitForMoveToFinish(pawn));

            Debug.Log("RMA Move Coroutine Finished");

            return(ActionResult.Success);
        }
Beispiel #22
0
 public override ActionResult Execute(AIPawn pawn)
 {
     return(Child.Execute(pawn));
 }
Beispiel #23
0
 public override ActionResult Execute(AIPawn pawn)
 {
     return(pawn.IsMoving ?
            ActionResult.Success :
            ActionResult.Failure);
 }
Beispiel #24
0
        public override ActionResult Execute(AIPawn pawn)
        {
            pawn.Facing = pawn.BehaviorState.FacingSelection;

            return(ActionResult.Success);
        }
Beispiel #25
0
 public abstract ActionResult Execute(AIPawn pawn);