// asettaa oikeat parametrit tileparameters oliolle ja tekee niistä keypairit private TileParameters GetRightTileParameters(BaseSerializedLayer serializedLayer, TileEngine tileEngine) { dynamic layer = serializedLayer; TileParameters tileParameters = new TileParameters(serializedLayer.MdiData, new List <BaseSerializedTile>(layer.Tiles), tileEngine); return(tileParameters); }
private object[] GetLayerAruments(BaseSerializedLayer layerData) { object[] args; args = new object[] { game, layerData.Name, layerData.Transparent, layerData.Visible, new Size(layerData.Width, layerData.Height), tileEngine }; return(args); }
private object[] GetMdiLayerArguments(BaseSerializedLayer layerData) { object[] args; args = new object[] { game, layerData.Name, layerData.Transparent, layerData.Visible, new Size(layerData.Width, layerData.Height), tileEngine, new Index( layerData.MdiData.PositionIndexX, layerData.MdiData.PositionIndexY ) }; return(args); }
// Prosessoi ja luo kaikki kartta objektit. private void ProcessMapObjects(BaseSerializedLayer serializedLayer, ILayer layer) { // luo uuden instanssin objekti prosessorista ja prosessoi datan // sekä luo kartta objektit MapObjectProcessor mapObjectProcessor = new MapObjectProcessor(game, map.TileEngine, mapDenecyContainer.MapObjectNamespaces); GameObjectManager gameObjectManager = mapObjectProcessor.Process(serializedLayer as SerializedObjectLayer, layer as Layer <ObjectTile>, map); // lisää kartan objekti managerille uuden kartta objektin map.ObjectManagers.AddManager(gameObjectManager); layer.Components.AddComponent(new GameObjectComponent(game, layer, gameObjectManager)); }
/// <summary> /// Luo uuden layerin parametrinä saatavasta datasta. /// </summary> /// <param name="layerData">Data josta halutaan luoda uusi layeri.</param> /// <param name="tileEngine">Kartan tilemoottori olio.</param> /// <returns>Datasta luotu layeri.</returns> public ILayer MakeNew(BaseSerializedLayer layerData) { object[] args = null; string tileTypeName = tileTypeName = layerData.GetType().Name.Replace("Serialized", "").Replace("Layer", ""); if (!(tileTypeName.Contains("Tile"))) { tileTypeName += "Tile"; } Type tileType = Type.GetType(tileNamespace + tileTypeName); Type layerType = layerData.IsMdiLayer ? typeof(MdiLayer <>) : typeof(Layer <>); layerType = layerType.MakeGenericType(tileType); args = layerData.IsMdiLayer ? GetMdiLayerArguments(layerData) : GetLayerAruments(layerData); // Kutsuu layerin muodostinta parametrillä ja palauttaa sen. return((ILayer)Activator.CreateInstance(layerType, args)); }
// Lisää orderin listaan pairs listaan. Lisätään se vain jos layeri ei ole rule layer. private void AddDrawOrder(List <Tuple <string, int> > drawOrderPairs, BaseSerializedLayer serializedLayer) { drawOrderPairs.Add(new Tuple <string, int>(serializedLayer.Name, serializedLayer.DrawOrder)); }