示例#1
0
            public Serialized(GameObject gameObject)
            {
                Animations = new List <Consoles.AnimatedTextSurface.Serialized>();

                foreach (var item in gameObject.Animations)
                {
                    Animations.Add(new Consoles.AnimatedTextSurface.Serialized(item.Value));
                }

                IsVisible           = gameObject.IsVisible;
                Position            = gameObject.position;
                RepositionRects     = gameObject.repositionRects;
                UsePixelPositioning = gameObject.usePixelPositioning;
                Name         = gameObject.Name;
                FontName     = gameObject.font.Name;
                FontSize     = gameObject.font.SizeMultiple;
                RenderOffset = gameObject.renderOffset;

                if (gameObject.Animations.ContainsValue(gameObject.animation) && gameObject.Animations.ContainsKey(gameObject.animation.Name))
                {
                    storedAsName        = true;
                    storedAnimationName = gameObject.animation.Name;
                }
                else
                {
                    storedAsName        = false;
                    storedAnimationName = gameObject.animation.Name;
                    Animation           = new Consoles.AnimatedTextSurface.Serialized(gameObject.animation);
                }
            }
 /// <summary>
 /// Creates a serialized object from an existing <see cref="TextSurfaceView"/>.
 /// </summary>
 /// <param name="surface">The surface to serialize.</param>
 public Serialized(TextSurfaceView surfaceView)
 {
     Area              = surfaceView.originalArea;
     FontName          = surfaceView.font.Name;
     FontMultiple      = surfaceView.font.SizeMultiple;
     DefaultBackground = surfaceView.DefaultBackground;
     DefaultForeground = surfaceView.DefaultForeground;
     Tint              = surfaceView.Tint;
 }
示例#3
0
        public EntityGuy(Font.FontSizes fontSize) : base(1, 1)
        {
            UseKeyboard = true;
            IsFocused   = true;
            //UsePixelPositioning = true;

            Font = Global.Fonts["EntityGuy"].GetFont(fontSize);

            InitializeAnimations();
        }
示例#4
0
 public Serialized(AnimatedTextSurface surface)
 {
     Frames            = surface.Frames.ToArray();
     Width             = surface.width;
     Height            = surface.height;
     AnimationDuration = surface.AnimationDuration;
     Name     = surface.Name;
     FontName = surface.font.Name;
     FontSize = surface.font.SizeMultiple;
     Repeat   = surface.Repeat;
     Center   = surface.Center;
 }
示例#5
0
文件: Font.cs 项目: x3nx1a/SadConsole
        /// <summary>
        /// Gets a sized font.
        /// </summary>
        /// <param name="multiple">How much to multiple the font size by.</param>
        /// <returns>A font.</returns>
        public Font GetFont(Font.FontSizes multiple)
        {
            if (cachedFonts.ContainsKey(multiple))
            {
                return(cachedFonts[multiple]);
            }

            var font = new Font(this, multiple);

            cachedFonts.Add(multiple, font);
            return(font);
        }
示例#6
0
 private void BeforeSerializing(StreamingContext context)
 {
     fontName = Font.Name;
     fontSize = Font.SizeMultiple;
 }
示例#7
0
 /// <summary>
 /// Gets a sized font.
 /// </summary>
 /// <param name="multiple">How much to multiple the font size by.</param>
 /// <returns>A font.</returns>
 public Font GetFont(Font.FontSizes multiple)
 {
     return(new Font(this, multiple));
 }
示例#8
0
        ////////////////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>   Constructor. </summary>
        ///
        /// <remarks>   Darrellp, 8/26/2016. </remarks>
        ///
        /// <param name="viewWidth">    Width of the console. </param>
        /// <param name="viewHeight">   Height of the console. </param>
        /// <param name="mapWidth">     Width of the underlying map. </param>
        /// <param name="mapHeight">    Height of the underlying map. </param>
        /// <param name="fontSize">     (Optional) size of the font. </param>
        ////////////////////////////////////////////////////////////////////////////////////////////////////

        public DungeonMapConsole(int viewWidth, int viewHeight, int mapWidth, int mapHeight, Font.FontSizes fontSize = Font.FontSizes.One)
            : base(mapWidth, mapHeight)
        {
            var fontMaster = Engine.LoadFont("Cheepicus12.font");
            var font       = fontMaster.GetFont(fontSize);

            TextSurface.Font = font;
            var mult = SizeMultipliers[fontSize];

            TextSurface.RenderArea = new Rectangle(0, 0, (int)(viewWidth * 2 / (3 * mult)), (int)(viewHeight * 3 / (2 * mult)) - 1);

            var playerAnimation = new AnimatedTextSurface("default", 1, 1, font);

            playerAnimation.CreateFrame();
            playerAnimation.CurrentFrame[0].Foreground = Color.Orange;
            playerAnimation.CurrentFrame[0].GlyphIndex = 1;//'@';

            Player = new GameObject(font)
            {
                Animation = playerAnimation,
                Position  = new Point(1, 1)
            };

            GenerateMap();
        }