Child Window popup for collision?

Aug 9, 2010 at 2:17 PM
Hi all, I really need help on this. I tried so hard but just couldn't figure it out. I am not familiar with silverlight or c# but i need this for my school project. I was wondering is there any ways to group the items together for example all the glass in one group and paper in paper group and et cetera. As you can see in coding below, my it is pretty much messy. I am currently doing on ChildWindow and i find it hard since i can't keep on repeating the same thing over and over again. Even my child window couldn't popup properly. I did these on Microsoft Expression Blend with the help of physics helper and in my canvas, the items are separated, i couldn't group them together as it is meant to be individual. Coding:- //////////when player drag the litter to the correct bin void _physicsController_Collision(string sprite1, string sprite2) { //glass if (sprite1 == "glass" && sprite2.StartsWith("glassBin")) Score += 10; if (sprite1 == "glass2" && sprite2.StartsWith("glassBin")) Score += 10; if (sprite1 == "glass3" && sprite2.StartsWith("glassBin")) Score += 10; if (sprite1 == "glass4" && sprite2.StartsWith("glassBin")) Score += 10; //paper else if (sprite1 == "paper" && sprite2.StartsWith("paperBin")) Score += 10; else if (sprite1 == "paper2" && sprite2.StartsWith("paperBin")) Score += 10; else if (sprite1 == "paper3" && sprite2.StartsWith("paperBin")) Score += 10; else if (sprite1 == "paper4" && sprite2.StartsWith("paperBin")) Score += 10; else if (sprite1 == "paper5" && sprite2.StartsWith("paperBin")) Score += 10; //can else if (sprite1 == "can1" && sprite2.StartsWith("cansBin")) Score += 50; else if(sprite1 == "can2" && sprite2.StartsWith("cansBin")) Score += 50; else if(sprite1 == "can3" && sprite2.StartsWith("cansBin")) Score += 50; } Child popup window: ///////////Congratulations void _physicsController_Congratulations(string sprite1, string sprite2) { //glass if (dlg == null && sprite1 == "glass" && sprite2 == "glassBin") { // dlg = new Congratulations(); // // dlg.Show(); if(dlg == null && sprite1 == "glass2" && sprite2 == "glassBin") { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "glass3" && sprite2 == "glassBin") { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "glass4" && sprite2 == "glassBin") { dlg = new Congratulations(); dlg.Show(); //paper if (dlg == null && sprite1 == "paper" && sprite2 == "paperBin" ) { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "paper2" && sprite2 == "paperBin") { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "paper3" && sprite2 == "paperBin") { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "paper4" && sprite2 == "paperBin") { dlg = new Congratulations(); dlg.Show(); if(dlg == null && sprite1 == "paper5" && sprite2 == "paperBin") { dlg = new Congratulations(); dlg.Show(); } } } } } } } } I know this is a mess! I need help, anyone? How do i group the items together and what are the proper coding for child window upon collision, meaning that after the player managed to put every items in the bin, it will display a popup window.