コード例 #1
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Fonts/Default");
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);

            float aspectRatio = GraphicsDevice.Viewport.AspectRatio;

            cameraPosition = new Vector3(0, 0, 30);
            view           = Matrix.CreateLookAt(cameraPosition, Vector3.Zero, Vector3.Up);
            projection     = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(30), aspectRatio, 1, 1000);

            // インスタンス情報を格納する為の頂点バッファの生成
            instanceVertexBuffer      = new WritableVertexBuffer <ObjectInstanceVertex>(GraphicsDevice, MaxGameObjectCount * 2);
            directMappingVertexBuffer = new WritableVertexBuffer <GameObject>(GraphicsDevice, MaxGameObjectCount * 2);

            // モデルの移動範囲の設定
            float sandBoxSize = 20.0f;

            Sandbox.Min.X = sandBoxSize * -0.5f * aspectRatio;
            Sandbox.Min.Y = sandBoxSize * -0.5f;
            Sandbox.Max.X = sandBoxSize * 0.5f * aspectRatio;
            Sandbox.Max.Y = sandBoxSize * 0.5f;

            // BlockMesh をロードします。
            LoadBlockMesh();

            // ゲームオブジェクトの初期化
            InitializeGameObjects();
        }
コード例 #2
0
ファイル: TimeRuler.cs プロジェクト: willcraftia/TestBlocks
        protected override void LoadContent()
        {
            var titleSafeArea = GraphicsDevice.Viewport.TitleSafeArea;

            // 表示幅を TitleSafeArea から余白を考慮した値に設定。
            width = titleSafeArea.Width - 16;

            // 表示位置を計算。
            // 高さはバーの数で変動するため、Bottom 合わせで固定し、Bottom ラインをベースに描画時に調整。
            var layout = new DebugLayout()
            {
                ContainerBounds     = titleSafeArea,
                Width               = width,
                Height              = 0,
                HorizontalMargin    = 8,
                VerticalMargin      = 8,
                HorizontalAlignment = DebugHorizontalAlignment.Center,
                VerticalAlignment   = DebugVerticalAlignment.Bottom
            };

            layout.Arrange();

            offsetX = layout.ArrangedBounds.X;
            offsetY = layout.ArrangedBounds.Y;

            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            spriteFont  = Game.Content.Load <SpriteFont>(fontAssetName);

            base.LoadContent();
        }
コード例 #3
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _gameSpriteBatch = new SpriteBatch(GraphicsDevice);
            _uiSpriteBatch   = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            _resources.SetTexture2D("tileTexture", Texture2DHelper.CreateWhiteTexture2D(GraphicsDevice, 32, 32));
        }
コード例 #4
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font        = Content.Load <SpriteFont>("Fonts/Debug");
            fontSize    = font.MeasureString("FPS: 00.00000");
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);

            base.LoadContent();
        }
コード例 #5
0
ファイル: MainGame.cs プロジェクト: willcraftia/TestBlocks
        protected override void LoadContent()
        {
            logger.Info("LoadContent");

            //----------------------------------------------------------------
            // ストレージ マネージャ

            StorageManager.SelectStorageContainer("Blocks.Demo.MainGame");

            //----------------------------------------------------------------
            // リソース ローダ

            ResourceLoader.Register(ContentResourceLoader.Instance);
            ResourceLoader.Register(TitleResourceLoader.Instance);
            ResourceLoader.Register(StorageResourceLoader.Instance);
            ResourceLoader.Register(FileResourceLoader.Instance);

            //----------------------------------------------------------------
            // ビュー コントローラ

            var viewport = GraphicsDevice.Viewport;

            viewInput.InitialMousePositionX = viewport.Width / 2;
            viewInput.InitialMousePositionY = viewport.Height / 2;
            viewInput.MoveVelocity          = moveVelocity;
            viewInput.DashFactor            = dashFactor;
            viewInput.Yaw(MathHelper.Pi);

            //----------------------------------------------------------------
            // ワールド マネージャ

            worldManager = new WorldManager(Services, GraphicsDevice);
            worldManager.Initialize();

            //----------------------------------------------------------------
            // リージョン

            // TODO
            region = worldManager.Load("dummy");

            //----------------------------------------------------------------
            // ブラシ マネージャ

            brushManager = new BrushManager(Services, GraphicsDevice, worldManager, commandManager);

            //----------------------------------------------------------------
            // その他

            spriteBatch         = new SpriteBatch(GraphicsDevice);
            font                = Content.Load <SpriteFont>("Fonts/Debug");
            fillTexture         = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            helpMessageFontSize = font.MeasureString(helpMessage);

            BuildInfoMessage();
            informationTextFontSize = font.MeasureString(stringBuilder);
        }
コード例 #6
0
        public override void LoadContent(ContentManager content)
        {
            base.LoadContent(content);

            number = new Number(
                Content.Load <SpriteFont>(@"Fonts/TestFont"),
                12345,
                new Rectangle(400, 240, 400, 240),
                TextControl.HorizontalAligments.Left,
                TextControl.VerticalAligments.Bottom,
                Color.White,
                Color.Red,
                2);
            number.MinDigits = 10;

            cow = new Cow(
                Texture2DHelper.Cut(Content.Load <Texture2D>(@"Textures/cowSheet1"), Vector2.Zero, 64, 64),
                Content.Load <Texture2D>(@"Textures/cowSheet2"),
                Content.Load <Texture2D>(@"Textures/cowSheet3"),
                Content.Load <Texture2D>(@"Textures/cowSheet4"));
            cow.Location = new Vector2(0, 0);
            cow.SetupCollisionCircles(
                new[] {
                new Circle(new Vector2(10, 0), 15.0f),
                new Circle(new Vector2(-5, -5), 10.0f)
            });
            cow.PlayAnimation("cow1");

            rotatedCow = new Cow(
                Content.Load <Texture2D>(@"Textures/cowSheet1"),
                Content.Load <Texture2D>(@"Textures/cowSheet2"),
                Content.Load <Texture2D>(@"Textures/cowSheet3"),
                Content.Load <Texture2D>(@"Textures/cowSheet4"));
            rotatedCow.Location = new Vector2(200, 200);
            rotatedCow.RotateToDirection(new Vector2(0, -1));
            rotatedCow.SetupCollisionCircles(
                new[] {
                new Circle(new Vector2(0, 10), 25.0f)
            });
            rotatedCow.PlayAnimation("cow1");

            scaledCow = new Cow(
                Content.Load <Texture2D>(@"Textures/cowSheet1"),
                Content.Load <Texture2D>(@"Textures/cowSheet2"),
                Content.Load <Texture2D>(@"Textures/cowSheet3"),
                Content.Load <Texture2D>(@"Textures/cowSheet4"));
            scaledCow.Location = new Vector2(300, 200);
            scaledCow.Scale    = 2.0f;
            scaledCow.SetupCollisionCircles(
                new[] {
                new Circle(Vector2.Zero, 15.0f),
                new Circle(new Vector2(-5, -5), 10.0f)
            });
            scaledCow.PlayAnimation("cow1");
        }
コード例 #7
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            if (ScreenFactory != null && !ScreenFactory.Initialized)
            {
                ScreenFactory.Initialize();
            }

            base.LoadContent();
        }
コード例 #8
0
        public Color GetColorFromInputHandler(Color prevColor, InputHandler inputHandler)
        {
            var textureToGetPixelFrom = Texture;

            if (textureToGetPixelFrom == null)
            {
                return(prevColor);
            }
            var pixelIndex = inputHandler.MouseState.Position - GetGlobalLocation().ToPoint();
            var pixels     = Creator.Texture2DHelper.GetPixels(textureToGetPixelFrom);

            return(Texture2DHelper.GetPixel(ref pixels, pixelIndex.X, pixelIndex.Y, textureToGetPixelFrom.Width));
        }
コード例 #9
0
        public BrushMesh(string name, GraphicsDevice graphicsDevice, Mesh mesh)
            : base(name)
        {
            if (graphicsDevice == null)
            {
                throw new ArgumentNullException("graphicsDevice");
            }
            if (mesh == null)
            {
                throw new ArgumentNullException("mesh");
            }

            this.graphicsDevice = graphicsDevice;
            this.mesh           = mesh;

            effect = new BasicEffect(graphicsDevice);

            Translucent = true;

            for (int i = 0; i < Side.Count; i++)
            {
                var meshPart = mesh.MeshParts[i];
                if (meshPart == null)
                {
                    continue;
                }

                var vertexCount = meshPart.Vertices.Length;
                var indexCount  = meshPart.Indices.Length;

                if (vertexCount == 0 || indexCount == 0)
                {
                    continue;
                }

                vertexBuffers[i] = new VertexBuffer(graphicsDevice, typeof(VertexPositionNormalTexture), vertexCount, BufferUsage.WriteOnly);
                vertexBuffers[i].SetData(meshPart.Vertices);

                indexBuffers[i] = new IndexBuffer(graphicsDevice, IndexElementSize.SixteenBits, indexCount, BufferUsage.WriteOnly);
                indexBuffers[i].SetData(meshPart.Indices);
            }

            fillTexture           = Texture2DHelper.CreateFillTexture(graphicsDevice);
            effect.Texture        = fillTexture;
            effect.TextureEnabled = true;

            Matrix.CreateScale(1.001f, out scale);
        }
コード例 #10
0
        public override void LoadContent(ContentManager content)
        {
            base.LoadContent(content);

            title = new Text(
                Content.Load <SpriteFont>(@"Fonts/TestFont"),
                "Bison Demo Game",
                ScreenManager.Instance.Viewport,
                TextControl.HorizontalAligments.Center,
                TextControl.VerticalAligments.Top,
                Color.White,
                Color.Red,
                2);

            startButton = new Button(
                Content.Load <Texture2D>(@"Textures/Button"),
                Content.Load <SpriteFont>(@"Fonts/TestFont"),
                "Start",
                new Vector2(200, 150));
            startButton.Text.OutlineColor = Color.Black;
            startButton.Text.OutlineWidth = 2;

            settingsButton = new Button(
                Content.Load <Texture2D>(@"Textures/Button"),
                Content.Load <SpriteFont>(@"Fonts/TestFont"),
                "Settings",
                new Vector2(200, 250));

            exitButton = new Button(
                Texture2DHelper.Create(400, 80, Color.DarkBlue),
                Content.Load <SpriteFont>(@"Fonts/TestFont"),
                "Exit",
                new Vector2(200, 350));
            exitButton.Text.Color        = Color.Black;
            exitButton.Text.OutlineColor = Color.White;
            exitButton.Text.OutlineWidth = 2;
        }