示例#1
0
        public override void Draw(RunState currentRunState)
        {
            base.Draw(currentRunState);
            Terminal.BkColor(Color.CornflowerBlue);
            Terminal.Color(Color.White);
            for (var x = 0; x < ScreenFrameAbs.Width; x += SpacingX)
            {
                Print(x, 0, ContentAlignment.TopLeft, "x");
            }

            Print(0, SpacingY, ContentAlignment.TopLeft, "0123456789ABCDEFGHIJKLMNO");


            Terminal.Layer(1);
            Terminal.BkColor(Color.Black);
            Terminal.Color(Color.White);

            var cameraFocusFilter = World.GetFilter(typeof(EcsFilter <Position, CameraFocusTag>));

            if (cameraFocusFilter.IsEmpty())
            {
                return;
            }

            ref var cameraFocus         = ref cameraFocusFilter.Entities[0];
示例#2
0
 public virtual void Draw(RunState currentRunState)
 {
     CurrentRunState = currentRunState;
     Terminal.Font("");
     Terminal.Layer(0);
     Terminal.BkColor(Color.Black);
     Terminal.Color(Color.White);
 }
示例#3
0
        private static void Draw()
        {
            Terminal.Color(Color.White);
            Terminal.BkColor(Color.Black);
            Terminal.Clear();

            CurrentState?.Draw();

            Terminal.Refresh();
        }
示例#4
0
        private static void Start()
        {
            GameWorld = new World();

            Terminal.Open();
            Terminal.Set("window: size=" + Constants.screenWidth.ToString() + "x" + Constants.screenHeight.ToString() + "; font: VeraMono.ttf, size=10");
            Terminal.BkColor(Color.FromArgb(255, 40, 40, 60));
            Terminal.Color(Color.FromArgb(255, 240, 234, 214));
            setUpGame();
            Terminal.Layer(0); // Set map to layer 0
            MapGen.updateMap();
            Terminal.Layer(2);
            GameWorld.battleGrid = new BattleGrid();
            Terminal.Layer(1); // Gamobjects to layer 1
        }
示例#5
0
        /// <summary>
        /// Place a single glyph at the specified coordinates
        /// </summary>
        /// <param name="x">The x coordinate of the glyph</param>
        /// <param name="y">The y coordinate of the glyph</param>
        /// <param name="glyph">The character to place</param>
        /// <param name="colour">The foreground colour of the char</param>
        /// <param name="bgColour">The background colour of the char</param>
        public void PlaceChar(int x, int y, int glyph, Color?colour = null, Color?bgColour = null)
        {
            Terminal.Layer(GAME_LAYER);
            if (colour == null)
            {
                colour = DefaultTextColour;
            }
            if (bgColour == null)
            {
                bgColour = DefaultBGColour;
            }
            Terminal.Color((Color)colour);
            Terminal.BkColor((Color)bgColour);

            Terminal.Put(x, y, glyph);

            // Colour the background
            Terminal.Layer(BG_LAYER);
            Terminal.Put(x, y, ' ');
        }
示例#6
0
        /// <summary>
        /// Print text centered inside a horizontal location
        /// </summary>
        /// <param name="text">The text to print</param>
        /// <param name="xMin">The minimum x coordinate in the terminal that can be used</param>
        /// <param name="xMax">The maximum x coordinate in the terminal that can be used</param>
        /// <param name="y">The y location in the terminal to print to</param>
        public void PrintCenter(string text, int xMin, int xMax, int y, Color?colour = null, Color?bgColour = null, bool decreaseSpace = false)
        {
            Terminal.Layer(GAME_LAYER);
            if (colour == null)
            {
                colour = DefaultTextColour;
            }
            if (bgColour == null)
            {
                bgColour = DefaultBGColour;
            }
            Terminal.Color((Color)colour);
            Terminal.BkColor((Color)bgColour);

            // Calculate how much padding we should put around the text to make it centered
            int space = xMax - xMin - text.Length;
            int textX = xMin + (space / 2);

            PrintText(textX, y, text, colour, bgColour, decreaseSpace);
        }
示例#7
0
        public void Show()
        {
            while (true)
            {
                Terminal.Layer(Renderer.DialogLayer);
                Terminal.Color(Color.White);
                Terminal.BkColor(Color.Black);
                Terminal.ClearArea(0, 0, Program.ScreenWidth, Program.ScreenHeight);

                Draw();

                Terminal.Refresh();

                InputManager.Update();

                if (Update())
                {
                    break;
                }
            }
        }
        protected override void RenderTile(Map map, int x, int y, Camera camera)
        {
            var tile = map.IsWalkable(x, y) ? Tile.Floor : Tile.Wall;

            if (map.FovMap.IsInFov(x, y) || Program.Game.IsDebugModeEnabled)
            {
                if (tile.BackColour.HasValue)
                {
                    Terminal.BkColor(tile.BackColour.Value);
                }

                if (tile.Glyph.HasValue)
                {
                    Terminal.Color(tile.Colour ?? Color.White);
                    Terminal.Put(x - camera.X, y - camera.Y, tile.Glyph.Value);
                }

                if (map.FovMap.IsInFov(x, y))
                {
                    map.SetExplored(x, y, true);
                }
            }
            else
            {
                if (map.IsExplored(x, y))
                {
                    if (tile.BackColour.HasValue)
                    {
                        Terminal.BkColor(tile.BackColour.Value.Lerp(Color.Black));
                    }

                    if (tile.Glyph.HasValue)
                    {
                        Terminal.Color((tile.Colour ?? Color.White).Lerp(Color.Black));
                        Terminal.Put(x - camera.X, y - camera.Y, tile.Glyph.Value);
                    }
                }
            }
        }
示例#9
0
 /// <summary>
 /// Clear the screen.
 /// </summary>
 public void Clear()
 {
     Terminal.Clear();
     Terminal.BkColor(Palette.GetColor(PaletteColor.Background));
 }
示例#10
0
        /// <summary>
        /// Print text to the terminal at the given coordinates
        /// </summary>
        /// <param name="x">The x coordinate of the first character</param>
        /// <param name="y">The y coordinate of the first character</param>
        /// <param name="text">The text to print</param>
        /// <param name="colour">The foreground colour of the text</param>
        /// <param name="bgColour">The background colour of the text</param>
        /// <param name="decreaseSpace">Decrease space between each character</param>
        /// <param name="underlineLetter">Underline a specific letter in the text</param>
        public void PrintText(int x, int y, string text, Color?colour = null, Color?bgColour = null, bool decreaseSpace = false, int underlineLetter = -1)
        {
            // Terminal settings
            Terminal.Layer(GAME_LAYER);
            if (colour == null)
            {
                Terminal.Color(DefaultTextColour);
            }
            else
            {
                Terminal.Color((Color)colour);
            }
            if (bgColour == null)
            {
                Terminal.BkColor(DefaultBGColour);
            }
            else
            {
                Terminal.BkColor((Color)bgColour);
            }

            // Decide if we want to decrease the space between each character
            if (decreaseSpace)
            {
                // Draw the first character without modifying anything
                Terminal.Put(x, y, text[0]);

                // How much to offset each character
                int dx = 0;
                int dy = 0;

                // Try to find out about the tile size to know how much to offset x by
                Int32.TryParse(Terminal.Get("ini.game.tile-size", "0"), out int tileSize);
                dx = (tileSize / 2) - 2;
                if (dx < 0)
                {
                    dx = 0;
                }

                // Insert the second character
                if (text.Length > 1)
                {
                    Terminal.PutExt(x + 1, y, -dx, dy, text[1]);
                }

                // Insert the rest of the characters
                if (text.Length > 2)
                {
                    for (int i = 2; i < text.Length; i++)
                    {
                        Terminal.PutExt(x + i, y, -(dx * i), dy, text[i]);
                    }
                }
            }
            else
            {
                Terminal.Print(x, y, text);

                // Check if we need to underline a letter
                if (underlineLetter > -1)
                {
                    Terminal.Composition(true);
                    Terminal.PutExt(x + underlineLetter, y, 0, 2, '_');
                }
            }
        }
示例#11
0
 /// <summary>
 /// Erase everything that's being displayed on the terminal
 /// </summary>
 public void Clear()
 {
     Terminal.BkColor(DefaultBGColour);
     Terminal.Clear();
 }
示例#12
0
        public void Render(long currentTime, long previousTime)
        {
            long delta = currentTime - previousTime;

            if (Input == Terminal.TK_LBRACKET || Input == Terminal.TK_ESCAPE)
            {
                H.Backward();
                return;
            }
            _now = _timer.ElapsedMilliseconds;

            _currentPlayerColor    = ((int)currentTime / 80) % 12;
            _currentHighlightColor = ((int)currentTime / 80) % 8;
            Position p = new Position(0, 0);
            Entity   acting = H.S.Entities[H.S.CurrentActor];
            int      top = H.S.Camera.Y - 12, bottom = H.S.Camera.Y + 12, left = H.S.Camera.X - 12, right = H.S.Camera.X + 12;

            if (top < 0)
            {
                bottom -= top;
                top     = 0;
            }
            if (bottom > H.S.DungeonStart.World.GetUpperBound(0))
            {
                top   -= bottom - H.S.DungeonStart.World.GetUpperBound(0);
                bottom = H.S.DungeonStart.World.GetUpperBound(0);
            }
            if (left < 0)
            {
                right -= left;
                left   = 0;
            }
            if (right > H.S.DungeonStart.World.GetUpperBound(1))
            {
                left -= right - H.S.DungeonStart.World.GetUpperBound(1);
                right = H.S.DungeonStart.World.GetUpperBound(1);
            }
            OffsetY = top;
            OffsetX = left;
            Terminal.Layer(0);
            if (H.S.CurrentReason == WaitReason.Receiving)
            {
                for (int y = OffsetY, sy = 0; sy < 25; y++, sy++)
                {
                    for (int x = OffsetX, sx = 0; sx < 25; x++, sx++)
                    {
                        if (Seeker.CombinedMap[y, x] <= acting.Stats.MoveSpeed)
                        {
                            Terminal.BkColor(_highlightColors[(_currentHighlightColor + 100 - Seeker.CombinedMap[y, x]) % _highlightColors.Length]);
                            Terminal.Put(sx * 2 + 1, sy + 1, ' ');
                            Terminal.Put(sx * 2 + 2, sy + 1, ' ');
                        }
                        else
                        {
                            Terminal.BkColor(_lightGray);
                            Terminal.Put(sx * 2 + 1, sy + 1, ' ');
                            Terminal.Put(sx * 2 + 2, sy + 1, ' ');
                        }
                    }
                }
            }
            else
            {
                for (int y = OffsetY, sy = 0; sy < 25; y++, sy++)
                {
                    for (int x = OffsetX, sx = 0; sx < 25; x++, sx++)
                    {
                        Terminal.BkColor(_lightGray);
                        Terminal.Put(sx * 2 + 1, sy + 1, ' ');
                        Terminal.Put(sx * 2 + 2, sy + 1, ' ');
                    }
                }
            }
            Terminal.Layer(1);

            for (int y = OffsetY, sy = 0; sy < 25; y++, sy++)
            {
                for (int x = OffsetX, sx = 0; sx < 25; x++, sx++)
                {
                    p.Y = y;
                    p.X = x;
                    Entity e = H.S.Entities[p];
                    if (e != null)
                    {
                        Terminal.Color(e.Coloring);
                        if (H.S.CurrentReason == WaitReason.AttackAnimating && BeingDamaged.ContainsKey(e.Name))
                        {
                            Terminal.Layer(3);
                            Terminal.PutExt(sx * 2 + 1, sy + 1, VisualRandom.Next(7) - 3, VisualRandom.Next(7) - 3, e.Left);
                            Terminal.PutExt(sx * 2 + 2, sy + 1, VisualRandom.Next(7) - 3, VisualRandom.Next(7) - 3, e.Right);
                            Terminal.Layer(1);
                            Terminal.Put(sx * 2 + 1, sy + 1, ' ');
                            Terminal.Put(sx * 2 + 2, sy + 1, ' ');
                        }
                        else
                        {
                            Terminal.Put(sx * 2 + 1, sy + 1, e.Left);
                            Terminal.Put(sx * 2 + 2, sy + 1, e.Right);
                        }
                        Terminal.Color(_darkGray);
                    }
                    else if (H.S.Cursor.Y == y && H.S.Cursor.X == x)
                    {
                        Terminal.Color(_playerColors[(_currentPlayerColor + 3) % _playerColors.Length]);
                        Terminal.Put(sx * 2 + 1, sy + 1, '{');
                        Terminal.Put(sx * 2 + 2, sy + 1, '}');
                        Terminal.Color(_darkGray);
                    }
                    else if (acting.Faction == 0 && acting.Seeker.Path.Contains(p))
                    {
                        Terminal.Color(_playerColors[_currentPlayerColor]);
                        Terminal.Put(sx * 2 + 1, sy + 1, H.S.DungeonStart.PairedWorld[y, x * 2]);
                        Terminal.Put(sx * 2 + 2, sy + 1, H.S.DungeonStart.PairedWorld[y, x * 2 + 1]);
                        Terminal.Color(_darkGray);
                    }

/*                    else if(seeker.CombinedMap[y, x] < 100)
 *                  {
 *                      Terminal.Print(sx * 2 + 1, sy + 1, "" + seeker.CombinedMap[y, x]);
 *                  }*/
                    else
                    {
                        Terminal.Put(sx * 2 + 1, sy + 1, H.S.DungeonStart.PairedWorld[y, x * 2]);
                        Terminal.Put(sx * 2 + 2, sy + 1, H.S.DungeonStart.PairedWorld[y, x * 2 + 1]);
                    }
                }
            }

            Terminal.Print(60, 9, "Acting: " + H.S.CurrentActor);
            Gauge hp = H.S.Entities[H.S.CurrentActor].Stats.Health;

            Terminal.Print(60, 10, "Health: " + hp.Current + "/" + hp.Max);
            Terminal.Print(60, 12, message);

/*            Terminal.Print(60, 10, "Y: " + Cursor.Y + ", X: " + Cursor.X);
 *          Terminal.Print(60, 11, "Seeker Value: " + seeker.CombinedMap[Cursor.Y, Cursor.X]);
 *          Terminal.Print(60, 12, "Physical Value: " + seeker.PhysicalMap[Cursor.Y, Cursor.X]);*/

            Terminal.Refresh();
            Terminal.Clear();
            if (H.S.CurrentReason == WaitReason.WalkAnimating)
            {
                if (delta < 85)
                {
                    _now = previousTime; // This run didn't count toward advancing animations.
                    return;
                }
                H.S.StepsLeft = H.S.Entities.Step(H.S.CurrentActor);
                ++H.S.StepsTaken;
                if (H.S.StepsLeft <= 0 || H.S.StepsTaken > acting.Stats.MoveSpeed)
                {
                    FinishMove();
                    if (H.S.CurrentReason == WaitReason.AttackAnimating)
                    {
                        return;
                    }
                    else
                    {
                        NextTurn();
                    }
                }
            }
            else if (H.S.CurrentReason == WaitReason.AttackAnimating)
            {
                if (delta < 120)
                {
                    _now = previousTime; // This run didn't count toward advancing animations.
                    return;
                }
                NextTurn();
            }
            else if (H.S.CurrentReason == WaitReason.CameraMoving)
            {
                if (delta < 55)
                {
                    _now = previousTime; // This run didn't count toward advancing animations.
                    return;
                }
                if (H.S.Camera.X < acting.Pos.X)
                {
                    H.S.Camera.Move(0, 1);
                    if (H.S.Camera.X + 12 > H.S.DungeonStart.World.GetUpperBound(1))
                    {
                        H.S.Camera.X = acting.Pos.X;
                    }
                }
                else if (H.S.Camera.X > acting.Pos.X)
                {
                    H.S.Camera.Move(0, -1);
                    if (H.S.Camera.X < 12)
                    {
                        H.S.Camera.X = acting.Pos.X;
                    }
                }
                if (H.S.Camera.Y < acting.Pos.Y)
                {
                    H.S.Camera.Move(1, 0);
                    if (H.S.Camera.Y + 12 > H.S.DungeonStart.World.GetUpperBound(0))
                    {
                        H.S.Camera.Y = acting.Pos.Y;
                    }
                }
                else if (H.S.Camera.Y > acting.Pos.Y)
                {
                    H.S.Camera.Move(-1, 0);
                    if (H.S.Camera.Y < 12)
                    {
                        H.S.Camera.Y = acting.Pos.Y;
                    }
                }
                if (H.S.Camera.X == acting.Pos.X && H.S.Camera.Y == acting.Pos.Y)
                {
                    if (acting.Faction == 0)
                    {
                        H.S.CurrentReason = WaitReason.Receiving;
                        H.Remember();
                    }
                    else
                    {
                        H.S.CurrentReason = WaitReason.WalkAnimating;
                        acting.Seeker.GetPath(acting, acting.Pos, H.S.Entities.NameToEntity.Where(kv => kv.Value.Faction == 0).Select(kv => kv.Value.Pos), acting.Stats.MoveSpeed);
                    }
                }
            }
        }