public void InitializeMap(MapParameters parameters) { MapBuilder builder = new ProcedureMapBuilder(); var director = new MapDirector(builder); var mapParams = new MapParameters { MapObjectPrefabs = _mapObjectPrefabs, MainMapSprite = _mainSprite, MapLength = _mapLength, MapWidth = _mapWidth, TileSize = _tileSize }; mapParams.MixWith(parameters); director.SetupMap(mapParams); _map = builder.GetMap(); _initialized = true; _mapObjects = new List <MapObject>(); DrawChunk(0); DrawChunk(1); DrawObjects(0); DrawObjects(1); }
public void MixWith(MapParameters newParams) { FieldInfo[] fields = typeof(MapParameters).GetFields(); foreach (var field in fields) { var oldValue = field.GetValue(this); var newValue = field.GetValue(newParams); if (newValue != null && newValue != oldValue) { field.SetValue(this, newValue); } } }
/// 1 tile is usually 2.56 in world coordinates public override void SetMapParams(MapParameters parameters) { _mapParams = parameters; }
public abstract void SetMapParams(MapParameters parameters);
public void SetupMap(MapParameters mapParams) { _mapBuilder.SetMapParams(mapParams); }