public void VerificaBlobBotao(Button b, Point p, int fID) { Rectangle re = new Rectangle(b.Left, b.Top, b.Width, b.Height); if (re.Contains(p)) { // Verificaçao especial para o botão bntMove-> Colocar no movo de movimentação do // do teclado if (b.Equals(bntMove)) { modoMoveBlob = true; modoMove = true; b.Tag = aPictures[fID]; aPictures[fID].Tag = b; b.BackColor = Color.Gray; // Desabilitando o teclado e as suas notas! this.groupTeclado.Enabled = false; foreach (Button bot in aButtonBlack) bot.Enabled = true; foreach (Button bot in aButtonWhite ) bot.Enabled = true; } aPictures[fID].Tag = b; b.BackColor = Color.Gray; } else { if (aPictures[fID].Tag != null) { if (aPictures[fID].Tag.Equals(b)) { if (!b.Equals(bntMove)) { aPictures[fID].Tag = null; b.BackColor = System.Drawing.SystemColors.Control; } } } } }
//Copy and paste the collides method from previous work //Make changes so that it detects button collisions public List<Button> collides(Button button) { if (collision == true) { //int collisionCount = objectCollided.Count; while (objectCollided.Count > 0) { //Empty out objectCollided list first //for (int i = 0; i < objectCollided.Count; i++) //{ objectCollided.RemoveRange(0,objectCollided.Count); //} } //Console.WriteLine(objectCollided.Count); } //List<Button> colButton = new List<Button>(); //objectCollided = null; //If the button tested is tank 1 if (button == collectionOfButtons[0]) { //Calculate the top1, bottom1, right1, and left1 of tank1 calculateAltTankDimensions(0); //Check to see if tank 1 collides with anything collisionDetection(1, 2, 3, 4, 5, 6, 7, 9, button); } //collectionOfButtons[1].Name = "tank 2"; //If button tested is tank 2 if (button.Equals(collectionOfButtons[1])) { //Calculate the top1, buttom1, right1, and left1 of tank 2 calculateAltTankDimensions(1); //Check to see if tank 2 collides with anything collisionDetection(0, 2, 3, 4, 5, 6, 7, 8, button); } if (collectionOfTanks[0].CanFire == false) { //If button tested is bullet 1 if (button == collectionOfButtons[8]) { //Calculate the top1, bottom1, right1, and left1 of bullet 1 calculateAltBulletDimensions(8); //Check to see if bullet 1 collides with anything collisionDetection(1, 2, 3, 4, 5, 6, 7, 9, button); } } //If button tested is bullet 2 if (button == collectionOfButtons[9]) { //Calculate the top1, botom1, right1, and left1 of bullet 2 calculateAltBulletDimensions(9); //Check to see if bullet 2 collides with anything collisionDetection(0, 2, 3, 4, 5, 6, 7, 8, button); } //Reset button //button = null; //Return the list of objects collided with each other return objectCollided; }