Shields and Rewards
Part of the Game Architecture in Unity section of Coddy's Unity journey. Lesson 57 of 64.
Challenge
MediumAdd the shield, and make each wave drop a reward.
ShieldimplementsIPickup:Collectcallshero.Protect(duration)and destroys the shield.- In
Hero,public void Protect(float seconds)setssafeUntil = Time.time + seconds;. - Give
Waveapublic GameObject reward. When a wave is cleared, before the rest, the spawner drops it, if set, at its own position.
Press Play and clear wave 1: a heart appears in the middle. Then Check.
Try it yourself
public interface IPickup
{
void Collect(Hero hero);
}
All lessons in Game Architecture in Unity
1Components, Not Hierarchies
Small ComponentsA Base Enemy ScriptAbstract ComponentsComponents Working TogetherRecap: Modular TurretRecap: Twin Cannon4Serialized Data
Serializable ClassesLists in the InspectorEnums in the InspectorRecap: Loot TableRecap: Roll the Loot7State Machines
States as ClassesThe Alert StateA State MachineTransitionsEnemy BrainsThe Knight AttacksRecap: Door States10Project: Arena Survivor
The HeroEnemy Types2Interfaces in Unity
IDamageableInterfaces and TryGetComponentGetComponentsRecap: Interact KeyRecap: Nearest in ReachPractice on your own: Unity playground