public void visible_property_sets_all_spriterobjects() { var soc = new SpriterObjectCollection {SpriterEntities = new Dictionary<string, SpriterObject> { { "test", SpriterObjectTest.GetSimpleSpriterObject() }, { "test2", SpriterObjectTest.GetSimpleSpriterObject() } }}; Assert.AreNotSame(soc.SpriterEntities["test"], soc.SpriterEntities["test2"]); Assert.AreEqual(true, soc.SpriterEntities["test"].Visible); Assert.AreEqual(true, soc.SpriterEntities["test2"].Visible); soc.Visible = false; Assert.AreEqual(false, soc.SpriterEntities["test"].Visible); Assert.AreEqual(false, soc.SpriterEntities["test2"].Visible); }
public SpriterObjectCollection Clone() { var soc = new SpriterObjectCollection(); if (SpriterEntities == null) { return soc; } soc.SpriterEntities = new Dictionary<string, SpriterObject>(); foreach (var spriterEntity in SpriterEntities) { if (spriterEntity.Value != null) { var so = spriterEntity.Value.Clone(); so.AttachTo(soc, false); soc.SpriterEntities.Add(spriterEntity.Key, so); } } return soc; }
public static void UnloadStaticContent() { if (LoadedContentManagers.Count != 0) { LoadedContentManagers.RemoveAt(0); mRegisteredUnloads.RemoveAt(0); } if (LoadedContentManagers.Count == 0) { if (BirdShapeCollection != null) { BirdShapeCollection.RemoveFromManagers(ContentManagerName != "Global"); BirdShapeCollection= null; } if (SpriterObjectCollectionFile != null) { SpriterObjectCollectionFile.Destroy(); SpriterObjectCollectionFile= null; } if (redball != null) { redball= null; } } }
public static void LoadStaticContent(string contentManagerName) { if (string.IsNullOrEmpty(contentManagerName)) { throw new ArgumentException("contentManagerName cannot be empty or null"); } ContentManagerName = contentManagerName; #if DEBUG if (contentManagerName == FlatRedBallServices.GlobalContentManager) { HasBeenLoadedWithGlobalContentManager = true; } else if (HasBeenLoadedWithGlobalContentManager) { throw new Exception("This type has been loaded with a Global content manager, then loaded with a non-global. This can lead to a lot of bugs"); } #endif bool registerUnload = false; if (LoadedContentManagers.Contains(contentManagerName) == false) { LoadedContentManagers.Add(contentManagerName); lock (mLockObject) { if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BirdStaticUnload", UnloadStaticContent); mRegisteredUnloads.Add(ContentManagerName); } } if (!FlatRedBallServices.IsLoaded<FlatRedBall.Math.Geometry.ShapeCollection>(@"content/entities/bird/birdshapecollection.shcx", ContentManagerName)) { registerUnload = true; } BirdShapeCollection = FlatRedBallServices.Load<FlatRedBall.Math.Geometry.ShapeCollection>(@"content/entities/bird/birdshapecollection.shcx", ContentManagerName); if (!FlatRedBallServices.IsLoaded<FlatRedBall_Spriter.SpriterObjectCollection>(@"content/entities/bird/spriterobjectcollectionfile.scml", ContentManagerName)) { registerUnload = true; } SpriterObjectCollectionFile = SpriterObjectSave.FromFile("content/entities/bird/spriterobjectcollectionfile.scml").ToRuntime(); if (!FlatRedBallServices.IsLoaded<Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/bird/redball.png", ContentManagerName)) { registerUnload = true; } redball = FlatRedBallServices.Load<Microsoft.Xna.Framework.Graphics.Texture2D>(@"content/entities/bird/redball.png", ContentManagerName); } if (registerUnload && ContentManagerName != FlatRedBallServices.GlobalContentManager) { lock (mLockObject) { if (!mRegisteredUnloads.Contains(ContentManagerName) && ContentManagerName != FlatRedBallServices.GlobalContentManager) { FlatRedBallServices.GetContentManagerByName(ContentManagerName).AddUnloadMethod("BirdStaticUnload", UnloadStaticContent); mRegisteredUnloads.Add(ContentManagerName); } } } CustomLoadStaticContent(contentManagerName); }