Example #1
0
        /// <summary>
        /// Initializes the specified graphic system.
        /// </summary>
        /// <param name="graphicSystem">The graphic system.</param>
        /// <param name="physicSystem">The physic system.</param>
        /// <param name="textSystem">The text system.</param>
        /// <param name="inputSystem">The input system.</param>
        /// <param name="exitAction">The exit action.</param>
        public virtual void Initialize(
            IGraphicSystem graphicSystem,
            IPhysicSystem physicSystem,
            ITextSystem textSystem,
            IInputSystem inputSystem,
            Action exitAction)
        {
            Components          = new List <IComponent>();
            _componentsToRemove = new List <IComponent>();
            _updatables         = new List <IUpdatable>();
            _drawables          = new List <IDrawable>();

            _time = new Time();
            _pendingSceneToOpen = new NullScene(this);

            graphicSystem.Initialize();
            textSystem.Initialize();

            _drawContext  = new DrawContext(graphicSystem, textSystem);
            GraphicSystem = graphicSystem;

            Bounds       = Bounds == Rectangle.Zero ? graphicSystem.Bounds : Bounds;
            PhysicSystem = physicSystem;

            LogSystem = new NullLogSystem();

            FontSystem = textSystem;

            InputSystem = inputSystem;

            this._exitAction = exitAction;
        }
Example #2
0
        /// <summary>
        /// Draws the text centralized in the Y coordinate.
        /// </summary>
        /// <param name="textSystem">The text system.</param>
        /// <param name="x">The x.</param>
        /// <param name="text">The text.</param>
        /// <param name="bounds">The bounds.</param>
        /// <param name="color">The text color.</param>
        /// <param name="fontName">Name of the font.</param>
        /// <returns>The text system.</returns>
        public static ITextSystem DrawCenterY(this ITextSystem textSystem, float x, string text, Rectangle bounds, Color color, string fontName = null)
        {
            var size         = textSystem.GetFont(fontName).GetTextSize(text);
            var boundsCenter = bounds.GetCenter();
            var y            = boundsCenter.Y - (size.Y / 2);

            return(textSystem.Draw(x, y, text, color, fontName));
        }
Example #3
0
        private bool disposed = false;         // To detect redundant calls

        public override void Initialize(
            IGraphicSystem graphicSystem,
            IPhysicSystem physicSystem,
            ITextSystem textSystem,
            IInputSystem inputSystem,
            Action exitAction)
        {
            var b = graphicSystem.Bounds;

            Bounds = new Rectangle(b.Left + 5, b.Top + 10, b.Width - 10, b.Height - 10);

            base.Initialize(graphicSystem, physicSystem, textSystem, inputSystem, exitAction);

            this.OpenScene <ClassicModeLevelScene>();
        }
Example #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DrawContext"/> class.
 /// </summary>
 /// <param name="canvas">The canvas.</param>
 /// <param name="textSystem">The text system.</param>
 public DrawContext(ICanvas canvas, ITextSystem textSystem)
 {
     Canvas     = canvas;
     TextSystem = textSystem;
 }
Example #5
0
 /// <summary>
 /// Draws the text in the center of bounds using the specified offset.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="offsetX">The offset x.</param>
 /// <param name="offsetY">The offset y.</param>
 /// <param name="text">The text.</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem DrawCenter(this ITextSystem textSystem, float offsetX, float offsetY, string text, Rectangle bounds, string fontName = null)
 {
     return(textSystem.DrawCenter(offsetX, offsetY, text, bounds, Color.White, fontName));
 }
Example #6
0
 /// <summary>
 /// Draws the text in the center of text system.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="text">The text.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem DrawCenter(this ITextSystem textSystem, string text, string fontName = null)
 {
     return(textSystem.DrawCenter(text, Color.White, fontName));
 }
Example #7
0
 /// <summary>
 /// Draws the text in the center of text system.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="text">The text.</param>
 /// <param name="color">The text color.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem DrawCenter(this ITextSystem textSystem, string text, Color color, string fontName = null)
 {
     return(textSystem.DrawCenter(text, textSystem.Context.Bounds, color, fontName));
 }
Example #8
0
 /// <summary>
 /// Draws the text in the center of the bounds.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="text">The text.</param>
 /// <param name="bounds">The bounds.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem DrawCenter(this ITextSystem textSystem, string text, Rectangle bounds, string fontName = null)
 {
     return(DrawCenter(textSystem, 0, 0, text, bounds, Color.White, fontName));
 }
Example #9
0
 /// <summary>
 /// Draw the specified text in the x and y coordinate.
 /// </summary>
 /// <returns>The draw.</returns>
 /// <param name="textSystem">The text system.</param>
 /// <param name="x">The x coordinate.</param>
 /// <param name="y">The y coordinate.</param>
 /// <param name="text">The text.</param>
 /// <param name="fontName">The font name.</param>
 public static ITextSystem Draw(this ITextSystem textSystem, float x, float y, string text, string fontName = null)
 {
     return(textSystem.Draw(x, y, text, Color.White, fontName));
 }
Example #10
0
 /// <summary>
 /// Draws the text in the specified position.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="position">The position.</param>
 /// <param name="text">The text.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem Draw(this ITextSystem textSystem, Point position, string text, string fontName = null)
 {
     return(textSystem.Draw(position, text, Color.White, fontName));
 }
Example #11
0
 /// <summary>
 /// Draws the text in the specified position.
 /// </summary>
 /// <param name="textSystem">The text system.</param>
 /// <param name="position">The position.</param>
 /// <param name="text">The text.</param>
 /// <param name="color">The text color.</param>
 /// <param name="fontName">Name of the font.</param>
 /// <returns>The text system.</returns>
 public static ITextSystem Draw(this ITextSystem textSystem, Point position, string text, Color color, string fontName = null)
 {
     return(textSystem.Draw(position.X, position.Y, text, color, fontName));
 }
Example #12
0
        public override void Initialize(IGraphicSystem graphicSystem, IPhysicSystem physicSystem, ITextSystem textSystem, IInputSystem inputSystem, Action exitAction)
        {
            base.Initialize(graphicSystem, physicSystem, textSystem, inputSystem, exitAction);

            this.OpenScene <MainScene>();
        }