Contains functions that update the Model.
More...
|
static bool | isEnemyUnitInRange (Graph graph, Unit unit, Unit enemyUnit) |
|
static void | startTurn (Player player, Camera camera) |
|
static bool | hasUnitFinishedActions (Unit unit) |
|
static bool | isTurnOver () |
|
static bool | isGameOver () |
|
static bool | isNodeAttackable (Unit unit, int unitX, int unitY, Node attackNode) |
|
static LinkedList< Node > | setMovableNodes (Graph graph, Unit unit) |
|
static LinkedList< Node > | getAttackableNodes (Graph graph, Unit unit) |
|
static LinkedList< Node > | getAttackRangeAfterMoving (Graph graph, Unit unit) |
|
static LinkedList< Node > | pathFinder (Graph graph, Unit unit, Node start, Node end) |
|
static void | removeUnit (Graph graph, Player player, Unit unit) |
|
static void | deselectUnit () |
|
static Unit | getUnitOnNodeClicked (Node clickedNode, Vector2 positionClicked, Player player) |
|
static void | updateUnitPosition (Graph graph, LinkedList< Node > path) |
|
static void | endTurn (Camera camera) |
|
static void | buttonAction (Button button, Graph graph) |
|
static bool | isMagicalAttack (Unit unit) |
|
static Button | getMenuButtonClicked (Vector2 mouseCoordinates, Camera camera) |
|
static void | scrollMap (Camera camera, int mouseX, int mouseY) |
|
Contains functions that update the Model.
This class holds useable functions in the scope of the entire gameplay. Such functions include updates to the Model. This is done through updating of the GameState or parameters passed into a function.
§ buttonAction()
static void Controller.GameFunction.buttonAction |
( |
Button |
button, |
|
|
Graph |
graph |
|
) |
| |
|
static |
Updates the Model in correspondence to unit menu button clicks. It does so by updating GameState's TurnState to the button that was clicked.
In addition, specific actions for each button include:
- If Attack is clicked, updates GameState's dropDownMenuOpen and attackSelect.
- If AttackConfirm is clicked, updates the unit's Active button states, unit stats (including damage to HP), as well as several GameState variables.
- If Move is clicked, updates GameState's dropDownMenuOpen.
- If Items is clicked, updates GameState's inventoryOppen.
- If Wait is clicked, deselects the unit and updates the Wait button's Active status.
- If any of the items in the inventory are clicked, causes the unit to equip the item and update the GameState's inventoryOpen.
Exceptions:
- The function does not handle non-null parameters.
- The function assumes that the GameState's selectedUnit is non-null, else changes made by this function will cause other functions to behave incorrectly.
- Parameters
-
button | Button that was clicked. |
graph | Graph of the map. |
§ deselectUnit()
static void Controller.GameFunction.deselectUnit |
( |
| ) |
|
|
static |
Deselects any selected unit. The function does so by updating the GameState's selectedUnit and selectedEnemyUnit. It also sets the GameState's TurnState, unitToAttack, attackConfirmOpen, dropDownMenuOpen, attackSelect, and inventoryOpen as a secondary effect.
§ endTurn()
static void Controller.GameFunction.endTurn |
( |
Camera |
camera | ) |
|
|
static |
Ends the current player's turn and starts the enemy player's turn. It does so by updating the GameState's currentPlayer and enemyPlayer. It also calls startTurn() and updates the GameState's endTurnButton and transitionTurn to activate the animation of turn transitioning.
- Parameters
-
camera | The camera of the game. Used to call startTurn after performing all actions to end the current turn. |
§ getAttackableNodes()
static LinkedList<Node> Controller.GameFunction.getAttackableNodes |
( |
Graph |
graph, |
|
|
Unit |
unit |
|
) |
| |
|
static |
Returns a LinkedList of Node that the specified unit can perform an attack on.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the unit has not yet moved, else the function does not behave correctly.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- Parameters
-
graph | Graph representing the current game map. |
unit | Specfied unit. |
§ getAttackRangeAfterMoving()
static LinkedList<Node> Controller.GameFunction.getAttackRangeAfterMoving |
( |
Graph |
graph, |
|
|
Unit |
unit |
|
) |
| |
|
static |
Returns a boolean value indicating whether or not the specified enemy unit is within attack range of the specified unit.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the unit has already moved, else the function does not behave correctly.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- Parameters
-
graph | Graph representing the current game map. |
Specified | unit. |
§ getMenuButtonClicked()
static Button Controller.GameFunction.getMenuButtonClicked |
( |
Vector2 |
mouseCoordinates, |
|
|
Camera |
camera |
|
) |
| |
|
static |
Returns the menu button that was clicked; if no menu button was clicked, returns null.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that mouseCoordinates be valid coordinates within the game window, else the function does not perform as expected.
- Parameters
-
mouseCoordinates | Coordinates of the mouse click. |
camera | The camera of the game. |
§ getUnitOnNodeClicked()
static Unit Controller.GameFunction.getUnitOnNodeClicked |
( |
Node |
clickedNode, |
|
|
Vector2 |
positionClicked, |
|
|
Player |
player |
|
) |
| |
|
static |
If an unit exists where user clicked (that belongs to player), return it; else, return null.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the clickedNode be a valid node in the game.
- The function requires that the positionClicked be a valid coordinate on the game map.
- The function requires that the player be a valid player in the current game.
- Parameters
-
clickedNode | Node where user has clicked. |
positionClicked | position (by node) of where the user has clicked. |
player | Player that is currently moving. |
§ hasUnitFinishedActions()
static bool Controller.GameFunction.hasUnitFinishedActions |
( |
Unit |
unit | ) |
|
|
static |
Returns a boolean value indicating whether or not the specified unit can perform actions. It does so by checking if the unit's AttackConfirm or Wait button is no longer Active. If so, then the unit can no longer perform actions.
Exceptions:
- The function does not support null parameters.
- The function requires that the unit has an AttackConfirm and Wait button, and does not behave correctly if these buttons are not available.
- Parameters
-
unit | Specified unit. Assumes unit is non-null and has an AttackConfirm and Wait button. |
§ isEnemyUnitInRange()
static bool Controller.GameFunction.isEnemyUnitInRange |
( |
Graph |
graph, |
|
|
Unit |
unit, |
|
|
Unit |
enemyUnit |
|
) |
| |
|
static |
Returns a boolean value indicating whether or not the specified enemy unit is within attack range of the specified unit.
Exceptions:
- The function does not check whether or not the units specified are actually on opposing sides, and simply assumes so.
- The function currently does not support null parameters, and requires that the parameters be non-null in order to operate correctly.
- The function assumes that both units specified have positions, and that the graph is made up of nodes. It also assumes that the positions of both units are valid positions on the graph.
- Parameters
-
graph | Graph representing the current game map. Required in order to determine which Node the units occupy and to give context on the range of the units. |
unit | Specified playable unit. Assume unit is non-null and has a position that is valid on the graph. |
enemyUnit | Specified enemy unit that holds interest in whether or not it is within attack range. Assume enemyUnit is non-null and has a position that is valid on the graph. |
§ isGameOver()
static bool Controller.GameFunction.isGameOver |
( |
| ) |
|
|
static |
Returns a boolean value indicating whether or not the game is over, based off win conditions. These conditions include whether or not one of the players in the game has any live units left.
Exceptions:
- The function requires that Player1 and Player2 stored in GameState are non-null.
- The function assumes that the two players stored in GameState are both different objects.
§ isMagicalAttack()
static bool Controller.GameFunction.isMagicalAttack |
( |
Unit |
unit | ) |
|
|
static |
Returns a boolean value indicating whether or not the unit performed a magical attack. This value is dependent on the unit's UnitType.
Exceptions:
- The function does not handle non-null parameters, else the behaviour of the function will not be correct.
- Parameters
-
§ isNodeAttackable()
static bool Controller.GameFunction.isNodeAttackable |
( |
Unit |
unit, |
|
|
int |
unitX, |
|
|
int |
unitY, |
|
|
Node |
attackNode |
|
) |
| |
|
static |
Returns a boolean value indicating whether or not a specified node is attackable based on the unit's equipped weapon's range.
It does so by first check that the specified node is not an obstacle, then checks that the attackNode is within range.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the unit have an equipped weapon with a range, and does not behave correctly otherwise.
- The function requires that the attackNode have a position on the game's graph, and does not behave correctly otherwise.
- The function assumes that unitX and unitY are correspondant to the unit's current or prospective position, and does not behave correctly otherwise.
- Parameters
-
unit | Unit to be checked for attackable nodes. |
unitX | The x coordinate of the unit (by nodes). |
unitY | The y coordinate of the unit (by nodes). |
attackNode | The specified attack node. |
§ isTurnOver()
static bool Controller.GameFunction.isTurnOver |
( |
| ) |
|
|
static |
Returns a boolean value indicating whether or not the current turn is over. It does so by checking if each unit in the current turn's player has already performed all actions.
Exceptions:
- The function assumes that the current player has live units left in the game, and does not behave properly if this is not the case.
§ pathFinder()
static LinkedList<Node> Controller.GameFunction.pathFinder |
( |
Graph |
graph, |
|
|
Unit |
unit, |
|
|
Node |
start, |
|
|
Node |
end |
|
) |
| |
|
static |
Returns a LinkedList of Node representing the path from the start node to the end node, with a maximum number of moves corresponding to the unit's movability. If no such path is valid, return null.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- The function requires that the unit have a movabiliy value, else the function cannot function correctly.
- The function requires that both the start and end Node are valid nodes on the Graph, else the function will not behave correctly.
- Parameters
-
graph | Graph representing the current game map. |
unit | Unit to move. |
start | Start Node of the path. |
end | End Node of the path |
§ removeUnit()
static void Controller.GameFunction.removeUnit |
( |
Graph |
graph, |
|
|
Player |
player, |
|
|
Unit |
unit |
|
) |
| |
|
static |
Removes the specified unit from the game. It does so by removing the unit from the Player player's list of ownedUnits.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- The function requires that the unit have a position, else the function cannot execute.
- The function does perform the specified action if the specified unit does not previously belong in the player's list of ownedUnits.
- Parameters
-
graph | Graph representing the current game map. |
player | The player that owns the unit to be removed. |
unit | unit to remove from the game. |
§ scrollMap()
static void Controller.GameFunction.scrollMap |
( |
Camera |
camera, |
|
|
int |
mouseX, |
|
|
int |
mouseY |
|
) |
| |
|
static |
Enables scrolling of the map based on mouse position. The map scrolls in the direction of the mouse position if the mouse position is at the edge/outside of the window and if the scrolling direction has not yet reached the end of the map.
- Parameters
-
camera | The camera of the game. |
mouseX | x-coordinate of the mouse position. |
mouseY | y-coordinate of the mouse position. |
§ setMovableNodes()
static LinkedList<Node> Controller.GameFunction.setMovableNodes |
( |
Graph |
graph, |
|
|
Unit |
unit |
|
) |
| |
|
static |
Returns a LinkedList of Node that the unit can move onto.
It does so by iterating through all nodes on the graph and checking if a path exists from the unit's current position to that node. If a path exists (pathFinder() does not return null), then it adds that node to the LinkedList of moveable nodes.
Exceptions:
- The function does not handle non-null values.
- The function requires that the specified unit has a valid position on the graph, and does not behave correctly otherwise.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- Parameters
-
graph | Graph representing the current game map. |
Specified | unit. |
§ startTurn()
static void Controller.GameFunction.startTurn |
( |
Player |
player, |
|
|
Camera |
camera |
|
) |
| |
|
static |
Must be called upon the start of a new turn. Resets all of the player's units' menu actions (by setting each unit's buttons to Active) and sets up game states. It does so by setting Game State's selectedUnit, unitToAttack, dropDownMenuOpen, attackConfirmOpen, and beforeMove.
Exceptions:
- The function does not support non-null values and assumes that each unit owned by the player has menu buttons.
- Parameters
-
player | Player of the new turn. Assume player is a valid player within the current game and is non-null. |
camera | The camera of the game. Used to set the camera to show a unit in the current player's turn. |
§ updateUnitPosition()
static void Controller.GameFunction.updateUnitPosition |
( |
Graph |
graph, |
|
|
LinkedList< Node > |
path |
|
) |
| |
|
static |
Moves the selected unit's position to the clicked position.
Note that the function also sets GameState's isAnimating during the movement animation.
Exceptions:
- The function does not handle non-null parameters.
- The function requires that the graph be initialized with nodes corresponding to the map of the game, and does not behave correctly otherwise.
- The function requires that the path consist of valid nodes on the graph.
- Parameters
-
graph | Graph representing the current game map. |
path | Path to move the unit along. |
The documentation for this class was generated from the following file:
- C:/Users/Thien Trandinh/Documents/Blaze-Brigade/src/Blaze-Brigade/Blaze_Brigade/GameFunction.cs