コード例 #1
0
ファイル: Game.cs プロジェクト: eldan-dex/randio
        //Displays all onscreen text
        private void DrawOSDs()
        {
            osdSpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);

            //Draw debug info
            if (DebugEnabled)
            {
                osdSpriteBatch.DrawString(font, "DEBUG ENABLED", new Vector2(10, 10), Color.Red);
                osdSpriteBatch.DrawString(font, "Player X: " + map.Player.Position.X + "     Player Y: " + map.Player.Position.Y + "\nDirection: " + (map.Player.Direction == 1 ? "right" : "left") + "\nCurrentTile: " + map.Player.CurrentTile + "\nHP: " + map.Player.HP.ToString() + "/" + map.Player.MaxHP.ToString() + ", Speed: " + map.Player.Speed.ToString() + "\nStrength: " + map.Player.Strength.ToString() + ", Defense: " + map.Player.Defense.ToString(), new Vector2(10, 30), Color.Red);
            }

            //Draw quests
            if (map.Quests != null)
            {
                Vector2 questPosition = (DebugEnabled ? new Vector2(0, 120) : new Vector2(0, 10));
                string  status        = map.Quests.QuestsStatus();
                GraphicsHelper.FillRectangle(map.Quests.Background, new Color(180, 180, 180));
                osdSpriteBatch.Draw(map.Quests.Background, new Rectangle((int)questPosition.X - 5, (int)questPosition.Y - 5, map.Quests.Background.Width, map.Quests.Background.Height), Color.White * 0.8f);
                osdSpriteBatch.DrawString(font, status, questPosition, ColorHelper.ChangeColorBrightness(ColorHelper.InvertColor(map.GetTileByIndex(map.Player.CurrentTile).Palette[0]), -0.6f));
            }

            //Draw button info, current tile and current item
            var   tu       = map.GetTileByIndex(map.Player.CurrentTile);
            Color invColor = ColorHelper.BlackWhiteContrasting(tu.Palette[1]);

            osdSpriteBatch.DrawString(font, "Current tile: " + map.Player.CurrentTile, new Vector2(100, 660), invColor, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
            osdSpriteBatch.DrawString(font, "Item: " + ((map.Player.HeldItem == null) ? "none" : map.Player.HeldItem.Properties.Name), new Vector2(930, 660), invColor, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
            osdSpriteBatch.DrawString(font, "  WSAD - move   J - attack   K - pick/put item   L - reset   L-SHIFT - slowmove   ESC - end level", new Vector2(10, 700), invColor, 0f, Vector2.Zero, 0.8f, SpriteEffects.None, 0f);
            osdSpriteBatch.End();
        }
コード例 #2
0
        //Generates texture of individual blocks
        public void CreateBlockTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            var tex = new Texture2D(device, width, height);

            GraphicsHelper.FillRectangle(tex, palette[1]);
            BlockTexture = tex;
        }
コード例 #3
0
        //Create the NPC texture (color indicates behaviour type)
        private Texture2D CreateTexture(GraphicsDevice graphicsDevice)
        {
            var texture = new Texture2D(graphicsDevice, Width, Height);

            Color color;

            if (Behaviour == NPCBehaviour.GoToPlayer)
            {
                color = Color.Violet;
            }
            else if (Behaviour == NPCBehaviour.RunAwayFromPlayer)
            {
                color = Color.Lime;
            }
            else
            {
                color = Color.Yellow;
            }

            GraphicsHelper.FillRectangle(texture, color);

            if (IsBoss)
            {
                outlineWidth = 6;
            }
            else
            {
                outlineWidth = 3;
            }

            return(texture);
        }
コード例 #4
0
ファイル: Item.cs プロジェクト: eldan-dex/randio
        //Creates the item texture (small white square)
        private void CreateTexture(GraphicsDevice device)
        {
            var texture = new Texture2D(device, Width, Height);

            GraphicsHelper.FillRectangle(texture, Color.White);
            Texture = texture;
        }
コード例 #5
0
ファイル: MountainsBG.cs プロジェクト: eldan-dex/randio
        //Generates the background texture
        public void CreateBackgroundTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            Texture = new RenderTarget2D(device, width, height);

            device.SetRenderTarget(Texture);
            device.Clear(palette[0]);
            batch.Begin();

            Color StarWhite = palette[2];
            Color StarBloom = ColorHelper.ChangeColorBrightness(palette[2], +0.4f);
            Color StarBig   = ColorHelper.ChangeColorBrightness(palette[2], +0.6f);

            foreach (Point Star in Stars)
            {
                //big star
                if (AlgorithmHelper.GetRandom(0, 5) == 4)
                {
                    RenderTarget2D BigStarSprite = new RenderTarget2D(device, 2, 2);
                    GraphicsHelper.FillRectangle(BigStarSprite, StarBig);

                    batch.Draw(BigStarSprite, new Rectangle(Star.X - 2, Star.Y, 2, 2), StarBloom);
                    batch.Draw(BigStarSprite, new Rectangle(Star.X + 2, Star.Y, 2, 2), StarBloom);
                    batch.Draw(BigStarSprite, new Rectangle(Star.X, Star.Y - 2, 2, 2), StarBloom);
                    batch.Draw(BigStarSprite, new Rectangle(Star.X, Star.Y + 2, 2, 2), StarBloom);
                    batch.Draw(BigStarSprite, new Rectangle(Star.X, Star.Y, 2, 2), StarWhite);

                    continue;
                }

                RenderTarget2D StarSprite = new RenderTarget2D(device, 1, 1);
                GraphicsHelper.FillRectangle(StarSprite, StarBig);

                batch.Draw(StarSprite, new Rectangle(Star.X - 1, Star.Y, 1, 1), StarBloom);
                batch.Draw(StarSprite, new Rectangle(Star.X + 1, Star.Y, 1, 1), StarBloom);
                batch.Draw(StarSprite, new Rectangle(Star.X, Star.Y - 1, 1, 1), StarBloom);
                batch.Draw(StarSprite, new Rectangle(Star.X, Star.Y + 1, 1, 1), StarBloom);
                batch.Draw(StarSprite, new Rectangle(Star.X, Star.Y, 1, 1), StarWhite);
            }

            int line = 0;

            for (int i = 0; i < heightLines.GetLength(1); i++)
            {
                int sh  = (int)(heightLines[0, i] * 0.75) + 50;
                int sh2 = (int)(heightLines[1, i]) + 50;
                int sh3 = (int)(heightLines[2, i] * 1.3) + 50;

                RenderTarget2D spike = new RenderTarget2D(device, 2, sh);
                GraphicsHelper.FillRectangle(spike, Color.White);

                batch.Draw(spike, new Rectangle(line, height - sh3, 2, sh3), palette[3]);
                batch.Draw(spike, new Rectangle(line, height - sh2, 2, sh2), palette[4]);
                batch.Draw(spike, new Rectangle(line, height - sh, 2, sh), palette[5]);
                line += 2;
            }

            batch.End();
            device.SetRenderTarget(null);
        }
コード例 #6
0
ファイル: Zone.cs プロジェクト: eldan-dex/randio
 //Default ctor
 public Zone(GraphicsDevice device, Rectangle coords, Color zoneOutline)
 {
     Active  = true;
     Texture = new Texture2D(device, coords.Width, coords.Height);
     Coords  = coords;
     GraphicsHelper.FillRectangle(Texture, Color.Transparent);
     GraphicsHelper.OutlineRectangle(Texture, zoneOutline, 6);
 }
コード例 #7
0
ファイル: MountainsBG.cs プロジェクト: eldan-dex/randio
        //Generates a separate texture for all blocks, which are the topmost of a stack of blocks.
        public void CreateTopmostBlockTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            //Base color
            var texture = new Texture2D(device, width, height);

            GraphicsHelper.FillRectangle(texture, ColorHelper.ChangeColorBrightness(palette[1], +0.3f));

            BlockTopmostTexture = texture; //Leave this here for topmost bloks to be identical to normal blocks. Replace with own texture generation to make them different.
        }
コード例 #8
0
ファイル: Player.cs プロジェクト: eldan-dex/randio
        //Creates player texture (blue with an arrow in the middle)
        private Texture2D CreateTexture(GraphicsDevice graphicsDevice, int width, int height)
        {
            var texture = new Texture2D(graphicsDevice, width, height);

            GraphicsHelper.FillRectangle(texture, Color.Blue);
            GraphicsHelper.DrawArrow(1, texture, Color.Black);
            outlineWidth = 3;

            return(texture);
        }
コード例 #9
0
ファイル: Loading.cs プロジェクト: eldan-dex/randio
        //Initialize message colors (depends on current Tile and it's palette)
        private void CreateGraphics()
        {
            var palette = map.GetTileByIndex(map.Player.CurrentTile).Palette;

            Background = new Texture2D(device, Coords.Width, Coords.Height);
            GraphicsHelper.FillRectangle(Background, palette[4]);
            GraphicsHelper.OutlineRectangle(Background, palette[3], 6);

            textColor = palette[3];
        }
コード例 #10
0
        //Generates texture of individual blocks
        public void CreateBlockTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            //Base color
            Color diffuse = Color.PaleTurquoise;

            var texture = new Texture2D(device, width, height);

            GraphicsHelper.FillRectangle(texture, palette[1]);

            BlockTexture = texture;
        }
コード例 #11
0
        //Generates the background texture
        public void CreateBackgroundTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            Texture = new RenderTarget2D(device, width, height);
            List <House> buildings = new List <House>();

            for (int zIndex = 0; zIndex < 3; zIndex++)
            {
                int fromLeft = 0;
                while (fromLeft < width)
                {
                    //build house
                    int   stories = AlgorithmHelper.GetRandom(50, 140) * (4 - zIndex);
                    House house   = new House(fromLeft, height - stories, stories, zIndex);
                    int   step    = (house.dimensions.Width / 12) + zIndex;

                    //fill house with windows
                    for (int X = (int)(step * 1.5); X < house.dimensions.Width - step; X += (int)(step * 1.5))
                    {
                        for (int Y = step; Y < house.dimensions.Height; Y += step + step / 2)
                        {
                            house.windows.Add(new Window(new Rectangle(house.dimensions.X + X, house.dimensions.Y + Y, step, step), AlgorithmHelper.GetRandom(0, 4)));
                        }
                    }

                    //add house to the city
                    buildings.Add(house);

                    //build street
                    fromLeft += house.dimensions.Width + AlgorithmHelper.GetRandom(10, 50);
                }
            }

            device.SetRenderTarget(Texture);
            device.Clear(palette[0]); //or Color.Black
            batch.Begin();

            foreach (House building in buildings)
            {
                //draw house
                RenderTarget2D house = new RenderTarget2D(device, building.dimensions.Width, building.dimensions.Height);
                GraphicsHelper.FillRectangle(house, palette[building.zIndex + 2]);
                batch.Draw(house, building.dimensions, Color.White);
                foreach (Window window in building.windows)
                {
                    //draw windows on house
                    RenderTarget2D house_window = new RenderTarget2D(device, window.dimensions.Width, window.dimensions.Height);
                    GraphicsHelper.FillRectangle(house_window, ColorHelper.ChangeColorBrightness(Color.Multiply(window.color, (0.5f * building.zIndex) + 1f), darkenBy));
                    batch.Draw(house_window, window.dimensions, Color.White);
                }
            }

            batch.End();
            device.SetRenderTarget(null);
        }
コード例 #12
0
        //Generates the background texture
        public void CreateBackgroundTexture(GraphicsDevice device, SpriteBatch batch, int width, int height)
        {
            Texture = new RenderTarget2D(device, width, height);
            List <LSystem.Rule> rules = new List <LSystem.Rule>();

            rules.Add(new LSystem.Rule("F", "1FF-[2-F+F-F]+[2+F-F+F]")); //basic tree

            defaultSystem = new LSystem("F", 10, 22, rules);
            turtle        = new Turtle(device, batch, new Vector2(200, 640), -90, Color.White, palette);

            device.SetRenderTarget(Texture);
            device.Clear(palette[0]);
            batch.Begin();

            RenderTarget2D target = new RenderTarget2D(device, width, height);

            //Pregenerate trees
            List <LSystem> trees = new List <LSystem>();

            for (int i = 0; i < 6; ++i)
            {
                var currentSystem = new LSystem(defaultSystem);
                currentSystem.Iterate(i);
                trees.Add(currentSystem);
            }

            //create clouds
            int count = Math.Max(1, AlgorithmHelper.GetRandom(width / 512, width / 96));
            int nextX = AlgorithmHelper.GetRandom(0, width / count);
            int nextY;

            for (int i = 1; i < count; ++i)
            {
                nextY = AlgorithmHelper.GetRandom(0, 100);
                int w = AlgorithmHelper.GetRandom(32, 512);
                int h = AlgorithmHelper.GetRandom(32, 128);

                Texture2D cloud = new Texture2D(device, w, h);
                GraphicsHelper.FillRectangle(cloud, palette[7]);
                GraphicsHelper.OutlineRectangle(cloud, ColorHelper.ChangeColorBrightness(palette[5], -0.2f), 8);

                batch.Draw(cloud, new Rectangle(nextX, nextY, w, h), Color.White);

                nextX += AlgorithmHelper.GetRandom(0, (int)(w * 1.5));
                if (nextX > width)
                {
                    nextX -= AlgorithmHelper.GetRandom(w, (int)(width / 1.5));
                }
            }

            count = Math.Max(1, AlgorithmHelper.GetRandom(width / 256, width / 64));
            nextX = AlgorithmHelper.GetRandom(0, width / count);
            for (int i = 0; i < count; ++i)
            {
                int size = AlgorithmHelper.GetRandom(1, trees.Count - 1);

                while (nextX + 100 * size > width)
                {
                    --size;
                }

                if (size == trees.Count - 2 && AlgorithmHelper.GetRandom(0, 10) > 6)
                {
                    size = size + 1;
                }

                if (size < 0)
                {
                    break;
                }

                if (i == 0 && nextX < size * 20)
                {
                    nextX = size * 20;
                }

                var currentSystem = trees[size];
                turtle.SetDefaults(new Vector2(nextX, 640), -90);
                turtle.DrawSystem(currentSystem, target);
                nextX += 50 * size;
            }

            batch.Draw(target, new Rectangle(0, 0, width, height), Color.White);

            batch.End();
            device.SetRenderTarget(null);
        }