Game Development Reference
In-Depth Information
Soldier tactics
In order to manage multiple influence maps, we can create common initialize and update
functions that wrap the update interval of different influence maps as well as the initial
setup. As the SoldierTactics initialize function will be responsible for the influence
map's configuration and construction, we can move the previous initialization code from
Sandbox.lua :
SoldierTactics.lua :
SoldierTactics = {};
SoldierTactics.InfluenceMap = {};
function SoldierTactics_InitializeTactics(sandbox)
-- Override the default influence map configuration.
local influenceMapConfig = {
CellHeight = 1,
CellWidth = 2,
BoundaryMinOffset = Vector.new(0.18, 0, 0.35) };
-- Create the sandbox influence map.
Sandbox.CreateInfluenceMap(
sandbox, "default", influenceMapConfig);
-- Initialize each layer of the influence map that has
-- an initialization function.
for key, value in pairs(SoldierTactics.InfluenceMap) do
value.initializeFunction(sandbox, value.layer);
end
end
Updating each influence map layer can be wrapped within the update function that the
sandbox will eventually call. Here, we can store layer-specific influence map update inter-
vals as well as the time since the last update:
SoldierTactics.lua :
Search WWH ::




Custom Search