Ejemplo n.º 1
0
        public void PerformFiltering()
        {
            if (_filter == null)
            {
                _filter = "";
            }
            //If _filter has a value (ie. user entered something in Filter textbox)
            //Lower-case and trim string
            var lowerCaseFilter = Filter.ToLowerInvariant().Trim();

            //Use LINQ query to get all personmodel names that match filter text, as a list
            var result =
                AllBugs.Where(n => n.name.ToLowerInvariant()
                              .Contains(lowerCaseFilter))
                .ToList();

            //Get list of values in current filtered list that we want to remove
            //(ie. don't meet new filter criteria)
            var toRemove = Bugs.Except(result).ToList();

            //Loop to remove items that fail filter
            foreach (var note in toRemove)
            {
                Bugs.Remove(note);
            }

            var resultCount = result.Count;

            // Add back in correct order.
            for (int i = 0; i < resultCount; i++)
            {
                var resultItem = result[i];
                if (i + 1 > Bugs.Count || !Bugs[i].Equals(resultItem))
                {
                    Bugs.Insert(i, resultItem);
                }
            }
        }
 public void Update(GameTime gameTime, GraphicsDeviceManager graphics)
 {
     if (!Balls.Any())
     {
         Balls.Add(new Ball(new Vector2(132, 132), new Vector2(0f, 0f), 0, BallTextures[0], Color.White));
         Balls.Add(new Ball(new Vector2(232, 232), new Vector2(0f, 0f), 0, BallTextures[1], Color.White));
         Balls.Add(new Ball(new Vector2(332, 332), new Vector2(0f, 0f), 0, BallTextures[2], Color.White));
     }
     Bugs.ForEach(bug =>
     {
         if (bug.ExpireTime != TimeSpan.MinValue && bug.ExpireTime <= gameTime.TotalGameTime)
         {
             Bugs.Remove(bug);
         }
     });
     if (Bugs.Count < NumberOfSimultaneousBugs || InsanityMode)
     {
         Bugs.Add(new Bug(new Vector2(Utility.GetRandomInt(0, graphics.GraphicsDevice.Viewport.Width - BugTexture.Width),
                                      Utility.GetRandomInt(0, graphics.GraphicsDevice.Viewport.Height - BugTexture.Height)),
                          BugTexture, BugSquishedTexture, Color.White));
     }
     UpdateInput();
     UpdatePositions(gameTime, graphics);
 }
 private void DestroyBug(MainBugPart bug) // Subscribed Function
 {
     Bugs.Remove((Bug)bug);
 }