Пример #1
0
        public void OnMainLoop(object sender, EventArgs e)
        {
            _sprite.Begin(Dx9.SpriteFlags.AlphaBlend);

            _font.DrawString(_sprite, "Hello World", 0, 0, SD.Color.White);
            _sprite.Draw(_circleTexture, Vector3.Zero, _mousePosition, new Color4(SD.Color.White));

            _sprite.End();

            using (Dx9.Sprite s = new Dx9.Sprite(_control.Device))
            {
                s.Begin(Dx9.SpriteFlags.AlphaBlend);

                s.Draw(_texture, Vector3.Zero, Vector3.Zero, new Color4(SD.Color.White));

                UpdateCamera();

                s.End();
            }

            _shipSprite.Begin(Dx9.SpriteFlags.AlphaBlend);

            Matrix matrix = Matrix.Transformation2D(new Vector2(0, 0), 0.0f, new Vector2(1f, 1f),
                                                    new Vector2(_shipVector3.X + 100f, _shipVector3.Y + 100f), _rotation, new Vector2(0f, 0f));

            _shipSprite.Transform = matrix;

            _shipSprite.Draw(_shipTexture, Vector3.Zero, _shipVector3, SD.Color.White);

            UpdateCamera();
            _shipSprite.End();
        }
Пример #2
0
        public void OnDeviceReset(object sender, EventArgs e)
        {
            _control = sender as DirectxControl;
            if (_control == null)
            {
                throw new ArgumentNullException(nameof(sender));
            }

            _sprite?.Dispose();
            _sprite = new Dx9.Sprite(_control.Device);

            _shipSprite?.Dispose();
            _shipSprite = new Dx9.Sprite(_control.Device);

            if (_texture == null)
            {
                _texture = Dx9.Texture.FromFile(_control.Device, "Ressources\\maxresdefault.jpg", _control.Device.Viewport.Width, _control.Device.Viewport.Height, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0, out _imageInformation);
            }
            if (_shipTexture == null)
            {
                _shipTexture = Dx9.Texture.FromFile(_control.Device, "Ressources\\Voyager.png", 200, 200, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0);
            }
            if (_circleTexture == null)
            {
                _circleTexture = Dx9.Texture.FromFile(_control.Device, "Ressources\\200px-65537-gon.svg.png", 20, 20, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0);
            }
            if (_font == null)
            {
                SD.Font f = new SD.Font("Arial", 20f, SD.FontStyle.Regular);

                _font = new Dx9.Font(_control.Device, f);
            }
        }
Пример #3
0
        public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer)
        {
            if (!(block && blendFade.IsFadingOut))
            {
                blendFade.Update(RenderTime.Elapsed);
            }

            if (!blendFade.IsOut)
            {
                SpriteRenderer.Transform = SlimDX.Matrix.Identity;
                System.Drawing.Rectangle rc = new System.Drawing.Rectangle(0, 0, size.x, size.y);
                SpriteRenderer.Draw(emptyTexture, rc, new SlimDX.Vector3(0, 0, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(blendFade.State, 0, 0, 0));
            }
        }
Пример #4
0
 /// <summary>
 /// Disposes of the object's resources.
 /// </summary>
 /// <param name="disposing">True if managed resources should be disposed.</param>
 private void Dispose(bool disposing)
 {
     if (!_disposed)
     {
         if (disposing)
         {
             // dispose managed resources
             if (Sprite != null)
             {
                 Sprite.Dispose();
                 Sprite = null;
             }
         }
     }
     // dispose unmanaged resources
     _disposed = true;
 }
Пример #5
0
        public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer)
        {
            // loading render
            rotationState += rotationSpeed * RenderTime.Elapsed;
            if (rotationState >= 1)
            {
                rotationState -= (float)System.Math.Floor(rotationState);
            }

            if (!engine.isLoading)
            {
                if (engine.loadingStack > 0 || engine.ResourceManager.IsLoading)
                {
                    loadingDelayState += loadingDelay * RenderTime.Elapsed;
                    if (loadingDelayState >= 1)
                    {
                        engine.isLoading = true;
                    }
                }
            }
            else
            {
                if (engine.loadingStack == 0 && !engine.ResourceManager.IsLoading)
                {
                    engine.isLoading = false;
                }
                loadingDelayState = 0;
                fadeOutState      = 1;
            }

            if (fadeOutState > 0)
            {
                SpriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend);

                SpriteRenderer.Transform = SlimDX.Matrix.Translation(size.x - 32, size.y - 32, 0);
                SpriteRenderer.Transform = SlimDX.Matrix.RotationZ(-(float)System.Math.PI * rotationState * 2) * SpriteRenderer.Transform;
                SpriteRenderer.Transform = SlimDX.Matrix.Scaling(1.5f, 1.5f, 1.5f) * SpriteRenderer.Transform;

                SpriteRenderer.Draw(loadingTexture, new SlimDX.Vector3(16, 16, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(fadeOutState, 1, 1, 1));

                SpriteRenderer.End();

                fadeOutState -= RenderTime.Elapsed * fadeOutSpeed;
            }
        }
Пример #6
0
        public void Render(GameTime RenderTime, SlimDX.Direct3D9.Sprite SpriteRenderer)
        {
            if (engine.crashed)
            {
                crashFade.FadeIn();
                crashFadeBack.FadeIn();
            }
            else
            {
                crashFade.FadeOut();
                crashFadeBack.FadeOut();
            }

            if (!crashFade.IsOut || engine.crashed)
            {
                crashFade.Update(RenderTime.Elapsed);
                crashFadeBack.Update(RenderTime.Elapsed);
                crashWait.Update(RenderTime.Elapsed);
                crashWait.FadeIn();

                SpriteRenderer.Begin(SpriteFlags.SortTexture | SpriteFlags.SortDepthFrontToBack | SpriteFlags.AlphaBlend);

                System.Drawing.Rectangle rc = new System.Drawing.Rectangle(0, 0, size.x, size.y);
                SpriteRenderer.Draw(emptyTexture, rc, new SlimDX.Vector3(0, 0, 0), new SlimDX.Vector3(0, 0, 0.001f), new SlimDX.Color4(crashFadeBack.State * 0.8f, 0, 0, 0));

                SpriteRenderer.Transform = SlimDX.Matrix.Translation(size.x / 2, size.y / 2, 0);
                SpriteRenderer.Transform = SlimDX.Matrix.Scaling(0.5f, 0.5f, 0.5f) * SpriteRenderer.Transform;

                SpriteRenderer.Draw(crashedTexture, new SlimDX.Vector3(128, 128, 0), new SlimDX.Vector3(0, 0, 0), new SlimDX.Color4(crashFade.State, 1, 1, 1));

                SpriteRenderer.End();
                if (crashWait.IsIn)
                {
                    engine.RecoverAfterCrash();
                    crashWait.State = 0;
                }
            }
        }
Пример #7
0
        void ReloadGraphicResources()
        {
            resourceManager.EmptyTexture = new Texture(device, 1, 1, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
            SlimDX.DataRectangle dr = resourceManager.EmptyTexture.LockRectangle(0, LockFlags.Discard);
            dr.Data.Write <uint>(0x00000000);
            resourceManager.EmptyTexture.UnlockRectangle(0);
            emptyTexture = new Texture(device, 1, 1, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
            dr           = emptyTexture.LockRectangle(0, LockFlags.Discard);
            dr.Data.Write <uint>(0xffffffff);
            emptyTexture.UnlockRectangle(0);

            spriteRenderer = new SlimDX.Direct3D9.Sprite(device);
            lineRenderer   = new Line(device);

            loadingOverlay.Load(device);
            blendOverlay.Load(device);
            errorOverlay.Load(device);

            renderToSurface = new RenderToSurface(device, engine.GameResolution.x * renderScale, engine.GameResolution.y * renderScale, Format.X8R8G8B8);
            renderToTexture = new Texture(device, engine.GameResolution.x * renderScale, engine.GameResolution.y * renderScale, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            deviceReadyForRender = true;
        }
Пример #8
0
        private void Main_Load(object sender, EventArgs e)
        {
            HotKey = new Hotkey();
            HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.Insert); // Delete //Insert
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F1);
            HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.N);
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F3);
            HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F5);
            //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.CapsLock);
            //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.Q);

            Native.SetWindowLong(this.Handle, -20, (IntPtr)((Native.GetWindowLong(this.Handle, -20) ^ 0x80000) ^ 0x20));
            Native.SetLayeredWindowAttributes(this.Handle, 0, 0xff, 2);

            PresentParameters parameters = new SlimDX.Direct3D9.PresentParameters();
            parameters.Windowed = true;
            parameters.SwapEffect = SwapEffect.Discard;
            parameters.BackBufferFormat = Format.A8R8G8B8;
            parameters.BackBufferHeight = this.Height;
            parameters.BackBufferWidth = this.Width;
            parameters.PresentationInterval = PresentInterval.One;

            DXDevice = new SlimDX.Direct3D9.Device(new Direct3D(), 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[] { parameters });
            if (System.IO.File.Exists("map_large.png")) DXTextrureMapLarge = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map_large.png");
            if (System.IO.File.Exists("map.png")) DXTextrureMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map.png");
            if (System.IO.File.Exists("LagerMap.jpg")) DXTextureGameMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "LagerMap.jpg");
            CircleVertices = new VertexBuffer(DXDevice, (circleComplexity + 2) * TexVertex.SizeBytes, Usage.WriteOnly, VertexFormat.None, Pool.Managed);
            DXSprite = new SlimDX.Direct3D9.Sprite(DXDevice);
            DXLine = new SlimDX.Direct3D9.Line(DXDevice);
            DXFont = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("NewRoman", 9f)); //NewRoman
            DXFontB = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("Tahoma", 12f)); //NewRoman

            if (this.GameMemory.Attach("H1Z1 PlayClient (Live)") == false) { Application.Exit(); return; }
            Thread dxThread = new Thread(new ThreadStart(DoProcess));
            dxThread.IsBackground = true;
            dxThread.Start();

            //Thread aimThread = new Thread(new ThreadStart(DoAiming));
            //aimThread.IsBackground = true;
            //aimThread.Start();
        }
Пример #9
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="device">Requests the DirectX graphics device.</param>
 public UISprite(D3D.Device device)
 {
     _device = device;
     Sprite  = new D3D.Sprite(device);
 }