Пример #1
0
        public static void DrawIntro()
        {
            var imageTex = sContentManager.GetTexture(
                GameContentManager.TextureType.Image, ClientConfiguration.Instance.IntroImages[Globals.IntroIndex]
                );

            if (imageTex != null)
            {
                DrawFullScreenTextureFitMinimum(imageTex);
            }
        }
Пример #2
0
        public void SetTileset(string name)
        {
            TilesetBase tSet     = null;
            var         tilesets = TilesetBase.Lookup;
            var         id       = Guid.Empty;

            foreach (var tileset in tilesets.Pairs)
            {
                if (tileset.Value.Name.ToLower() == name.ToLower())
                {
                    id = tileset.Key;

                    break;
                }
            }

            if (id != Guid.Empty)
            {
                tSet = TilesetBase.Get(id);
            }

            if (tSet != null)
            {
                if (File.Exists("resources/tilesets/" + tSet.Name))
                {
                    picTileset.Show();
                    Globals.CurrentTileset = tSet;
                    Globals.CurSelX        = 0;
                    Globals.CurSelY        = 0;
                    var tilesetTex = GameContentManager.GetTexture(GameContentManager.TextureType.Tileset, tSet.Name);
                    if (tilesetTex != null)
                    {
                        picTileset.Width  = tilesetTex.Width;
                        picTileset.Height = tilesetTex.Height;
                    }

                    cmbTilesets.SelectedItem = name;
                    CreateSwapChain();
                }
            }
        }
Пример #3
0
        void DrawUpperFrame()
        {
            if (mUpperWindow == null || mEditorItem == null)
            {
                return;
            }

            if (!mPlayUpper)
            {
                mUpperFrame = scrlUpperFrame.Value - 1;
            }

            var graphicsDevice = Core.Graphics.GetGraphicsDevice();

            Core.Graphics.EndSpriteBatch();
            graphicsDevice.SetRenderTarget(mUpperDarkness);
            graphicsDevice.Clear(Microsoft.Xna.Framework.Color.Black);
            if (mUpperFrame < mEditorItem.Upper.Lights.Length)
            {
                Core.Graphics.DrawLight(
                    picUpperAnimation.Width / 2 + mEditorItem.Upper.Lights[mUpperFrame].OffsetX,
                    picUpperAnimation.Height / 2 + mEditorItem.Upper.Lights[mUpperFrame].OffsetY,
                    mEditorItem.Upper.Lights[mUpperFrame], mUpperDarkness
                    );
            }

            Core.Graphics.DrawTexture(
                Core.Graphics.GetWhiteTex(), new RectangleF(0, 0, 1, 1),
                new RectangleF(0, 0, mUpperDarkness.Width, mUpperDarkness.Height),
                System.Drawing.Color.FromArgb((byte)((float)(100 - scrlDarkness.Value) / 100f * 255), 255, 255, 255),
                mUpperDarkness, BlendState.Additive
                );

            Core.Graphics.EndSpriteBatch();
            graphicsDevice.SetRenderTarget(mUpperWindow);
            graphicsDevice.Clear(Microsoft.Xna.Framework.Color.White);
            var animTexture = GameContentManager.GetTexture(
                GameContentManager.TextureType.Animation, cmbUpperGraphic.Text
                );

            if (animTexture != null)
            {
                long w = animTexture.Width / (int)nudUpperHorizontalFrames.Value;
                long h = animTexture.Height / (int)nudUpperVerticalFrames.Value;
                long x = 0;
                if (mUpperFrame > 0)
                {
                    x = mUpperFrame % (int)nudUpperHorizontalFrames.Value * w;
                }

                var y = (int)Math.Floor(mUpperFrame / nudUpperHorizontalFrames.Value) * h;
                Core.Graphics.DrawTexture(
                    animTexture, new RectangleF(x, y, w, h),
                    new RectangleF(
                        picUpperAnimation.Width / 2 - (int)w / 2, (int)picUpperAnimation.Height / 2 - (int)h / 2, w,
                        h
                        ), mUpperWindow
                    );
            }

            Core.Graphics.DrawTexture(mUpperDarkness, 0, 0, mUpperWindow, Core.Graphics.MultiplyState);
            Core.Graphics.EndSpriteBatch();
            mUpperWindow.Present();
        }
Пример #4
0
        public void Draw(RenderTarget2D target, bool upper = false, bool alternate = false)
        {
            if (!upper && alternate != MyBase.Lower.AlternateRenderLayer)
            {
                return;
            }

            if (upper && alternate != MyBase.Upper.AlternateRenderLayer)
            {
                return;
            }

            if (!upper)
            {
                //Draw Lower
                var tex = GameContentManager.GetTexture(GameContentManager.TextureType.Animation, MyBase.Lower.Sprite);
                if (mShowLower)
                {
                    if (mLowerFrame >= MyBase.Lower.FrameCount)
                    {
                        return;
                    }

                    if (tex != null)
                    {
                        if (MyBase.Lower.XFrames > 0 && MyBase.Lower.YFrames > 0)
                        {
                            var frameWidth  = (int)tex.Width / MyBase.Lower.XFrames;
                            var frameHeight = (int)tex.Height / MyBase.Lower.YFrames;
                            Core.Graphics.DrawTexture(
                                tex,
                                new RectangleF(
                                    mLowerFrame % MyBase.Lower.XFrames * frameWidth,
                                    (float)Math.Floor((double)mLowerFrame / MyBase.Lower.XFrames) * frameHeight,
                                    frameWidth, frameHeight
                                    ),
                                new RectangleF(
                                    mRenderX - frameWidth / 2, mRenderY - frameHeight / 2, frameWidth, frameHeight
                                    ), System.Drawing.Color.White, target, BlendState.NonPremultiplied
                                );
                        }
                    }

                    Core.Graphics.AddLight(
                        Options.MapWidth * Options.TileWidth -
                        Core.Graphics.CurrentView.Left +
                        (int)mRenderX +
                        MyBase.Lower.Lights[mLowerFrame].OffsetX,
                        Options.MapHeight * Options.TileHeight -
                        Core.Graphics.CurrentView.Top +
                        (int)mRenderY +
                        MyBase.Lower.Lights[mLowerFrame].OffsetY, MyBase.Lower.Lights[mLowerFrame]
                        );
                }
            }
            else
            {
                //Draw Upper
                var tex = GameContentManager.GetTexture(GameContentManager.TextureType.Animation, MyBase.Upper.Sprite);
                if (mShowUpper)
                {
                    if (mUpperFrame >= MyBase.Upper.FrameCount)
                    {
                        return;
                    }

                    if (tex != null)
                    {
                        if (MyBase.Upper.XFrames > 0 && MyBase.Upper.YFrames > 0)
                        {
                            var frameWidth  = (int)tex.Width / MyBase.Upper.XFrames;
                            var frameHeight = (int)tex.Height / MyBase.Upper.YFrames;
                            Core.Graphics.DrawTexture(
                                tex,
                                new RectangleF(
                                    mUpperFrame % MyBase.Upper.XFrames * frameWidth,
                                    (float)Math.Floor((double)mUpperFrame / MyBase.Upper.XFrames) * frameHeight,
                                    frameWidth, frameHeight
                                    ),
                                new RectangleF(
                                    mRenderX - frameWidth / 2, mRenderY - frameHeight / 2, frameWidth, frameHeight
                                    ), System.Drawing.Color.White, target, BlendState.NonPremultiplied
                                );
                        }
                    }

                    Core.Graphics.AddLight(
                        Options.MapWidth * Options.TileWidth -
                        Core.Graphics.CurrentView.Left +
                        (int)mRenderX +
                        MyBase.Upper.Lights[mUpperFrame].OffsetX,
                        Options.MapHeight * Options.TileHeight -
                        Core.Graphics.CurrentView.Top +
                        (int)mRenderY +
                        MyBase.Upper.Lights[mUpperFrame].OffsetY, MyBase.Upper.Lights[mUpperFrame]
                        );
                }
            }
        }