void Trainer_TouchMove(object sender, libSMARTMultiTouch.Input.TouchContactEventArgs e) { Point pt = new Point(); Point ptTopLeft = new Point(); Point ptBotRight = new Point(); Ellipse whaleMouth = whale.whaleMouth; SpeechBubble speech = SpeechBubble.getInstance(); canvas.Children.Remove(speech); //center coordinates of the pie being dragged pt.X = (double)this.GetValue(Canvas.LeftProperty) + this.TranslateTransform.X + (this.Width / 2); pt.Y = (double)this.GetValue(Canvas.TopProperty) + this.TranslateTransform.Y + (this.Height / 2); //its a bit hacked.. -- mouth coordinates ptTopLeft.X = (double)whaleMouth.GetValue(Canvas.LeftProperty) + 300; ptTopLeft.Y = (double)whaleMouth.GetValue(Canvas.TopProperty) + 200; ptBotRight.X = ptTopLeft.X + whaleMouth.Width; ptBotRight.Y = ptTopLeft.Y + whaleMouth.Height; #region feeding the whale if (pt.X > ptTopLeft.X && pt.X < ptBotRight.X && pt.Y > ptTopLeft.Y && pt.Y < ptBotRight.Y) { //whale eats the pies (remove it) and increment pie counter canvas.Children.Remove(this); Scoreboard scoreboard = Scoreboard.getInstance(); PieStash stash = PieStash.getInstance(); canvas.Children.Remove(speech); canvas.Children.Remove(stash); //sound saulEaten.Open(new Uri(@"saulEaten.wav", UriKind.Relative)); saulEaten.Play(); //animation if (!this.whale.inAnimation) { this.whale.inAnimation = true; Storyboard saulEat = (Storyboard)whale.Resources["SaulEat"]; saulEat.Completed += new EventHandler(eating_Completed); saulEat.Begin(); } }//end if for checking mouth boundaries #endregion }
//when the pie is moved, and what happens when the whale eats it void Pie_TouchMove(object sender, libSMARTMultiTouch.Input.TouchContactEventArgs e) { Pie temp = (Pie)sender; Point pt = new Point(); Point ptTopLeft = new Point(); Point ptBotRight = new Point(); Point blowholeTopLeft = new Point(); Point blowholeBotRight = new Point(); Ellipse whaleMouth = whale.whaleMouth; //center coordinates of the pie being dragged pt.X = (double)this.GetValue(Canvas.LeftProperty) + this.TranslateTransform.X + (this.Width / 2); pt.Y = (double)this.GetValue(Canvas.TopProperty) + this.TranslateTransform.Y + (this.Height / 2); //its a bit hacked.. -- mouth coordinates ptTopLeft.X = (double)whaleMouth.GetValue(Canvas.LeftProperty) + 300; ptTopLeft.Y = (double)whaleMouth.GetValue(Canvas.TopProperty) + 300; ptBotRight.X = ptTopLeft.X + whaleMouth.Width; ptBotRight.Y = ptTopLeft.Y + whaleMouth.Height; #region feeding the whale if (pt.X > ptTopLeft.X && pt.X < ptBotRight.X && pt.Y > ptTopLeft.Y && pt.Y < ptBotRight.Y) { //whale eats the pies (remove it) and increment pie counter canvas.Children.Remove(this); Random r = new Random(); int num = r.Next(1, 3); String uri = ""; switch (num) { case 1: uri = "whaleEat1.wav"; break; case 2: uri = "whaleEat3.wav"; break; case 3: uri = "whaleEat2.wav"; break; } //sound whaleEat.Open(new Uri(@uri, UriKind.Relative)); whaleEat.Play(); if (!this.whale.inAnimation) { int count = Int16.Parse(this.pieSize.Content.ToString()); scoreboard.updatePieCount(this.id, this.player, count); //animation this.whale.inAnimation = true; Storyboard eating = (Storyboard)whale.Resources["Eating"]; eating.Completed += new EventHandler(eating_Completed); eating.Begin(); } }//end if for checking mouth boundaries #endregion #region done feeding //blowhole coordinates blowholeTopLeft.X = (double)whale.blowhole.GetValue(Canvas.LeftProperty) + 310; blowholeTopLeft.Y = (double)whale.blowhole.GetValue(Canvas.TopProperty) + 200; blowholeBotRight.X = blowholeTopLeft.X + whale.blowhole.Width; blowholeBotRight.Y = blowholeTopLeft.Y + whale.blowhole.Height; if (pt.X > blowholeTopLeft.X && pt.X < blowholeBotRight.X && pt.Y > blowholeTopLeft.Y && pt.Y < blowholeBotRight.Y) { canvas.Children.Remove(this); processAnswer(); } #endregion }