Пример #1
0
 public Text(string text, Font font, int maxWidth)
 {
     _text = text;
     _font = font;
     _maxWidth = maxWidth;
     CreateText(0, 0, _maxWidth);
 }
Пример #2
0
 /// <summary>
 /// This is a slow but often convient function.
 /// </summary>
 /// <param name="text"></param>
 /// <param name="font"></param>
 public void DrawText(double x, double y, string text, Font font)
 {
     Text textObj = new Text(text, font);
     textObj.SetColor(new Color(0,0,0,1));
     textObj.SetPosition(x, y);
     DrawText(textObj);
 }
Пример #3
0
        private void InitializeMenu()
        {
            menuFont = new Font(textureManager.Get("menu_font"), FontParser.Parse("menuFont.fnt"));
            menu = new VerticalMenu(0, -100, input, new Color(1, 1, 1, 1), new Color(0, 0, 1, 1));

            // Create start, controls, exit for menu
            Button start = new Button(delegate(object sender, EventArgs e)
            {
                stateSystem.ChangeState("inner_game");
                ResetGameData();
            },
            new Text("Start", menuFont));

            Button controls = new Button(delegate(object sender, EventArgs e)
            {
                stateSystem.ChangeState("controls");
            },
            new Text("Controls", menuFont));

            Button exit = new Button(delegate(object sender, EventArgs e)
            {
                System.Windows.Forms.Application.Exit();
            },
            new Text("Exit", menuFont));

            menu.AddButton(start);
            menu.AddButton(controls);
            menu.AddButton(exit);
        }
 public StartMenuState(Engine.Font titleFont)
 {
     _title = new Text("Shooter", titleFont);
     _title.SetColor(new Color(0, 0, 0, 1));
     // Centerre on the x and place somewhere near the top
     _title.SetPosition(-_title.Width / 2, 300);
 }
Пример #5
0
        private void InitializeFonts()
        {
            // Fonts are loaded here.

            _titleFont   = FontParser.CreateFont("title_font.fnt", _textureManager);
            _generalFont = FontParser.CreateFont("general_font.fnt", _textureManager);
        }
Пример #6
0
        private void InitializeFonts()
        {
            // Fonts are loaded here.
            _titleFont = new Engine.Font(_textureManager.Get("title_font"),
                                    FontParser.Parse("title_font.fnt"));


        }
Пример #7
0
 public Text(string text, Font font, int maxWidth)
 {
     this.text = text;
     this.font = font;
     color = new Color(1, 1, 1, 1);
     this.maxWidth = maxWidth;
     CreateText(0, 0);
 }
Пример #8
0
 public InnerGameState(StateSystem system, Input input, PersistantGameData gameData, Font generalFont)
 {
     _input = input;
     _system = system;
     _gameData = gameData;
     _generalFont = generalFont;
     OnGameStart();
 }
Пример #9
0
        private void InitializeFonts()
        {
            // Fonts are loaded here.
            _titleFont = new Engine.Font(_textureManager.Get("title_font"),
                                         FontParser.Parse("title_font.fnt"));

            _generalFont = new Engine.Font(_textureManager.Get("general_font"),
                                           FontParser.Parse("general_font.fnt"));
        }
Пример #10
0
 public Scoreboard(GameData gameData, TextureManager textureManager)
 {
     this.gameData = gameData;
     font = new Font(textureManager.Get("effects_font"), FontParser.Parse("effectsFont.fnt"));
     level = new Text("Level: " + gameData.Level.ToString(), font);
     score = new Text("Score : " + gameData.Score.ToString(), font);
     position = new Point((float)Block.WIDTH * 7, -30);
     UpdateWidth();
 }
Пример #11
0
 public InnerGameState(StateSystem system, Input input, TextureManager textureManager, PersistentGameData gameData, Font generalFont)
 {
     _system = system;
     _input = input;
     _textureManager = textureManager;
     _gameData = gameData;
     _generalFont = generalFont;
     OnGameStart();
 }
Пример #12
0
 //int fontSize;
 public Font(String fontName, float fontSize)
 {
     try{
         this.font = new Font(fontName, fontSize);
     }catch (Exception e){
         Console.Write("Font not found" + e);
         this.font = new Font("Times New Roman", 12.0f);
     }
 }
Пример #13
0
 public InnerGameState(StateSystem system, Input input, TextureManager textureManager, PersistantGameData gameData, Font generalFont, Font titleFont, Size windowSize)
 {
     _input          = input;
     _system         = system;
     _gameData       = gameData;
     _generalFont    = generalFont;
     _textureManager = textureManager;
     _titleFont      = titleFont;
     _windowSize     = windowSize;
     OnGameStart();
 }
Пример #14
0
        public StartMenuState(Font titleFont, Font generalFont, Input input, StateSystem system)
        {
            _input = input;
            _system = system;
            _generalFont = generalFont;
            InitializeMenu();
            _title = new Text("Another Castle", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));

            // Center on x and move toward the top
            _title.SetPosition(-_title.Width/2, 300);
        }
Пример #15
0
        public PauseGameState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system)
        {
            _input = input;
            _system = system;
            _generalFont = generalFont;
            InitializeMenu();
            _title = new Text("Pause", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));

            // Center on x and move toward the top
            _title.SetPosition(-_title.Width / 2, 300);
        }
Пример #16
0
        public StartMenuState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system)
        {
            _system = system;
            _input = input;
            _generalFont = generalFont;
            InitializeMenu();

            _title = new Text("Immunity vs. Invaders", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));

            _title.SetPosition(-_title.Width / 2, 300);
        }
Пример #17
0
        public StartMenuState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system)
        {
            _system = system;

            _generalFont = generalFont;
            _input = input;
            InitializeMenu();
            _title = new Text("Shooter", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));
            // Centerre on the x and place somewhere near the top
            _title.SetPosition(-_title.Width / 2, 300);
        }
        public StartMenuState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system)
        {
            _system = system;

            _generalFont = generalFont;
            _input       = input;
            InitializeMenu();
            _title = new Text("Shooter", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));
            // Centerre on the x and place somewhere near the top
            _title.SetPosition(-_title.Width / 2, 300);
        }
Пример #19
0
        public StartMenuState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system, TextureManager textureManager)
        {
            _system = system;

            _generalFont = generalFont;
            _input = input;
            _textureManager = textureManager;
            _blockManager = new BlockManager(_textureManager, 0, 0, new Vector(1, 1, 1));
            DropBlocks();
            InitializeMenu();
            _title = new Text("Subway Tetris", titleFont);
            _title.SetColor(new Color(0.85f, 0.85f, 0.10f, 1));
            // Centerre on the x and place somewhere near the top
            _title.SetPosition(-_title.Width / 2, 300);
        }
Пример #20
0
        public InnerGameState(StateSystem system, Input input, TextureManager textureManager, PersistentGameData gameData, Font generalFont)
        {
            _input = input;
            _system = system;
            _gameData = gameData;
            _generalFont = generalFont;
            _textureManager = textureManager;

            _bloodStream = new Text("BloodStream", generalFont);
            _bloodStream.SetColor(new Color(0, 0, 0, 1));

            _bloodStream.SetPosition(-600, 0);

            OnGameStart();
        }
Пример #21
0
        public StartMenuState(StateSystem stateSystem, TextureManager textureManager, 
            Input input, GameData gameData)
        {
            this.input = input;
            this.textureManager = textureManager;
            this.stateSystem = stateSystem;
            this.gameData = gameData;

            // Create title
            titleFont = new Font(textureManager.Get("title_font"), FontParser.Parse("titleFont.fnt"));
            titleText = new Text("bTris", titleFont);
            titleText.SetPosition(-titleText.Width / 2, 150);
            titleText.SetColor(new Color(1, 1, 1, 1));

            InitializeMenu();
        }
Пример #22
0
        public CreditState(PersistantGameData data, StateSystem system, Input input, Font generalFont, Font titleFont)
        {
            _gameData = data;
            _system = system;
            _input = input;
            _generalFont = generalFont;
            _titleFont = titleFont;

            _titleHelp = new Text("How to Play", _titleFont);
            _blurbHelp = new Text("", _generalFont);
            _blurbHelp = new Text("Directional keys-move,Enter or X(gamepad) to fire", _generalFont);
            

            FormatText(_titleHelp, 300);
            FormatText(_blurbHelp, 200);
        }
Пример #23
0
        public KabajiEgara(PersistantGameData data, StateSystem system, Input input, Font generalFont, Font titleFont)
        {
            _gameData = data;
            _system = system;
            _input = input;
            _generalFont = generalFont;
            _titleFont = titleFont;

            _titleHelp = new Text("Kabaji Egara", _titleFont);
            //_blurbHelp = new Text("", _generalFont);
            _blurbHelp = new Text("COM-0513-10 2013", _generalFont);
            

            FormatText(_titleHelp, 300);
            FormatText(_blurbHelp, 200);
        }
Пример #24
0
        //EnemyManager _enemyManager;
        public Level(Input input, TextureManager textureManager, PersistantGameData gameData, Engine.Font generalFont, Engine.Font titleFont, Size windowSize)
        {
            //_testSprite.Texture = textureManager.Get("explosion");
            //_testSprite.SetAnimation(4, 4);

            _input          = input;
            _gameData       = gameData;
            _textureManager = textureManager;
            _effectsManager = new EffectsManager(_textureManager);

            _background = new Background(textureManager.Get("background"));
            //_background.Speed = 0.15f;
            widthScale2  = _windowSize.Width / 900.0;
            heightScale2 = _windowSize.Height / 695.0;
            _background.SetScale(2.0, 2.0);

            //_backgroundLayer = new Background(textureManager.Get("background_layer_1"));
            //_backgroundLayer.Speed = 0.1f;
            //_backgroundLayer.SetScale(2.0, 2.0);
            m_ChessBoard = Form1.InitChessBoard;
            _chessBoard  = new ChessBoard(_textureManager, _moveChessManager);

            //_system = system;

            //_input = input;

            _generalFont   = generalFont;
            _titleFont     = titleFont;
            settingChecked = SettingMenu();
            Option  optionChecked = OptionMenu();
            Engines engineChecked = EngineMenu();

            _enginemenu._rvdisable = true;

            _optiontitle = new Text("选项", _titleFont);
            _optiontitle.SetColor(new Color(0, 0, 0, 1));
            //Center on the x and place somewhere near the top
            _optiontitle.SetPosition(-_optiontitle.Width / 2 - 450, 300);

            //EngineMenu();
            _optiontitle = new Text("引擎", _titleFont);
            _optiontitle.SetColor(new Color(0, 0, 0, 1));
            // Center on the x and place somewhere near the top
            _optiontitle.SetPosition(-_optiontitle.Width / 2 + 450, 300);

            //_enemyManager = new EnemyManager(_textureManager, _effectsManager, _bulletManager, _playerCharacter, -1300);
        }
Пример #25
0
        public GameOverState(PersistentGameData data, StateSystem system, Input input, Font generalFont, Font titleFont)
        {
            _gameData = data;
            _system = system;
            _input = input;
            _generalFont = generalFont;
            _titleFont = titleFont;

            _titleWin = new Text("Completed this level!", _titleFont);
            _blurbWin = new Text("You defeated the invaders!", _generalFont);
            _titleLose = new Text("Game Over!", _titleFont);
            _blurbLose = new Text("Try again . ..", _generalFont);

            FormatText(_titleWin, 300);
            FormatText(_blurbWin, 200);

            FormatText(_titleLose, 300);
            FormatText(_blurbLose, 200);
        }
Пример #26
0
        public GameOverState(Input input, StateSystem stateSystem, 
            GameData gameData, TextureManager textureManager)
        {
            this.input = input;
            this.stateSystem = stateSystem;
            this.gameData = gameData;
            this.textureManager = textureManager;

            scoreboard = new Scoreboard(gameData, textureManager);
            scoreboard.SetPosition(new Point(-scoreboard.Width / 2, 0));

            gameOverFont = new Font(textureManager.Get("title_font"), FontParser.Parse("titleFont.fnt"));
            gameOverText = new Text("Game Over", gameOverFont);
            gameOverText.SetPosition(-gameOverText.Width / 2, 100);

            returnFont = new Font(textureManager.Get("effects_font"), FontParser.Parse("effectsFont.fnt"));
            returnText = new Text("Press Enter to return to the start menu", returnFont);
            returnText.SetPosition(-returnText.Width / 2, -200);
        }
Пример #27
0
        public GameOverState(PersistentGameData data, StateSystem system, Input input, Font generalFont, Font titleFont)
        {
            _gameData = data;
            _system = system;
            _input = input;
            _generalFont = generalFont;
            _titleFont = titleFont;

            _titleWin = new Text("Complete!", _titleFont);
            _blurbWin = new Text("Congratulations, you won!", _generalFont);
            _titleLose = new Text("Game Over!", _titleFont);
            _blurbLose = new Text("Please try again...", _generalFont);

            FormatText(_titleWin, 300);
            FormatText(_blurbWin, 200);

            FormatText(_titleLose, 300);
            FormatText(_blurbLose, 200);
        }
Пример #28
0
        public StartMenuState(Engine.Font titleFont, Engine.Font generalFont, Input input, StateSystem system, TextureManager textureManager, Size windowSize)
        {
            _system = system;

            _input          = input;
            _generalFont    = generalFont;
            _textureManager = textureManager;
            _windowSize     = windowSize;
            _effectsManager = new EffectsManager(_textureManager);
            InitializeMenu();
            _backgroundLayer = new Background(textureManager.Get("background_layer_1"));
            //_background.Speed = 0.15f;
            widthScale  = _windowSize.Width / 500.0;
            heightScale = _windowSize.Height / 375.0;
            _backgroundLayer.SetScale(widthScale, heightScale);
            _title = new Text("中国象棋", titleFont);
            _title.SetColor(new Color(0, 0, 0, 1));
            // Center on the x and place somewhere near the top
            _title.SetPosition(-_title.Width / 2, 300);
        }
Пример #29
0
 public PlayingState(StateSystem system, TextureManager manager, Input input, Engine.Font infoFont, Vector playArea, Vector clientSize)
 {
     _system = system;
     _textureManager = manager;
     _input = input;
     _infoFont = infoFont;
     _playArea = playArea;
     _clientSize = clientSize;
     InitializeMenu();
     _paused = false;
     _blockManager = new BlockManager(_textureManager, clientSize.X, clientSize.Y, new Vector(_scalingFactor, _scalingFactor, 0));
     if (_scalingFactor < 1.0 && _scalingFactor > 0.5)
     {
         _playArea.X += _blockManager.BlockWidth * _scalingFactor;
     }
     _blockManager.SetBounds(-(_playArea.Y), _playArea.Y, -(_playArea.X), _playArea.X);
     _scoreText = new Text("Score: " + _blockManager.CompletedRows, _infoFont);
     _scoreText.SetPosition((clientSize.X / 2) - 250, 0);
     _scoreText.SetColor(new Color(0.19f, 0.8f, 0.19f, 1));
     _pausedText = new Text("PAUSED", _infoFont);
     _pausedText.SetPosition(-_pausedText.Width/2, 250);
     _pausedText.SetColor(new Color(0.35f, 0.35f, 0.67f, 1));
     GameStart();
 }
Пример #30
0
 private void InitializeFonts()
 {
     // Fonts are loaded here.
     _numberFont = Engine.FontParser.CreateFont("numberFont.fnt", _textureManager);
 }
Пример #31
0
 private void InitializeFonts()
 {
     _titleFont = new Font(_textureManager.Get("title_font"), FontParser.Parse("./Content/Fonts/title_font.fnt"));
     _generalFont = new Font(_textureManager.Get("general_font"),
         FontParser.Parse("./Content/Fonts/general_font.fnt"));
 }
Пример #32
0
        public void DoRenderUI( GuiRenderer renderer )
        {
            if( transparency == 0.0f )
                return;

            if( firstRender )
            {
                texture = TextureManager.Instance.Load( "Gui\\Various\\Console.dds",
                    Texture.Type.Type2D, 0 );
                font = FontManager.Instance.LoadFont( "Default", .025f );

                firstRender = false;
            }

            if( font == null )
                return;

            Rect textureRect = new Rect( 0, 0, 1, 1 );
            textureRect += textureOffset;

            renderer.AddQuad( new Rect( 0, 0, 1, .5f ), textureRect, texture,
                new ColorValue( 1, 1, 1, transparency ), false, new Rect( 0, 0, 1, 1 ) );
            renderer.AddQuad( new Rect( 0, .495f, 1, .5f ),
                new ColorValue( .8f, .8f, .8f, transparency ) );

            string staticText = "Version " + EngineVersionInformation.Version;
            if( staticText != null && staticText != "" )
            {
                renderer.AddText( font, staticText, new Vec2( .99f, .5f - font.Height ),
                    HorizontalAlign.Right, VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );
            }

            float fontheight = font.Height;

            float x = .01f;

            float y = .5f - fontheight;

            string str;
            if( stringDownPosition != strings.Count - 1 )
            {
                str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                    " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
            }
            else
                str = currentString + "_";

            renderer.AddText( font, str, new Vec2( x, y ), HorizontalAlign.Left,
                VerticalAlign.Center, new ColorValue( 1, 1, 1, transparency ) );

            y -= fontheight + fontheight * .5f;

            int startpos = stringDownPosition;
            if( startpos > strings.Count - 1 )
                startpos = strings.Count - 1;
            for( int n = startpos; n >= 0 && y - fontheight > 0; n-- )
            {
                renderer.AddText( font, strings[ n ].text, new Vec2( x, y ), HorizontalAlign.Left,
                    VerticalAlign.Center, strings[ n ].color * new ColorValue( 1, 1, 1, transparency ) );
                y -= fontheight;
            }
        }
Пример #33
0
 private void InitializeFonts()
 {
     // Fonts are loaded here.
     _titleFont = new Engine.Font(_textureManager.Get("title_font"), Engine.FontParser.Parse("Fonts/title_font.fnt"));
     _generalFont = new Engine.Font(_textureManager.Get("general_font"), Engine.FontParser.Parse("Fonts/general_font.fnt"));
     _blockFont = new Engine.Font(_textureManager.Get("block_font"), Engine.FontParser.Parse("Fonts/blockFont.fnt"));
 }
 public PathCreationState(Input input, PathData pathData, Engine.Font numberFont)
 {
     _input = input;
     _pathData = pathData;
     _font = numberFont;
 }
        private void AddTextWithShadow(GuiRenderer renderer, Font font, string text, Vec2 position,
            HorizontalAlign horizontalAlign, VerticalAlign verticalAlign, ColorValue color)
        {
            Vec2 shadowOffset = 1.0f / renderer.ViewportForScreenGuiRenderer.DimensionsInPixels.Size.ToVec2();

            renderer.AddText(font, text, position + shadowOffset, horizontalAlign, verticalAlign,
                new ColorValue(0, 0, 0, color.Alpha / 2));
            renderer.AddText(font, text, position, horizontalAlign, verticalAlign, color);
        }
Пример #36
0
 private void InitializeFonts()
 {
     _titleFont = new Engine.Font(_textureManager.Get("title_font"), FontParser.Parse("title_font.fnt"));
     _generalFont = new Engine.Font(_textureManager.Get("general_font"), FontParser.Parse("general_font.fnt"));
 }
Пример #37
0
        /// <summary>
        /// 初始化字体
        /// </summary>
        private void InitializeFonts()
        {
            _titleFont = new Engine.Font(_textureManager.Get("chinese_font"), FontParser.Parse("chinese_font.fnt", 2));

            _generalFont = new Engine.Font(_textureManager.Get("chinese_yy"), FontParser.Parse("chinese_yy.fnt", 1));
        }
Пример #38
0
        private void InitializeFonts()
        {
            // Fonts are loaded here.

            _titleFont = FontParser.CreateFont("title_font.fnt", _textureManager);
            _generalFont = FontParser.CreateFont("general_font.fnt", _textureManager);
        }
        public void RenderScreenUI(GuiRenderer renderer)
        {
            for (int viewIndex = 0; viewIndex < views.Count; viewIndex++)
            {
                View view = views[viewIndex];

                //draw view on screen
                if (view.Opacity > 0)
                {
                    renderer.PushTextureFilteringMode(GuiRenderer.TextureFilteringModes.Point);
                    renderer.AddQuad(view.Rectangle, new Rect(0, 0, 1, 1), view.Texture,
                        new ColorValue(1, 1, 1, view.Opacity), true);
                    renderer.PopTextureFilteringMode();
                }

                //draw debug info
                if (drawDebugInfo)
                {
                    Viewport screenViewport = renderer.ViewportForScreenGuiRenderer;
                    Vec2 pixelOffset = 1.0f / screenViewport.DimensionsInPixels.Size.ToVec2();
                    ColorValue color = new ColorValue(1, 1, 0);
                    renderer.AddRectangle(new Rect(
                        view.Rectangle.LeftTop + pixelOffset,
                        view.Rectangle.RightBottom - pixelOffset * 2),
                        color);
                    renderer.AddLine(view.Rectangle.LeftTop, view.Rectangle.RightBottom, color);
                    renderer.AddLine(view.Rectangle.RightTop, view.Rectangle.LeftBottom, color);

                    if (debugFont == null)
                        debugFont = FontManager.Instance.LoadFont("Default", .03f);

                    string sizeString = "";
                    if (view.Texture != null)
                        sizeString = string.Format("{0}x{1}", view.Texture.Size.X, view.Texture.Size.Y);
                    string text = string.Format("View {0}, {1}", viewIndex, sizeString);
                    Vec2 position = new Vec2(view.Rectangle.Right - pixelOffset.X * 5, view.Rectangle.Top);
                    AddTextWithShadow(renderer, debugFont, text, position, HorizontalAlign.Right,
                        VerticalAlign.Top, new ColorValue(1, 1, 1));
                }
            }
        }
 public PathCreationState(Input input, PathData pathData, Engine.Font numberFont)
 {
     _input    = input;
     _pathData = pathData;
     _font     = numberFont;
 }