/// <summary>
 /// If this playground does not have a plate with identity id,
 /// then a new plate is created, added to the list thePlates, and the returnvalue is true,
 /// else the returnvalue is false.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="initialNrOfCookies"></param>
 /// <returns></returns>
 public bool AddPlate(string id, int x, int y, int initialNrOfCookies)
 {
     if (GetPlate(id) == null)
     {
         Plate temp = new Plate(id, x, y, initialNrOfCookies);
         thePlates.Add(temp);
         return(true);
     }
     return(false);
 }
        /// <summary>
        /// If this playground has a plate with identity id1 and also a plate with identity id2,
        /// then the id2-plate is added as a neighbor to the id1-plate, and also
        ///      the id1-plate is added as a neighbor to the id2-plate
        ///      and the returnvalue is true,
        /// else the returnvalue is false.
        /// </summary>
        /// <param name="id1"></param>
        /// <param name="id2"></param>
        /// <returns></returns>
        public bool AddConnection(string id1, string id2)
        {
            Plate plate1 = GetPlate(id1);
            Plate plate2 = GetPlate(id2);

            if (plate1 != null && plate2 != null)
            {
                plate1.AddNeighbor(plate2);
                plate2.AddNeighbor(plate1);
                return(true);
            }
            return(false);
        }
Exemple #3
0
        private void PbPlayground_MouseUp(object sender, MouseEventArgs e)
        {
            Plate plate = pg.GetPlate(e.X, e.Y);

            if (plate != null)
            {
                plate.AddCookie();
                foreach (Plate item in plate.Neighbors)
                {
                    item.AddCookie();
                }
                pg.IncrementNrOfMoves();
                PbPlayground.Invalidate();
                if (pg.CheckWin())
                {
                    MessageBox.Show("Yay you won!");
                }
            }
        }
Exemple #4
0
 /// <summary>
 /// adds plate p to its neighbors
 /// </summary>
 /// <param name="p"></param>
 public void AddNeighbor(Plate p)
 {
     Neighbors.Add(p);
 }