/// <summary> /// /// </summary> /// <param name="disposing"></param> protected virtual void Dispose(bool disposing) { if (disposing) { PresentParams = null; } if (Direct3D != null) { Direct3D.Dispose(); Direct3D = null; } if (Sprite != null) { Sprite.Dispose(); Sprite = null; } if (Device != null) { Device.Dispose(); Device = null; } if (d3dFont != null) { d3dFont.Dispose(); d3dFont = null; } }
public void OnDeviceDestroyed(object sender, EventArgs e) { if (_sprite != null && !_sprite.Disposed) { _sprite.Dispose(); } if (_texture != null && !_texture.Disposed) { _texture.Dispose(); _texture = null; } }
/// <summary> /// Clean up. /// </summary> public void Dispose() { if (textSprite != null) { textSprite.Dispose(); textSprite = null; } if (font != null) { font.Dispose(); font = null; } }
/// <summary> /// Dispose /// </summary> public new void Dispose() { TerminateMessage(); InGame.Temp.IsMessageWindowShowing = false; if (inputNumberWindow != null) { inputNumberWindow.Dispose(); } if (faceset != null) { faceset.Dispose(); } base.Dispose(); }
public void Spawn() { float lastX = 0; Sprite spAsteroid = new Sprite(_gm.LoadImage(asteroidName)); spAsteroid.AutoDispose = false; while (_spawner.IsRunning) { SpriteAsteroid asteroid = new SpriteAsteroid(spAsteroid); do { asteroid.Position.X = RandomManager.Instance.Next(100, (int)World.Instance.WorldSize.X - 100); } while (lastX > asteroid.Position.X && lastX + 100f < asteroid.Position.X); lastX = asteroid.Position.X; asteroid.Position.Y = -200; asteroid.Velocity.Y = (float)(RandomManager.Instance.Next(500, 4500) / 1000f); asteroid.Life = (float)(RandomManager.Instance.Next(150, 800) / 100f); //asteroid.Life = 1000f; asteroid.Type = ObjectType.ENEMY; asteroid.EventDestroyed += EnemyDestoryed; player.DebugObject = asteroid; SceneManager.Add(asteroid, 5); // Wait to spawn another enemy int waitTime = RandomManager.Instance.Next(1000, 5000); ThreadManager.Sleep(waitTime, _spawner); } spAsteroid.Dispose(); }
protected override void OnPaint(PaintEventArgs pe) { if ((this.m_FormRenderFrame.Device != null) && (this.m_FormRenderFrame.Texture != null) && (this.Visible) && (this.WindowState != FormWindowState.Minimized)) { try { this.m_FormRenderFrame.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1F, 0); SurfaceDescription surfaceDescription = this.m_FormRenderFrame.Texture.GetLevelDescription(0); Size size = new Size(surfaceDescription.Width, surfaceDescription.Height); Size targetSize = new Size(Math.Max(1, (Int32)((Single)size.Width * this.m_ZoomFactor)), Math.Max(1, (Int32)((Single)size.Height * this.m_ZoomFactor))); if (this.Size != targetSize) { this.Size = targetSize; } this.m_FormRenderFrame.Device.BeginScene(); Sprite sprite = new Sprite(this.m_FormRenderFrame.Device); sprite.Begin(SpriteFlags.None); sprite.Draw2D(this.m_FormRenderFrame.Texture, new Rectangle(new Point(0, 0), size), new SizeF(((Single)size.Width * this.m_ZoomFactor), ((Single)size.Height * this.m_ZoomFactor)), new PointF(0F, 0F), Color.FromArgb(255, 255, 255, 255)); sprite.End(); sprite.Dispose(); this.m_FormRenderFrame.Device.EndScene(); this.m_FormRenderFrame.Device.Present(); } catch { } } }
public void Run() { app.SetMouseCursorVisible(false); SetMousePointerInTheMiddleOfTheScreen(); // Start the game loop while (app.IsOpen) { // Process events app.DispatchEvents(); if (!Pause) { SetMousePointerInTheMiddleOfTheScreen(); } game.Action(); DrawBackground(app); DrawBorders(app); DrawBricks(app); DrawPad(app); DrawBall(app); DrawTexts(app); // Update the window app.Display(); } font?.Dispose(); background?.Dispose(); }
/// <summary> /// RenderableObject abstract member (needed) /// OBS: Worker thread (don't update UI directly from this thread) /// </summary> public override void Dispose() { isInitialized = false; Save(); base.Dispose(); if (CornerTexture != null) { CornerTexture.Dispose(); CornerTexture = null; } if (Sprite != null) { Sprite.Dispose(); Sprite = null; } if (menu != null) { menu.Dispose(); menu = null; } }
public void Draw() { if (IsGameOpen()) { stateManager.IsDrawing = true; deviceManager.Device.Clear(ClearFlags.Target, Color.RoyalBlue, 0, 0); deviceManager.Device.BeginScene(); Sprite s = new Sprite(deviceManager.Device); s.Begin(SpriteFlags.AlphaBlend); // Draw Current Map if (game != null) { game.Draw(s); } s.End(); s.Dispose(); deviceManager.Device.EndScene(); if (IsGameOpen()) { deviceManager.Device.Present(); } stateManager.IsDrawing = false; } }
/// <summary> /// Disposes of the resources used by this FAR3Archive instance. /// <param name="Disposed">Was this resource disposed explicitly?</param> /// </summary> protected virtual void Dispose(bool Disposed) { if (Disposed) { if (CompiledTexture != null) { CompiledTexture.Dispose(); } foreach (DrawGroupSprite Sprite in m_Sprites) { if (Sprite != null) { Sprite.Dispose(); } } // Prevent the finalizer from calling ~DGRPImg, since the object is already disposed at this point. GC.SuppressFinalize(this); } else { m_Logger.Error("DGRPImg not explicitly disposed!"); } }
private void FreeResources() { if (d3dFont != null) { d3dFont.Dispose(); d3dFont = null; } if (sprite != null) { sprite.Dispose(); sprite = null; } if (device != null) { device.Dispose(); device = null; } if (gdiFont != null) { gdiFont.Dispose(); gdiFont = null; } }
private static void OnUnload(object sender, UnloadEventArgs unloadEventArgs) { try { _unloaded = true; if (_sprite != null && !_sprite.IsDisposed) { _sprite.Dispose(); } foreach (var font in Fonts.Where(font => font.Value != null && !font.Value.IsDisposed)) { font.Value.Dispose(); } foreach (var line in Lines.Where(line => line != null && !line.IsDisposed)) { line.Dispose(); } Drawing.OnPreReset -= OnDrawingPreReset; Drawing.OnPostReset -= OnDrawingPostReset; } catch (Exception ex) { Global.Logger.AddItem(new LogItem(ex)); } }
public void Dispose() { if (_graphic != null) { _graphic.Dispose(); } }
public void Dispose() { if (m_font != null) { m_font.Dispose(); } if (m_sprite != null) { m_sprite.Dispose(); } if (m_nameRect != null) { m_nameRect.Clear(); } if (m_cityTexture != null) { m_cityTexture.Dispose(); } if (m_elseTexture != null) { m_elseTexture.Dispose(); } m_font = null; m_sprite = null; }
/// <summary> Disposes of the button </summary> public void Dispose() { _Sprite.Dispose(); OnButtonPress = null; OnButtonRelease = null; TouchManager.Instance.RemoveTouchListener(this); }
/// <summary> /// This event function will be called fired after the Direct3D device has /// entered a lost state and before Device.Reset() is called. Resources created /// in the OnResetDevice callback should be released here, which generally includes all /// Pool.Default resources. See the "Lost Devices" section of the documentation for /// information about lost devices. /// </summary> private void OnLostDevice(object sender, EventArgs e) { if (firstFont != null) { firstFont.OnLostDevice(); } if (secondFont != null) { secondFont.OnLostDevice(); } if (batchSprite != null) { batchSprite.OnLostDevice(); } if (mesh3DText != null) { mesh3DText.Dispose(); mesh3DText = null; } if (textSprite != null) { textSprite.Dispose(); textSprite = null; } }
/// <summary> /// Unload contents /// </summary> public override void UnloadContent() { PixelCollision.Dispose(); if (Logo != null) { Logo.Dispose(); } if (Star != null) { Star.Dispose(); } if (Font != null) { Font.Dispose(); } if (Sprite != null) { Sprite.Dispose(); } Sprite = null; }
/// <summary> /// 内部objectを破棄します。 /// </summary> public void Dispose() { foreach (Figure fig in FigureList) { fig.Dispose(); } if (line != null) { line.Dispose(); } if (sprite != null) { sprite.Dispose(); } if (ztex_zbuf != null) { ztex_zbuf.Dispose(); } if (dev_zbuf != null) { dev_zbuf.Dispose(); } if (dev_surface != null) { dev_surface.Dispose(); } if (effect != null) { effect.Dispose(); } if (device != null) { device.Dispose(); } }
private void FormOverlay_FormClosing(object sender, FormClosingEventArgs e) { IsRunning = false; renderThread.Abort(); if (!device.Disposed) { device.Dispose(); } if (!sprite.Disposed) { sprite.Dispose(); } if (!smallFont.Disposed) { smallFont.Dispose(); } if (!largeFont.Disposed) { largeFont.Dispose(); } if (!line.Disposed) { line.Dispose(); } Game.CloseProcess(); }
//Rendering function public void frame(RenderWindow window, GameObject[,] objArray, int[] numObj) { window.Clear(clearColor); setWindowDimension(window); Vector2f halfSize = (Vector2f)screenSize / 2; Vector2f halfSpriteSize; for (int i = 0; i < numObj.Length; i++) { for (int j = 0; j < numObj[i]; j++) { if (objArray[i, j].Visible && objArray[i, j].ImageExists) { Sprite sprite = new Sprite(); sprite.Texture = new Texture(objArray[i, j].Img); sprite.Scale = multiplyVector(objArray[i, j].scale, resolutionScale); halfSpriteSize = multiplyVector((Vector2f)sprite.Texture.Size / 2, objArray[i, j].scale); sprite.Position = multiplyVector(objArray[i, j].position - camera.position - halfSpriteSize, resolutionScale) + halfSize; window.Draw(sprite); sprite.Texture.Dispose(); sprite.Dispose(); } } } window.Display(); }
private void MoveGhostsFromTreeToTree(Vector2D start, Vector2D end, bool dragDone, Tree startTree) { if (start.DistanceTo(startTree.DrawArea.Center) > 0.04f) { return; } var targetTree = FindNearestTree(startTree, end); arrow.IsVisible = false; if (startTree.CurrentTeam != MainMenu.PlayerTeam || targetTree == startTree || MainMenu.State != GameState.Game || startTree.Center.DistanceTo(end) < 0.05f) { return; } arrow.Dispose(); arrow = Effects.CreateArrow(startTree.Center, targetTree.Center); arrow.Color = startTree.CurrentTeam.ToColor(); arrow.IsVisible = !dragDone; if ((dragDone && Time.Total - lastWaveSend > TimeBetweenWaves || !dragDone && Time.CheckEvery(TimeBetweenWaves)) && startTree.NumberOfGhosts >= 1) { lastWaveSend = Time.Total; SendWave(startTree, targetTree); } }
private static void OnUnload(object sender, Entry.UnloadEventArgs unloadEventArgs) { try { _unloaded = true; if (_sprite != null && !_sprite.IsDisposed) { _sprite.Dispose(); } foreach (var font in Fonts.Where(font => font.Value != null && !font.Value.IsDisposed)) { font.Value.Dispose(); } foreach (var line in Lines.Where(line => line != null && !line.IsDisposed)) { line.Dispose(); } Drawing.OnPreReset -= OnDrawingPreReset; Drawing.OnPostReset -= OnDrawingPostReset; } catch (Exception e) { Console.WriteLine(@"An error occurred: '{0}'", e); } }
/// <summary> /// Destroy any resources and clear the caches /// </summary> public void OnDestroyDevice() { foreach (FontNode fn in fontCache) { if (fn.Font != null) { fn.Font.Dispose(); } } foreach (TextureNode tn in textureCache) { if (tn.Texture != null) { tn.Texture.Dispose(); } } if (dialogSprite != null) { dialogSprite.Dispose(); dialogSprite = null; } if (dialogStateBlock != null) { dialogStateBlock.Dispose(); dialogStateBlock = null; } }
/// <summary> /// Unload contents /// </summary> public override void UnloadContent() { if (Font != null) { Font.Dispose(); } Font = null; if (Shader != null) { Shader.Dispose(); } Shader = null; if (Sprite != null) { Sprite.Dispose(); } Sprite = null; if (Trefoil != null) { Trefoil.Dispose(); } Trefoil = null; if (Torus != null) { Torus.Dispose(); } Torus = null; }
private void DrawScreen() { Color[,] colors = new Color[64, 32]; for (int x = 0; x < 64; x++) { for (int y = 0; y < 32; y++) { colors[x, y] = emu.screen[y * 64 + x] ? Color.White : Color.Transparent; } } Image img = new Image(colors); Texture tex = new Texture(img); Sprite s = new Sprite(tex) { Scale = new Vector2f(10, 10), Color = new Color(255, 255, 255, 255) }; Draw(s); s.Dispose(); tex.Dispose(); img.Dispose(); }
private void frmMain_Load(object sender, EventArgs e) { txtFile.Text = Application.StartupPath + Path.DirectorySeparatorChar + "input" + Path.DirectorySeparatorChar; txtOutputPath.Text = Application.StartupPath + Path.DirectorySeparatorChar + "output" + Path.DirectorySeparatorChar; Console.WriteLine("Initializing preview window render thread..."); RenderThread = new Thread(() => { Console.WriteLine("Initializing SFML preview window..."); Render = new RenderWindow(new VideoMode((uint)Size.Width, (uint)Size.Height), "Crestelia - Preview", Styles.Titlebar) { Position = new Vector2i(Location.X + Size.Width, Location.Y) }; Sprite sprite = new Sprite(); Console.WriteLine("Rendering SFML preview window..."); while (Render != null && Render.IsOpen && !IsClosed) { Render.Position = new Vector2i(Location.X + Size.Width - 12, Location.Y); Render.Clear(Color.Black); if (Resource != null && Resource.Texture != null && Resource.Image != null) { try { var cols = ((int)numericX.Value >= 1) ? (int)numericX.Value : 1; var rows = ((int)numericY.Value >= 1) ? (int)numericY.Value : 1; sprite.Texture = Resource.Texture; sprite.TextureRect = new IntRect(0, 0, (int)Resource.Image.Size.X / cols, (int)Resource.Image.Size.Y / rows); sprite.Position = new Vector2f(0, 0); Render.Draw(sprite); } catch { } } Render.Display(); Render.DispatchEvents(); Application.DoEvents(); } sprite?.Dispose(); sprite = null; Console.WriteLine("Disposing SFML preview window..."); Render.Dispose(); Render = null; }); Console.WriteLine("Starting preview window render thread..."); RenderThread.Start(); }
/// <summary> /// 内部objectを破棄します。 /// </summary> public new void Dispose() { if (tra_sprite != null) { tra_sprite.Dispose(); } base.Dispose(); }
/// <summary> /// Dispose the Direct3D sprite. /// </summary> protected virtual void DisposeSprite() { if (textSprite != null) { textSprite.Dispose(); textSprite = null; } }
void Dispose(bool isDisposing) { if (isDisposing) { fontSprite.Dispose(); font.Dispose(); } }
/// <summary> /// This event function will be called fired after the Direct3D device has /// entered a lost state and before Device.Reset() is called. Resources created /// in the OnResetDevice callback should be released here, which generally includes all /// Pool.Default resources. See the "Lost Devices" section of the documentation for /// information about lost devices. /// </summary> private void OnLostDevice(object sender, EventArgs e) { if (textSprite != null) { textSprite.Dispose(); textSprite = null; } }
/// <summary> /// Draw the player information. /// </summary> /// <param name="device">The direct3D device.</param> private void DrawInfo(Device device) { try { int deviceWidth = device.Viewport.Width; int deviceHeight = device.Viewport.Height; long frameCounter = _memory.GetFrameCount(); if (frameCounter > 10) { if (string.IsNullOrEmpty(_playerOneName)) { _playerOneName = _memory.GetCharacter(1); } if (string.IsNullOrEmpty(_playerTwoName)) { _playerTwoName = _memory.GetCharacter(2); } _sprite = new Sprite(_device); _sprite.Begin(SpriteFlags.AlphaBlend); _sprite.Transform = Matrix.Scaling(new Vector3(_fontSize / (12 / 2), _fontSize / (7 / 2), 0)); _spritePosition = new Vector2( _fontSize, (deviceHeight / _fontSize) * 7); _sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White); _spritePosition = new Vector2( deviceWidth - (_fontSize * 13), (deviceHeight / _fontSize) * 7); _sprite.Draw(_background, new Vector3(1, 1, 0), new Vector3(_spritePosition, -1), Color.White); _sprite.End(); _sprite.Dispose(); _sprite = new Sprite(_device); _sprite.Begin(SpriteFlags.AlphaBlend); // P1 string playerOneHeader = string.Format("-{0}'s STATS-", _playerOneName); string playerOnePos = string.Format( "[{0},{1}]", _memory.GetPosX(1).ToString("F3"), _memory.GetPosY(1).ToString("F3")); string playerOneHealth = string.Format("HP : {0}", _memory.GetHealth(1)); string playerOneStun = string.Format("STUN : {0}", _memory.GetStun(1)); string playerOneEx = string.Format("EX : {0}", _memory.GetEXmeter(1)); string playerOneUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(1)); string playerOneScript = string.Format( "ANIM : {0} ({1})", _memory.PlayerAnim(1), _memory.GetAnimFrame(1)); int playerOneInterruptFrame = _memory.GetInterruptFrame(1); string playerOneInterrupt = string.Format("INTRPT: {0}", playerOneInterruptFrame); // P2 string playerTwoHeader = string.Format("-{0}'s STATS-", _playerTwoName); string playerTwoPos = string.Format( "[{0},{1}]", _memory.GetPosX(2).ToString("F3"), _memory.GetPosY(2).ToString("F3")); string playerTwoHealth = string.Format("HP : {0}", _memory.GetHealth(2)); string playerTwoStun = string.Format("STUN : {0}", _memory.GetStun(2)); string playerTwoEx = string.Format("EX : {0}", _memory.GetEXmeter(2)); string playerTwoUltra = string.Format("ULTRA : {0}", _memory.GetUltraMeter(2)); string playerTwoScript = string.Format( "ANIM : {0} ({1})", _memory.PlayerAnim(2), _memory.GetAnimFrame(2)); int playerTwoInterruptFrame = _memory.GetInterruptFrame(2); string playerTwoInterrupt = string.Format("INTRPT: {0}", playerTwoInterruptFrame); string playerOneAdv = string.Format("ADV : {0}", playerOneInterruptFrame - playerTwoInterruptFrame); string playerTwoAdv = string.Format("ADV : {0}", playerTwoInterruptFrame - playerOneInterruptFrame); string playerOneStats = string.Join( "\n", playerOneHeader, playerOnePos, playerOneHealth, playerOneStun, playerOneEx, playerOneUltra, playerOneScript, playerOneInterrupt, playerOneAdv); string playerTwoStats = string.Join( "\n", playerTwoHeader, playerTwoPos, playerTwoHealth, playerTwoStun, playerTwoEx, playerTwoUltra, playerTwoScript, playerTwoInterrupt, playerTwoAdv); _font.DrawString(null, playerOneStats, _fontSize, (deviceHeight / _fontSize) * 8, _textColor); _font.DrawString(null, playerTwoStats, deviceWidth - (_fontSize * 13), (deviceHeight / _fontSize) * 8, _textColor); // Both _font.DrawString( null, string.Format("Combo Counter: {0}", _memory.ComboCounter()), deviceWidth / 20 * 9, 30, _textColor); _font.DrawString( null, string.Format("Distance: {0}", _memory.GetDistance()), deviceWidth / 20 * 8, deviceHeight / 20 * 18, _textColor); _font.DrawString( null, string.Format("Frame Counter: {0}", frameCounter), deviceWidth / 20 * 8, deviceHeight / 20 * 19, _textColor); _sprite.End(); _sprite.Dispose(); } else { _playerOneName = string.Empty; _playerTwoName = string.Empty; } } catch { } }