コード例 #1
0
ファイル: SplashScene.cs プロジェクト: eylvisaker/BallBusterX
        public SplashScene(GraphicsDevice graphicsDevice, IContentProvider content, CImage img, CSound snd)
        {
            this.graphicsDevice = graphicsDevice;
            this.content        = content;
            this.img            = img;
            this.snd            = snd;
            this.spriteBatch    = new SpriteBatch(graphicsDevice);

            img.preload(content);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                delay = 500;
            }

            StringBuilder text = new StringBuilder();

            text.AppendLine("Ball: Buster eXtreme");
            text.AppendLine("Copyright 2004-18 Patrick Avella, Erik Ylvisaker");
            text.AppendLine("Game Programming: Patrick Avella (patrickavella.com)");
            text.AppendLine("eXtreme Version Programming: Erik Ylvisaker (vermiliontower.com)");
            text.AppendLine("Game Art: Patrick Avella (patrickavella.com)");
            text.AppendLine("Background Music: Partners in Rhyme (musicloops.com)");
            text.AppendLine("Sound Effects: A1 Free Sound Effects (a1freesoundeffects.com)");

            ContentLayoutEngine layout = new ContentLayoutEngine(img.Fonts);

            textLayout = layout.LayoutContent(text.ToString(), font: new FontStyleProperties {
                Color = Color.Black
            });

            initialDelay = delay;
        }
コード例 #2
0
ファイル: LabelTest.cs プロジェクト: eylvisaker/BallBusterX
        public LabelTest()
        {
            fontCore = new FakeFontCore("default");
            font     = new Font(fontCore);

            fontProvider = new FontProvider();
            fontProvider.Add("default", font);

            contentLayout = new ContentLayoutEngine(fontProvider);

            context = CommonMocks.RenderContext(contentLayout);
        }
コード例 #3
0
        public void LayoutText()
        {
            var text = @"Enemies with shields can block your attacks.
Try crouching with {Color Yellow}Down{Color White} and slashing with {Color Yellow}Sword{Color White} to beat enemies with shields.
Be careful! Some enemies may anticipate this!";

            var fontProvider = CommonMocks.FontProvider("temp");

            ContentLayoutEngine layoutEngine = new ContentLayoutEngine(fontProvider.Object);

            var result = (ContentLayout)layoutEngine.LayoutContent(text, 200);

            result.Draw(Vector2.Zero);

            var items = result.Items.Cast <ContentText>().ToList();

            ValidateItem(items, 0, new Vector2(0, 0), "Enemies with shields can block your");
            ValidateItem(items, 1, new Vector2(0, 10), "attacks.");
            ValidateItem(items, 2, new Vector2(0, 20), "Try crouching with ");
            ValidateItem(items, 3, new Vector2(95, 20), "Down");
            ValidateItem(items, 4, new Vector2(115, 20), " and slashing");
        }
コード例 #4
0
ファイル: App.cs プロジェクト: eylvisaker/ShootTheTraps
        private void DrawIntro(SpriteBatch spriteBatch)
        {
            if (mIntroLines == null)
            {
                mIntroLines = mIntroduction.Split('\n');
            }

            ContentLayoutEngine layoutEngine = new ContentLayoutEngine(fonts);

            layoutEngine.AddCommand("draw", new DrawTextureCommand().Add("trap", Trap.Image));

            var content = layoutEngine.LayoutContent(mIntroduction);

            // center introduction text
            var textPt = new Vector2((Coordinates.Width - content.Size.Width) / 2, 20);

            var boxArea = new Rectangle(
                (int)textPt.X - 10,
                (int)textPt.Y - 10,
                content.Size.Width + 20,
                (mIntroLines.Length + 1) * font.FontHeight + 20);

            FillRect(spriteBatch, boxArea, new Color(Color.Black, 196));

            content.Draw(textPt, spriteBatch);

            //for (int i = 0; i < mIntroLines.Length; i++)
            //{
            //    font.DrawText(textPt.X, textPt.Y, mIntroLines[i],
            //        Trap.Image,
            //        LayoutCacheAlterFont.Scale(2, 2),
            //        LayoutCacheAlterFont.Scale(1, 1),
            //        LayoutCacheAlterFont.Color(Color.White),
            //        LayoutCacheAlterFont.Color(Color.Yellow));

            //    textPt.Y += font.FontHeight;
            //}
        }