Game Development Reference
In-Depth Information
The following screenshot shows the Mono Framework interface:
The Mono Framework ships with the Unity engine
Lists and collections
Perhaps, the most common task when programming games is to store lists of data.
The nature of this data varies tremendously: high scores, player stats, enemy stats,
inventory items, weapons, power-ups, level lists, and more. Wherever possible,
choose static arrays to hold data due to their speed and efficiency. Static arrays were
considered in detail in Chapter 1 , Unity C# Refresher . In short, static arrays are created
ahead of time, and their maximum capacity is fixed from the outset. Items can be
added and removed from them at runtime, but their total size can never change.
If their maximum capacity is not utilized, then space would be wasted. Static arrays,
as their name implies, are an excellent choice for storing lists of data that remain
constant, such as all levels in the game, all weapons that can possibly be collected,
all power-ups that can possibly be collected, and so on.
However, you'll often need dynamic arrays, which can grow and shrink in capacity
to exactly accommodate the data you need as it changes, such as when enemies are
spawned and destroyed, inventory items come and go, weapons are collected and
discarded, and so on. The Mono Framework offers many classes to maintain lists
of data. The three main classes are List , Stack , and Dictionary . Each of these is
useful for a specific purpose.
 
Search WWH ::




Custom Search