/// <summary> /// Creates a new instance of the ColoredString class with the specified string value, foreground and background colors, and a cell effect. /// </summary> /// <param name="value">The backing string.</param> /// <param name="foreground">The foreground color for each character.</param> /// <param name="background">The background color for each character.</param> /// <param name="effect">The cell effect for each character.</param> public ColoredString(string value, Color foreground, Color background, ICellEffect effect) { this.Foreground = foreground; this.Background = background; this.Effect = effect; this.String = value; }
/// <summary> /// Draws the string on the console at the specified location, wrapping if needed. /// </summary> /// <param name="x">X location of the text.</param> /// <param name="y">Y location of the text.</param> /// <param name="text">The string to display.</param> /// <param name="appearance">The appearance of the cell</param> /// <param name="effect">An optional effect to apply to the printed cells.</param> public void Print(int x, int y, string text, Cell appearance, ICellEffect effect = null) { if (String.IsNullOrEmpty(text)) { return; } if (x >= textSurface.Width || x < 0 || y >= textSurface.Height || y < 0) { throw new Exception("X,Y is out of range for Print"); } int index = y * textSurface.Width + x; int total = index + text.Length > textSurface.Cells.Length ? textSurface.Cells.Length - index : index + text.Length; int charIndex = 0; for (; index < total; index++) { Cell cell = textSurface.Cells[index]; appearance.CopyAppearanceTo(cell); cell.Glyph = text[charIndex]; Effects.SetEffect(cell, effect); charIndex++; } textSurface.IsDirty = true; }
public override bool Equals(ICellEffect other) { if (other is ConcurrentEffect) { if (base.Equals(other)) { var effect = (ConcurrentEffect)other; var effects1 = this.Effects.ToList(); var effects2 = effect.Effects.ToList(); if (effects1.Count == effects2.Count) { for (int i = 0; i < effects1.Count; i++) { if (!effects1[i].Equals(effects2[i])) { return(false); } } return(true); } } } return(false); }
/// <summary> /// Applies the referenced cell effect to every character in the colored string. /// </summary> /// <param name="effect">The effect to apply.</param> public void SetEffect(ICellEffect effect) { for (int i = 0; i < _characters.Count; i++) { _characters[i].Effect = effect; } }
/// <summary> /// Removes an effect and associated cells from the manager. /// </summary> /// <param name="effect">Effect to remove.</param> public void Remove(ICellEffect effect) { CellEffectData data = _effects[effect]; foreach (var cell in data.Cells) ClearCellEffect(cell); }
public override bool Equals(ICellEffect other) { if (other is ConcurrentEffect) { if (base.Equals(other)) { var effect = (ConcurrentEffect)other; var effects1 = this.Effects.ToList(); var effects2 = effect.Effects.ToList(); if (effects1.Count == effects2.Count) { for (int i = 0; i < effects1.Count; i++) { if (!effects1[i].Equals(effects2[i])) return false; } return true; } } } return false; }
/// <summary> /// Prints text on the console. /// </summary> /// <param name="text">The text to print.</param> /// <param name="template">The way the text will look when it is printed.</param> /// <param name="templateEffect">Effect to apply to the text as its printed.</param> /// <returns>Returns this cursor object.</returns> public Cursor Print(string text, ICellAppearance template, ICellEffect templateEffect) { var coloredString = text.CreateColored(template.Foreground, template.Background, template.SpriteEffect); coloredString.SetEffect(templateEffect); return(Print(coloredString)); }
/// <summary> /// Changes the effect of the <paramref name="cells"/> provided. /// </summary> /// <param name="cells">Cells to change the effect on.</param> /// <param name="effect">The effect to associate with the cell.</param> public void SetEffect(IEnumerable <Cell> cells, ICellEffect effect) { var list = new List <Cell>(backingSurface.Cells); foreach (var cell in cells) { if (!list.Contains(cell)) { throw new Exception("Cell is not part of the surface used to create this effects manager."); } } if (effect != null) { CellEffectData workingEffect; if (effect.CloneOnApply) { effect = effect.Clone(); workingEffect = new CellEffectData(effect); _effects.Add(workingEffect.Effect, workingEffect); } else { // Is the effect unknown? Add it. if (GetKnownEffect(effect, out workingEffect) == false) { _effects.Add(workingEffect.Effect, workingEffect); } } foreach (var cell in cells) { if (!workingEffect.Cells.Contains(cell)) { // Remove the targeted cell from the known cells list if it is already there (associated with another effect) ClearCellEffect(cell); // Add the cell to the effects by cell key and to list of known cells for the effect _effectCells.Add(cell, workingEffect); cell.Effect = workingEffect.Effect; workingEffect.Cells.Add(cell); } else // Make sure the effect is attached to the cell. { cell.Effect = workingEffect.Effect; } } } else { foreach (var cell in cells) { ClearCellEffect(cell); } } }
/// <summary> /// Removes an effect and associated cells from the manager. /// </summary> /// <param name="effect">Effect to remove.</param> public void Remove(ICellEffect effect) { CellEffectData data = _effects[effect]; foreach (var cell in data.Cells) { ClearCellEffect(cell); } }
/// <summary> /// Generates an empty cell. /// </summary> public Cell() : base(@"Sprites\LevelSprites\Empty") { cellEffect = null; gridPosition = new Point(0, 0); isWall = false; size = new Vector2(50, 50); this.position = calculatePosition(); }
/// <summary> /// Creates a <see cref="ColoredString"/> object from an existing string with the specified foreground, background, and cell effect. /// </summary> /// <param name="value">The current string.</param> /// <param name="foreground">The foreground color.</param> /// <param name="background">The background color.</param> /// <param name="effect">The cell effect.</param> /// <returns>A <see cref="ColoredString"/> object instace.</returns> public static ColoredString CreateColored(this string value, Color foreground, Color background, ICellEffect effect) { ColoredString newString = new ColoredString(value); newString.Foreground = foreground; newString.Background = background; newString.Effect = effect; newString.UpdateWithDefaults(); return newString; }
/// <summary> /// Prints text on the console. /// </summary> /// <param name="text">The text to print.</param> /// <param name="template">The way the text will look when it is printed.</param> /// <returns>Returns this cursor object.</returns> public Cursor Print(string text, ICellAppearance template, ICellEffect templateEffect) { // TODO: Look for the flag 7 on settings. This means allow word wrap. So without it we need to test if the text will reach the end of the screen and cut it off. //((Console)_console.Target).DrawString(_location.X, _location.Y, text, PrintAppearance.Foreground, PrintAppearance.Background, PrintAppearance.Effect); var console = (Console)_console.Target; foreach (var character in text) { if (character == '\r') { CarriageReturn(); } else if (character == '\n') { LineFeed(); } else { var cell = console.CellData[_position.X, _position.Y]; if (!PrintOnlyCharacterData) { template.CopyAppearanceTo(cell); console._cellData.SetEffect(cell, templateEffect); } cell.CharacterIndex = character; _position.X += 1; if (_position.X >= console.CellData.Width) { _position.X = 0; _position.Y += 1; if (_position.Y >= console.CellData.Height) { _position.Y -= 1; if (AutomaticallyShiftRowsUp) { console.CellData.ShiftUp(); if (console.CellData.ResizeOnShift) { _position.Y++; } } } } } } return(this); }
public void Start() { if (Effects.Count > 0) { _activeIndex = 0; _activeEffect = Effects[0]; _enabled = true; } else _enabled = false; }
/// <summary> /// Removes an effect and associated cells from the manager. /// </summary> /// <param name="effect">Effect to remove.</param> public void Remove(ICellEffect effect) { if (_effects.ContainsKey(effect)) { Cell[] cells = _effects[effect].Cells.ToArray(); foreach (var cell in cells) { ClearCellEffect(cell); } } }
/// <summary> /// Removes an effect and associated cells from the manager. /// </summary> /// <param name="effect">Effect to remove.</param> public void Remove(ICellEffect effect) { if (_effects.ContainsKey(effect)) { ColoredGlyphWithState[] states = _effects[effect].CellsStates.ToArray(); foreach (var state in states) { ClearCellEffect(state.CellIndex); } } }
/// <summary> /// Gets effect data from the dicronary if it exists. /// </summary> /// <param name="effect">The effect to get.</param> /// <param name="effectData">The effect data ssociated with the effect.</param> /// <returns><see langword="true"/> when the effect exists; otherwise <see langword="false"/>.</returns> protected bool GetKnownEffect(ICellEffect effect, out ColoredGlyphEffectData effectData) { if (_effects.ContainsKey(effect)) { effectData = _effects[effect]; return(true); } else { effectData = new ColoredGlyphEffectData(effect); return(false); } }
public void Start() { if (Effects.Count > 0) { _activeIndex = 0; _activeEffect = Effects[0]; _enabled = true; } else { _enabled = false; } }
/// <summary> /// Determines if the passed in ICellEffect equals this one or not. /// </summary> /// <param name="other">The other ICellEffect to test.</param> /// <returns>True or false indicating equality.</returns> public virtual bool Equals(ICellEffect other) { if (IsFinished == other.IsFinished && CloneOnApply == other.CloneOnApply && StartDelay == other.StartDelay && RemoveOnFinished == other.RemoveOnFinished && Permanent == other.Permanent && IsFinished == other.IsFinished) return true; else return false; }
public RenderComponent(int owner, CellAppearance appearance, int layer = 0) { OwnerID = owner; Appearance = appearance; Layer = layer; Explored = new Recolor() { Foreground = Color.LightGray * 0.3f, Background = Color.LightGray * 0.3f, DoForeground = true, DoBackground = true, CloneOnApply = false }; }
public override bool Equals(ICellEffect effect) { if (effect is Delay) { if (base.Equals(effect)) { var effect2 = (Delay)effect; return(StartDelay == effect2.StartDelay && DelayTime == effect2.DelayTime); } } return(false); }
public override bool Equals(ICellEffect effect) { if (effect is Delay) { if (base.Equals(effect)) { var effect2 = (Delay)effect; return StartDelay == effect2.StartDelay && DelayTime == effect2.DelayTime; } } return false; }
/// <summary> /// Determines if the passed in ICellEffect equals this one or not. /// </summary> /// <param name="other">The other ICellEffect to test.</param> /// <returns>True or false indicating equality.</returns> public virtual bool Equals(ICellEffect other) { if (IsFinished == other.IsFinished && CloneOnApply == other.CloneOnApply && StartDelay == other.StartDelay && RemoveOnFinished == other.RemoveOnFinished && Permanent == other.Permanent && IsFinished == other.IsFinished) { return(true); } else { return(false); } }
public override bool Equals(ICellEffect effect) { if (effect is BlinkCharacter) { if (base.Equals(effect)) { var effect2 = (BlinkCharacter)effect; return(CharacterIndex == effect2.CharacterIndex && BlinkSpeed == effect2.BlinkSpeed && RemoveOnFinished == effect2.RemoveOnFinished && StartDelay == effect2.StartDelay); } } return(false); }
public override bool Equals(ICellEffect effect) { if (effect is EffectsChain) { if (base.Equals(effect)) { var effect2 = (EffectsChain)effect; return(StartDelay == effect2.StartDelay && RemoveOnFinished == effect2.RemoveOnFinished && DelayBetweenEffects == effect2.DelayBetweenEffects && Repeat == effect2.Repeat); } } return(false); }
/// <summary> /// Prints text on the console. /// </summary> /// <param name="text">The text to print.</param> /// <param name="template">The way the text will look when it is printed.</param> /// <param name="templateEffect">Effect to apply to the text as its printed.</param> /// <returns>Returns this cursor object.</returns> public Cursor Print(string text, ICellAppearance template, ICellEffect templateEffect) { ColoredString coloredString; if (UseStringParser) { var console = (SurfaceEditor)_console.Target; coloredString = ColoredString.Parse(text, _position.Y * console.TextSurface.Width + _position.X, console.TextSurface, console, new StringParser.ParseCommandStacks()); } else { coloredString = text.CreateColored(template.Foreground, template.Background, template.SpriteEffect); coloredString.SetEffect(templateEffect); } return(Print(coloredString)); }
public override bool Equals(ICellEffect effect) { if (effect is Blink) { if (base.Equals(effect)) { var effect2 = (Blink)effect; return(BlinkOutColor == effect2.BlinkOutColor && BlinkSpeed == effect2.BlinkSpeed && UseCellBackgroundColor == effect2.UseCellBackgroundColor && StartDelay == effect2.StartDelay && BlinkCount == effect2.BlinkCount); } } return(false); }
public override bool Equals(ICellEffect effect) { if (effect is Recolor) { if (base.Equals(effect)) { var effect2 = (Recolor)effect; return(Foreground == effect2.Foreground && Background == effect2.Background && Permanent == effect2.Permanent && RemoveOnFinished == effect2.RemoveOnFinished && StartDelay == effect2.StartDelay); } } return(false); }
/// <summary> /// Changes the effect of a specific cell. /// </summary> /// <param name="cellIndex">Cell index to set the effect for.</param> /// <param name="effect">The effect to associate with the cell.</param> public void SetEffect(int cellIndex, ICellEffect effect) { ColoredGlyph cell = _backingSurface[cellIndex]; if (effect != null) { ColoredGlyphEffectData workingEffect; if (effect.CloneOnAdd) { effect = effect.Clone(); workingEffect = new ColoredGlyphEffectData(effect); _effects.Add(workingEffect.Effect, workingEffect); } else { // Is the effect unknown? Add it. if (GetKnownEffect(effect, out workingEffect) == false) { _effects.Add(workingEffect.Effect, workingEffect); } else { if (workingEffect.ContainsCell(cellIndex)) { // Make sure the effect is attached to the cell. return; } } } // Remove the targeted cell from the known cells list if it is already there (associated with another effect) ClearCellEffect(cellIndex); // Add the cell to the effects by cell key and to list of known cells for the effect _effectCells.Add(cellIndex, workingEffect); workingEffect.CellsStates.Add(new ColoredGlyphWithState(cell, cellIndex)); } else { ClearCellEffect(cellIndex); } }
/// <summary> /// Changes the effect of the <paramref name="cellIndicies"/> provided. /// </summary> /// <param name="cellIndicies">A list of cell indicies to change the effect on.</param> /// <param name="effect">The effect to associate with the cell.</param> public void SetEffect(IEnumerable <int> cellIndicies, ICellEffect effect) { if (effect != null) { ColoredGlyphEffectData workingEffect; if (effect.CloneOnAdd) { effect = effect.Clone(); workingEffect = new ColoredGlyphEffectData(effect); _effects.Add(workingEffect.Effect, workingEffect); } else { // Is the effect unknown? Add it. if (GetKnownEffect(effect, out workingEffect) == false) { _effects.Add(workingEffect.Effect, workingEffect); } } foreach (int index in cellIndicies) { if (!workingEffect.ContainsCell(index)) { // Remove the targeted cell from the known cells list if it is already there (associated with another effect) ClearCellEffect(index); // Add the cell to the effects by cell key and to list of known cells for the effect _effectCells.Add(index, workingEffect); workingEffect.CellsStates.Add(new ColoredGlyphWithState(_backingSurface[index], index)); } } } else { foreach (int index in cellIndicies) { ClearCellEffect(index); } } }
public MapObjectBase(Color foreground, Color background, int character) { Appearance = new CellAppearance(foreground, background, character); EffectSeen = new Recolor() { Foreground = Color.LightGray * 0.3f, Background = Color.LightGray * 0.3f, DoForeground = true, DoBackground = true, CloneOnApply = false }; EffectHidden = new Recolor() { Foreground = Color.Black, Background = Color.Black, DoForeground = true, DoBackground = true, CloneOnApply = false }; }
public override bool Equals(ICellEffect effect) { if (effect is Fade) { if (base.Equals(effect)) { var effect2 = (Fade)effect; return(DestinationBackground == effect2.DestinationBackground && DestinationForeground == effect2.DestinationForeground && FadeForeground == effect2.FadeForeground && FadeBackground == effect2.FadeBackground && UseCellForeground == effect2.UseCellForeground && UseCellBackground == effect2.UseCellBackground && FadeDuration == effect2.FadeDuration && Permanent == effect2.Permanent && RemoveOnFinished == effect2.Permanent && StartDelay == effect2.StartDelay); } } return(false); }
/// <summary> /// Changes the effect of a cell to the specified effect. /// </summary> /// <param name="index">Index of the cell.</param> /// <param name="effect">The desired effect.</param> public void SetEffect(int index, ICellEffect effect) { Effects.SetEffect(textSurface[index], effect); }
/// <summary> /// Prints text on the console. /// </summary> /// <param name="text">The text to print.</param> /// <param name="template">The way the text will look when it is printed.</param> /// <param name="templateEffect">Effect to apply to the text as its printed.</param> /// <returns>Returns this cursor object.</returns> public Cursor Print(string text, ICellAppearance template, ICellEffect templateEffect) { ColoredString coloredString; if (UseStringParser) { var console = (SurfaceEditor)_console.Target; coloredString = ColoredString.Parse(text, _position.Y * console.TextSurface.Width + _position.X, console.TextSurface, console, new StringParser.ParseCommandStacks()); } else { coloredString = text.CreateColored(template.Foreground, template.Background, template.SpriteEffect); coloredString.SetEffect(templateEffect); } return Print(coloredString); }
/// <summary> /// Changes the effect of the <paramref name="cells"/> provided. /// </summary> /// <param name="cells">Cells to change the effect on.</param> /// <param name="effect">The effect to associate with the cell.</param> public void SetEffect(IEnumerable<Cell> cells, ICellEffect effect) { var list = new List<Cell>(backingSurface.Cells); foreach (var cell in cells) { if (!list.Contains(cell)) throw new Exception("Cell is not part of the surface used to create this effects manager."); } if (effect != null) { CellEffectData workingEffect; if (effect.CloneOnApply) { effect = effect.Clone(); workingEffect = new CellEffectData(effect); _effects.Add(workingEffect.Effect, workingEffect); } else { // Is the effect unknown? Add it. if (GetKnownEffect(effect, out workingEffect) == false) _effects.Add(workingEffect.Effect, workingEffect); } foreach (var cell in cells) { if (!workingEffect.Cells.Contains(cell)) { // Remove the targeted cell from the known cells list if it is already there (associated with another effect) ClearCellEffect(cell); // Add the cell to the effects by cell key and to list of known cells for the effect _effectCells.Add(cell, workingEffect); cell.Effect = workingEffect.Effect; workingEffect.Cells.Add(cell); } else // Make sure the effect is attached to the cell. cell.Effect = workingEffect.Effect; } } else { foreach (var cell in cells) ClearCellEffect(cell); } }
protected bool GetKnownEffect(ICellEffect effect, out CellEffectData effectData) { if (_effects.ContainsKey(effect)) { effectData = _effects[effect]; return true; } else { effectData = new CellEffectData(effect); return false; } }
/// <summary> /// Changes the glyph, foreground, background, and effect of a cell. /// </summary> /// <param name="x">The x location of the cell.</param> /// <param name="y">The y location of the cell.</param> /// <param name="glyph">The desired glyph.</param> /// <param name="foreground">The desired foreground.</param> /// <param name="background">The desired background.</param> /// <param name="effect">Sets the effect of the cell</param> public void SetGlyph(int x, int y, int glyph, Color foreground, Color background, ICellEffect effect) { int index = y * textSurface.Width + x; textSurface.Cells[index].Background = background; textSurface.Cells[index].Foreground = foreground; textSurface.Cells[index].GlyphIndex = glyph; Effects.SetEffect(textSurface.Cells[index], effect); }
public override void Update(double gameTimeSeconds) { if (_enabled) { _timeElapsed += gameTimeSeconds; if (_delayFinished) { // Check to see if we are in a chain delay, if so, we wait x seconds until we move on to the next chained effect. if (!_inChainDelay) { // Process the effect _activeEffect.Update(gameTimeSeconds); // If the effect finished, we move on to the next effect if (_activeEffect.IsFinished) { _activeIndex++; if (_activeIndex != Effects.Count) { _activeEffect = Effects[_activeIndex]; // When moving to the next effect, check and see if we have a delay. If so, flag and wait. if (DelayBetweenEffects != 0f) { _inChainDelay = true; _timeElapsed = 0d; } } else { _activeIndex = -1; _activeEffect = null; IsFinished = true; } } // No effect to process? End this chain, which sets enabled = false. if (_activeEffect == null) { if (!Repeat) { End(); } else { _inChainDelay = true; _timeElapsed = 0d; IsFinished = false; } } } else { if (_timeElapsed >= DelayBetweenEffects) { _inChainDelay = false; // If we do not have another effect to move on to and repeat is enabled, start over. // We can only do this if the effects have ended with repeat, otherwise End() is called which instantly disables the chain if (_activeEffect == null && Repeat) { Restart(); } } } } else { if (_timeElapsed >= _startDelay) { _delayFinished = true; } } } }
public override bool Equals(ICellEffect effect) { if (effect is Blink) { if (base.Equals(effect)) { var effect2 = (Blink)effect; return BlinkOutColor == effect2.BlinkOutColor && BlinkSpeed == effect2.BlinkSpeed && UseCellBackgroundColor == effect2.UseCellBackgroundColor && StartDelay == effect2.StartDelay && BlinkCount == effect2.BlinkCount; } } return false; }
/// <summary> /// Creates a <see cref="ColoredString"/> object from an existing string with the specified foreground, background, and cell effect. /// </summary> /// <param name="value">The current string.</param> /// <param name="appearance">The foreground and background color.</param> /// <param name="effect">The cell effect.</param> /// <returns>A <see cref="ColoredString"/> object instace.</returns> public static ColoredString CreateColored(this string value, ICellAppearance appearance, ICellEffect effect) { ColoredString newString = new ColoredString(value); newString.Foreground = appearance.Foreground; newString.Background = appearance.Background; newString.Effect = effect; newString.UpdateWithDefaults(); return newString; }
/// <summary> /// Creates a new instance of the cell-effect mapping. /// </summary> /// <param name="effect">The effect.</param> public ColoredGlyphEffectData(ICellEffect effect) { Effect = effect; CellsStates = new List <ColoredGlyphWithState>(); }
public override bool Equals(ICellEffect effect) { if (effect is EffectsChain) { if (base.Equals(effect)) { var effect2 = (EffectsChain)effect; return StartDelay == effect2.StartDelay && RemoveOnFinished == effect2.RemoveOnFinished && DelayBetweenEffects == effect2.DelayBetweenEffects && Repeat == effect2.Repeat; } } return false; }
/// <summary> /// Draws the string on the console at the specified location, wrapping if needed. /// </summary> /// <param name="x">X location of the text.</param> /// <param name="y">Y location of the text.</param> /// <param name="text">The string to display.</param> /// <param name="appearance">The appearance of the cell</param> /// <param name="effect">An optional effect to apply to the printed cells.</param> public void Print(int x, int y, string text, ICellAppearance appearance, ICellEffect effect = null) { if (String.IsNullOrEmpty(text)) return; if (x >= textSurface.Width || x < 0 || y >= textSurface.Height || y < 0) throw new Exception("X,Y is out of range for Print"); int index = y * textSurface.Width + x; int total = index + text.Length > textSurface.Cells.Length ? textSurface.Cells.Length - index : index + text.Length; int charIndex = 0; for (; index < total; index++) { Cell cell = textSurface.Cells[index]; appearance.CopyAppearanceTo(cell); cell.GlyphIndex = text[charIndex]; Effects.SetEffect(cell, effect); charIndex++; } }
/// <summary> /// Prints text on the console. /// </summary> /// <param name="text">The text to print.</param> /// <param name="template">The way the text will look when it is printed.</param> /// <returns>Returns this cursor object.</returns> public Cursor Print(string text, ICellAppearance template, ICellEffect templateEffect) { // TODO: Look for the flag 7 on settings. This means allow word wrap. So without it we need to test if the text will reach the end of the screen and cut it off. //((Console)_console.Target).DrawString(_location.X, _location.Y, text, PrintAppearance.Foreground, PrintAppearance.Background, PrintAppearance.Effect); var console = (Console)_console.Target; foreach (var character in text) { if (character == '\r') { CarriageReturn(); } else if (character == '\n') { LineFeed(); } else { var cell = console.CellData[_position.X, _position.Y]; if (!PrintOnlyCharacterData) { template.CopyAppearanceTo(cell); console._cellData.SetEffect(cell, templateEffect); } cell.CharacterIndex = character; _position.X += 1; if (_position.X > console.CellData.Width - 1) { _position.X = 0; _position.Y += 1; if (_position.Y > console.CellData.Height - 1) { _position.Y -= 1; if (AutomaticallyShiftRowsUp) console.CellData.ShiftRowsUp(); } } } } return this; }
public override bool Equals(ICellEffect effect) { if (effect is Fade) { if (base.Equals(effect)) { var effect2 = (Fade)effect; return DestinationBackground == effect2.DestinationBackground && DestinationForeground == effect2.DestinationForeground && FadeForeground == effect2.FadeForeground && FadeBackground == effect2.FadeBackground && UseCellForeground == effect2.UseCellForeground && UseCellBackground == effect2.UseCellBackground && FadeDuration == effect2.FadeDuration && Permanent == effect2.Permanent && RemoveOnFinished == effect2.Permanent && StartDelay == effect2.StartDelay; } } return false; }
/// <summary> /// Changes the effect of a cell to the specified effect. /// </summary> /// <param name="index">Index of the cell.</param> /// <param name="effect">The desired effect.</param> public void SetEffect(int index, ICellEffect effect) { Effects.SetEffect(textSurface[index], effect); textSurface.IsDirty = true; }
public CellEffectData(ICellEffect effect) { Effect = effect; Cells = new List<Cell>(); }
public override void Update(double gameTimeSeconds) { if (_enabled) { _timeElapsed += gameTimeSeconds; if (_delayFinished) { // Check to see if we are in a chain delay, if so, we wait x seconds until we move on to the next chained effect. if (!_inChainDelay) { // Process the effect _activeEffect.Update(gameTimeSeconds); // If the effect finished, we move on to the next effect if (_activeEffect.IsFinished) { _activeIndex++; if (_activeIndex != Effects.Count) { _activeEffect = Effects[_activeIndex]; // When moving to the next effect, check and see if we have a delay. If so, flag and wait. if (DelayBetweenEffects != 0f) { _inChainDelay = true; _timeElapsed = 0d; } } else { _activeIndex = -1; _activeEffect = null; IsFinished = true; } } // No effect to process? End this chain, which sets enabled = false. if (_activeEffect == null) { if (!Repeat) End(); else { _inChainDelay = true; _timeElapsed = 0d; IsFinished = false; } } } else { if (_timeElapsed >= DelayBetweenEffects) { _inChainDelay = false; // If we do not have another effect to move on to and repeat is enabled, start over. // We can only do this if the effects have ended with repeat, otherwise End() is called which instantly disables the chain if (_activeEffect == null && Repeat) Restart(); } } } else { if (_timeElapsed >= _startDelay) _delayFinished = true; } } }
/// <summary> /// Creates a <see cref="ColoredString"/> object from an existing string with the specified foreground gradient, background gradient, and cell effect. /// </summary> /// <param name="value">The current string.</param> /// <param name="startingForeground">The starting foreground color to blend.</param> /// <param name="endingForeground">The ending foreground color to blend.</param> /// <param name="startingBackground">The starting background color to blend.</param> /// <param name="endingBackground">The ending background color to blend.</param> /// <param name="effect">The cell effect.</param> /// <returns>A <see cref="ColoredString"/> object instace.</returns> public static ColoredString CreateGradient(this string value, Color startingForeground, Color endingForeground, Color startingBackground, Color endingBackground, ICellEffect effect) { ColoredString newString = new ColoredString(value); for (int i = 0; i < value.Length; i++) { newString[i].Foreground = Color.Lerp(startingForeground, endingForeground, (float)i / (float)value.Length); newString[i].Background = Color.Lerp(startingBackground, endingBackground, (float)i / (float)value.Length); newString[i].Effect = newString.Effect; } return newString; }
public CellEffectData(ICellEffect effect) { Effect = effect; Cells = new List <Cell>(); }
public override bool Equals(ICellEffect effect) { if (effect is BlinkCharacter) { if (base.Equals(effect)) { var effect2 = (BlinkCharacter)effect; return CharacterIndex == effect2.CharacterIndex && BlinkSpeed == effect2.BlinkSpeed && RemoveOnFinished == effect2.RemoveOnFinished && StartDelay == effect2.StartDelay; } } return false; }
public override bool Equals(ICellEffect effect) { if (effect is Recolor) { if (base.Equals(effect)) { var effect2 = (Recolor)effect; return Foreground == effect2.Foreground && Background == effect2.Background && Permanent == effect2.Permanent && RemoveOnFinished == effect2.RemoveOnFinished && StartDelay == effect2.StartDelay; } } return false; }