Esempio n. 1
0
 /// <summary>
 /// Update cell status
 /// </summary>
 public override void Update()
 {
     base.Update();
     if (OccupiedBy != null)
     {
         int hw = (int)((Bound.R.Width - (OccupiedBy.Count() * Pawn.SIZE)) / (OccupiedBy.Count() + 1));
         int hh = (int)(Bound.R.Height - Pawn.SIZE) / 2;
         int vw = (int)(Bound.R.Width - Pawn.SIZE) / 2;
         int vh = (int)((Bound.R.Height - (OccupiedBy.Count() * Pawn.SIZE)) / (OccupiedBy.Count() + 1));
         if (IsHorizontal)
         {
             for (int i = 0; i < OccupiedBy.Count(); i++)
             {
                 OccupiedBy[i].Bound.SetRect(new System.Drawing.Rectangle(
                                                 Bound.R.Left + hw + (i * (Pawn.SIZE + hw)),
                                                 Bound.R.Top + hh,
                                                 Pawn.SIZE,
                                                 Pawn.SIZE
                                                 ));
             }
         }
         else
         {
             for (int i = 0; i < OccupiedBy.Count(); i++)
             {
                 OccupiedBy[i].Bound.SetRect(new System.Drawing.Rectangle(
                                                 Bound.R.Left + vw,
                                                 Bound.R.Top + vh + (i * (Pawn.SIZE + vh)),
                                                 Pawn.SIZE,
                                                 Pawn.SIZE
                                                 ));
             }
         }
     }
     // GameApp.Instance.Update();
 }
Esempio n. 2
0
 /// <summary>
 /// Checks if the pawn can move to cell
 /// </summary>
 /// <param name="pawn"></param>
 /// <returns></returns>
 public bool CanAddPawn(Pawn pawn)
 {
     return(OccupiedBy.Count() == 0 || OccupiedBy[0].Owner.ID == pawn.Owner.ID || !IsShield);
 }