public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var actions = new List <EncounterAction>(); var parentPos = parent.GetComponent <PositionComponent>().EncounterPosition; var playerPos = state.Player.GetComponent <PositionComponent>().EncounterPosition; // Close distance if further than 5 if (parentPos.DistanceTo(playerPos) >= 5f) { // PERF: We may want to make pathfinding stateful/cache it or something, to save on turn times var path = Pathfinder.AStarWithNewGrid(parentPos, playerPos, state); if (path != null) { actions.Add(new MoveAction(parent.EntityId, path[0])); } } // Fire shotgun pellets=5, spread=5 every 4th turn, else fire single cannon (this is honestly a comical amount of spread though) if (this.CurrentShotgunCooldown == 0) { actions.AddRange(FireProjectileAction.CreateSmallShotgunAction(parent.EntityId, playerPos, numPellets: 5, spread: 5, state.EncounterRand)); this.CurrentShotgunCooldown += this.ShotgunCooldown; } else { actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); if (this.CurrentShotgunCooldown > 0) { this.CurrentShotgunCooldown -= 1; } } return(actions); }
public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var actions = new List <EncounterAction>(); var parentPos = parent.GetComponent <PositionComponent>().EncounterPosition; var playerPos = state.Player.GetComponent <PositionComponent>().EncounterPosition; // Always attempt to close distance var path = Pathfinder.AStarWithNewGrid(parentPos, playerPos, state); if (path != null) { actions.Add(new MoveAction(parent.EntityId, path[0])); } // Fire comically dense & inaccurate shotgun volley every 4 turns, and shotgun otherwise if (this.CurrentVolleyCooldown == 0) { actions.AddRange(FireProjectileAction.CreateSmallShotgunAction(parent.EntityId, playerPos, numPellets: 30, spread: 7, state.EncounterRand)); actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); this.CurrentVolleyCooldown += VolleyCooldown; } else { actions.AddRange(FireProjectileAction.CreateSmallShotgunAction(parent.EntityId, playerPos, numPellets: 2, spread: 1, state.EncounterRand)); if (this.CurrentVolleyCooldown > 0) { this.CurrentVolleyCooldown -= 1; } } return(actions); }
public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var actions = new List <EncounterAction>(); var parentPos = parent.GetComponent <PositionComponent>().EncounterPosition; var playerPos = state.Player.GetComponent <PositionComponent>().EncounterPosition; // Always attempt to close distance var path = Pathfinder.AStarWithNewGrid(parentPos, playerPos, state); if (path != null) { actions.Add(new MoveAction(parent.EntityId, path[0])); } // Fire reverser + cannon every 3rd turn, and shotgun + secondary batteries otherwise if (this.CurrentReverserCooldown == 0) { actions.Add(FireProjectileAction.CreateReverserAction(parent.EntityId, playerPos)); actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); this.CurrentReverserCooldown += ReverserCooldown; } else { actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); actions.AddRange(FireProjectileAction.CreateSmallShotgunAction(parent.EntityId, playerPos, numPellets: 2, spread: 3, state.EncounterRand)); if (this.CurrentReverserCooldown > 0) { this.CurrentReverserCooldown -= 1; } } return(actions); }
public override List <EncounterAction> _DecideNextAction(EncounterState state, Entity parent) { var actions = new List <EncounterAction>(); var parentPos = parent.GetComponent <PositionComponent>().EncounterPosition; var playerPos = state.Player.GetComponent <PositionComponent>().EncounterPosition; var distanceToPlayer = parentPos.DistanceTo(playerPos); // Only attempt to close distance if >=7 squares away if (distanceToPlayer >= 7f) { var path = Pathfinder.AStarWithNewGrid(parentPos, playerPos, state); if (path != null) { actions.Add(new MoveAction(parent.EntityId, path[0])); } } // Always fire cannon actions.Add(FireProjectileAction.CreateSmallCannonAction(parent.EntityId, playerPos)); // Fire railgun on cooldown (every 3rd turn) if (this.CurrentRailgunCooldown == 0) { actions.Add(FireProjectileAction.CreateRailgunAction(parent.EntityId, playerPos)); this.CurrentRailgunCooldown += this.RailgunCooldown; } else if (this.CurrentRailgunCooldown > 0) { this.CurrentRailgunCooldown -= 1; } // If player is close and flak is off cooldown, fire if (distanceToPlayer <= 4 && this.CurrentFlakCooldown == 0) { actions.AddRange(FireProjectileAction.CreateSmallShotgunAction(parent.EntityId, playerPos, numPellets: 30, spread: 5, state.EncounterRand)); this.CurrentFlakCooldown = this.FlakCooldown; } else if (this.CurrentFlakCooldown > 0) { this.CurrentFlakCooldown -= 1; } return(actions); }