コード例 #1
0
ファイル: TextFormatting.cs プロジェクト: klnsem/bovcslik
        public static TextRow AlignText(TextAlignment alignment, TextRow textRow)
        {
            if (textRow.message.Length > 50)
            {
                throw new Exception("Exception: tried to align a row longer" +
                                    "than 50 characters.");
            }
            if (alignment == TextAlignment.LEFT)
            {
                textRow.x             = 0;
                textRow.textAlignment = TextAlignment.LEFT;
            }
            if (alignment == TextAlignment.RIGHT)
            {
                textRow.x             = 50 - textRow.message.Length;
                textRow.textAlignment = TextAlignment.RIGHT;
            }
            if (alignment == TextAlignment.CENTER)
            {
                int charsLeft = 50 - textRow.message.Length;
                textRow.textAlignment = TextAlignment.CENTER;
                if (textRow.message.Length % 2 == 0)
                {
                    textRow.x = charsLeft / 2;
                }
                else   // Yeah, even + uneven = uneven, so we're making the best of it.
                {
                    textRow.x = charsLeft - 1;
                }
            }

            return(textRow);
        }
コード例 #2
0
ファイル: Player.cs プロジェクト: klnsem/bovcslik
        public TextRow[] GetAllText()
        {
            TextRow tr = new TextRow {
                x       = X,
                y       = Y,
                message = "@"
            };

            throw new NotImplementedException();
        }
コード例 #3
0
        private void CreateIntroPage()
        {
            TextRow tr1 = new TextRow {
                x       = 5,
                y       = 5,
                message = "hello darkness my old friend"
            };
            TextRow tr2 = new TextRow {
                x       = 10,
                y       = 10,
                message = "something something again"
            };
            TextRow tr3 = new TextRow {
                x       = 20,
                y       = 15,
                message = "######### @ ##"
            };

            screenText    = new TextRow[3];
            screenText[0] = tr1;
            screenText[1] = tr2;
            screenText[2] = tr3;
        }