コード例 #1
0
        public override void Draw(CustomSpriteBatch g, Matrix View)
        {
            Matrix World = Matrix.CreateTranslation(0f, 0f, 0f);

            VehiculeDrawablePart.ArrayParticles[0].Position     = Position;
            VehiculeDrawablePart.ArrayParticles[0 + 1].Position = Position;
            VehiculeDrawablePart.ArrayParticles[0 + 2].Position = Position;
            VehiculeDrawablePart.ArrayParticles[0 + 3].Position = Position;

            VehiculeDrawablePart.MoveParticle(0, Vector3.Zero);
            VehiculeDrawablePart.SetViewProjection(World * View, Projection);
            VehiculeDrawablePart.Draw(g.GraphicsDevice);

            foreach (Object3D AntiGravPropulsor in ArrayAntiGravPropulsor)
            {
                AntiGravPropulsor.Draw(g, View);
            }
        }
コード例 #2
0
        public override void Draw(CustomSpriteBatch g, Matrix View, Matrix Projection, int ScreenWidth, int ScreenHeight)
        {
            int MaxRepeatX = 0;

            if (ActiveBillboardSystem.RepeatX)
            {
                MaxRepeatX = MaxRepeat;
            }

            for (int X = -MaxRepeatX; X <= MaxRepeatX; ++X)
            {
                int MaxRepeatY = 0;
                if (ActiveBillboardSystem.RepeatY)
                {
                    MaxRepeatY = MaxRepeat;
                }

                for (int Y = -MaxRepeatY; Y <= MaxRepeatY; Y++)
                {
                    int MaxRepeatZ = 0;
                    if (ActiveBillboardSystem.RepeatZ)
                    {
                        MaxRepeatZ = MaxRepeat;
                    }

                    for (int Z = -MaxRepeatZ; Z <= MaxRepeatZ; Z++)
                    {
                        Matrix World = Matrix.CreateTranslation(X * ActiveBillboardSystem.RepeatOffset.X, Y * ActiveBillboardSystem.RepeatOffset.Y, Z * ActiveBillboardSystem.RepeatOffset.Z);

                        ActiveBillboardSystem.SetViewProjection(World * View, Projection);

                        //g.GraphicsDevice.Viewport.Unproject(MyVector3Location, Projection, View, World);
                        ActiveBillboardSystem.Draw(GameScreen.GraphicsDevice);
                    }
                }
            }
        }
コード例 #3
0
ファイル: Game1.cs プロジェクト: AD-7/PBL_Game
        protected override void Draw(GameTime gameTime)
        {
            graphics.GraphicsDevice.Clear(Color.Black);


            if (!hud.huntingSystem.active)
            {
                if (gameInMainMenu)
                {
                    mainMenu.Draw();
                }
                else if (mainMenu.ifIntro)
                {
                    mainMenu.intro.Draw();
                }
                else
                {
                    RasterizerState originalRasterizerState = graphics.GraphicsDevice.RasterizerState;
                    RasterizerState rasterizerState         = new RasterizerState();
                    rasterizerState.CullMode = CullMode.None;
                    graphics.GraphicsDevice.RasterizerState = rasterizerState;
                    GraphicsDevice.SamplerStates[1]         = SamplerState.LinearClamp;

                    device.SetRenderTarget(renderTarget);
                    device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);



                    foreach (Wolf w in wataha.wolves)
                    {
                        w.Draw(camera, "ShadowMap");
                    }
                    foreach (Animal rabit in rabits)
                    {
                        rabit.Draw(camera, "ShadowMap");
                    }

                    if (QuestSystem.currentQuest is SheepQuest)
                    {
                        foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                        {
                            sheep.Draw(camera, "ShadowMap");
                        }
                    }
                    if (QuestSystem.currentQuest is FindToolsQuest)
                    {
                        foreach (GameObject tool in ((FindToolsQuest)QuestSystem.currentQuest).tools)
                        {
                            tool.Draw(camera, "ShadowMap");
                        }
                    }

                    foreach (QuestGiver q in QuestSystem.questGivers)
                    {
                        q.Draw(camera, "ShadowMap");
                    }
                    trees.Draw(camera, "ShadowMap");
                    if (!(QuestSystem.questGivers[1].actualQuest == null && QuestSystem.questGivers[1].questCompleted.Count == QuestSystem.questGivers[1].questsList.Count))
                    {
                        blockade.Draw(camera, "ShadowMap");
                    }
                    blockade2.Draw(camera, "ShadowMap");
                    croft.Draw(camera, "ShadowMap");
                    barrell.Draw(camera, "ShadowMap");
                    device.SetRenderTarget(null);


                    foreach (Wolf w in wataha.wolves)
                    {
                        w.shadowMap = (Texture2D)renderTarget;
                    }
                    foreach (Animal rabit in rabits)
                    {
                        rabit.shadowMap = (Texture2D)renderTarget;
                    }

                    if (QuestSystem.currentQuest is SheepQuest)
                    {
                        foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                        {
                            sheep.shadowMap = (Texture2D)renderTarget;
                        }
                    }
                    if (QuestSystem.currentQuest is FindToolsQuest)
                    {
                        foreach (GameObject tool in ((FindToolsQuest)QuestSystem.currentQuest).tools)
                        {
                            tool.shadowMap = (Texture2D)renderTarget;
                        }
                    }

                    foreach (QuestGiver q in QuestSystem.questGivers)
                    {
                        q.shadowMap = (Texture2D)renderTarget;
                    }
                    trees.shadowMap     = (Texture2D)renderTarget;
                    blockade.shadowMap  = (Texture2D)renderTarget;
                    blockade2.shadowMap = (Texture2D)renderTarget;
                    croft.shadowMap     = (Texture2D)renderTarget;
                    barrell.shadowMap   = (Texture2D)renderTarget;

                    device.SetRenderTarget(renderTarget2);

                    device.Clear(ClearOptions.Target | ClearOptions.DepthBuffer, Color.Black, 1.0f, 0);

                    device.BlendState = BlendState.AlphaBlend;


                    foreach (Wolf w in wataha.wolves)
                    {
                        w.Draw(camera, "ShadowedScene");
                    }
                    foreach (Animal rabit in rabits)
                    {
                        rabit.Draw(camera, "ShadowedScene");
                    }

                    if (QuestSystem.currentQuest is SheepQuest)
                    {
                        foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                        {
                            sheep.Draw(camera, "ShadowedScene");
                        }
                    }
                    if (QuestSystem.currentQuest is FindToolsQuest)
                    {
                        foreach (GameObject tool in ((FindToolsQuest)QuestSystem.currentQuest).tools)
                        {
                            tool.Draw(camera, "ShadowedScene");
                        }
                    }
                    foreach (QuestGiver q in QuestSystem.questGivers)
                    {
                        q.Draw(camera, "ShadowedScene");
                    }
                    trees.Draw(camera, "ShadowedScene");
                    if (!(QuestSystem.questGivers[1].actualQuest == null && QuestSystem.questGivers[1].questCompleted.Count == QuestSystem.questGivers[1].questsList.Count))
                    {
                        blockade.Draw(camera, "ShadowedScene");
                    }
                    blockade2.Draw(camera, "ShadowedScene");
                    croft.Draw(camera, "ShadowedScene");
                    barrell.Draw(camera, "ShadowedScene");
                    device.BlendState = BlendState.Opaque;
                    skybox.Draw(camera);
                    reflekt.DrawModelWithEffect(camera.View, camera.Projection, camera);

                    foreach (QuestGiver q in QuestSystem.questGivers)
                    {
                        q.shadowMap = null;
                    }

                    foreach (Wolf w in wataha.wolves)
                    {
                        w.shadowMap = null;
                    }
                    foreach (Animal rabit in rabits)
                    {
                        rabit.shadowMap = null;
                    }

                    if (QuestSystem.currentQuest is SheepQuest)
                    {
                        foreach (Animal sheep in ((SheepQuest)QuestSystem.currentQuest).sheeps)
                        {
                            sheep.shadowMap = null;
                        }
                    }
                    if (QuestSystem.currentQuest is FindToolsQuest)
                    {
                        foreach (GameObject tool in ((FindToolsQuest)QuestSystem.currentQuest).tools)
                        {
                            tool.shadowMap = null;
                        }
                    }


                    trees.shadowMap     = null;
                    blockade.shadowMap  = null;
                    blockade2.shadowMap = null;
                    croft.shadowMap     = null;
                    barrell.shadowMap   = null;
                    graphics.GraphicsDevice.RasterizerState = originalRasterizerState;


                    billboardTest.Draw(camera.View, camera.Projection, wolf.cam.up, camera.right);
                    billboardTest2.Draw(camera.View, camera.Projection, wolf.cam.up, camera.right);
                    ps.Draw(camera.View, camera.Projection, wolf.cam.up, wolf.cam.right);

                    hud.Draw();

                    device.SetRenderTarget(null);
                    GraphicsDevice.Clear(Color.Black);


                    spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.Opaque,
                                      SamplerState.LinearClamp, DepthStencilState.Default,
                                      RasterizerState.CullNone, Content.Load <Effect>("Effects/post"));
                    spriteBatch.Draw(renderTarget2, new Rectangle(0, 0, device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight), Color.White);

                    spriteBatch.End();
                }
            }

            else
            {
                hud.huntingSystem.Draw();
            }

            base.Draw(gameTime);
        }
コード例 #4
0
ファイル: MainGame.cs プロジェクト: RubenTipparach/Kobayashi
        /// <summary>
        /// Primary draw method.
        /// </summary>
        /// <param name="gameTime">Handeled by the framework, the passage of time is updated automagically.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);

            _skybox.Draw(_camera.View, _camera.Projection, _camera.Position);

            foreach (BasicModel model in _models)
            {
                if (_camera.BoundingVolumeIsInView(model.BoundingSphere))
                {
                    model.Draw(_camera.View, _camera.Projection, _camera.Position);
                }
            }

            _lineDrawer.Begin(_camera.View, _camera.Projection);

            _lineDrawer.DrawHexagonGrid(Vector2.One * -9930, (new Vector2(80, 40)), 200, Color.Red);
            _lineDrawer.DrawLine(_models[0].Position, new Vector3(_models[0].Position.X, 0, _models[0].Position.Z), Color.CornflowerBlue);

            ShipMovement.DrawHeading();
            ShipMovement.DrawMarker();

            _lineDrawer.End();

            _stars.Draw(_camera.View, _camera.Projection, _camera.Up, _camera.Right);

            // if rendered card buffer is null, initialize it here
            if (_renderedCardBuffer == null)
            {
                // Choosing a random card for testing...
                Random r = new Random();
                //Card c = _cards[r.Next(_cards.Count)];
                Card c = null;
                foreach (Card cx in _cards)
                {
                    if (cx.Title == "Patrol Drone")
                    //if (_rulesTextFont.MeasureString(WrapText(_rulesTextFont, cx.RulesText, _cardRulesWidth)).Y > _cardRulesHeight)
                    {
                        c = cx;
                        //Debug.WriteLine("{0}", _rulesTextFont.MeasureString(WrapText(_rulesTextFont, cx.RulesText, _cardRulesWidth)).Y - _cardRulesHeight);
                        break;
                    }
                }

                string someRandomText = c.RulesText;
                someRandomText = WrapText(_rulesTextFont, someRandomText, _cardRulesWidth);
                Vector2 textSize = _rulesTextFont.MeasureString(someRandomText);

                string  titleString = c.Title;
                Vector2 titleSize   = _titleFont.MeasureString(titleString);

                string typeString    = c.Supertype.ToString();
                string subtypeString = c.Subtype.ToString();
                if (subtypeString != "None")
                {
                    typeString = typeString + " - " + c.Subtype.ToString();
                }
                Vector2 typeSize = _typeFont.MeasureString(typeString);

                string  costString = (c.EnergyCostType == AmountType.Variable) ? Description.ToDescription(c.EnergyCostVar).Replace("+", string.Empty) : c.EnergyCost.ToString();
                Vector2 costSize   = _statFont.MeasureString(costString);

                Rectangle cardRect = new Rectangle(
                    0,
                    0,
                    _cardTexture.Width,
                    _cardTexture.Height);

                float titleScale = 1;
                if (titleSize.X > _cardTitleWidth)
                {
                    titleScale = _cardTitleWidth / titleSize.X;
                }

                float typeScale = 1;
                if (typeSize.X > _cardTypeWidth)
                {
                    typeScale = _cardTypeWidth / typeSize.X;
                }

                float costScale = 1;
                if (costSize.X > _cardCostWidth)
                {
                    costScale = _cardCostWidth / costSize.X;
                }

                // render the title text's shadow
                RenderTarget2D titleShadowTarget = new RenderTarget2D(GraphicsDevice, _cardTitleWidth, _cardTitleHeight, false,
                                                                      GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
                GraphicsDevice.SetRenderTarget(titleShadowTarget);
                GraphicsDevice.Clear(Color.Transparent);
                _spriteBatch.Begin();
                _spriteBatch.DrawString(_titleFont, titleString,
                                        new Vector2((int)((_cardTitleWidth - titleSize.X * titleScale) / 2), (int)((_cardTitleHeight - titleSize.Y * titleScale) / 2)),
                                        Color.White, 0, Vector2.Zero, titleScale, SpriteEffects.None, 0);
                _spriteBatch.End();

                // do blur
                GaussianBlur gaussianBlur = new GaussianBlur(this);
                gaussianBlur.ComputeKernel(4, 2);
                int            renderTargetWidth  = titleShadowTarget.Width / 2;
                int            renderTargetHeight = titleShadowTarget.Height / 2;
                RenderTarget2D rt1 = new RenderTarget2D(GraphicsDevice,
                                                        renderTargetWidth, renderTargetHeight, false,
                                                        GraphicsDevice.PresentationParameters.BackBufferFormat,
                                                        DepthFormat.None);
                RenderTarget2D rt2 = new RenderTarget2D(GraphicsDevice,
                                                        renderTargetWidth, renderTargetHeight, false,
                                                        GraphicsDevice.PresentationParameters.BackBufferFormat,
                                                        DepthFormat.None);
                gaussianBlur.ComputeOffsets(renderTargetWidth, renderTargetHeight);
                Texture2D titleShadowResult = gaussianBlur.PerformGaussianBlur(titleShadowTarget, rt1, rt2, _spriteBatch);

                // render the type text's shadow
                RenderTarget2D typeShadowTarget = new RenderTarget2D(GraphicsDevice, _cardTypeWidth, _cardTypeHeight, false,
                                                                     GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
                GraphicsDevice.SetRenderTarget(typeShadowTarget);
                GraphicsDevice.Clear(Color.Transparent);
                _spriteBatch.Begin();
                _spriteBatch.DrawString(_typeFont, typeString,
                                        new Vector2((int)((_cardTypeWidth - typeSize.X * typeScale) / 2), (int)((_cardTypeHeight - typeSize.Y * typeScale) / 2)),
                                        Color.White, 0, Vector2.Zero, typeScale, SpriteEffects.None, 0);
                _spriteBatch.End();

                // do blur
                renderTargetWidth  = typeShadowTarget.Width / 2;
                renderTargetHeight = typeShadowTarget.Height / 2;
                rt1 = new RenderTarget2D(GraphicsDevice,
                                         renderTargetWidth, renderTargetHeight, false,
                                         GraphicsDevice.PresentationParameters.BackBufferFormat,
                                         DepthFormat.None);
                rt2 = new RenderTarget2D(GraphicsDevice,
                                         renderTargetWidth, renderTargetHeight, false,
                                         GraphicsDevice.PresentationParameters.BackBufferFormat,
                                         DepthFormat.None);
                gaussianBlur.ComputeOffsets(renderTargetWidth, renderTargetHeight);
                Texture2D typeShadowResult = gaussianBlur.PerformGaussianBlur(typeShadowTarget, rt1, rt2, _spriteBatch);

                // render the card
                _renderedCardBuffer = new RenderTarget2D(GraphicsDevice, _cardTexture.Width, _cardTexture.Height, false,
                                                         GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24);
                GraphicsDevice.SetRenderTarget(_renderedCardBuffer);
                GraphicsDevice.Clear(Color.Transparent);

                _spriteBatch.Begin();
                _spriteBatch.Draw(_cardTexture, cardRect, Color.White);
                _spriteBatch.DrawString(_rulesTextFont, someRandomText,
                                        new Vector2(_cardRulesLeftX, (int)(_cardRulesTopY + (_cardRulesHeight - textSize.Y) / 2)),
                                        Color.Black, 0, Vector2.Zero, 1, SpriteEffects.None, 0);

                _spriteBatch.Draw(titleShadowResult,
                                  new Rectangle((int)(_cardTitleLeftX + (_cardTitleWidth - titleShadowResult.Width * 2) / 2), (int)(_cardTitleTopY + (_cardTitleHeight - titleShadowResult.Height * 2) / 2), titleShadowResult.Width * 2, titleShadowResult.Height * 2),
                                  new Rectangle(0, 0, titleShadowResult.Width, titleShadowResult.Height),
                                  Color.White);
                _spriteBatch.Draw(typeShadowResult,
                                  new Rectangle((int)(_cardTypeLeftX + (_cardTypeWidth - typeShadowResult.Width * 2) / 2), (int)(_cardTypeTopY + (_cardTypeHeight - typeShadowResult.Height * 2) / 2), typeShadowResult.Width * 2, typeShadowResult.Height * 2),
                                  new Rectangle(0, 0, typeShadowResult.Width, typeShadowResult.Height),
                                  Color.White);
                _spriteBatch.DrawString(_titleFont, titleString,
                                        new Vector2((int)(_cardTitleLeftX + (_cardTitleWidth - titleSize.X * titleScale) / 2), (int)(_cardTitleTopY + (_cardTitleHeight - titleSize.Y * titleScale) / 2)),
                                        Color.Black, 0, Vector2.Zero, titleScale, SpriteEffects.None, 0);
                _spriteBatch.DrawString(_typeFont, typeString,
                                        new Vector2((int)(_cardTypeLeftX + (_cardTypeWidth - typeSize.X * typeScale) / 2), (int)(_cardTypeTopY + (_cardTypeHeight - typeSize.Y * typeScale) / 2)),
                                        Color.Black, 0, Vector2.Zero, typeScale, SpriteEffects.None, 0);
                _spriteBatch.DrawString(_statFont, costString,
                                        new Vector2((int)(_cardCostLeftX + (_cardCostWidth - costSize.X * costScale) / 2), (int)(_cardCostTopY + (_cardCostHeight - costSize.Y * costScale) / 2)),
                                        Color.Black, 0, Vector2.Zero, costScale, SpriteEffects.None, 0);

                _spriteBatch.End();

                GraphicsDevice.SetRenderTarget(null);
            }

            // Draw cards *this should always appear at the end so its on top
            _spriteBatch.Begin();
            float scale = .4f;

            // Note: this is arbitrary rules text for testing...
            Rectangle retval = new Rectangle(
                0 + 10,
                GraphicsDevice.Viewport.Height - (int)(_cardTexture.Height * scale) - 10,
                (int)(_cardTexture.Width * scale),
                (int)(_cardTexture.Height * scale));

            _spriteBatch.Draw(_renderedCardBuffer, retval, Color.White);

            _spriteBatch.End();

            base.Draw(gameTime);
        }