Time for action – Expanding AwesomeGame
We'll start with something simple. Usually when you're working on a project you might not want to go straight toward your goal, but instead you'd use a process like the one we're about to use to slowly work your game towards your desired goal. This helps to break down tasks even further and make sure your code is working each step of the way.
Let's start by making it so we win the game by collecting all of our AwesomeWeaponUpgrade
actors.
The first thing we need to do is count the number of
AwesomeWeaponUpgrade
actors and set our goal to that number. We'll use the foreach iterator to find them. Let's add aPostBeginPlay
function to ourAwesomeGame
class:simulated function PostBeginPlay() { local AwesomeWeaponUpgrade AW; super.PostBeginPlay(); GoalScore = 0; foreach DynamicActors(class'AwesomeWeaponUpgrade', AW) GoalScore++; }
GoalScore
is a variable declared inGameInfo
that holds the score limit for the game. When this number...