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; }
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); } }
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); } } }
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); } }
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); } } } }
public void Exit(SmartFarmer i) { }
public void Execute(SmartFarmer i) { if (i.patrolRoute.Count > 0) if (!i.FollowingPath) i.FollowPath(i.patrolRoute, true); }
public void Enter(SmartFarmer i) { }
public LoS(SmartFarmer i) { agent = i; }