Dana Vrajitoru
B583/C490 Game Programming and Design

B583/C490/I400 Homework 10

Due Date: Wednesday, November 23, 2022.

In this homework we will continue Lab 9 to implement the game Monster Run. Here is an an example (http://www.cs.iusb.edu/~danav/teach/b583/monsterGL/) of the intended result.

In this game, the player advances on a path where it can find tiles containing either nothing special, or a treat (candy or pumpkin) or a monster. They must start from the starting position and will win the game when they reach the finish position. Here are the rules of the game:

The game can be summarized by the following finite state machine, where R = player's roll (the die in GameMaster), PU = player's powerup, MP = monster's power, store = stored powerup.

Ex. 1. Implement the functionality of the game by doing the following:

Here are some implementation suggestions:

Add attributes in GameMaster for the stored powerup, for the powerup to use in a fight, the score, the monster's power.

Add a function MoveBy that moves the player by a given number of tiles. This function would have to update the value of playerPos, make sure it's not outside the bounds of the tiles array, and then call PlacePlayer with the new position. Note that when moving, if the result should be a tile of a negative index, then you should place the player back at the starting position 0. Similarly, if the resulting tile number is larger than or equal to the size of the array of tiles, then you should place the player on the last position.

For bigger actions, it's probably better to define a separate function. For example, you could define two functions called MoveAction and FightAction to handle those actions. Then you can call them in the appropriate places from the Action functions.

The FightAction function would roll the die and then decide whether the fight is won or lost. In case of a win, it would update the score with the difference between the player's hit (powerup plus die) and the monster's power. In case of a loss, it would have to move the player back by the amount of the difference.

The MoveAction function first moves the player by that number of places and then based on the type of tile it lands on, goes into another state: monster, powerup, or idle. The buttons and info are updated accordingly.

Ex. 3. (optional) Any additional features at your discretion for up to 3 extra credit points. For example, if you want to make the player move continuously from one tile to the next, you can look up the function Vector3.MoveTowards to help with that.

Turn in to Canvas: a zip file with the script GameMaster.cs and a Windows or WebGL build.