The goals of this programming exercise are:
- to gain experience with the factory software design pattern
- to create significant portions of game programming systems from scratch or lighter outlines
- to implement tables and equations (as given by designers) as game procedures and logic
The points distribution for the stages totals 70 points and can be found in the table below. The remaining 30 points are for your peer review of another student's submission.
| Stage | Points |
|---|---|
| 1 | 15 |
| 2 | 15 |
| 3.1 | 15 |
| 3.2 | 10 |
| 4 | 15 |
The due date and submission information are on the official class communication channels.
- Main Camera is the main viewport into the lab.
- Laboratory is the root scene that composes the testing facility's laboratory. Inside there are the sides of the room, test pedestals, a weapon, and a shield.
- ShieldAparatus contains a
ShieldGeneratorwhere the shields (i.e. the test subjects) spawn. - WeaponAparatus holds the test weapon that contains the
ProjectileSpawnlocation for newProjectiles to spawn at.
- ShieldAparatus contains a
Scenes of note:
- DamageIndicator is a prefab that implements the dynamic health bar shown above the shield.
- Projectile is a prefab for the projectiles shot by the test weapon.
Scripts:
- Shield.cs contains the game logic for test
Shields. It is where the refreshing capabilities of the shield should be implemented. It contains references to theDamageIndicatorscene. - Effects holds the
enumfor the projectile and shield types. - Laboratory implements firing a
Projectileinstance that moves from theProjectileSpawntoward theShieldAparatusonui_acceptinput. Your factory logic could go here. - Projectile holds the physical parameters of the projectile and has information on the damage the projectile should do to a shield. It also controls the motion of the
Projectile - DamageIndicator partially controls the upward-scrolling damage values that appear when a
Projectilecollides with aShield.
The Aegis prototype shield mechanism is nearly complete. Your task is to complete the shield's functionality by adding a recharging mechanism which consists of the following:
- Use the
recharge_rateandrechare_delayproperties of theShieldclass to enable:- After the shield has taken damage or is not at maximum capacity, it enters a recharge delay period lasting
recharge_delayseconds. - After the recharge delay period, the shield begins to recharge at
recharge_ratecapacity points per second. - If the shield is damaged before it is fully recharged, the shield stops recharging and enters another recharge delay period.
- Shields cannot recharge greater than their
max_capacityvalue. - Shield
current_levelcan never be negative.
- After the shield has taken damage or is not at maximum capacity, it enters a recharge delay period lasting
Create a DamageEngine class that implements the following combat algorithm:
damage = ProjectileDamage * (TypeFactor)
| Damage Type Factors | Shield Type | |||
|---|---|---|---|---|
| Kinetic | Energy | Arcane | ||
| ProjectileType | Kinetic | 1 | 0.5 | 2 |
| Energy | 2 | 1 | 0.5 | |
| Arcane | 0.5 | 2 | 1 |
This class should be autoloaded via the Project Settings. This class does not need to be explicitly linked to a Node. It doesn't necessarily have to be a class. It does need to provide a static function that takes the parameters of a shield and the parameters of a projectile and returns a damage value as denoted by the combat algorithm.
Your task is to create factories that generate shields and projectiles via specification classes. These generated items should be instantiated as Nodes. Use shield and projectile placeholders in the project as a guide for how they should interact with the scene.
This task has the following objectives:
- Create a
ShieldFactoryand aProjectileFactoryusing the factory design pattern. - You need to create
ShieldSpecandProjectileSpecclasses whose only role is to hold a specification to be used by your factory. These types of data classes typically only have properties and no methods. - Your factory's
buildfunction should take a specification class as a parameter and should refresh theProjectiles andShields based on the specification. - Your factories should be able
generate_random_shields andgenerate_random_projectiles with properties within the stated specification ranges.
The automated factories in Aegis are primarily built to external specifications. Specifications consist of the following values and ranges:
Shield Specifications:
- Capacity: 50 to 250
- Recharge Delay: 0.5 to 5 seconds
- Recharge Rate: 1 to 25 capacity per second.
- Type: Kinetic, Energy, or Arcane.
Projectile Specifications:
- Damage: 1 to 50
- Charge Time: 0.5 to 3 seconds.
- Type: Kinetic, Energy, or Arcane.
Unfortunately, your factories are also limited in the quality of shields and projectiles they can produce. Shields are limited to a power rating of 300, while projectiles are limited to a rating of 100. The following functions can determine ratings:
shield_rating = max_capacity + (5.0 - recharge_delay) * 5.0 + recharge_rate * (recharge_rate / 2.0)
projectile_rating = damage * 2.0 + (3.0 - charge_time) ** 4.0
Your factories should not produce shields or projectiles with power ratings higher than the stated limits. If your factory receives a specification with a power rating over the stated limits, your factory should scale down the specification to be within the rating limit. How your factory scales down the specifications is your design choice; you could increase delay or change times, lower all properties by a percentage, or even randomly generate an entirely new shield.
This was a triumph!
I'm making a note here:
Huge success!It's hard to overstate
my satisfaction.Aperture Science:
We do what we must
because we can
For the good of all of us.
Except the ones who are dead.
Still Alive, Portal, 2007, Jonathan Coulton
In the grand traditions of automation and ever-increasing abstraction, this stage tasks you with creating a TestFactory that tests the output of factories.
Your TestFactory's build method should create the following:
- A
ShieldSpec.- A shield based on the generated specification.
- 5 to 10
ProjectileSpecs.- Projectile instantiations of those 5 to 10
ProjectileSpecs
- Projectile instantiations of those 5 to 10
- A
TestSchedulethat is capable of firing the projectiles in a sequential order while respecting theirChargeTimes. - Setting up the generated
Shieldand theTestSchedulein the scene. - Running the test by shooting the projectiles at the shield via the
TestSchedule.
You should report failure and huge success with the appropriate fanfare.