コード例 #1
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(item_rec);
 }
コード例 #2
0
 public void Draw(RenderTarget target, RenderStates states) // funkcja imolementowana z interfejsu Drawable umożliwia wyświetlnie kształtu na ekranie
 {
     target.Draw(this.circle, states);
 }
コード例 #3
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     window.SetView(view);
     target.Draw(world, states);
 }
コード例 #4
0
ファイル: Brick.cs プロジェクト: xDAndrew/Tetris
 public void Draw(RenderTarget target, RenderStates states)
 {
     _brickSprite.Position = new Vector2f(LeftAngle.X + (float)BrickSize * X * Scale + 1, LeftAngle.Y + (float)BrickSize * Y * Scale + 1);
     target.Draw(_brickSprite);
 }
コード例 #5
0
        public void Render(RenderTarget renderTarget, Tilemap tilemap, RenderStates renderStates)
        {
            if (renderTarget == null)
            {
                throw new ArgumentNullException("renderTarget");
            }

            // cas de 'non-affichage'
            if (tilemap == null)
            {
                return;
            }
            if (Tiles.Count == 0)
            {
                return;
            }
            if (TileSize == 0F)
            {
                return;
            }

            // restreint le nombre de tuiles à afficher en fonction du viewport.
            var view         = renderTarget.GetView();
            var viewHalfSize = view.Size / 2F;
            var viewPort     = new Vector2i(
                (int)(view.Center.X - viewHalfSize.X),
                (int)(view.Center.Y - viewHalfSize.Y)
                );
            var startColumn = viewPort.X / (int)TileSize;
            var startRow    = viewPort.Y / (int)TileSize;
            var endColumn   = startColumn + ((int)view.Size.X / (int)TileSize) + 2;
            var endRow      = startRow + ((int)view.Size.Y / (int)TileSize) + 2;

            // s'assure que les indices de tuile soient corrects
            startColumn = startColumn < 0 ? 0 : startColumn;
            startRow    = startRow < 0 ? 0 : startRow;
            endColumn   = endColumn > tilemap.Width ? tilemap.Width : endColumn;
            endRow      = endRow > tilemap.Height ? tilemap.Height : endRow;

            // affichage
            var        tilePosition   = new Vector2f(startColumn * TileSize, startRow * TileSize);
            GroundType previousGround = Tiles.Keys.First();
            Sprite     tile;

            Tiles.TryGetValue(previousGround, out tile);

            for (var horizontalIndex = startColumn; horizontalIndex < endColumn; horizontalIndex++)
            {
                for (var verticalIndex = startRow; verticalIndex < endRow; verticalIndex++)
                {
                    var ground = tilemap[horizontalIndex, verticalIndex];
                    if (ground != previousGround)
                    {
                        Tiles.TryGetValue(ground, out tile);
                        previousGround = ground;
                    }

                    if (tile != null)
                    {
                        tile.Position = tilePosition;
                        renderTarget.Draw(tile, renderStates);
                    }

                    tilePosition.Y += TileSize;
                }

                tilePosition.X += TileSize;
                tilePosition.Y  = startRow * TileSize;
            }
        }
コード例 #6
0
ファイル: Drawer.cs プロジェクト: Mectonri/BirdHouse-Battle
        public Shape[] PlacementDisplay(Arena arena)
        {
            Vector2f Bsize = new Vector2f(75, 25); //button size

            Shape[]        buttons = new Shape[9];
            RenderStates   rs      = new RenderStates();
            RectangleShape team1   = new RectangleShape(Bsize);
            RectangleShape team2   = new RectangleShape(Bsize);
            RectangleShape team3   = new RectangleShape(Bsize);
            RectangleShape team4   = new RectangleShape(Bsize);
            RectangleShape font    = new RectangleShape(new Vector2f(560, 200));
            RectangleShape over1   = new RectangleShape(new Vector2f(512, 128));
            RectangleShape over2   = new RectangleShape(new Vector2f(512, 128));

            if (arena.FindTeam("green") == true)
            {
                over1 = new RectangleShape(new Vector2f(128, 128));
                over2 = new RectangleShape(new Vector2f(128, 128));
            }

            RectangleShape over3 = new RectangleShape(new Vector2f(128, 128));
            RectangleShape over4 = new RectangleShape(new Vector2f(128, 128));

            team1.Position = new Vector2f(0, 0);
            team2.Position = new Vector2f(0, 0);
            font.Position  = new Vector2f(0, 510);

            if (arena.FindTeam("green") == true)
            {
                team3.Position = new Vector2f(0, 0);
            }

            if (arena.FindTeam("yellow") == true)
            {
                team4.Position = new Vector2f(0, 0);
            }

            buttons[0] = team1;
            buttons[1] = team2;
            buttons[2] = team3;
            buttons[3] = team4;
            buttons[4] = font;
            buttons[5] = over1;
            buttons[6] = over2;
            buttons[7] = over3;
            buttons[8] = over4;

            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i].FillColor = new Color(250, 250, 250);
                //buttons[i].Position = new Vector2f(0,300);
            }

            foreach (var t in buttons)
            {
                t.Draw(_window, rs);
                _window.Draw(t);
            }

            return(buttons);
        }
コード例 #7
0
        public override bool Init()
        {
            if (!base.Init())
            {
                return(false);
            }

            Effects.InitAll(Device);
            InputLayouts.InitAll(Device);
            RenderStates.InitAll(Device);
            Patch.InitPatchData(Terrain.CellsPerPatch, Device);

            _sky = new Sky(Device, "Textures/grasscube1024.dds", 5000.0f);

            var tii = new InitInfo {
                HeightMapFilename = null,
                LayerMapFilename0 = "textures/grass.png",
                LayerMapFilename1 = "textures/hills.png",
                LayerMapFilename2 = "textures/stone.png",
                LayerMapFilename3 = "Textures/lightdirt.dds",
                LayerMapFilename4 = "textures/snow.png",
                Material          = new Material()
                {
                    Ambient  = Color.LightGray,
                    Diffuse  = Color.LightGray,
                    Specular = new Color4(64, 0, 0, 0)
                },
                BlendMapFilename = null,
                HeightScale      = 50.0f,
                HeightMapWidth   = 2049,
                HeightMapHeight  = 2049,
                CellSpacing      = 0.5f,

                Seed         = MathF.Rand(),
                NoiseSize1   = 3.0f,
                Persistence1 = 0.7f,
                Octaves1     = 7,
                NoiseSize2   = 2.5f,
                Persistence2 = 0.8f,
                Octaves2     = 3,
            };

            _terrain = new Terrain();
            //_terrain.DebugQuadTree = true;
            _terrain.Init(Device, ImmediateContext, tii);

            _camera.Height = _terrain.Height;


            _camera.SetLens(0.25f * MathF.PI, AspectRatio, 1.0f, 1000.0f);
            _ssao = new Ssao(Device, ImmediateContext, ClientWidth, ClientHeight, _camera.FovY, _camera.FarZ);

            _whiteTex = ShaderResourceView.FromFile(Device, "Textures/white.dds");

            _sMap = new ShadowMap(Device, SMapSize, SMapSize);

            _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(_terrain.Width * _terrain.Width + _terrain.Depth * _terrain.Depth) / 2);

            _minimap = new Minimap(Device, ImmediateContext, MinimapSize, MinimapSize, _terrain, _camera);

            _sphereModel = new BasicModel();
            _sphereModel.CreateSphere(Device, 0.25f, 10, 10);
            _sphereModel.Materials[0] = new Material {
                Ambient  = new Color4(63, 0, 0),
                Diffuse  = Color.Red,
                Specular = new Color4(32, 1.0f, 1.0f, 1.0f)
            };
            _sphereModel.DiffuseMapSRV[0] = _whiteTex;

            _sphere = new BasicModelInstance(_sphereModel);

            _unit = new Unit(_sphere, _terrain.GetTile(511, 511), _terrain);

            FontCache.RegisterFont("bold", 16, "Courier New", FontWeight.Bold);


            return(true);
        }
コード例 #8
0
ファイル: Direct3DFont.cs プロジェクト: deobald/midget
        public void InitializeDeviceObjects(Device dev)
        {
            if (dev != null)
            {
                // Set up our events
                dev.DeviceReset += new System.EventHandler(this.RestoreDeviceObjects);
            }

            // Keep a local copy of the device
            device = dev;
            textureState0 = device.TextureState[0];
            textureState1 = device.TextureState[1];
            samplerState0 = device.SamplerState[0];
            renderState = device.RenderState;

            // Create a bitmap on which to measure the alphabet
            Bitmap bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            Graphics g = Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.Default;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
            g.TextContrast = 0;

            // Establish the font and texture size
            textureScale  = 1.0f; // Draw fonts into texture without scaling

            // Calculate the dimensions for the smallest power-of-two texture which
            // can hold all the printable characters
            textureWidth = textureHeight = 128;
            for (;;)
            {
                try
                {
                    // Measure the alphabet
                    PaintAlphabet(g, true);
                }
                catch (System.InvalidOperationException)
                {
                    // Scale up the texture size and try again
                    textureWidth *= 2;
                    textureHeight *= 2;
                    continue;
                }

                break;
            }

            // If requested texture is too big, use a smaller texture and smaller font,
            // and scale up when rendering.
            Caps d3dCaps = device.DeviceCaps;

            // If the needed texture is too large for the video card...
            if (textureWidth > d3dCaps.MaxTextureWidth)
            {
                // Scale the font size down to fit on the largest possible texture
                textureScale = (float)d3dCaps.MaxTextureWidth / (float)textureWidth;
                textureWidth = textureHeight = d3dCaps.MaxTextureWidth;

                for(;;)
                {
                    // Create a new, smaller font
                    fontSize = (int) Math.Floor(fontSize * textureScale);
                    font = new System.Drawing.Font(font.Name, fontSize, font.Style);

                    try
                    {
                        // Measure the alphabet
                        PaintAlphabet(g, true);
                    }
                    catch (System.InvalidOperationException)
                    {
                        // If that still doesn't fit, scale down again and continue
                        textureScale *= 0.9F;
                        continue;
                    }

                    break;
                }
            }

            // Release the bitmap used for measuring and create one for drawing
            bmp.Dispose();
            bmp = new Bitmap(textureWidth, textureHeight, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            g = Graphics.FromImage(bmp);
            g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            g.TextContrast = 0;

            // Draw the alphabet
            PaintAlphabet(g, false);

            // Create a new texture for the font from the bitmap we just created
            fontTexture = Texture.FromBitmap(device, bmp, 0, Pool.Managed);
            RestoreDeviceObjects(null, null);
        }
コード例 #9
0
 public void Draw(RenderTarget window, RenderStates states)
 {
     drawableElement.Draw(window, states);
 }
コード例 #10
0
 public abstract void Draw(RenderTarget target, RenderStates states);
コード例 #11
0
ファイル: Debug.cs プロジェクト: Phantaxein/RaceGame
 public static void Draw(RenderWindow window, RenderStates states)
 {
     textList.ForEach(x => x.Draw(window, states));
     textList.Clear();
 }
コード例 #12
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     Text.Draw(target, states);
 }
コード例 #13
0
ファイル: Game.cs プロジェクト: robodylan/LD-29
        /// <summary>
        /// Load things
        /// </summary>
        public void Load()
        {
            // Create Post Process
            glowMap                 = new RenderTexture(window.Size.X, window.Size.Y);
            glowMap2                = new RenderTexture(window.Size.X, window.Size.Y);
            post                    = new RenderTexture(window.Size.X, window.Size.Y);
            glowDisplay             = new Sprite();
            glowDisplay.TextureRect = new IntRect(0, 0, (int)window.Size.X, (int)window.Size.Y);

            blurHorizontal = new Shader("Content/default.vs", "Content/blurh.fs");
            blurHorizontal.SetParameter("texelSize", new Vector2f(1 / (float)window.Size.X, 1 / (float)window.Size.Y));

            blurShaderHorizontal        = new RenderStates(RenderStates.Default);
            blurShaderHorizontal.Shader = blurHorizontal;

            blurVertical = new Shader("Content/default.vs", "Content/blurv.fs");
            blurVertical.SetParameter("texelSize", new Vector2f(1 / (float)window.Size.X, 1 / (float)window.Size.Y));

            blurShaderVertical        = new RenderStates(RenderStates.Default);
            blurShaderVertical.Shader = blurVertical;

            final = new Shader("Content/default.vs", "Content/final.fs");
            final.SetParameter("texelSize", new Vector2f(1 / (float)window.Size.X, 1 / (float)window.Size.Y));

            finalShader        = new RenderStates(RenderStates.Default);
            finalShader.Shader = final;

            // Load Level
            enemies         = new EnemyHandler();
            enemies.OnHit  += (s, e) => { Console.WriteLine("Au"); };
            enemies.OnDead += (s, e) => { Console.WriteLine("Ded"); };

            testlevel = LevelLoader.LoadLevel("Level" + Score + "/", enemies);
            Score    += 1;

            // Load Physics
            testlevel.ComputePhysics();

            // Load Character
            character = new CapsuleShape(0.01f, 0.2f, new PhysicsParams()
            {
                Static = false, Density = 20.0f, X = 6, Y = 56, IsSleeping = false, FixedRotation = true, Friction = 0.5f
            });
            character.Body.CollisionCategories = Category.Cat2;
            tex               = new Texture("Content/character.png");
            spr               = new PhysicsSprite(character.Body, character.Width, character.Height);
            raycpoint         = new OffsetSprite(10, 10);
            raycpoint.Texture = tex;
            raycpoint.Scale   = new Vector2f(Global.Scale, Global.Scale) * 0.1f;
            spr.Texture       = tex;
            Console.WriteLine(Global.Scale);
            spr.Scale   = new Vector2f(Global.Scale * 3, Global.Scale * 3);
            spr.Offset  = new Vector2f(32, -64 - 128) * Global.Scale;
            player      = new Player();
            defaultFont = new Font("Content/consolas.ttf");

            line = new Vertex[3];

            line[0] = new Vertex(new Vector2f(), Color.White);
            line[1] = new Vertex(new Vector2f(), Color.White);
            line[2] = new Vertex(new Vector2f(), Color.White);

            if (Sound)
            {
                // Load Music
                music        = new Music("Content/BackgroundMusic.wav");
                music.Loop   = true;
                music.Volume = vol;
                music.Play();
            }

            // Bullets
            shooting = false;
            bullets  = new BulletHandler();
        }
コード例 #14
0
        public TextBuffer(uint W, uint H, Texture Fnt, int CharW = 8, int CharH = 12)
        {
            this.W = (int)W;
            this.H = (int)H;
            this.CharW = CharW;
            this.CharH = CharH;
            Dirty = true;

            SetFontTexture(Fnt);

            ForeDataRaw = new byte[W * H * 4];
            ForeData = new Texture(new Image(W, H, ForeDataRaw));
            ForeData.Smooth = false;
            BackDataRaw = new byte[W * H * 4];
            BackData = new Texture(new Image(W, H, BackDataRaw));
            BackData.Smooth = false;

            RT = new RenderTexture(W * (uint)CharW, H * (uint)CharH);
            RT.Texture.Smooth = true;
            Sprite = new Sprite(RT.Texture);
            if (TextBufferShader == null)
                TextBufferShader = Shader.FromString(TextBufferVert, TextBufferFrag);
            TextStates = new RenderStates(TextBufferShader);

            ScreenQuad = new Vertex[] {
                new Vertex(new Vector2f(0, 0), Color.White, new Vector2f(0, 0)),
                new Vertex(new Vector2f(RT.Size.X, 0), Color.White, new Vector2f(1, 0)),
                new Vertex(new Vector2f(RT.Size.X, RT.Size.Y), Color.White, new Vector2f(1, 1)),
                new Vertex(new Vector2f(0, RT.Size.Y), Color.White, new Vector2f(0, 1)),
            };

            Clear();
        }
コード例 #15
0
ファイル: Menu.cs プロジェクト: Sinnaj94/csharp-games
 public override void Draw(RenderTarget target, RenderStates states)
 {
     base.Draw(target, states);
     helpSprite.Draw(target, states);
 }
コード例 #16
0
 public void SetRenderState(RenderStates state, int val)
 {
     device.SetRenderState(state, val);
 }
コード例 #17
0
        public void Draw(RenderTarget target, RenderStates states)
        {
            states.Transform *= Transform;

            float ui_size = Tile.tile_size * inventory_ui_size * Core.game_view.Size.X / 1000;
            float full_inventory_poz_x = Core.game_view.Size.X / 2 - small_invent_size / 2 * ui_size;

            inventory_rectangle.Size        = new SFML.System.Vector2f(ui_size, ui_size);
            inventory_icon_rectangle.Size   = new SFML.System.Vector2f(ui_size, ui_size);
            inventory_cursor_rectangle.Size = new SFML.System.Vector2f(ui_size, ui_size);

            for (int i = 0; i < small_invent_size; i++)
            {
                inventory_rectangle.Position        = new Vector2f(full_inventory_poz_x + i * ui_size, Core.game_view.Size.Y - ui_size - ui_size / 10 * 2);
                inventory_icon_rectangle.Position   = new Vector2f(full_inventory_poz_x + i * ui_size, Core.game_view.Size.Y - ui_size - ui_size / 10 * 2);
                inventory_cursor_rectangle.Position = new Vector2f(full_inventory_poz_x + now_cell_ch * ui_size, Core.game_view.Size.Y - ui_size - ui_size / 10 * 2);

                inventory_icon_index       = new Text(inventar_cell_count[invent_size - (small_invent_size - i)].ToString(), font);
                inventory_icon_index.Color = Color.Black;
                inventory_icon_index.Scale = new SFML.System.Vector2f(ui_size / 40, ui_size / 40);

                inventory_icon_index.Position = new Vector2f(i * ui_size + full_inventory_poz_x + ui_size / 8, Core.game_view.Size.Y - ui_size - ui_size / 10 * 2);


                inventory_icon_rectangle.TextureRect = get_icon_rect(inventar_cell_type[invent_size - (small_invent_size - i)]);


                target.Draw(inventory_rectangle, states);
                if (inventar_cell_type[invent_size - (small_invent_size - i)] != TileType.AIR)
                {
                    target.Draw(inventory_icon_rectangle, states);
                }
                if (inventar_cell_count[invent_size - (small_invent_size - i)] != 0)
                {
                    target.Draw(inventory_icon_index, states);
                }
                target.Draw(inventory_cursor_rectangle, states);
            }

            if (full_invent_ui_visibal)
            {
                var rec = new RectangleShape(new SFML.System.Vector2f(Core.game_view.Size.X, Core.game_view.Size.Y));
                rec.Position    = new SFML.System.Vector2f(0, 0);
                rec.Texture     = content.inventory;
                rec.TextureRect = get_rect(0, 1);
                target.Draw(rec, states);


                float full_inventory_poz_y = Core.game_view.Size.Y / 2 - invent_size / small_invent_size / 2 * ui_size - ui_size - 1;

                for (int y = 0; y < invent_size / small_invent_size; y++)
                {
                    if (y == (invent_size / small_invent_size - 1))
                    {
                        full_inventory_poz_y += inventory_ui_size;                                            // small_in_ofset
                    }
                    for (int x = 0; x < small_invent_size; x++)
                    {
                        inventory_rectangle.Position = new Vector2f(x * ui_size + full_inventory_poz_x, y * ui_size + full_inventory_poz_y);

                        inventory_icon_rectangle.Position = new Vector2f(x * ui_size + full_inventory_poz_x, y * ui_size + full_inventory_poz_y);



                        inventory_icon_index       = new Text(inventar_cell_count[y * small_invent_size + x].ToString(), font);
                        inventory_icon_index.Color = Color.Black;
                        inventory_icon_index.Scale = new SFML.System.Vector2f(ui_size / 40, ui_size / 40);

                        inventory_icon_index.Position = new Vector2f(x * ui_size + full_inventory_poz_x + ui_size / 8, full_inventory_poz_y + ui_size * y);


                        inventory_icon_rectangle.TextureRect = get_icon_rect(inventar_cell_type[small_invent_size * y + x]);



                        target.Draw(inventory_rectangle, states);
                        if (inventar_cell_type[y * small_invent_size + x] != TileType.AIR)
                        {
                            target.Draw(inventory_icon_rectangle, states);
                        }
                        if (inventar_cell_count[y * small_invent_size + x] != 0)
                        {
                            target.Draw(inventory_icon_index, states);
                        }
                        target.Draw(inventory_cursor_rectangle, states);
                    }
                }
            }
        }
コード例 #18
0
ファイル: Segment.cs プロジェクト: DipCoy/Tonight
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(rect);
 }
コード例 #19
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(vertices, PrimitiveType.Lines);
 }
コード例 #20
0
 public new void Draw(RenderTarget target, RenderStates states)
 {
     base.Draw(target, states);
     target.Draw(t);
 }
コード例 #21
0
ファイル: InfoOverlay.cs プロジェクト: Syntox32/TowerDefense
 public override void Render(RenderTarget target, RenderStates states)
 {
     _infoPanel.Draw(target, states);
     _unitLabel.Draw(target, states);
     _waveLabel.Draw(target, states);
 }
コード例 #22
0
ファイル: Drawer.cs プロジェクト: Mectonri/BirdHouse-Battle
        public Shape[] PlacementDisplay(Arena arena, string[] status, int[,] teamCompo, int[,] compoLeft,
                                        Unit[] unitToDraw)
        {
            Vector2f Bsize    = new Vector2f(75, 25); //button size
            Font     textfont = new Font("../../../../res/Overlock-Regular.ttf");

            RectangleShape font = new RectangleShape(new Vector2f(1000, 1000));

            font.Position = new Vector2f(0, 512);

            RectangleShape blueFont   = new RectangleShape(new Vector2f(256, 512));
            RectangleShape redFont    = new RectangleShape(new Vector2f(256, 512));
            RectangleShape yellowFont = new RectangleShape(new Vector2f(0, 0));
            RectangleShape greenFont  = new RectangleShape(new Vector2f(0, 0));

            yellowFont.FillColor = new Color(0, 0, 0, 255);
            greenFont.FillColor  = new Color(0, 0, 0, 255);

            RectangleShape button1      = new RectangleShape(new Vector2f(30, 25));
            RectangleShape button10     = new RectangleShape(new Vector2f(30, 25));
            RectangleShape button100    = new RectangleShape(new Vector2f(30, 25));
            Text           txtButton1   = new Text("10", textfont, 15);
            Text           txtButton10  = new Text("30", textfont, 15);
            Text           txtButton100 = new Text("50", textfont, 15);

            RectangleShape selectionRed    = new RectangleShape(Bsize);
            RectangleShape selectionBlue   = new RectangleShape(Bsize);
            RectangleShape selectionGreen  = new RectangleShape(new Vector2f(0, 0));
            RectangleShape selectionYellow = new RectangleShape(new Vector2f(0, 0));

            button1.Position       = new Vector2f(330, 520);
            button10.Position      = new Vector2f(360, 520);
            button100.Position     = new Vector2f(390, 520);
            txtButton1.Position    = new Vector2f(340, 520);
            txtButton10.Position   = new Vector2f(360, 520);
            txtButton100.Position  = new Vector2f(390, 520);
            txtButton1.FillColor   = new Color(0, 0, 0);
            txtButton10.FillColor  = new Color(0, 0, 0);
            txtButton100.FillColor = new Color(0, 0, 0);

            selectionRed.Position   = new Vector2f(90, 520);
            selectionRed.FillColor  = new Color(255, 0, 0);
            selectionBlue.Position  = new Vector2f(10, 520);
            selectionBlue.FillColor = new Color(0, 0, 255);

            Shape buttonUnitSelect = new CircleShape(5);

            buttonUnitSelect.FillColor = new Color(255, 0, 0);

            if (status[2] == "archer")
            {
                buttonUnitSelect.Position = new Vector2f(5, 560);
            }
            else if (status[2] == "drake")
            {
                buttonUnitSelect.Position = new Vector2f(5, 600);
            }
            else if (status[2] == "goblin")
            {
                buttonUnitSelect.Position = new Vector2f(5, 640);
            }
            else if (status[2] == "paladin")
            {
                buttonUnitSelect.Position = new Vector2f(120, 560);
            }
            else if (status[2] == "balista")
            {
                buttonUnitSelect.Position = new Vector2f(120, 600);
            }
            else if (status[2] == "catapult")
            {
                buttonUnitSelect.Position = new Vector2f(120, 640);
            }

            if (arena.FindTeam("green"))
            {
                selectionGreen           = new RectangleShape(Bsize);
                selectionGreen.Position  = new Vector2f(170, 520);
                selectionGreen.FillColor = new Color(0, 255, 0);
            }

            if (arena.FindTeam("yellow"))
            {
                selectionYellow           = new RectangleShape(Bsize);
                selectionYellow.Position  = new Vector2f(250, 520);
                selectionYellow.FillColor = new Color(255, 255, 0);
            }



            if (status[1] == "10")
            {
                button1.FillColor   = new Color(100, 100, 100);
                button10.FillColor  = new Color(200, 200, 200);
                button100.FillColor = new Color(200, 200, 200);
            }
            else if (status[1] == "30")
            {
                button1.FillColor   = new Color(200, 200, 200);
                button10.FillColor  = new Color(100, 100, 100);
                button100.FillColor = new Color(200, 200, 200);
            }
            else
            {
                button1.FillColor   = new Color(200, 200, 200);
                button10.FillColor  = new Color(200, 200, 200);
                button100.FillColor = new Color(100, 100, 100);
            }



            font.FillColor = new Color(255, 255, 255);
            font.Position  = new Vector2f(0, 512);


            redFont.Position  = new Vector2f(256, 0);
            blueFont.Position = new Vector2f(0, 0);

            if (!arena.FindTeam("green"))
            {
                if (status[0] == "red")
                {
                    redFont.FillColor  = new Color(255, 0, 0, 50);
                    blueFont.FillColor = new Color(50, 50, 50, 150);
                }
                else if (status[0] == "blue")
                {
                    redFont.FillColor  = new Color(50, 50, 50, 150);
                    blueFont.FillColor = new Color(0, 0, 255, 50);
                }
            }
            else
            {
                redFont   = new RectangleShape(new Vector2f(256, 256));
                blueFont  = new RectangleShape(new Vector2f(256, 256));
                greenFont = new RectangleShape(new Vector2f(256, 256));

                redFont.Position   = new Vector2f(0, 256);
                blueFont.Position  = new Vector2f(0, 0);
                greenFont.Position = new Vector2f(256, 0);

                selectionGreen.FillColor = new Color(0, 255, 0);

                if (arena.FindTeam("yellow"))
                {
                    yellowFont                = new RectangleShape(new Vector2f(256, 256));
                    yellowFont.Position       = new Vector2f(256, 256);
                    selectionYellow.FillColor = new Color(255, 255, 0);
                    yellowFont.FillColor      = new Color(50, 50, 50, 150);
                }

                if (status[0] == "red")
                {
                    redFont.FillColor   = new Color(255, 0, 0, 50);
                    blueFont.FillColor  = new Color(50, 50, 50, 150);
                    greenFont.FillColor = new Color(50, 50, 50, 150);
                }
                else if (status[0] == "blue")
                {
                    blueFont.FillColor  = new Color(0, 0, 255, 50);
                    redFont.FillColor   = new Color(50, 50, 50, 150);
                    greenFont.FillColor = new Color(50, 50, 50, 150);
                }
                else if (status[0] == "green")
                {
                    greenFont.FillColor = new Color(0, 255, 0, 50);
                    redFont.FillColor   = new Color(50, 50, 50, 150);
                    blueFont.FillColor  = new Color(50, 50, 50, 150);
                }
                else if (status[0] == "yellow")
                {
                    yellowFont.FillColor = new Color(255, 255, 0, 50);
                    redFont.FillColor    = new Color(50, 50, 50, 150);
                    blueFont.FillColor   = new Color(50, 50, 50, 150);
                    greenFont.FillColor  = new Color(50, 50, 50, 150);
                }
            }

            RectangleShape aPoint = new RectangleShape(new Vector2f(0, 0));
            RectangleShape bPoint = new RectangleShape(new Vector2f(0, 0));

            if (status[3] != "NA")
            {
                aPoint           = new RectangleShape(new Vector2f(4, 4));
                aPoint.Position  = new Vector2f(Int32.Parse(status[3]), Int32.Parse(status[4]));
                aPoint.FillColor = new Color(0, 0, 0);
            }

            if (status[5] != "NA")
            {
                bPoint           = new RectangleShape(new Vector2f(4, 4));
                bPoint.Position  = new Vector2f(Int32.Parse(status[5]), Int32.Parse(status[6]));
                bPoint.FillColor = new Color(0, 0, 0);
            }


            Shape[]        buttons         = new Shape[23];
            RenderStates   rs              = new RenderStates();
            RectangleShape randomPlacement = new RectangleShape(Bsize);

            randomPlacement.FillColor = new Color(90, 90, 90);
            randomPlacement.Position  = new Vector2f(380, 600);

            buttons[0]  = font;
            buttons[1]  = redFont;
            buttons[2]  = blueFont;
            buttons[3]  = selectionRed;
            buttons[4]  = selectionBlue;
            buttons[5]  = greenFont;
            buttons[6]  = yellowFont;
            buttons[7]  = selectionGreen;
            buttons[8]  = selectionYellow;
            buttons[9]  = button1;
            buttons[10] = button10;
            buttons[11] = button100;
            buttons[12] = CreateShape(Bsize, "../../../../res/button_archer.png", 10, 560);
            buttons[13] = CreateShape(Bsize, "../../../../res/button_drake.png", 10, 600);
            buttons[14] = CreateShape(Bsize, "../../../../res/button_goblin.png", 10, 640);
            buttons[15] = CreateShape(Bsize, "../../../../res/button_paladin.png", 125, 560);
            buttons[16] = CreateShape(Bsize, "../../../../res/button_balista.png", 125, 600);
            buttons[17] = CreateShape(Bsize, "../../../../res/button_catapult.png", 125, 640);
            buttons[18] = buttonUnitSelect;
            buttons[19] = aPoint;
            buttons[20] = bPoint;
            buttons[21] = CreateShape(Bsize, "../../../../res/button_play.png", 380, 640);
            buttons[22] = randomPlacement;

            Text txtArcher   = new Text("*", textfont, 15);
            Text txtDrake    = new Text("*", textfont, 15);
            Text txtGobelin  = new Text("*", textfont, 15);
            Text txtPaladin  = new Text("*", textfont, 15);
            Text txtBalista  = new Text("*", textfont, 15);
            Text txtCatapult = new Text("*", textfont, 15);
            Text random      = new Text("random", textfont, 15);

            random.Position = new Vector2f(390, 600);

            if (status[0] == "red")
            {
                txtArcher   = new Text("*" + compoLeft[0, 0].ToString(), textfont, 15);
                txtDrake    = new Text("*" + compoLeft[0, 1].ToString(), textfont, 15);
                txtGobelin  = new Text("*" + compoLeft[0, 2].ToString(), textfont, 15);
                txtPaladin  = new Text("*" + compoLeft[0, 3].ToString(), textfont, 15);
                txtBalista  = new Text("*" + compoLeft[0, 4].ToString(), textfont, 15);
                txtCatapult = new Text("*" + compoLeft[0, 5].ToString(), textfont, 15);
            }
            else if (status[0] == "blue")
            {
                txtArcher   = new Text("*" + compoLeft[1, 0].ToString(), textfont, 15);
                txtDrake    = new Text("*" + compoLeft[1, 1].ToString(), textfont, 15);
                txtGobelin  = new Text("*" + compoLeft[1, 2].ToString(), textfont, 15);
                txtPaladin  = new Text("*" + compoLeft[1, 3].ToString(), textfont, 15);
                txtBalista  = new Text("*" + compoLeft[1, 4].ToString(), textfont, 15);
                txtCatapult = new Text("*" + compoLeft[1, 5].ToString(), textfont, 15);
            }
            else if (status[0] == "green")
            {
                txtArcher   = new Text("*" + compoLeft[2, 0].ToString(), textfont, 15);
                txtDrake    = new Text("*" + compoLeft[2, 1].ToString(), textfont, 15);
                txtGobelin  = new Text("*" + compoLeft[2, 2].ToString(), textfont, 15);
                txtPaladin  = new Text("*" + compoLeft[2, 3].ToString(), textfont, 15);
                txtBalista  = new Text("*" + compoLeft[2, 4].ToString(), textfont, 15);
                txtCatapult = new Text("*" + compoLeft[2, 5].ToString(), textfont, 15);
            }
            else
            {
                txtArcher   = new Text("*" + compoLeft[3, 0].ToString(), textfont, 15);
                txtDrake    = new Text("*" + compoLeft[3, 1].ToString(), textfont, 15);
                txtGobelin  = new Text("*" + compoLeft[3, 2].ToString(), textfont, 15);
                txtPaladin  = new Text("*" + compoLeft[3, 3].ToString(), textfont, 15);
                txtBalista  = new Text("*" + compoLeft[3, 4].ToString(), textfont, 15);
                txtCatapult = new Text("*" + compoLeft[3, 5].ToString(), textfont, 15);
            }


            txtArcher.Position   = new Vector2f(90, 560);
            txtDrake.Position    = new Vector2f(90, 600);
            txtGobelin.Position  = new Vector2f(90, 640);
            txtPaladin.Position  = new Vector2f(205, 560);
            txtBalista.Position  = new Vector2f(205, 600);
            txtCatapult.Position = new Vector2f(205, 640);

            Text[] text = new Text[10];

            text[0] = txtButton1;
            text[1] = txtButton10;
            text[2] = txtButton100;
            text[3] = txtArcher;
            text[4] = txtDrake;
            text[5] = txtGobelin;
            text[6] = txtPaladin;
            text[7] = txtBalista;
            text[8] = txtCatapult;
            text[9] = random;

            for (int i = 3; i < text.Length; i++)
            {
                text[i].FillColor = new Color(0, 0, 0);
            }

            foreach (var t in buttons)
            {
                _window.Draw(t);
            }

            foreach (var t2 in text)
            {
                t2.Draw(_window, rs);
                _window.Draw(t2);
            }

            for (int i = 0; i < 800; i++)
            {
                if (!(unitToDraw[i] is null))
                {
                    Shape shape;
                    _window.Draw(shape = DisplayUnit(unitToDraw[i]));
                }
            }

            return(buttons);
        }
コード例 #23
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(_sprite, states);
     target.SetView(target.DefaultView);
 }
コード例 #24
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Draws the widget on the render target
        /// </summary>
        ///
        /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public override void Draw(RenderTarget target, RenderStates states)
        {
            // Apply the transformation
            states.Transform *= Transform;

            // Remember the current transformation
            Transform oldTransform = states.Transform;

            // Check if the image is split
            if (m_SplitImage)
            {
                float scalingY = m_Size.Y / m_TextureBack_M.Size.Y;

                // Scale the image
                states.Transform.Scale(scalingY, scalingY);

                // Draw the left image of the loading bar
                target.Draw(m_TextureBack_L.sprite, states);
                target.Draw(m_TextureFront_L.sprite, states);

                // Check if the middle image may be drawn
                if ((scalingY * (m_TextureBack_L.Size.X + m_TextureBack_R.Size.X)) < m_Size.X)
                {
                    // Put the middle image on the correct position
                    states.Transform.Translate(m_TextureBack_L.Size.X, 0);

                    // Draw the middle image
                    target.Draw(m_TextureBack_M.sprite, states);
                    target.Draw(m_TextureFront_M.sprite, states);

                    // Put the right image on the correct position
                    states.Transform.Translate(m_TextureBack_M.sprite.GetGlobalBounds().Width, 0);

                    // Draw the right image
                    target.Draw(m_TextureBack_R.sprite, states);
                    target.Draw(m_TextureFront_R.sprite, states);
                }
                else // The loading bar isn't width enough, we will draw it at minimum size
                {
                    // Put the right image on the correct position
                    states.Transform.Translate(m_TextureBack_L.sprite.GetGlobalBounds().Width, 0);
                    states.Transform.Translate(m_TextureBack_L.Size.X, 0);

                    // Draw the right image
                    target.Draw(m_TextureBack_R.sprite, states);
                    target.Draw(m_TextureFront_R.sprite, states);
                }
            }
            else // The image is not split
            {
                // Scale the image
                states.Transform.Scale(m_Size.X / m_TextureBack_M.Size.X, m_Size.Y / m_TextureBack_M.Size.Y);

                // Draw the loading bar
                target.Draw(m_TextureBack_M.sprite, states);
                target.Draw(m_TextureFront_M.sprite, states);
            }

            // Check if there is a text to draw
            if (m_Text.DisplayedString.Length != 0)
            {
                // Reset the transformations
                states.Transform = oldTransform;

                // Get the current size of the text, so that we can recalculate the position
                FloatRect rect = m_Text.GetGlobalBounds();

                // Calculate the new position for the text
                rect.Left = (m_Size.X - rect.Width) * 0.5f - rect.Left;
                rect.Top  = (m_Size.Y - rect.Height) * 0.5f - rect.Top;

                // Set the new position
                states.Transform.Translate((float)System.Math.Floor(rect.Left + 0.5), (float)System.Math.Floor(rect.Top + 0.5));

                // Draw the text
                target.Draw(m_Text, states);
            }
        }
コード例 #25
0
 public override void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(_sprite, states);
 }
コード例 #26
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     target.Draw(this._array, states);
 }
コード例 #27
0
 public void Draw(RenderTarget target, RenderStates renderstate)
 {
     target.Draw(obj);
 }
コード例 #28
0
 static internal void Batchable(VertexArray vertices, RenderStates states)
 {
     SpriteBatch.Begin();
     SpriteBatch.Draw(vertices, states);
 }
コード例 #29
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     Update();
     uiGrid.Draw(target, states);
 }
コード例 #30
0
 public void Draw(RenderTarget target, RenderStates states)
 {
     states.Transform *= this.Transform;
     target.Draw(mBack, states);
 }
コード例 #31
0
        /// <summary>
        /// Handles the actual drawing of the buffer to a <see cref="RenderTarget"/>.
        /// </summary>
        /// <param name="buffer">The <see cref="Texture"/> of the buffer that is to be drawn to the <paramref name="target"/>.</param>
        /// <param name="sprite">The <see cref="SFML.Graphics.Sprite"/> set up to draw the <paramref name="buffer"/>.</param>
        /// <param name="target">The <see cref="RenderTarget"/> to draw the <paramref name="buffer"/> to.</param>
        /// <param name="camera">The <see cref="ICamera2D"/> that was used during the creation of the buffer.</param>
        protected override void HandleDrawBufferToTarget(Texture buffer, SFML.Graphics.Sprite sprite, RenderTarget target, ICamera2D camera, RenderStates renderStates)
        {
            renderStates.BlendMode = BlendMode.None;

            // Set up the shader
            DrawToTargetShader.SetParameter("ColorMap", _colorMap);
            DrawToTargetShader.SetParameter("NoiseMap", buffer);

            base.HandleDrawBufferToTarget(buffer, sprite, target, camera, renderStates);
        }
コード例 #32
0
 public void Draw(RenderTarget R, RenderStates S)
 {
     Update();
     Sprite.Draw(R, S);
 }
コード例 #33
0
ファイル: Tile.cs プロジェクト: Sinnaj94/csharp-games
 public void DebugDraw(RenderTarget target, RenderStates states)
 {
     test.Draw(target, states);
 }
コード例 #34
0
 public void SetRenderState(ref int cachedValue, RenderStates state, int val)
 {
     if (cachedValue != val) {
         cachedValue = val;
         device.SetRenderState(state, val);
     }
 }
コード例 #35
0
		public void Draw(RenderTarget target, RenderStates states)
		{
			Update();
			target.Draw(background, states);
			foreach (var drawable in texts) target.Draw(drawable, states);
		}
コード例 #36
0
ファイル: Direct3DHost.cs プロジェクト: deobald/midget
        private void Initialize3DEnvironment()
        {
            DisplayAdapter adapterInfo = graphicsSettings.DisplayAdapter;
            DisplayDevice deviceInfo = graphicsSettings.DisplayDevice;

            isWindowed = graphicsSettings.IsWindowed;

            // Prepare window for possible windowed/fullscreen change
            // AdjustWindowForChange();

            // Set up the presentation parameters
            RefreshPresentParameters();

            if(deviceInfo.Caps.PrimitiveMiscCaps.IsNullReference)
            {
                // Warn user about null ref device that can't render anything
                throw new ApplicationException("null reference device");
            }

            CreateFlags createFlags = new CreateFlags();
            switch(graphicsSettings.VertexProcessingType)
            {
                case VertexProcessingType.Software:
                    createFlags = CreateFlags.SoftwareVertexProcessing;
                    break;
                case VertexProcessingType.Mixed:
                    createFlags = CreateFlags.MixedVertexProcessing;
                    break;
                case VertexProcessingType.Hardware:
                    createFlags = CreateFlags.HardwareVertexProcessing;
                    break;
                case VertexProcessingType.PureHardware:
                    createFlags = CreateFlags.HardwareVertexProcessing | CreateFlags.PureDevice;
                    break;
                default:
                    throw new ApplicationException("Unable to determine vertex processing method.");
            }

            // Create the device
            device = new Device(graphicsSettings.AdapterOrdinal,
                graphicsSettings.DisplayDevice.DeviceType,
                this.viewport,
                createFlags,
                this.presentParameters);

            if( device != null )
            {
                // Cache our local objects
                renderStates = device.RenderState;
                samplerStates = device.SamplerState;
                textureStates = device.TextureState;
                // When moving from fullscreen to windowed mode, it is important to
                // adjust the window size after recreating the device rather than
                // beforehand to ensure that you get the window size you want.  For
                // example, when switching from 640x480 fullscreen to windowed with
                // a 1000x600 window on a 1024x768 desktop, it is impossible to set
                // the window size to 1000x600 until after the display mode has
                // changed to 1024x768, because windows cannot be larger than the
                // desktop.
                if(graphicsSettings.IsWindowed && (this.viewport is System.Windows.Forms.Form))
                {
                    // Make sure main window isn't topmost, so error message is visible
                    this.viewport.Location = new System.Drawing.Point(rectWindowBounds.Left, rectWindowBounds.Top);
                    this.viewport.Size = new System.Drawing.Size(( rectWindowBounds.Right - rectWindowBounds.Left ), ( rectWindowBounds.Bottom - rectWindowBounds.Top));
                }

                // Store device Caps
                graphicsCaps = device.DeviceCaps;
                behavior = createFlags;

                // Store render target surface desc
                Surface BackBuffer = device.GetBackBuffer(0,0, BackBufferType.Mono);
                backBufferDesc = BackBuffer.Description;
                BackBuffer.Dispose();
                BackBuffer = null;

                // Set up the fullscreen cursor
                if(showFullScreenCursor && !graphicsSettings.IsWindowed)
                {
                    System.Windows.Forms.Cursor ourCursor = this.viewport.Cursor;
                    device.SetCursor(ourCursor, true);
                    device.ShowCursor(true);
                }

                // Confine cursor to fullscreen window
                if(clipFullScreenCursor)
                {
                    if (!isWindowed)
                    {
                        System.Drawing.Rectangle rcWindow = this.viewport.ClientRectangle;
                    }
                }

                // Setup the event handlers for our device
                device.DeviceLost += InvalidateDeviceObjects;
                device.DeviceReset += RestoreDeviceObjects;
                device.Disposing += DeleteDeviceObjects;
                device.DeviceResizing += new CancelEventHandler(EnvironmentResized);

                // Initialize the app's device-dependent objects
                try
                {
                    if(InitDeviceObjects != null)
                        InitDeviceObjects(null, null);

                    if(RestoreDeviceObjects != null)
                        RestoreDeviceObjects(null, null);

                    return;
                }
                catch
                {
                    // Cleanup before we try again
                    if(InvalidateDeviceObjects != null)
                        InvalidateDeviceObjects(null, null);

                    if(DeleteDeviceObjects != null)
                        DeleteDeviceObjects(null, null);

                    device.Dispose();
                    device = null;

                    if(this.viewport.Disposing)
                        return;
                }
            }

            //	HACK: removed fallback to reference rasterizer
            /*
            // If that failed, fall back to the reference rasterizer
            if( deviceInfo.DevType == Direct3D.DeviceType.Hardware )
            {
                if (FindBestWindowedMode(false, true))
                {
                    isWindowed = true;
                    if(viewport is System.Windows.Forms.Form)
                    {
                        // Make sure main window isn't topmost, so error message is visible
                        this.viewport.Location = new System.Drawing.Point(windowBoundsRect.Left, windowBoundsRect.Top);
                        this.viewport.Size = new System.Drawing.Size(( windowBoundsRect.Right - windowBoundsRect.Left ), ( windowBoundsRect.Bottom - windowBoundsRect.Top));
                        //AdjustWindowForChange();
                    }

                    // Let the user know we are switching from HAL to the reference rasterizer
                    //DisplayErrorMsg( null, AppMsgType.WarnSwitchToRef);

                    Initialize3DEnvironment();
                }
            }
            */
        }
コード例 #37
0
        /// <summary>
        /// Imposta il tipo di riempimento dei poligoni.
        /// </summary>
        /// <param name="RenderState"></param>
        /// <returns></returns>
        public bool SetRenderState(RenderStates RenderState)
        {
            switch (RenderState)
            {
                case RenderStates.Wireframe:
                    device.RenderState.FillMode = FillMode.WireFrame;
                    return true;
                case RenderStates.Solid:
                    device.RenderState.FillMode = FillMode.Solid;
                    return true;
                case RenderStates.Point:
                    device.RenderState.FillMode = FillMode.Point;
                    return true;
                default:
                    return false;

            }
        }