-
Notifications
You must be signed in to change notification settings - Fork 0
Game Model
The central class of the Game Model. Manages and updates all of the entities.
- timer: the tick system that calls the update method every tick
- entityList: the central list of entities
- fileName: the filename to be loading and saving to
- gameSpeed: the speed of the current game being played
- score: the current score of the game
- computer: the computer associated with this game
- update(): iterates through the entity list and calls update on each entity object
- stopTimer(): pauses the timer, halting the update loop and thus pausing the game
- startTimer(): starts timer, thus starting the update loop and resuming the game
- save(): pauses the game, and saves all of the objects in entityList to the game file
- load(): loads the saved game from gamefile, populating entityList with the saved game's state
- innitialize(Difficulty difficulty, String lvlName): starts a new game instance from the inputs given
- selectTroops(Coordinate coord1, Coordinate coord2, Nationality nationality): selects troops within a certain coordiante box of a certain nationality
A class which creates methods used by the three different computer difficulties.
- difficulty: the difficulty stored as an enum
- turnCount: number of ticks elapsed
- executeAction(Game game): looks at current state of game, and depending on what difficulty the computer is, will determine an action and execute said action
Each of these classes will extend computer and create an executeAction method that will vary depending on their difficulty level
An enum which represents the difficulty of a computer
The class which all game entities extend
- turnCount: number of ticks elapsed
- location: the x, y coordinate pair for where the object is on the screen
- observer: EntityObserver that is paired to an object so that an object can update the position of its image while maintaining model/view separation
- update(): update method which updates attributes of object
- serialize(DataOutputStream wr): a method to package and save an
- update(): entity
Each entity will have an observer associated with it that will update the position of it's image upon being called
Objects that consist of x, y coordinate points
- x: x-position on coordinate plane
- y: y-position on coordinate plane
- isEqual(Coordinate c): checks if coordinate that is passed in is equal to coordinate
- round(double value, int places): rounds double to places number of digits
A structure that creates troops and deploys them
- population: number of troops in a city
- incrementRate: the speed at which a city produces population
- type: states whether city is friendly, enemy, or neutral
- selected: boolean value that determines if a city is selected for deploying troops or not
- fireRate: rate at which city will fire arrows to defend itself, increases over time
- serialize(): a method to package and save an entity
- update(): hijacks the entity update method to update certain attributes of this
- sendTroops(double percentage, Coordinate destination): sends troops according to the amount that the user has selected and decrements population accordingly
- fireProjectile(): generates a projectile that will kill an oncoming enemy within a range
A class that extends Entity to create moving entities
- speed: the speed at which the entity traverses the screen
- heading: the angle at which the entity as in the fourth Cartesian plane
- destination: the coordinate point that is the endpoint for the entity
- update(): hijacks the entity update method to update certain attributes of this
An event that happens at random and has a random effect on troops
- type: the type of weather
- update(): hijacks the entity update method to update certain attributes of this
- serialize(): a method to package and save an entity
An enum representing the various types of possible weathers
Damaging projectiles sent out of cities to kill troops
- damage: the damage of an projectile, typically set to one
- collisionDetection(): triggers when the projectile collides with a troop of the opposite nation
- update(): hijacks the entity update method to update certain attributes of this
- serialize(): a method to package and save an entity
Units which are sent to attack enemy cities and defend friendly cities
- health: amount of damage that the troop can take
- nationality: the side that this troop is on
- selected: boolean value depicting if unit is in selected or not
- update(): hijacks the entity update method to update certain attributes of this
- serialize(): a method to package and save an entity
- collisionDetection(): checks if troop has collided with either another troop of the opposite nationality