A generic figure, either a hero or a monster
Inheritance: Drawable
Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Attack"/> class.
        /// </summary>
        /// <param name="attackingFigure">
        /// The attacking Figure.
        /// </param>
        /// <param name="targetSquare">
        /// The square that is attacked
        /// </param>
        public Attack(Figure attackingFigure, Point targetSquare)
        {
            Contract.Requires(attackingFigure != null);
            Contract.Requires(FullModel.Board.IsSquareWithinBoard(targetSquare));
            Contract.Requires(attackingFigure.DiceForAttack != null && attackingFigure.DiceForAttack.Count > 0);

            this.figure = attackingFigure;
            diceForAttack = figure.DiceForAttack;
            surgeAbilities = figure.SurgeAbilities;
            this.TargetSquare = targetSquare;
            MissedAttack = false;
        }
Esempio n. 2
0
        /// <summary>
        /// Places a figure at a specific point
        /// </summary>
        /// <param name="figure">
        /// The figure that is placed
        /// </param>
        /// <param name="point">
        /// The upper left corner of the figure
        /// </param>
        public void PlaceFigure(Figure figure, Point point)
        {
            Contract.Requires(figure != null);
            Contract.Requires(point.X >= 0 && point.Y >= 0 && point.X < Width && point.Y < Height);

            for (int x = point.X;
                 x < point.X + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Width : figure.Size.Height);
                 x++)
            {
                for (int y = point.Y;
                     y < point.Y + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Height : figure.Size.Width);
                     y++)
                {
                    board[x, y].Figure = figure;
                }
            }
            figuresOnBoard[figure] = point;
            boardChanged = true;
        }
Esempio n. 3
0
        /// <summary>
        /// Moves a figure to a specific point.
        /// </summary>
        /// <param name="figure">
        /// The figure that is moved
        /// </param>
        /// <param name="point">
        /// The upper left corner of the figure, that is moved to
        /// </param>
        public void MoveFigure(Figure figure, Point point)
        {
            Contract.Requires(figure != null);
            Contract.Requires(this.CanFigureMoveToPoint(figure, point));

            // Remove monsters from old position
            Point p = FiguresOnBoard[figure];
            for (int x = p.X;
                 x < p.X + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Width : figure.Size.Height);
                 x++)
            {
                for (int y = p.Y;
                     y < p.Y + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Height : figure.Size.Width);
                     y++)
                {
                    board[x, y].Figure = null;
                }
            }

            for (int x = point.X;
                 x < point.X + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Width : figure.Size.Height);
                 x++)
            {
                for (int y = point.Y;
                     y < point.Y + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Height : figure.Size.Width);
                     y++)
                {
                    board[x, y].Figure = figure;
                }
            }

            figuresOnBoard[figure] = point;
            boardChanged = true;
        }
Esempio n. 4
0
        /// <summary>
        /// Indicates whethere there's nothing in the way from one figure to another.
        /// Can ignore monsters.
        /// </summary>
        /// <param name="from">"From" figure.</param>
        /// <param name="to">"To" figure.</param>
        /// <param name="ignoreMonsters">Will ignore monsters if true.</param>
        /// <returns></returns>
        public bool IsThereLineOfSight(Figure from, Figure to, bool ignoreMonsters)
        {
            Contract.Requires(from != null);
            Contract.Requires(to != null);
            Point[] fromPoints = FullModel.Board.FigureSquares(from);
            Point[] toPoints = FullModel.Board.FigureSquares(to);
            foreach (Point fromPoint in fromPoints)
            {
                foreach (Point toPoint in toPoints)
                {
                    if (IsThereLineOfSight(fromPoint, toPoint, ignoreMonsters)) return true;
                }
            }

            return false;
        }
Esempio n. 5
0
 /// <summary>
 /// Creates an array of all points a figure is on
 /// </summary>
 /// <param name="figure">
 /// The figure
 /// </param>
 /// <returns>
 /// The figure squares the figure is standing on
 /// </returns>
 public Point[] FigureSquares(Figure figure)
 {
     Contract.Requires(figure != null);
     List<Point> list = new List<Point>();
     Point point = this.FiguresOnBoard[figure];
     for (int x = point.X;
          x < point.X + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Width : figure.Size.Height);
          x++)
     {
         for (int y = point.Y;
              y < point.Y + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Height : figure.Size.Width);
              y++)
         {
             list.Add(new Point(x, y));
         }
     }
     return list.ToArray();
 }
Esempio n. 6
0
        /// <summary>
        /// Gets a value indicating whether a figure can move to a point
        /// </summary>
        /// <param name="figure">
        /// The figure
        /// </param>
        /// <param name="point">
        /// The upper left corner of the end point
        /// </param>
        /// <returns>
        /// Whether all squares of the final destination are legal
        /// </returns>
        public bool CanFigureMoveToPoint(Figure figure, Point point)
        {
            Contract.Requires(figure != null);
            if (figure.Size.Width == 1 && figure.Size.Height == 1) return IsStandable(point.X, point.Y);

            bool canMove = true;

            List<Point> list = new List<Point>();
            for (int x = point.X;
                 x < point.X + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Width : figure.Size.Height);
                 x++)
            {
                for (int y = point.Y;
                     y < point.Y + (figure.Orientation.Equals(Orientation.V) ? figure.Size.Height : figure.Size.Width);
                     y++)
                {
                    canMove &= IsStandable(x, y) || (IsSquareWithinBoard(x, y) && this[x, y].Figure == figure);
                }
            }

            return canMove;
        }
Esempio n. 7
0
 private bool RightPosition(Figure f, Point toTest)
 {
     return board.FiguresOnBoard.ContainsKey(f) && board.FiguresOnBoard[f].Equals(toTest);
 }
Esempio n. 8
0
 /// <summary>
 /// Applys the ability to a figure
 /// </summary>
 /// <param name="figure">
 /// The figure to apply the figure to
 /// </param>
 public void Apply(Figure figure, bool remove = false)
 {
     this.figure = figure;
     if (!triggered || trigger.Invoke())
     {
         switch (bonus)
         {
             case AbilityBonus.Damage:
                 if (!remove) figure.DamageContribution += IntBonus;
                 else figure.DamageContribution -= IntBonus;
                 break;
             case AbilityBonus.Pierce:
                 if (!remove) figure.PierceContribution += IntBonus;
                 else figure.PierceContribution -= IntBonus;
                 break;
             case AbilityBonus.Range:
                 if (!remove) figure.RangeContribution += IntBonus;
                 else figure.RangeContribution -= IntBonus;
                 break;
             case AbilityBonus.Surge:
                 if (!remove) figure.SurgeContribution += IntBonus;
                 else figure.SurgeContribution -= IntBonus;
                 break;
             case AbilityBonus.QuickShot:
                 break;
             case AbilityBonus.Armor:
                 if (!remove) figure.ArmorContribution += IntBonus;
                 else figure.ArmorContribution -= IntBonus;
                 break;
         }
     }
 }