private void moveStoneToCup(StoneObj s, CupObj oldC, CupObj newC) { Random rnd = new Random(); Point oldCupLoc = oldC.Location; Point newCupLoc = newC.Location; int stoneX = s.Location.X + (newCupLoc.X - oldCupLoc.X); int stoneY = s.Location.Y + (newCupLoc.Y - oldCupLoc.Y); int randomInt = rnd.Next(0, 2); //if moving to a mancala cup, Y should occasionally be incremented by more to put it in the bottom half if (randomInt == 1 && ((int)newC.Tag == 7 || (int)newC.Tag == 14)) { stoneY += 80; } s.Location = new Point(stoneX, stoneY); s.Tag = newC.Tag; }
private void drawStoneInCup(StoneObj s, CupObj c, Random rnd) { int stoneCol = rnd.Next(1, 6); Bitmap stoneImg; if (stoneCol == 1) { stoneImg = new Bitmap(MancalaGUI.Properties.Resources.rockBlue); } else if (stoneCol == 2) { stoneImg = new Bitmap(MancalaGUI.Properties.Resources.rockGreen); } else if (stoneCol == 3) { stoneImg = new Bitmap(MancalaGUI.Properties.Resources.rockPurple); } else if (stoneCol == 4) { stoneImg = new Bitmap(MancalaGUI.Properties.Resources.rockRed); } else { stoneImg = new Bitmap(MancalaGUI.Properties.Resources.rockYellow); } s.BackgroundImage = stoneImg; s.BackgroundImageLayout = ImageLayout.Stretch; s.Enabled = false; s.Visible = true; s.Size = new Size(35, 25); s.BackColor = Color.Transparent; s.BorderStyle = BorderStyle.None; Point cupLoc = c.Location; Size cupSize = c.Size; int stoneX = rnd.Next(c.Location.X, c.Location.X + c.Width - s.Width); int stoneY = rnd.Next(c.Location.Y, c.Location.Y + c.Height - s.Height); s.Location = new Point(stoneX, stoneY); }