Dana Vrajitoru
B583/C490 Game Programming and Design

B583/C490/I400 Homework 6

Due Date: Wednesday, October 5, 2022.

In this homework we'll implement the second level of the 2D scroller game. You are in control of a rocket that you can move in four directions. You float in space encountering parachutes and rocks. You must catch 7 parachutes but avoid rocks altogether. To help with the navigation, you can shoot bullets at the rocks.

Here is an example of the intended result (http://www.cs.iusb.edu/~danav/teach/b583/shooterGL/) or just level 2 (http://www.cs.iusb.edu/~danav/teach/b583/shooterL2/).

Ex. 1. Complete Lab 6.

Ex. 2. Continue the implementation of this game by adding the following features:

a. Add a countdown of friend critters left to catch to the GameMaster class and every time the player collides with a friend object (by using a tag, for example), decrease this countdown by 1. Show it somewhere on screen. Then make the game master check for this countdown becoming 0 in the function CheckEndLevel for level 2.

Note that if Collision2D colInfo is your parameter in a collision detection function, then colInfo.gameObject is the game object attached to it.

b. Add an attribute to the player class called health and an attribute to the critter class called healthValue. Then in both scenes (Level1 and Level2) set player's health to 1. Set the health value of all the critters to 0 except for the rock to 1. You can set it in the prefab for all critters. Then in the player's class proceed to add or remove the health value of the critters to/from the player's health based on whether they are friends or foes, just like it is done with the score value. Add a test in the GameMaster to also end the game when the player's health becomes 0 in level 2.

c. Add a bullet prefab with the same general properties as the critters, but with a gravity scale of 0. Freeze the rotation for this one. Add a reference to the prefab in the PlayerControl class. In the function Fire, instantiate one object of type bullet. The position should be based on the player's position and the speed should be a pretty fast positive vertical speed.

You can use the critter class for the bullet, or write a new one for it (it will not be very different), or write a new class that inherits from CritterControl. If you use the critter class, then the bullet does not respawn. You have to check for collision with objects that are not friends and when it happens, the object should increment the score and then destroy itself using the instruction

Destroy(gameObject);

The same (without the score changing) should happen if the bullet leaves the screen.

The critter itself should also test for collision with bullets (you can use the tag "Ammo" or "Bullet") and respawn itself when it happens if they are not a friend. Play the critter's sound in that case.

Turn in: the source files .cs and a WebGL or Windows build.