public override void CopyValuesTo(SceneItem target) { base.CopyValuesTo(target); TextItem text = target as TextItem; text.Font = this.Font; text.Text = this.Text; text.AutoCenterPivot = this.AutoCenterPivot; text.Shadow = this.Shadow; text.Tint = this.Tint; }
private static void WriteTextItem(XmlNode itemNode, XmlDocument doc, TextItem text) { string _source = GetAssetSource(text.Font); itemNode.Attributes.Append(doc.CreateAttribute("fontSource")).InnerText = _source; itemNode.Attributes.Append(doc.CreateAttribute("fontRef")).InnerText = text.Font.Name; itemNode.AppendChildIfNotNull(WriteProperty("Text", text, doc)); itemNode.AppendChildIfNotNull(WriteProperty("AutoCenterPivot", text, doc)); itemNode.AppendChildIfNotNull(WriteProperty("Scale", text, doc)); itemNode.AppendChildIfNotNull(WriteProperty("Tint", text, doc)); itemNode.AppendChildIfNotNull(WriteProperty("Shadow", text, doc)); }
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; }
private static TextItem LoadTextItem(XmlNode node, SceneBase scene) { TraceLogger.TraceInfo("Loading TextItem"); TextItem _textItem = new TextItem(); LoadBaseSceneItem(node, _textItem); _textItem.Font = LoadFontFromNode(node, scene); SetProperty("Text", _textItem, node); SetProperty("AutoCenterPivot", _textItem, node); SetProperty("Shadow", _textItem, node); SetProperty("Tint", _textItem, node); return _textItem; }