/// <summary> /// 调用XNA资源卸载函数(禁止重载) /// </summary> protected sealed override void UnloadContent() { if (process != null) { process.End(); } if (useXNAListener) { xna_listener.UnloadContent(this); } XNA_UnloadContent(); if (content != null) { content.Unload(); } }
public Scene7(Game game, ContentManager content, GameComponentCollection components) : base(game, content, components) { Components = components; Content = content; colorList = GameTools.elementColors(colorList); gameStorage = new GameData("lobby"); Content.Unload(); }
/// <summary> /// Method to reset map to a new map /// <param name="contentMgr">Content manager</param> /// </summary> public static void clearMap(ContentManager contentMgr) { content.Clear(); contentMgr.Unload(); skyBoxTexture = null; mapRadius = 200000; skyBoxRepeat = 10; skyBoxDrawer = null; }
public static async Task CreateXML(Mainmap _map, Camera _camera, ContentManager _content) { CreateMix(_content); CreateWalls(_content, "wall1"); CreateWalls(_content, "wall2"); CreateWalls(_content, "wall3"); CreateFloor(_content, "floor1"); CreateFloor(_content, "floor2"); CreateFloor(_content, "floor3"); CreateWalls(_content, "wall4"); _content.Unload(); CreateActor(_map, _content, _camera, "bat"); CreateActor(_map, _content, _camera, "bow"); CreateActor(_map, _content, _camera, "croc"); CreateActor(_map, _content, _camera, "Cyclops"); CreateActor(_map, _content, _camera, "dead"); CreateActor(_map, _content, _camera, "devil"); CreateActor(_map, _content, _camera, "dragon"); CreateActor(_map, _content, _camera, "fairy"); CreateActor(_map, _content, _camera, "Ghost"); CreateActor(_map, _content, _camera, "gnome"); CreateActor(_map, _content, _camera, "guard"); CreateActor(_map, _content, _camera, "Luigi"); CreateActor(_map, _content, _camera, "mage"); CreateActor(_map, _content, _camera, "monk"); CreateActor(_map, _content, _camera, "mouse"); CreateActor(_map, _content, _camera, "Mummy"); CreateActor(_map, _content, _camera, "Necro"); CreateActor(_map, _content, _camera, "NPC1"); CreateActor(_map, _content, _camera, "player"); CreateActor(_map, _content, _camera, "princess"); CreateActor(_map, _content, _camera, "rat"); CreateActor(_map, _content, _camera, "skeleton"); CreateActor(_map, _content, _camera, "skull"); CreateActor(_map, _content, _camera, "spider"); CreateActor(_map, _content, _camera, "thief"); CreateActor(_map, _content, _camera, "vamp"); CreateActor(_map, _content, _camera, "wolf"); CreateActor(_map, _content, _camera, "xmas"); CreateActor(_map, _content, _camera, "Zombie"); _content.Unload(); return; }
public void instance(string[] args) { try { Form form = new Form(); GraphicsDeviceService gds = GraphicsDeviceService.AddRef(form.Handle, form.ClientSize.Width, form.ClientSize.Height); ServiceContainer services = new ServiceContainer(); services.AddService<IGraphicsDeviceService>(gds); var content = new ContentManager(services); foreach (string p in args) { Console.WriteLine(System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + " " + p); if (File.Exists(p)) { if (Path.GetExtension(p).Equals(".xnb")) { ConvertToPng(content, p); } } else { Console.WriteLine("Invalid file path or file"); } } foreach (string f in filesToDelete) { File.Delete(f); } content.Unload(); } catch (Exception e) { Console.WriteLine(e.Message); } }
protected override void UnloadContent() { Content.Unload(); }
private void UnloadContent(ContentManager Content) { Content.Unload(); }
public override void LoadContent() { mScene = new Scene(); mActorMan = new ActorManager(mViews); GameResources.ActorManager = mActorMan; LevelManifest manifest; using (ContentManager manifestLoader = new ContentManager(SharedResources.Game.Services, "Content")) { manifest = manifestLoader.Load<LevelManifest>(mRequest.LevelName); manifestLoader.Unload(); // a LevelManifest does not use any Disposable resources, so this is ok. } // The IScreenHoncho tells this gameplay screen how to set up the PlayerViews and DrawSegments required to play this level IScreenHoncho screenHoncho = Activator.CreateInstance(Type.GetType(manifest.ScreenHonchoTypeName)) as IScreenHoncho; mViewContentLoader = new ContentManager(SharedResources.Game.Services, "Content"); foreach (PlayerInfo player in GameResources.PlaySession.Players) { mViews.Add(PlayerViewFactory.Create(player, mRequest.CharacterSelections[player.PlayerId], screenHoncho, mViewContentLoader)); } // Determine screen layout and create DrawSegments if (screenHoncho.PlayersUseSeparateViewports) { switch (GameResources.PlaySession.LocalPlayers.Count) { case 1: mScreenLayout = ViewportLayout.FullScreen; break; case 2: mScreenLayout = GameOptions.PreferHorizontalSplit ? ViewportLayout.HorizontalSplit : ViewportLayout.VerticalSplit; break; case 3: case 4: mScreenLayout = ViewportLayout.FourWaySplit; break; default: throw new InvalidOperationException("Unsupported number of local players."); } foreach (int playerId in GameResources.PlaySession.LocalPlayers.Keys) { HumanView playerView = mViews.Single(v => v.PlayerId == playerId) as HumanView; ICameraProvider cameraPlayerView = playerView as ICameraProvider; if (cameraPlayerView == null) throw new LevelManifestException("When IScreenHoncho.PlayersUseSeparateViewports is true, HumanViews must implement the ICameraProvider interface."); DrawSegment ds = new DrawSegment(mScene, cameraPlayerView.Camera); mDrawSegments.Add(ds); playerView.DrawSegment = ds; } } else { mScreenLayout = ViewportLayout.FullScreen; DrawSegment ds = new DrawSegment(mScene); mDrawSegments.Add(ds); foreach (int playerId in GameResources.PlaySession.LocalPlayers.Keys) { HumanView playerView = mViews.Single(v => v.PlayerId == playerId) as HumanView; playerView.DrawSegment = ds; } } // TODO: P3: Make sure all non-local players are connected mScene.Load(); mActorMan.LoadContent(manifest); // TODO: P3: Make sure all remote clients have loaded their game. foreach (PlayerView view in mViews) { view.Load(); } GameResources.LoadNewLevelDelegate = LoadNewLevel; SharedResources.Game.GraphicsDevice.DeviceLost += DeviceLostHandler; SharedResources.Game.GraphicsDevice.DeviceResetting += DeviceResettingHandler; SharedResources.Game.GraphicsDevice.DeviceReset += DeviceResetHandler; }
private static void _AddActivity(ContentManager _content, ActorView actor, string character, string action, Backend.Activity activity) { if (System.IO.File.Exists(".\\content\\" + character + "-" + action + ".xnb")) { try { Texture2D texture = _content.Load<Texture2D>(character + "-" + action); int size = texture.Height / 8; int cols = texture.Width / size; actor.width = size; actor.height = size; int diff = 0; if (size < 128) { diff = 128 - size; } // add offset / crop actor.Add(activity, Backend.Direction.DownRight, character + "-" + action, new Backend.Coords(size * 0, size * 0), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); actor.Add(activity, Backend.Direction.UpRight, character + "-" + action, new Backend.Coords(size * 0, size * 1), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok actor.Add(activity, Backend.Direction.Right, character + "-" + action, new Backend.Coords(size * 0, size * 2), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK actor.Add(activity, Backend.Direction.Up, character + "-" + action, new Backend.Coords(size * 0, size * 3), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok actor.Add(activity, Backend.Direction.DownLeft, character + "-" + action, new Backend.Coords(size * 0, size * 4), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // Ok actor.Add(activity, Backend.Direction.Down, character + "-" + action, new Backend.Coords(size * 0, size * 5), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); actor.Add(activity, Backend.Direction.Left, character + "-" + action, new Backend.Coords(size * 0, size * 6), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); // OK actor.Add(activity, Backend.Direction.UpLeft, character + "-" + action, new Backend.Coords(size * 0, size * 7), cols, 1, new Backend.Coords(diff / 2, diff / 2), new Backend.Coords(diff - diff / 2, diff - diff / 2)); } catch { } _content.Unload(); } }
void LoadSprite2D(string fileName, Sprite sprite) { Cursor = Cursors.WaitCursor; contentBuilder = new ContentBuilder(); contentManager = new ContentManager(this.Services, contentBuilder.OutputDirectory); contentManager.Unload(); contentBuilder.Clear(); contentBuilder.Add(fileName, fileName.Substring(fileName.LastIndexOf(@"\") + 1, fileName.Length - fileName.LastIndexOf(@"\") - 5), null, null); string buildError = contentBuilder.Build(); if (string.IsNullOrEmpty(buildError)) { sprite.SpriteTexture = contentManager.Load<Texture2D>(fileName.Substring(fileName.LastIndexOf(@"\") + 1, fileName.Length - fileName.LastIndexOf(@"\") - 5)); } Cursor = Cursors.Default; }
public static void Init(ContentManager cont) { ContentManager Content = new ContentManager(cont.ServiceProvider, cont.RootDirectory); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c01, new PlayerPalette.PaletteData("Pale", Content.Load<Texture2D>("Shaders/Palettes/Skin/01"))); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c02, new PlayerPalette.PaletteData("White", Content.Load<Texture2D>("Shaders/Palettes/Skin/02"))); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c03, new PlayerPalette.PaletteData("Tanned", Content.Load<Texture2D>("Shaders/Palettes/Skin/03"))); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c04, new PlayerPalette.PaletteData("Dark", Content.Load<Texture2D>("Shaders/Palettes/Skin/04"))); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c05, new PlayerPalette.PaletteData("Dark", Content.Load<Texture2D>("Shaders/Palettes/Skin/05"))); PlayerPalette.denSkinPalettes.Add(PlayerPalette.SkinColors.c06, new PlayerPalette.PaletteData("Yellow", Content.Load<Texture2D>("Shaders/Palettes/Skin/06"))); for (byte i = 0; i < 30; i += 1) { PlayerPalette.PonchoColors en = (PlayerPalette.PonchoColors)i; PlayerPalette.denPonchoPalettes.Add(en, new PlayerPalette.PaletteData(en.ToString(), Content.Load<Texture2D>("Shaders/Palettes/Poncho/" + en.ToString()))); PlayerPalette.denShirtPalettes.Add(en, new PlayerPalette.PaletteData(en.ToString(), Content.Load<Texture2D>("Shaders/Palettes/Shirt/" + en.ToString()))); PlayerPalette.denHairPalettes.Add(en, new PlayerPalette.PaletteData(en.ToString(), Content.Load<Texture2D>("Shaders/Palettes/Hair/" + en.ToString()))); PlayerPalette.denPantPalettes.Add(en, new PlayerPalette.PaletteData(en.ToString(), Content.Load<Texture2D>("Shaders/Palettes/Pants/" + en.ToString()))); } PlayerPalette.denShoePalettes.Add(PlayerPalette.ShoeColors.Brown, new PlayerPalette.PaletteData("Brown", Content.Load<Texture2D>("Shaders/Palettes/Shoes/brown"))); PlayerPalette.denxClothingSets.Add(PlayerPalette.ClothingSet.SetNames.TypeA, new PlayerPalette.ClothingSet(PlayerPalette.SkinColors.c02, PlayerPalette.PonchoColors.red01, PlayerPalette.PonchoColors.black01, PlayerPalette.PonchoColors.teal01)); PlayerPalette.denxClothingSets.Add(PlayerPalette.ClothingSet.SetNames.TypeB, new PlayerPalette.ClothingSet(PlayerPalette.SkinColors.c05, PlayerPalette.PonchoColors.blue01, PlayerPalette.PonchoColors.green01, PlayerPalette.PonchoColors.red01)); PlayerPalette.denxClothingSets.Add(PlayerPalette.ClothingSet.SetNames.TypeC, new PlayerPalette.ClothingSet(PlayerPalette.SkinColors.c06, PlayerPalette.PonchoColors.purple01, PlayerPalette.PonchoColors.black01, PlayerPalette.PonchoColors.teal01)); Content.Unload(); foreach (PlayerPalette.SkinColors en2 in PlayerPalette.denSkinPalettes.Keys) { PlayerPalette.lenSkinsAsList.Add(en2); } foreach (PlayerPalette.PonchoColors en3 in PlayerPalette.denPonchoPalettes.Keys) { PlayerPalette.lenPonchosAsList.Add(en3); } foreach (PlayerPalette.ShoeColors en4 in PlayerPalette.denShoePalettes.Keys) { PlayerPalette.lenShoesAsList.Add(en4); } foreach (PlayerPalette.ClothingSet.SetNames en5 in PlayerPalette.denxClothingSets.Keys) { PlayerPalette.lenSetsAsList.Add(en5); } }
public void UnloadContent(ContentManager content) { content.Unload(); }
/// <summary> /// Unloads graphics content for this screen. /// </summary> public override void UnloadContent() { content.Unload(); }