Exemple #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();
        }
Exemple #2
0
        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();
        }
Exemple #3
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();
        }
Exemple #4
0
        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);
        }
Exemple #5
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            fillTexture = Texture2DHelper.CreateFillTexture(GraphicsDevice);
            if (ScreenFactory != null && !ScreenFactory.Initialized)
            {
                ScreenFactory.Initialize();
            }

            base.LoadContent();
        }
Exemple #6
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);
        }