Beispiel #1
0
 public void CopyValuesTo(AnimationInfo target, AnimatedSprite newParent)
 {
     target.Parent = newParent;
     target.Name = Name;
     target.IsPaused = this.IsPaused;
     target.IsStopped = this.IsStopped;
     target.LoopMax = this.LoopMax;
     target.AutoPlay = this.AutoPlay;
     target.HideWhenStopped = this.HideWhenStopped;
     // copy frames (it's a struct, so it's copied by value)
     target.AnimationFrames.Clear();
     for (int i = 0; i < this.AnimationFrames.Count; i++)
     {
         target.AnimationFrames.Add(this.AnimationFrames[i]);
     }
     target.Reset();
 }
Beispiel #2
0
 private static void WriteAnimatedSpriteItemBase(XmlNode itemNode, XmlDocument _doc, AnimatedSprite item)
 {
     XmlNode _animList = itemNode.AppendChild(_doc.CreateElement("Animations"));
     foreach (AnimationInfo info in item.Animations)
     {
         WriteAnimationInfo(_doc, _animList, info);
     }
     WriteIAnimationDirectorProperties(_doc, itemNode, item as IAnimationDirector);
 }
Beispiel #3
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;
        }
Beispiel #4
0
 private static AnimatedSprite LoadAnimatedSprite(XmlNode _node, SceneBase scene)
 {
     try
     {
         TraceLogger.TraceInfo("Beginning Serialize AnimatedSprite");
         AnimatedSprite _sprite = new AnimatedSprite();
         LoadBaseSceneItem(_node, _sprite);
         SetIAnimationDirectorProperties(_node, _sprite);
         _sprite.Material = GetMaterialAssetFromNode(_node, scene);
         TraceLogger.TraceInfo("Loading AnimationInfo Data");
         XmlNode _anList = _node.SelectSingleNode("Animations");
         if (_anList != null)
         {
             foreach (XmlNode item in _anList.ChildNodes)
             {
                 _sprite.AddAnimation(GetAnimationInfoFromNode(item));
             }
         }
         TraceLogger.TraceInfo("Ending Serialize AnimatedSprite");
         return _sprite;
     }
     catch (Exception err)
     {
         string errMessage = "Error Occurred In LoadAnimatedSprite";
         errMessage += Environment.NewLine + _node.InnerText;
         TraceLogger.TraceError(errMessage);
         throw new InvalidOperationException(errMessage, err);
     }
 }