Ejemplo n.º 1
0
        /// </summary>
        /// <param name="x">Starting X position to print.</param>
        /// <param name="y">Starting Y position to print.</param>
        /// <param name="maxLines">Maximum number of lines, -1 for no limit.</param>
        /// <param name="text">Text to be printed.</param>
        /// <param name="color">Color to be printed.</param>
        /// <param name="backColor">BackColor to be printed.</param>
        /// <param name="wrap">Characters to print before wrapping to the next line.</param>
        /// <param name="z">Z buffer value.</param>
        /// <returns>Number of lines printed.</returns>
        public int Print(int x, int y, int maxLines, string text, RLColor color, RLColor?backColor, int wrap, int z)
        {
            if (text == null)
            {
                return(0);
            }
            StringBuilder sb = new StringBuilder(wrap);

            string[] words = text.Split(' ');
            int      i     = 0;
            int      lines = 0;

            while (i < words.Length && (maxLines == -1 || lines <= maxLines))
            {
                while (i < words.Length && sb.Length + words[i].Length + 1 < wrap)
                {
                    sb.Append(words[i++] + " ");
                }

                string line = sb.ToString();
                sb.Clear();

                for (int j = 0; j < line.Length; j++)
                {
                    SetColor(x + j, y + lines, color, z);
                    SetChar(x + j, y + lines, line[j], z);
                    if (backColor.HasValue)
                    {
                        SetBackColor(x + i, y, backColor.Value, z);
                    }
                }
                lines++;
            }
            return(lines);
        }
Ejemplo n.º 2
0
 public Star(string name, string type, RLColor color)
 {
     this.Name          = name;
     this.Type          = type;
     this.Color         = color;
     distanceFromParent = 1f;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Sets the color at the specified location.
 /// </summary>
 /// <param name="x">X position to set.</param>
 /// <param name="y">Y position to set.</param>
 /// <param name="color">Color to set.</param>
 public void SetColor(int x, int y, RLColor color)
 {
     if (x >= 0 && y >= 0 && x < Width && y < Height)
     {
         cells[x, y].color = color;
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Sets the color at the specified location.
 /// </summary>
 /// <param name="x">X position to set.</param>
 /// <param name="y">Y position to set.</param>
 /// <param name="color">Color to set.</param>
 public void SetColor(int x, int y, RLColor color, int z)
 {
     if (x >= 0 && y >= 0 && x < Width && y < Height && zBuffer[x, y] <= z)
     {
         zBuffer[x, y]     = z;
         cells[x, y].color = color;
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Sets the color in the specified rectangle.
 /// </summary>
 /// <param name="x">X position to set.</param>
 /// <param name="y">Y position to set.</param>
 /// <param name="width">Width of the rectangle.</param>
 /// <param name="height">Height of the rectangle.</param>
 /// <param name="color">Color to set.</param>
 /// <param name="z">Z buffer value.</param>
 public void SetColor(int x, int y, int width, int height, RLColor color, int z)
 {
     if (width > 0 && height > 0)
     {
         for (int iy = y; iy < height + y; iy++)
         {
             for (int ix = x; ix < width + x; ix++)
             {
                 SetColor(ix, iy, color, z);
             }
         }
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Clears the console.
 /// </summary>
 /// <param name="character">Character to set.</param>
 /// <param name="backColor">Background color to set.</param>
 /// <param name="color">Color to set.</param>
 /// <param name="z">Z value to set.</param>
 public void Clear(int character, RLColor backColor, RLColor color, int z)
 {
     for (int iy = 0; iy < Height; iy++)
     {
         for (int ix = 0; ix < Width; ix++)
         {
             cells[ix, iy].backColor = backColor;
             cells[ix, iy].color     = color;
             cells[ix, iy].character = character;
             zBuffer[ix, iy]         = z;
         }
     }
 }
Ejemplo n.º 7
0
        public Animation(List <char> list, int tm, Creature ownr, Action onFinish)
        {
            for (int i = 0; i < list.Count; i++)
            {
                this.animChars.Add(list[i]);
            }
            this.time  = tm;
            this.owner = ownr;

            this.onFinishAction = onFinish;

            this._startColor = owner.color;
            this._startChar  = owner.symbol;

            this.timer = new Timer(owner.symbol + "'s animation", this.time, OnTimeEnded);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Prints the text to the console.
 /// </summary>
 /// <param name="x">Starting X position to print.</param>
 /// <param name="y">Starting Y position to print.</param>
 /// <param name="text">Text to be printed.</param>
 /// <param name="color">Color to be printed.</param>
 /// <param name="z">Z buffer value.</param>
 /// <param name="backColor">BackColor to be printed.</param>
 public void Print(int x, int y, string text, RLColor color, int z, RLColor?backColor = null)
 {
     if (text == null)
     {
         return;
     }
     for (int i = 0; i < text.Length; i++)
     {
         SetColor(x + i, y, color, z);
         SetChar(x + i, y, text[i], z);
         if (backColor.HasValue)
         {
             SetBackColor(x + i, y, backColor.Value, z);
         }
     }
 }
Ejemplo n.º 9
0
 static RLColor()
 {
     CGA     = new RLColor[16];
     CGA[0]  = Black = new RLColor(0, 0, 0);
     CGA[1]  = Blue = new RLColor(0, 0, 255);
     CGA[2]  = Green = new RLColor(0, 170, 0);
     CGA[3]  = Cyan = new RLColor(0, 170, 170);
     CGA[4]  = Red = new RLColor(170, 0, 0);
     CGA[5]  = Magenta = new RLColor(170, 0, 170);
     CGA[6]  = Brown = new RLColor(170, 85, 0);
     CGA[7]  = LightGray = new RLColor(170, 170, 170);
     CGA[8]  = Gray = new RLColor(85, 85, 85);
     CGA[9]  = LightBlue = new RLColor(85, 85, 255);
     CGA[10] = LightGreen = new RLColor(85, 255, 85);
     CGA[11] = LightCyan = new RLColor(85, 255, 255);
     CGA[12] = LightRed = new RLColor(255, 85, 85);
     CGA[13] = LightMagenta = new RLColor(255, 85, 255);
     CGA[14] = Yellow = new RLColor(255, 255, 85);
     CGA[15] = White = new RLColor(255, 255, 255);
 }
Ejemplo n.º 10
0
 public RLCell(RLColor backColor, RLColor color, int character)
 {
     this.backColor = backColor;
     this.color     = color;
     this.character = character;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Clears the console.
 /// </summary>
 /// <param name="character">Character to set.</param>
 /// <param name="backColor">Background color to set.</param>
 /// <param name="color">Color to set.</param>
 public void Clear(int character, RLColor backColor, RLColor color)
 {
     Clear(character, backColor, color, int.MinValue);
 }
Ejemplo n.º 12
0
 public void SetColor(RLColor color)
 {
     this.Color = color;
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Prints the text to the console.
 /// </summary>
 /// <param name="x">Starting X position to print.</param>
 /// <param name="y">Starting Y position to print.</param>
 /// <param name="text">Text to be printed.</param>
 /// <param name="color">Color to be printed.</param>
 /// <param name="backColor">BackColor to be printed.</param>
 /// <param name="wrap">Characters to print before wrapping to the next line.</param>
 /// <param name="z">Z buffer value.</param>
 /// <returns>Number of lines printed.</returns>
 public int Print(int x, int y, string text, RLColor color, RLColor?backColor, int wrap, int z)
 {
     return(Print(x, y, -1, text, color, backColor, wrap, z));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Blends the two colors
 /// </summary>
 /// <param name="ColorA">Primary Color</param>
 /// <param name="ColorB">Secondary Color</param>
 /// <param name="Ratio">Ratio of the colors that are blended (255 - Full Primary, 0 - Full Secondary)</param>
 /// <returns>New Blended Color</returns>
 public static RLColor Blend(RLColor primary, RLColor secondary, byte ratio)
 {
     return(Blend(primary, secondary, (float)ratio / 255f));
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Evenly blends two colors
 /// </summary>
 /// <param name="color1"></param>
 /// <param name="color2"></param>
 /// <returns>New Blended Color</returns>
 public static RLColor Blend(RLColor color1, RLColor color2)
 {
     return(Blend(color1, color2, .5f));
 }
Ejemplo n.º 16
0
 /// <summary>
 /// Blends the two colors
 /// </summary>
 /// <param name="ColorA">Primary Color</param>
 /// <param name="ColorB">Secondary Color</param>
 /// <param name="Ratio">Ratio of the colors that are blended (1f - Full Primary, 0f - Full Secondary)</param>
 /// <returns>New Blended Color</returns>
 public static RLColor Blend(RLColor primary, RLColor secondary, float ratio)
 {
     return(secondary - ((secondary - primary) * ratio));
 }
Ejemplo n.º 17
0
 public Star()
 {
     distanceFromParent = 1f;
     this.Color         = RLNET.RLColor.Yellow;
 }