Inheritance: ICellAppearance
Exemplo n.º 1
0
        public virtual void RenderToCell(SadConsole.Cell sadConsoleCell)
        {
            Appearance.CopyAppearanceTo(sadConsoleCell);

            // Clear out the old effect if there was one
            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            if (Info.IsInFOV)
            {
                // Do nothing if it's in view, it's a normal colored square
                // You could do something later like check how far the cell is from the player and tint it
            }

            if (Info.IsExplored && !Info.IsInFOV)
            {
                sadConsoleCell.Effect = EffectExplored;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
                return;
            }

            if (!Info.IsExplored && !Info.IsInFOV)
            {
                RemoveCellFromView(sadConsoleCell);
                //sadConsoleCell.Effect = EffectHidden;
                //sadConsoleCell.Effect.Apply( sadConsoleCell );
                //sadConsoleCell.Effect.Apply( sadConsoleCell );
                return;
            }
        }
Exemplo n.º 2
0
        public virtual void RenderToCell(SadConsole.Cell sadConsoleCell, bool isFov, bool isExplored)
        {
            Appearance.CopyAppearanceTo(sadConsoleCell);

            // Clear out the old effect if there was one
            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            if (isFov)
            {
                // Do nothing if it's in view, it's a normal colored square
                // You could do something later like check how far the cell is from the player and tint it
            }
            else if (isExplored)
            {
                sadConsoleCell.Effect = EffectSeen;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
            else
            {
                sadConsoleCell.Effect = EffectHidden;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
        }
Exemplo n.º 3
0
        public virtual void RenderToCell(SadConsole.Cell sadConsoleCell, bool isFov, bool isExplored)
        {
            Appearance.CopyAppearanceTo(sadConsoleCell);

            // Clear out the old effects if there are any.
            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            if (isFov)
            {
                // Do nothing if it is in view, it's a normal coloured square.
                // Possible to add light effects here?
            }
            else if (isExplored)
            {
                sadConsoleCell.Effect = EffectSeen;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
            else
            {
                sadConsoleCell.Effect = EffectHidden;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
        }
Exemplo n.º 4
0
        public virtual void RemoveCellFromView(SadConsole.Cell sadConsoleCell)
        {
            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            sadConsoleCell.Effect = EffectSeen;
            sadConsoleCell.Effect.Apply(sadConsoleCell);
        }
Exemplo n.º 5
0
        public virtual void RemoveCellFromView(SadConsole.Cell sadConsoleCell)
        {
            // Clear out the old effect if there was one
            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            sadConsoleCell.Effect = EffectSeen;
            sadConsoleCell.Effect.Apply(sadConsoleCell);
        }
Exemplo n.º 6
0
        public LineTool()
        {
            frameEffect = new SadConsole.Effects.Fade()
            {
                UseCellBackground = true,
                FadeForeground = true,
                FadeDuration = 1f,
                AutoReverse = true
            };

            lineCell = new Cell();

            settingsPanel = new LineToolPanel();
            ControlPanels = new CustomPanel[] { settingsPanel, CharacterPickPanel.SharedInstance };

            // Configure the animations
            Brush = new SadConsole.Game.GameObject();
            Brush.Font = Settings.Config.ScreenFont;
            AnimatedTextSurface animation = new AnimatedTextSurface("single", 1, 1, Settings.Config.ScreenFont);
            animation.CreateFrame()[0].GlyphIndex = 42;
            Brush.Animations.Add(animation.Name, animation);
            ResetLine();
        }
Exemplo n.º 7
0
        public virtual void RenderToCell(SadConsole.Cell sadConsoleCell, bool isFov, bool isExplored)
        {
            Appearance.CopyAppearanceTo(sadConsoleCell);

            if (sadConsoleCell.Effect != null)
            {
                sadConsoleCell.Effect.Clear(sadConsoleCell);
                sadConsoleCell.Effect = null;
            }

            if (isFov)
            {
            }
            else if (isExplored)
            {
                sadConsoleCell.Effect = EffectSeen;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
            else
            {
                sadConsoleCell.Effect = EffectHidden;
                sadConsoleCell.Effect.Apply(sadConsoleCell);
            }
        }
Exemplo n.º 8
0
        public void Render()
        {
            if (HotspotPanel.DrawHotspots && Hotspots.Count != 0)
            {
                SpriteBatch batch = new SpriteBatch(Engine.Device);
                batch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied, SamplerState.PointClamp, DepthStencilState.DepthRead, RasterizerState.CullNone);

                foreach (var spot in Hotspots)
                {
                    Cell cell = new Cell();
                    spot.DebugAppearance.CopyAppearanceTo(cell);
                    Point offset = consoleWrapper.Position - consoleWrapper.TextSurface.RenderArea.Location;
                    foreach (var position in spot.Positions)
                    {
                        Point adjustedPosition = position + offset;
                        if (consoleWrapper.TextSurface.RenderArea.Contains(position))
                            cell.Render(batch,
                                        new Rectangle(adjustedPosition.ConsoleLocationToWorld(Settings.Config.ScreenFont.Size.X, Settings.Config.ScreenFont.Size.Y), Settings.Config.ScreenFont.Size),
                                        Settings.Config.ScreenFont);

                    }

                }

                batch.End();
            }
            if (ZonesPanel.DrawZones)
                foreach (var zone in Zones)
                {
                    zone.Render();
                }

            if (GameObjectPanel.DrawObjects)
                foreach (var entity in Objects)
                {
                    entity.Render();
                }
        }
Exemplo n.º 9
0
 /// <summary>
 /// Copies this cells information to a new cell. Preserves appearance, Actual* properties, and glyph information.
 /// </summary>
 /// <param name="destination">The cell to copy to.</param>
 public virtual void Copy(Cell destination)
 {
     CopyAppearanceTo(destination);
     destination.ActualGlyphIndex = this.ActualGlyphIndex;
     destination.ActualBackground = this.ActualBackground;
     destination.ActualForeground = this.ActualForeground;
     destination.ActualSpriteEffect = this.ActualSpriteEffect;
 }
Exemplo n.º 10
0
 public virtual void RenderToCell(SadConsole.Cell sadConsoleCell)
 {
     Appearance.CopyAppearanceTo(sadConsoleCell);
 }
Exemplo n.º 11
0
 public void Clear(SadConsole.Cell sadConsoleCell)
 {
     sadConsoleCell.Reset();
 }
Exemplo n.º 12
0
 /// <summary>
 /// Creates a cell state from a cell.
 /// </summary>
 /// <param name="source">The source cell to create a state from.</param>
 public CellState(Cell source) : this(source.Foreground, source.Background, source.Glyph, source.Mirror, source.IsVisible, source.Decorators) { }
Exemplo n.º 13
0
 /// <summary>
 /// Copies this cells information to a new cell. Preserves appearance, Actual* properties, and character information.
 /// </summary>
 /// <param name="destination">The cell to copy to.</param>
 public virtual void Copy(Cell destination)
 {
     CopyAppearanceTo(destination);
     destination.ActualCharacterIndex = this.ActualCharacterIndex;
     destination.ActualBackground = this.ActualBackground;
     destination.ActualForeground = this.ActualForeground;
 }
Exemplo n.º 14
0
        public void MouseMoveSurface(MouseInfo info, ITextSurface surface)
        {
            Brush.Position = info.ConsoleLocation;
            Brush.IsVisible = true;

            if (info.LeftClicked)
            {
                Cell cellToMatch = new Cell();
                Cell currentFillCell = new Cell();

                surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y).Copy(cellToMatch);
                cellToMatch.Effect = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y).Effect;

                currentFillCell.GlyphIndex = CharacterPickPanel.SharedInstance.SettingCharacter;
                currentFillCell.Foreground = CharacterPickPanel.SharedInstance.SettingForeground;
                currentFillCell.Background = CharacterPickPanel.SharedInstance.SettingBackground;
                currentFillCell.SpriteEffect = CharacterPickPanel.SharedInstance.SettingMirrorEffect;

                Func<Cell, bool> isTargetCell = (c) =>
                {
                    bool effect = c.Effect == null && cellToMatch.Effect == null;

                    if (c.Effect != null && cellToMatch.Effect != null)
                        effect = c.Effect == cellToMatch.Effect;

                    if (c.GlyphIndex == 0 && cellToMatch.GlyphIndex == 0)
                        return c.Background == cellToMatch.Background;

                    return c.Foreground == cellToMatch.Foreground &&
                           c.Background == cellToMatch.Background &&
                           c.GlyphIndex == cellToMatch.GlyphIndex &&
                           c.SpriteEffect == cellToMatch.SpriteEffect &&
                           effect;
                };

                Action<Cell> fillCell = (c) =>
                {
                    currentFillCell.Copy(c);
                    //console.TextSurface.SetEffect(c, _currentFillCell.Effect);
                };

                System.Collections.Generic.List<Cell> cells = new System.Collections.Generic.List<Cell>(surface.Cells);

                Func<Cell, SadConsole.Algorithms.NodeConnections<Cell>> getConnectedCells = (c) =>
                {
                    Algorithms.NodeConnections<Cell> connections = new Algorithms.NodeConnections<Cell>();

                    Point position = TextSurface.GetPointFromIndex(cells.IndexOf(c), surface.Width);

                    connections.West = surface.IsValidCell(position.X - 1, position.Y) ? surface.GetCell(position.X - 1, position.Y) : null;
                    connections.East = surface.IsValidCell(position.X + 1, position.Y) ? surface.GetCell(position.X + 1, position.Y) : null;
                    connections.North = surface.IsValidCell(position.X, position.Y - 1) ? surface.GetCell(position.X, position.Y - 1) : null;
                    connections.South = surface.IsValidCell(position.X, position.Y + 1) ? surface.GetCell(position.X, position.Y + 1) : null;

                    return connections;
                };

                if (!isTargetCell(currentFillCell))
                    SadConsole.Algorithms.FloodFill<Cell>(surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y), isTargetCell, fillCell, getConnectedCells);
            }

            if (info.RightButtonDown)
            {
                var cell = surface.GetCell(info.ConsoleLocation.X, info.ConsoleLocation.Y);

                CharacterPickPanel.SharedInstance.SettingCharacter = cell.GlyphIndex;
                CharacterPickPanel.SharedInstance.SettingForeground = cell.Foreground;
                CharacterPickPanel.SharedInstance.SettingBackground = cell.Background;
                CharacterPickPanel.SharedInstance.SettingMirrorEffect = cell.SpriteEffect;
            }
        }
Exemplo n.º 15
0
        public unsafe void DrawCell(Cell cell, Rectangle screenRect, Color defaultBackground, SadConsole.Font font)
        {
            if (cell.IsVisible)
            {
                var glyphRect = font.GlyphIndexRects[cell.ActualGlyphIndex];

                if ((cell.ActualSpriteEffect & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally)
                {
                    var temp = glyphRect.Left;
                    glyphRect.Left = glyphRect.Width;
                    glyphRect.Width = temp;
                }

                if ((cell.ActualSpriteEffect & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically)
                {
                    var temp = glyphRect.Top;
                    glyphRect.Top = glyphRect.Height;
                    glyphRect.Height = temp;
                }

                fixed (Vertex* verts = m_verticies)
                {
                    if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != defaultBackground)
                    {
                        // Background
                        verts[vertIndexCounter].Position.X = screenRect.Left;
                        verts[vertIndexCounter].Position.Y = screenRect.Top;
                        verts[vertIndexCounter].TexCoords.X = solidRect.Left;
                        verts[vertIndexCounter].TexCoords.Y = solidRect.Top;
                        verts[vertIndexCounter].Color = cell.ActualBackground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Width; // SadConsole w/SFML changed Width to be left + width...
                        verts[vertIndexCounter].Position.Y = screenRect.Top;
                        verts[vertIndexCounter].TexCoords.X = solidRect.Width;
                        verts[vertIndexCounter].TexCoords.Y = solidRect.Top;
                        verts[vertIndexCounter].Color = cell.ActualBackground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Width;
                        verts[vertIndexCounter].Position.Y = screenRect.Height;
                        verts[vertIndexCounter].TexCoords.X = solidRect.Width;
                        verts[vertIndexCounter].TexCoords.Y = solidRect.Height;
                        verts[vertIndexCounter].Color = cell.ActualBackground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Left;
                        verts[vertIndexCounter].Position.Y = screenRect.Height;
                        verts[vertIndexCounter].TexCoords.X = solidRect.Left;
                        verts[vertIndexCounter].TexCoords.Y = solidRect.Height;
                        verts[vertIndexCounter].Color = cell.ActualBackground;
                        vertIndexCounter++;
                    }

                    if (cell.ActualForeground != Color.Transparent)
                    {
                        // Foreground
                        verts[vertIndexCounter].Position.X = screenRect.Left;
                        verts[vertIndexCounter].Position.Y = screenRect.Top;
                        verts[vertIndexCounter].TexCoords.X = glyphRect.Left;
                        verts[vertIndexCounter].TexCoords.Y = glyphRect.Top;
                        verts[vertIndexCounter].Color = cell.ActualForeground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Width; // SadConsole w/SFML changed Width to be left + width...
                        verts[vertIndexCounter].Position.Y = screenRect.Top;
                        verts[vertIndexCounter].TexCoords.X = glyphRect.Width;
                        verts[vertIndexCounter].TexCoords.Y = glyphRect.Top;
                        verts[vertIndexCounter].Color = cell.ActualForeground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Width;
                        verts[vertIndexCounter].Position.Y = screenRect.Height;
                        verts[vertIndexCounter].TexCoords.X = glyphRect.Width;
                        verts[vertIndexCounter].TexCoords.Y = glyphRect.Height;
                        verts[vertIndexCounter].Color = cell.ActualForeground;
                        vertIndexCounter++;

                        verts[vertIndexCounter].Position.X = screenRect.Left;
                        verts[vertIndexCounter].Position.Y = screenRect.Height;
                        verts[vertIndexCounter].TexCoords.X = glyphRect.Left;
                        verts[vertIndexCounter].TexCoords.Y = glyphRect.Height;
                        verts[vertIndexCounter].Color = cell.ActualForeground;
                        vertIndexCounter++;

                    }
                }

            }
        }
Exemplo n.º 16
0
        public unsafe void DrawCell(Cell cell, Rectangle screenRect, Rectangle solidRect, Color defaultBackground, SadConsole.Font font)
        {
            if (lastDrawCall.Texture != font.FontImage && lastDrawCall.Texture != null)
            {
                End();
                lastDrawCall.VertIndex = 0;
            }

            lastDrawCall.Texture = font.FontImage;

            if (lastDrawCall.VertIndex >= maxIndex)
            {
                global::System.Array.Resize(ref lastDrawCall.Verticies, lastDrawCall.Verticies.Length + lastDrawCall.Verticies.Length / 2);
                maxIndex = lastDrawCall.Verticies.Length - 200;
            }

            var glyphRect = font.GlyphIndexRects[cell.ActualGlyphIndex];

            if ((cell.ActualSpriteEffect & SpriteEffects.FlipHorizontally) == SpriteEffects.FlipHorizontally)
            {
                var temp = glyphRect.Left;
                glyphRect.Left = glyphRect.Width;
                glyphRect.Width = temp;
            }

            if ((cell.ActualSpriteEffect & SpriteEffects.FlipVertically) == SpriteEffects.FlipVertically)
            {
                var temp = glyphRect.Top;
                glyphRect.Top = glyphRect.Height;
                glyphRect.Height = temp;
            }

            fixed (Vertex* verts = lastDrawCall.Verticies)
            {
                if (cell.ActualBackground != Color.Transparent && cell.ActualBackground != defaultBackground)
                {
                    // Background
                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Left;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Top;
                    verts[lastDrawCall.VertIndex].TexCoords.X = solidRect.Left;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = solidRect.Top;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualBackground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Width; // SadConsole w/SFML changed Width to be left + width...
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Top;
                    verts[lastDrawCall.VertIndex].TexCoords.X = solidRect.Width;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = solidRect.Top;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualBackground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Width;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Height;
                    verts[lastDrawCall.VertIndex].TexCoords.X = solidRect.Width;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = solidRect.Height;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualBackground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Left;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Height;
                    verts[lastDrawCall.VertIndex].TexCoords.X = solidRect.Left;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = solidRect.Height;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualBackground;
                    lastDrawCall.VertIndex++;

                    //lastDrawCall.Verticies.AddRange(singleDrawVerticies);
                }

                if (cell.ActualForeground != Color.Transparent)
                {
                    // Foreground
                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Left;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Top;
                    verts[lastDrawCall.VertIndex].TexCoords.X = glyphRect.Left;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = glyphRect.Top;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualForeground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Width; // SadConsole w/SFML changed Width to be left + width...
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Top;
                    verts[lastDrawCall.VertIndex].TexCoords.X = glyphRect.Width;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = glyphRect.Top;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualForeground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Width;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Height;
                    verts[lastDrawCall.VertIndex].TexCoords.X = glyphRect.Width;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = glyphRect.Height;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualForeground;
                    lastDrawCall.VertIndex++;

                    verts[lastDrawCall.VertIndex].Position.X = screenRect.Left;
                    verts[lastDrawCall.VertIndex].Position.Y = screenRect.Height;
                    verts[lastDrawCall.VertIndex].TexCoords.X = glyphRect.Left;
                    verts[lastDrawCall.VertIndex].TexCoords.Y = glyphRect.Height;
                    verts[lastDrawCall.VertIndex].Color = cell.ActualForeground;
                    lastDrawCall.VertIndex++;

                    //lastDrawCall.Verticies.AddRange(singleDrawVerticies);
                }
            }
        }