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; }
public EntityGuy(Font.FontSizes fontSize) : base(1, 1) { UseKeyboard = true; IsFocused = true; //UsePixelPositioning = true; Font = Global.Fonts["EntityGuy"].GetFont(fontSize); InitializeAnimations(); }
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; }
/// <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); }
private void BeforeSerializing(StreamingContext context) { fontName = Font.Name; fontSize = Font.SizeMultiple; }
/// <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)); }
//////////////////////////////////////////////////////////////////////////////////////////////////// /// <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(); }