예제 #1
0
        public HitType LookForHits(Dictionary <Bone, BoneData> segments, int playerId)
        {
            DateTime cur     = DateTime.Now;
            HitType  allHits = HitType.None;

            // Zero out score if necessary
            if (!scores.ContainsKey(playerId))
            {
                scores.Add(playerId, 0);
            }

            foreach (var pair in segments)
            {
                for (int i = 0; i < things.Count; i++)
                {
                    HitType hit   = HitType.None;
                    Thing   thing = things[i];
                    switch (thing.State)
                    {
                    case ThingState.Bouncing:
                    case ThingState.Falling:
                    {
                        var     hitCenter       = new Point(0, 0);
                        double  lineHitLocation = 0;
                        Segment seg             = pair.Value.GetEstimatedSegment(cur);
                        if (thing.Hit(seg, ref hitCenter, ref lineHitLocation))
                        {
                            if (seg.IsCircle())
                            {
                                Guess guess = new Guess {
                                    GueAnsID = dropItems[thing.dropItemIndex].AnsID
                                };

                                // Correct Answer
                                if (Convert.ToBoolean(thing.correctAnswer))
                                {
                                    hit |= HitType.Correct;
                                    AddToScore(thing.TouchedBy, 5, thing.Center);

                                    //if there are no more correct answers, get rid of all balloons.
                                    dropItems[thing.dropItemIndex].AnsInactive = true;
                                    bool moreCorrectAnswers = false;

                                    foreach (Answer answer in dropItems.Where(answer => Convert.ToBoolean(answer.AnsCorrect) && Convert.ToBoolean(answer.AnsInactive == false)))
                                    {
                                        moreCorrectAnswers = true;
                                    }

                                    if (!moreCorrectAnswers)
                                    {
                                        foreach (Answer answer in dropItems)
                                        {
                                            answer.AnsInactive = true;
                                        }
                                    }
                                }
                                // Wrong answer
                                else
                                {
                                    hit |= HitType.Incorrect;
                                }
                                //dropItems[thing.dropItemIndex].AnsInactive = true;
                                thing.State = ThingState.Remove;
                                things[i]   = thing;
                            }
                        }
                    }

                    break;
                    }

                    allHits |= hit;
                }
            }

            return(allHits);
        }
예제 #2
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Guesses EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToGuesses(Guess guess)
 {
     base.AddObject("Guesses", guess);
 }