Exemple #1
0
        public Enemy GenerateRandomEnemy(int round)
        {
            // figure out min-max for stats
            Weapons weapon;
            int     hp         = randAttribute.Next(100, 200);
            int     speed      = randAttribute.Next(5, 10);
            int     damage     = randAttribute.Next(45, 100);
            DFColor enemyColor = (DFColor)randAttribute.Next(0, 5);
            //attackType random
            AttackType attackType;
            int        randAttackType = randAttribute.Next(0, 50);

            if (randAttackType < 25)
            {
                attackType = AttackType.Melee;
            }
            else
            {
                attackType = AttackType.Ranged;
            }
            //end AttackType Random

            if (attackType == AttackType.Melee)
            {
                weapon = (Weapons)randAttribute.Next(0, 2);
            }
            else
            {
                weapon = (Weapons)randAttribute.Next(3, 5);
            }
            int score = 5 * round;

            return(new Enemy(hp, speed, damage, attackType, enemyColor.ToString(), weapon, round, score));
        }
Exemple #2
0
        /// <summary>
        /// Gets colour at specified index.
        /// </summary>
        /// <param name="Index">Index into colour array.</param>
        /// <returns>DFColor object.</returns>
        public DFColor Get(int Index)
        {
            int     offset = headerLength + Index * 3;
            DFColor col    = new DFColor(paletteBuffer[offset], paletteBuffer[offset + 1], paletteBuffer[offset + 2]);

            return(col);
        }
Exemple #3
0
            public static DFColor FromRGBA(byte r, byte g, byte b, byte a = 255)
            {
                DFColor color = new DFColor()
                {
                    r = r,
                    g = g,
                    b = b,
                    a = a,
                };

                return(color);
            }
Exemple #4
0
        /// <summary>
        /// Gets pixel DFColor from DFBitmap.
        /// </summary>
        /// <param name="bitmap">DFBitmap.</param>
        /// <param name="x">X position.</param>
        /// <param name="y">Y position.</param>
        /// <returns>DFColor.</returns>
        static public DFColor GetPixel(DFBitmap bitmap, int x, int y)
        {
            DFColor color  = new DFColor();
            int     srcPos = y * bitmap.Stride + x * bitmap.FormatWidth;

            color.r = bitmap.Data[srcPos++];
            color.g = bitmap.Data[srcPos++];
            color.b = bitmap.Data[srcPos++];
            color.a = bitmap.Data[srcPos++];

            return(color);
        }
Exemple #5
0
        /// <summary>
        /// Sets pixel in DFBitmap. Colour formats only.
        /// </summary>
        /// <param name="bitmap">DFBitmap.</param>
        /// <param name="x">X position.</param>
        /// <param name="y">Y position.</param>
        /// <param name="colour">Fill colour.</param>
        static public void SetPixel(DFBitmap bitmap, int x, int y, DFColor color)
        {
            int pos = y * bitmap.Stride + x * bitmap.FormatWidth;

            if (bitmap.Format == Formats.RGBA)
            {
                bitmap.Data[pos++] = color.r;
                bitmap.Data[pos++] = color.g;
                bitmap.Data[pos++] = color.b;
                bitmap.Data[pos]   = color.a;
            }
            else if (bitmap.Format == Formats.ARGB)
            {
                bitmap.Data[pos++] = color.a;
                bitmap.Data[pos++] = color.r;
                bitmap.Data[pos++] = color.g;
                bitmap.Data[pos]   = color.b;
            }
        }
Exemple #6
0
 /// <summary>
 /// Sets pixel in DFBitmap. Colour formats only.
 /// </summary>
 /// <param name="bitmap">DFBitmap.</param>
 /// <param name="x">X position.</param>
 /// <param name="y">Y position.</param>
 /// <param name="r">Red value.</param>
 /// <param name="g">Green value.</param>
 /// <param name="b">Blue value.</param>
 /// <param name="a">Alpha value.</param>
 static public void SetPixel(DFBitmap bitmap, int x, int y, byte r, byte g, byte b, byte a)
 {
     SetPixel(bitmap, x, y, DFColor.FromRGBA(r, g, b, a));
 }
Exemple #7
0
 /// <summary>
 /// Fills DFBitmap with specified colour.
 /// </summary>
 /// <param name="bitmap">DFBitmap to fill.</param>
 /// <param name="color">Source colour.</param>
 static public void Fill(DFBitmap bitmap, DFColor color)
 {
     Fill(bitmap, color.r, color.g, color.b, color.a);
 }
Exemple #8
0
 /// <summary>
 /// Constructor.
 /// Creates a new DFBitmap with sized data array filled to specified colour.
 /// </summary>
 /// <param name="width">Image width.</param>
 /// <param name="height">Image height.</param>
 /// <param name="color">Fill colour.</param>
 public DFBitmap(int width, int height, DFColor color)
     : this(width, height)
 {
     Fill(this, color);
 }
 /// <summary>
 /// Constructor.
 /// Creates a new DFBitmap with sized data array filled to specified colour.
 /// </summary>
 /// <param name="width">Image width.</param>
 /// <param name="height">Image height.</param>
 /// <param name="color">Fill colour.</param>
 public DFBitmap(int width, int height, DFColor color)
     : this(width, height)
 {
     Fill(this, color);
 }
 public static DFColor FromRGBA(byte r, byte g, byte b, byte a = 255)
 {
     DFColor color = new DFColor()
     {
         r = r,
         g = g,
         b = b,
         a = a,
     };
     return color;
 }
 /// <summary>
 /// Sets pixel in DFBitmap. Colour formats only.
 /// </summary>
 /// <param name="bitmap">DFBitmap.</param>
 /// <param name="x">X position.</param>
 /// <param name="y">Y position.</param>
 /// <param name="colour">Fill colour.</param>
 public static void SetPixel(DFBitmap bitmap, int x, int y, DFColor color)
 {
     int pos = y * bitmap.Stride + x * bitmap.FormatWidth;
     if (bitmap.Format == Formats.RGBA)
     {
         bitmap.Data[pos++] = color.r;
         bitmap.Data[pos++] = color.g;
         bitmap.Data[pos++] = color.b;
         bitmap.Data[pos] = color.a;
     }
     else if (bitmap.Format == Formats.ARGB)
     {
         bitmap.Data[pos++] = color.a;
         bitmap.Data[pos++] = color.r;
         bitmap.Data[pos++] = color.g;
         bitmap.Data[pos] = color.b;
     }
 }
        /// <summary>
        /// Gets pixel DFColor from DFBitmap.
        /// </summary>
        /// <param name="bitmap">DFBitmap.</param>
        /// <param name="x">X position.</param>
        /// <param name="y">Y position.</param>
        /// <returns>DFColor.</returns>
        public static DFColor GetPixel(DFBitmap bitmap, int x, int y)
        {
            DFColor color = new DFColor();
            int srcPos = y * bitmap.Stride + x * bitmap.FormatWidth;
            color.r = bitmap.Data[srcPos++];
            color.g = bitmap.Data[srcPos++];
            color.b = bitmap.Data[srcPos++];
            color.a = bitmap.Data[srcPos++];

            return color;
        }
 /// <summary>
 /// Fills DFBitmap with specified colour.
 /// </summary>
 /// <param name="bitmap">DFBitmap to fill.</param>
 /// <param name="color">Source colour.</param>
 public static void Fill(DFBitmap bitmap, DFColor color)
 {
     Fill(bitmap, color.r, color.g, color.b, color.a);
 }