示例#1
0
        public override void CopyValuesTo(SceneItem target)
        {
            base.CopyValuesTo(target);
            TileGrid tileGrid = target as TileGrid;

            tileGrid.TileSize   = this.TileSize;
            tileGrid.TileCols   = this.TileCols;
            tileGrid.TileRows   = this.TileRows;
            tileGrid.TileLayers = new List <TileLayer>();
            for (int i = 0; i < this.TileLayers.Count; i++)
            {
                TileLayer newLayer = new TileLayer(this.TileCols, this.TileRows);
                newLayer.Parent = tileGrid;
                this.TileLayers[i].CopyValuesTo(newLayer);
                tileGrid.TileLayers.Add(newLayer);
            }
            tileGrid.TileSheet = this.TileSheet;
        }
示例#2
0
        internal SceneItem InstanciateNewItemOfType(SceneItemType type)
        {
            SceneItem item = null;
            switch (type)
            {
                case SceneItemType.AnimatedSprite:
                    item = new AnimatedSprite();
                    AnimatedSprite animatedSprite = item as AnimatedSprite;
                    animatedSprite.Material = SceneManager.GetEmbeddedTileGridMaterial();
                    AnimationInfo newAnim = new AnimationInfo("Counting");
                    newAnim.AnimationFrames.Add(new AnimationFrame(20, "1"));
                    newAnim.AnimationFrames.Add(new AnimationFrame(20, "2"));
                    newAnim.AnimationFrames.Add(new AnimationFrame(20, "3"));
                    newAnim.AnimationFrames.Add(new AnimationFrame(20, "4"));
                    animatedSprite.AddAnimation(newAnim);
                    animatedSprite.PlayAnimation("Counting");
                    break;
                case SceneItemType.ParticleEffect:
                    item = new ParticleEffect();
                    ParticleEffect effect = item as ParticleEffect;
                    IceCream.SceneItems.ParticlesClasses.ParticleType pType = new IceCream.SceneItems.ParticlesClasses.ParticleType();
                    pType.Material = SceneManager.GetEmbeddedParticleMaterial();                    
                    effect.Emitter.ParticleTypes.Add(pType);
                    effect.Name = "New Particle Effect";
                    effect.Play();
                    break;
                case SceneItemType.PostProcessingAnimation:
                    item = new PostProcessAnimation();
                    item.Layer = 1;
                    break;
                case SceneItemType.Sprite:
                    item = new Sprite();
                    Sprite sprite = item as Sprite;
                    sprite.Name = GetNewSpriteName(); ;
                    sprite.Material = SceneManager.GetEmbeddedParticleMaterial();
                    break;
                case SceneItemType.TextItem:
                    item = new TextItem();
                    TextItem text = item as TextItem;
                    text.Name = GetNewTextItemName();
                    text.Font = SceneManager.GetEmbeddedFont("DefaultFont");
                    break;
                case SceneItemType.TileGrid:
                    item = new TileGrid();
                    TileGrid tileGrid = item as TileGrid;
                    tileGrid.Name = "New Tile Grid";
                    tileGrid.Material = SceneManager.GetEmbeddedTileGridMaterial();

                    tileGrid.TileRows = 4;
                    tileGrid.TileCols = 10;
                    tileGrid.TileSize = new Microsoft.Xna.Framework.Point(32, 32);
                    TileLayer newLayer = new TileLayer(tileGrid.TileCols, tileGrid.TileRows);
                    newLayer.Parent = tileGrid;
                    newLayer.Visible = true;
                    newLayer.Name = "Layer 1";
                    for (int tx = 0; tx < tileGrid.TileCols; tx++)
                    {
                        for (int ty = 0; ty < tileGrid.TileRows; ty++)
                        {
                            newLayer.Tiles[tx][ty].Index = 0;
                        }
                    }
                    tileGrid.TileLayers.Add(newLayer);
                    break;       
                case SceneItemType.CompositeEntity:
                    item = new CompositeEntity();
                    CompositeEntity composite = item as CompositeEntity;
                    break;
                default:
                    item = new SceneItem();
                    break;
            }
            return item;
        }
示例#3
0
        private static void WriteTileGrid(XmlNode itemNode, XmlDocument doc, TileGrid tileGrid)
        {
            if (tileGrid.TileSheet != null)
            {                
                String scope;
                if (tileGrid.TileSheet.Scope == AssetScope.Global)
                {
                    scope = "GLOBAL";
                }
                else
                {
                    scope = "LOCAL";
                }
                itemNode.Attributes.Append(doc.CreateAttribute("tileSheetSource")).Value = scope;
                itemNode.Attributes.Append(doc.CreateAttribute("tileSheetRef")).Value = tileGrid.TileSheet.Name;                
            }
            XmlNode _gridSettings = itemNode.AppendChild(doc.CreateElement("TileGridSettings"));
            _gridSettings.AppendChildIfNotNull(WriteProperty("UseTilingSafeBorders", tileGrid, doc));
            _gridSettings.AppendChildIfNotNull(WriteProperty("TileRows", tileGrid, doc));
            _gridSettings.AppendChildIfNotNull(WriteProperty("TileCols", tileGrid, doc));
            _gridSettings.AppendChildIfNotNull(WriteProperty("TileSize", tileGrid, doc));

            XmlNode _layers = _gridSettings.AppendChild(doc.CreateElement("TileLayers"));
            foreach (TileLayer layer in tileGrid.TileLayers)
            {
                XmlNode _layer = _layers.AppendChild(doc.CreateElement("TileLayer"));
                _layer.Attributes.Append(doc.CreateAttribute("Name")).Value = layer.Name;
                _layer.Attributes.Append(doc.CreateAttribute("Order")).Value = "1";
                _layer.Attributes.Append(doc.CreateAttribute("Visible")).Value = layer.Visible.ToString();
                layer.ConstructData();
                _layer.InnerText = layer.TileData;
            }
        }
示例#4
0
 private static void LoadTileGridSettings(XmlNode gridsettings, TileGrid tilegrid)
 {
     tilegrid.UseTilingSafeBorders = bool.Parse(gridsettings.SelectSingleNode("UseTilingSafeBorders").InnerText);
     tilegrid.TileRows = int.Parse(gridsettings.SelectSingleNode("TileRows").InnerText, CultureInfo.InvariantCulture);
     tilegrid.TileCols = int.Parse(gridsettings.SelectSingleNode("TileCols").InnerText, CultureInfo.InvariantCulture);
     SetProperty("TileSize", tilegrid, gridsettings);
     XmlNode _layers = gridsettings.SelectSingleNode("TileLayers");
     if (_layers != null)
     {
         tilegrid.TileLayers = new List<TileLayer>();
         foreach (XmlNode _layerNode in _layers.ChildNodes)
         {
             TileLayer layer = new TileLayer(tilegrid.TileCols, tilegrid.TileRows);
             layer.Name = _layerNode.Attributes["Name"].InnerText;
             layer.Visible = bool.Parse(_layerNode.Attributes["Visible"].InnerText);
             layer.TileData = _layerNode.InnerText;
             layer.Parent = tilegrid;
             tilegrid.TileLayers.Add(layer);
         }
     }
 }
示例#5
0
 private static SceneItem LoadTileGrid(XmlNode _node, SceneBase scene)
 {
     TileGrid tilegrid = new TileGrid();
     LoadBaseSceneItem(_node, tilegrid);                        
     XmlNode gridsettings = _node.SelectSingleNode("TileGridSettings");            
     if (gridsettings != null)
     {
         LoadTileGridSettings(gridsettings, tilegrid);
     }
     tilegrid.TileSheet = LoadTileSheetFromNode(_node, scene, tilegrid);
     if (tilegrid.TileSheet == null)
     {
         tilegrid.Material = GetMaterialAssetFromNode(_node, scene);
     }
     return tilegrid;
 }