Example #1
0
        public void Execute(SmartFarmer i)
        {
            i.lastSpotted = EntityManager.Instance.GetPlayer().Position;
            i.FollowingPath = false;

            Vector2 force = i.Seek(i.lastSpotted);

            if (!AStarGame.ApproximatelyZero(force))
                i.Velocity += force;
            else
                i.Velocity = Vector2.Zero;
        }
Example #2
0
        public void Enter(SmartFarmer i)
        {
            if (i.patrolRoute.Count > 0)
            {
                AStarSearch patrolStart = new AStarSearch(
                    AStarGame.GameMap.NavigationGraph,
                    AStarGame.GameMap.ClosestNodeIndex(i.Position),
                    AStarGame.GameMap.ClosestNodeIndex(i.patrolRoute[0]),
                    AStarHeuristics.Distance);

                List<int> patrolSearchNodes;
                patrolStart.PathToTarget(out patrolSearchNodes);

                List<Vector2> patrolSearchPos;
                patrolSearchPos = AStarGame.GameMap.getWorldfromNodes(patrolSearchNodes);

                i.FollowPath(patrolSearchPos, false);
            }
        }
Example #3
0
        public EnemyManager(EnemiesDescription enemiesDescription)
        {
            player = EntityManager.Instance.GetPlayer();

            if (enemiesDescription.EnemiesInfo != null)
            {
                foreach (EnemiesDescription.EnemyInfo curEnemyInfo in enemiesDescription.EnemiesInfo)
                {
                    List<Vector2> curPatrolRoute = curEnemyInfo.PatrolTilePositions;
                    for (int i = 0; i < curPatrolRoute.Count; i++)
                        curPatrolRoute[i] = AStarGame.GameMap.TilePosToWorldPos(curPatrolRoute[i]);

                    Vector2 curEnemyPosition = AStarGame.GameMap.TilePosToWorldPos(curEnemyInfo.StartingTilePosition);
                    IGameEntity curEnemy = new SmartFarmer(TextureManager.FarmerSprite, curEnemyPosition, curPatrolRoute);
                    curEnemy.MaxSpeed = curEnemyInfo.MaxSpeed;

                    Enemies.Add(curEnemy);
                }
            }
        }
Example #4
0
        public void Enter(SmartFarmer i)
        {
            bushes = BushRadar.getBushes();

            if (bushes.Count == 0)
                i.doneSearching = true;
            else
            {
                bushSearch = new AStarSearch(
                    AStarGame.GameMap.NavigationGraph,
                    AStarGame.GameMap.ClosestNodeIndex(i.Position + (15.0f * i.Heading)),
                    AStarGame.GameMap.ClosestNodeIndex(bushes[0]),
                    AStarHeuristics.Distance);

                bushSearch.PathToTarget(out bushSearchNodes);
                bushSearchPos = AStarGame.GameMap.getWorldfromNodes(bushSearchNodes);

                i.FollowPath(bushSearchPos, false);
            }
        }
Example #5
0
        public void Execute(SmartFarmer i)
        {
            if (!i.doneSearching)
            {
                bool reachedBush = AStarGame.ApproximatelyEqual(i.Position, bushes[nextBush]);
                if (reachedBush)
                {
                    nextBush++;
                    i.FollowingPath = false;

                    if (nextBush >= bushes.Count)
                    {
                        i.doneSearching = true;
                        return;
                    }
                }

                if (!i.FollowingPath)
                {
                    if (!AStarGame.GameMap.WallsBetween(i.Position, bushes[nextBush]))
                    {
                        Vector2 force = i.Seek(bushes[nextBush]);
                        i.Velocity += force;
                    }
                    else
                    {
                        bushSearch = new AStarSearch(
                            AStarGame.GameMap.NavigationGraph,
                            AStarGame.GameMap.ClosestNodeIndex(i.Position),
                            AStarGame.GameMap.ClosestNodeIndex(bushes[nextBush]),
                            AStarHeuristics.Distance);

                        bushSearch.PathToTarget(out bushSearchNodes);
                        bushSearchPos = AStarGame.GameMap.getWorldfromNodes(bushSearchNodes);

                        i.FollowPath(bushSearchPos, false);
                    }
                }
            }
        }
Example #6
0
 public void Exit(SmartFarmer i)
 {
 }
Example #7
0
 public void Execute(SmartFarmer i)
 {
     if (i.patrolRoute.Count > 0)
         if (!i.FollowingPath)
             i.FollowPath(i.patrolRoute, true);
 }
Example #8
0
 public void Enter(SmartFarmer i)
 {
 }
Example #9
0
 public LoS(SmartFarmer i)
 {
     agent = i;
 }