logan-r / vilify

Unleash Your Inner Mad Scientist and Destroy the World (with Ice Cream) in this Open Source HTML5 Game
http://logan-r.github.io/vilify/
GNU General Public License v3.0
32 stars 25 forks source link

Tower AI #15

Closed ralph-the-mighty closed 11 years ago

ralph-the-mighty commented 11 years ago

Anyone have any suggestions for the tower AI? I have an idea here that I just wanted to throw out and see what you think.

  1. Include an array for each tower to keep track of the heroes in the tower's range (how we would do that I'm not sure) when a hero comes into range, add it to the array, and when it exits the tower's range, remove it.
  2. Also include variable (originally set to null) to store the tower's current target.
  3. Set the target variable to refer to the first hero in the array.
  4. When the hero exits the tower's range, select the next hero in the array for the new target (if the array is empty, set target variable back to null.
sru commented 11 years ago

@ThyberZee We could start with that. And we could add more advanced AI like AI in Balloon Tower Defense 5

ghost commented 11 years ago

@ThyberZee The only thing that has to be stored is the tower's target. The target would be set to the furthest advanced hero within range of the tower. Checking if a hero is within range can be done with the distance formula. Then for knowing which hero is furthest advanced, we would need to store the hero's total distance traveled from when it enters the map.

ralph-the-mighty commented 11 years ago

All right. Should the methods go in the Tower object constructor in the engine.js file, then?