Beispiel #1
0
        /// <summary>
        /// Draws a given dice-type to the target GUIElement. By using this method
        /// to draw the EDice, you're sure it's drawn the same way every time.
        /// </summary>
        /// <param name="target">The GUIElement to display the dice in.</param>
        /// <param name="dice">The dice to display.</param>
        /// <param name="x">The top-left x-coordinate to start drawing from.</param>
        /// <param name="y">The top-left y-coordinate to start drawing from.</param>
        /// <param name="size">The width and height in pixels.</param>
        public static void DrawDice(GUIElement target, EDice dice, int x, int y, int size)
        {
            Contract.Requires(target != null);
            Contract.Requires(target.HasPoint(x, y));
            Contract.Requires(size > 0);
            Contract.Requires(x + size < target.Bound.X + target.Bound.Width);

            if (dicetinary == null) LoadDiceTextures(target.Game);

            target.AddDrawable(target.Name, new Image(dicetinary[dice]), new Rectangle(x, y, size, size));
        }
Beispiel #2
0
 public static Dice GetDice(EDice dice)
 {
     Contract.Ensures(Contract.Result<Dice>().Color == dice);
     return diceDictionary[dice].Clone();
 }
Beispiel #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Dice"/> class.
 /// </summary>
 /// <param name="color">
 /// The color.
 /// </param>
 /// <param name="sides">
 /// The sides.
 /// </param>
 /// <param name="textures">
 /// The textures.
 /// </param>
 public Dice(EDice color, int[][] sides, Texture2D[] textures)
 {
     this.color = color;
     this.sides = sides;
     this.textures = textures;
 }