Exemplo n.º 1
0
        private void toolCollisionOccured()
        {
            // Create a rectangle for the red Cursor and update the position relative to the position of the Users Right hand.
            cursorRect = new Rectangle((int)cursorPosition.X, (int)cursorPosition.Y, cursor.Width, cursor.Height);

            // Create a rectangle and set is position.
            scalpalRect = new Rectangle((int)scalpal_pos.X, (int)scalpal_pos.Y, tool_scalpal.Width, tool_scalpal.Height);
            suctionRect = new Rectangle((int)suction_pos.X, (int)suction_pos.Y, tool_suction.Width, tool_suction.Height);
            syringeRect = new Rectangle((int)syringe_pos.X, (int)syringe_pos.Y, tool_syringe.Width, tool_syringe.Height);
            handRect = new Rectangle((int)hand_pos.X, (int)hand_pos.Y, tool_hand.Width, tool_hand.Height);

            xMarkRect = new Rectangle((int)xMarkPos.X, (int)xMarkPos.Y, xMark.Width, xMark.Height);
            heartCutRect = new Rectangle((int)heartCutPos.X, (int)heartCutPos.Y, heartCut.Width, heartCut.Height);
            cutStartRect = new Rectangle((int)cutStartPos.X, (int)cutStartPos.Y, cutStart.Width, cutStart.Height);
            cutEndRect = new Rectangle((int)cutEndPos.X, (int)cutEndPos.Y, cutEnd.Width, cutEnd.Height);

            // Collision Detection.
            collision = new CollisionDetection();
            //Check for collision between the Cursor and the Scalpal
            if (collision.IntersectPixel(cursorRect, cursor_data, scalpalRect, scalpal_data))
            {
                scalpalHit = true;
                if (speech.returnMsg() == ": Scalpal Recognized!")
                {
                    currentState = cursorState.Scalpal;
                }
            }
            else
            {
                scalpalHit = false;
            }
            //Check for collision between the Cursor and the Suction
            if (collision.IntersectPixel(cursorRect, cursor_data, suctionRect, suction_data))
            {
                suctionHit = true;
                if (speech.returnMsg() == ": Suction Recognized!")
                {
                    currentState = cursorState.Suction;
                }
            }
            else
            {
                suctionHit = false;
            }
            //Check for collision between the Cursor and the syringe
            if (collision.IntersectPixel(cursorRect, cursor_data, syringeRect, syringe_data))
            {
                syringeHit = true;
                if (speech.returnMsg() == ": Syringe Recognized!")
                {
                    currentState = cursorState.Syringe;
                }
            }
            else
            {
                syringeHit = false;
            }
            //Check for collision between the Cursor and the hand
            if (collision.IntersectPixel(cursorRect, cursor_data, handRect, hand_data))
            {
                handHit = true;
                if (speech.returnMsg() == ": Hand Recognized!")
                {
                    currentState = cursorState.Hand;
                }
            }
            else
            {
                handHit = false;
            }
            ///
            // Collision with the Xmarks the spot image
            ///
            if (collision.IntersectPixel(cursorRect, cursor_data, xMarkRect, xMark_data))
            {
                if (currentState == cursorState.Syringe)
                {
                    if (speech.returnMsg() == ": inject")
                    {
                        mainMessage = "The Patient is now Sedated. Now select the Scalpal and cut along the \nwhite marker from Green to blue. Say 'begin Incision' when \nin green, and when at blue say 'end incision'";
                        xMarkHit = true;
                        currentState = cursorState.Hand;
                    }
                }
                else if (currentState != cursorState.Syringe)
                {
                    if (speech.returnMsg() == ": inject")
                    {
                        mainMessage = "Please Select the Syringe";
                        if (xMarkHit)
                        {
                            mainMessage = "The Patient is now Sedated. Now select the Scalpal and cut along the \nwhite marker from Green to blue. Say 'begin Incision' when \nin green, and when at blue say 'end incision'";
                        }
                    }
                }
            }
            else
            {
                if (currentState == cursorState.Syringe)
                {
                    if (speech.returnMsg() == ": inject")
                    {
                        mainMessage = "You injected in the wrong area (-10)";
                        score -= 10;
                        xMarkHit = true;
                        currentState = cursorState.Hand;
                    }
                }
            }

            ///
            // Collision with white broken line
            ///
            if (!collision.IntersectPixel(cursorRect, cursor_data, heartCutRect, heartCutData))
            {
                if (cutting)
                {
                    score -= 0.1;

                }
            }
            if (collision.IntersectPixel(cursorRect, cursor_data, heartCutRect, heartCutData))
            {
                if (cutting)
                {
                    score = score;
                }
            }

            ///
            // Collision with green marker
            ///
            if (collision.IntersectPixel(cursorRect, cursor_data, cutStartRect, cutStartData))
            {
                if (xMarkHit)
                {
                    if (currentState == cursorState.Scalpal)
                    {
                        if (speech.returnMsg() == ": begin incision")
                        {
                            mainMessage = "cutting";
                            cutting = true;
                        }
                    }
                    else if (currentState != cursorState.Scalpal)
                    {
                        if (speech.returnMsg() == ": begin incision")
                        {
                            mainMessage = "Please Select the Scalpal";
                        }
                    }
                }
            }

            ///
            // Collision with blue marker
            ///
            if (collision.IntersectPixel(cursorRect, cursor_data, heartCutRect, heartCutData))
            {
                if (cutting)
                {
                    if (speech.returnMsg() == ": end incision")
                    {
                        mainMessage = "finished cutting";
                        cutting = false;
                    }
                }

            }
        }
Exemplo n.º 2
0
 private void nurseSelectTool()
 {
     if (speech.returnMsg() == ": nurse scalpal")
     {
         currentState = cursorState.Scalpal;
     }
     else if (speech.returnMsg() == ": nurse suction")
     {
         currentState = cursorState.Suction;
     }
     else if (speech.returnMsg() == ": nurse syringe")
     {
         currentState = cursorState.Syringe;
     }
     else if (speech.returnMsg() == ": nurse hand")
     {
         currentState = cursorState.Hand;
     }
 }