示例#1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details . Use this information to set up game objects positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = screenBounds.Bottom - PaddleBottom.Height;
            PaddleTop      = new Paddle(0, 0, 0);
            PaddleTop.X    = 0;
            PaddleTop.Y    = 0;
            Ball           = new Ball(0, 0, 0)
            {
                X = 0,
                Y = 0
            };
            Background = new Background(screenBounds.Width, screenBounds.Height);
            // Add our game objects to the sprites that should be drawn collection .
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);
            base.Initialize();
        }
示例#2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details . Use this information to set up game objects positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom   = new Paddle(GameConstants.PaddleDefaultWidth, GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = screenBounds.Bottom - 2 * PaddleBottom.Height;
            PaddleTop      = new Paddle(GameConstants.PaddleDefaultWidth, GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleTop.X    = screenBounds.Width / 2f - PaddleTop.Width / 2f;
            PaddleTop.Y    = screenBounds.Top + PaddleTop.Height;
            Ball           = new Ball(100000, 1, 0.00001f)
            {
                X = 250,
                Y = 450
            };
            Background = new Background(screenBounds.Width, screenBounds.Height);
            Walls      = new List <Wall>()
            {
                // try with 100 for default wall size !
                new Wall(-GameConstants.WallDefaultSize, 0, GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize, screenBounds.Height)
            };
            Goals = new List <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width, GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize, screenBounds.Width, GameConstants.WallDefaultSize)
            };
            // Add our game objects to the sprites that should be drawn collection .
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);
            base.Initialize();
        }
 public void Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Where(s => s.Equals(todoItem)).FirstOrDefault() != null)
     {
         throw new DuplicateTodoItemException("duplicate id: {" + todoItem.Id + "}");
     }
     _inMemoryTodoDatabase.Add(todoItem);
 }
示例#4
0
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.FirstOrDefault(i => i.Id.Equals(todoItem.Id)) != null)
     {
         throw new DuplicateTodoItemException("duplicate id: " + todoItem.Id.ToString());
     }
     _inMemoryTodoDatabase.Add(todoItem);
     return(todoItem);
 }
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateTodoItemException($"duplicate id: {todoItem.Id}");
     }
     _inMemoryTodoDatabase.Add(todoItem);
     return(todoItem);
 }
示例#6
0
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateTodoItemException("dupicate id: " + todoItem.Id);
     }
     _inMemoryTodoDatabase.Add(todoItem);
     return(Get(todoItem.Id));
 }
示例#7
0
        public TodoItem Add(TodoItem todoItem)
        {
            if (_inMemoryTodoDatabase.Contains(todoItem))
            {
                throw new DuplicateTodoItemException("Item already exists within this database");
            }

            _inMemoryTodoDatabase.Add(todoItem);
            return(todoItem);
        }
示例#8
0
 public void Add(TodoItem todoItem)
 {
     if (Get(todoItem.Id) != null)
     {
         throw new DuplicateTodoItemException("duplicate id: {todoItem.Id}");
     }
     else
     {
         _inMemoryTodoDatabase.Add(todoItem);
     }
 }
示例#9
0
 public void Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateTodoItemException(String.Format("duplicate id: {0}", todoItem.Id));
     }
     else
     {
         _inMemoryTodoDatabase.Add(todoItem);
     }
 }
示例#10
0
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateTodoItemException("Duplicate id: {" + todoItem.Id + "}");
     }
     else
     {
         _inMemoryTodoDatabase.Add(todoItem);
         return(todoItem);
     }
 }
示例#11
0
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateWaitObjectException($"duplicated id: {todoItem.Id}");
     }
     else
     {
         _inMemoryTodoDatabase.Add(todoItem);
         return(todoItem);
     }
 }
 public TodoItem Add(TodoItem todoItem)
 {
     if (_inMemoryTodoDatabase.Any(s => s.Equals(todoItem)))
     {
         throw new DuplicateTodoItemException();
     }
     else
     {
         _inMemoryTodoDatabase.Add(todoItem);
         return(todoItem);
     }
 }
示例#13
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            // Screen bounds details . Use this information to set up game objects
            // positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;



            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = 100;
            PaddleBottom.Y = 580;
            PaddleTop      = new Paddle(GameConstants.PaddleDefaultWidth,
                                        GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleTop.X = 100;
            PaddleTop.Y = 0;
            Ball        = new Ball(GameConstants.DefaultBallSize,
                                   GameConstants.DefaultInitialBallSpeed,
                                   GameConstants.DefaultBallBumpSpeedIncreaseFactor)
            {
                X = 180,
                Y = 280
            };
            Background = new Background(400, 600);

            // Add our game objects to the sprites that should be drawn collection ..
            // you ’ll see why in a second
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);

            Walls = new List <Wall>()
            {
                // try with 100 for default wall size !
                new Wall(-GameConstants.WallDefaultSize, 0,
                         GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize,
                         screenBounds.Height),
            };


            Goals = new List <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width, GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize,
                         screenBounds.Width, GameConstants.WallDefaultSize),
            };

            base.Initialize();
        }
示例#14
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);

            PaddleBottom.X = 250 - PaddleBottom.Width / 2;
            PaddleBottom.Y = 900 - PaddleBottom.Height;

            PaddleTop = new Paddle(GameConstants.PaddleDefaultWidth,
                                   GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);

            PaddleTop.X = 250 - PaddleTop.Width / 2;
            PaddleTop.Y = 0;

            Background = new Background(500, 900);

            Ball = new Ball(GameConstants.DefaultBallSize,
                            GameConstants.DefaultInitialBallSpeed,
                            GameConstants.DefaultBallBumpSpeedIncreaseFactor,
                            GameConstants.DefaultMaxSpeed)
            {
                X = 250,
                Y = 450
            };

            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);

            Walls = new List <Wall>
            {
                new Wall(-GameConstants.WallDefaultSize, 0,
                         GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize,
                         screenBounds.Height)
            };

            Goals = new List <Wall>
            {
                new Wall(0, screenBounds.Height,
                         screenBounds.Width, GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize,
                         screenBounds.Width, GameConstants.WallDefaultSize)
            };

            base.Initialize();
        }
示例#15
0
        public void ListExample(IGenericList <float> list)
        {
            list.Add(2);
            list.Add(3);
            Console.WriteLine(list);
            list.Add(4);
            list.Add(5);

            list.RemoveAt(0);
            Console.WriteLine(list);
            Console.WriteLine(list.Count);
            Console.ReadLine();
        }
示例#16
0
        public TodoItem Add(TodoItem todoItem)
        {
            if (!_inMemoryTodoDatabase.Contains(todoItem))
            {
                _inMemoryTodoDatabase.Add(todoItem);
            }
            else
            {
                throw new DuplicateTodoItemException("duplicate id: " + todoItem.Id);
            }

            return(todoItem);
        }
示例#17
0
 public TodoItem Add(TodoItem todoItem)
 {
     if (todoItem == null)
     {
         throw new ArgumentNullException();
     }
     else if (_inMemoryTodoDatabase.Contains(todoItem))
     {
         throw new DuplicateTodoItemException(todoItem.Id);
     }
     _inMemoryTodoDatabase.Add(todoItem);
     return(todoItem);
 }
示例#18
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here


            // Screen bounds details . Use this information to set up game objects positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = screenBounds.Bottom - PaddleBottom.Height;
            PaddleTop      = new Paddle(GameConstants.PaddleDefaultWidth,
                                        GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleTop.X = screenBounds.Width / 2f - PaddleTop.Width / 2f;
            PaddleTop.Y = screenBounds.Top;
            Ball        = new Ball(GameConstants.DefaultBallSize, GameConstants.DefaultInitialBallSpeed,
                                   GameConstants.DefaultBallBumpSpeedIncreaseFactor)
            {
                X = screenBounds.Width / 2f,
                Y = screenBounds.Height / 2f
            };
            Background = new Background(screenBounds.Width, screenBounds.Height);
            // Add our game objects to the sprites that should be drawn collection .
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);


            // Adds walls and goals to the game. Walls are horizontal borders, and goals vertical.
            Walls = new GenericList <Wall>()
            {
                // try with 100 for default wall size !
                new Wall(-GameConstants.WallDefaultSize, 0,
                         GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize,
                         screenBounds.Height),
            };
            Goals = new GenericList <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width,
                         GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize,
                         screenBounds.Width, GameConstants.WallDefaultSize),
            };



            base.Initialize();
        }
示例#19
0
        /// <summary >
        /// Adds new TodoItem object in database .
        /// If object with the same id already exists ,
        /// method should throw DuplicateTodoItemException with the message " duplicate id: {id }".
        /// </ summary >
        public void Add(TodoItem todoItem)
        {
            if (todoItem == null)
            {
                throw new ArgumentNullException();
            }

            if (Get(todoItem.Id) != null)
            {
                throw new DuplicateTodoItemException(todoItem.Id);
            }

            _inMemoryTodoDatabase.Add(todoItem);
        }
示例#20
0
        public void Add(TodoItem todoItem)
        {
            if (todoItem == null)
            {
                throw new ArgumentNullException();
            }
            TodoItem i = _inMemoryTodoDatabase.Where(x => x.Id == todoItem.Id).FirstOrDefault();

            if (i != null)
            {
                throw new DuplicateTodoItemException("duplicate id: {" + i.Id + "}");
            }
            _inMemoryTodoDatabase.Add(todoItem);
        }
示例#21
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details . Use this information to set up game objects positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaultHeight, GameConstants.PaddleDefaultSpeed);
            PaddleBottom.Name = "PaddleBottom";
            PaddleTop         = new Paddle(GameConstants.PaddleDefaultWidth,
                                           GameConstants.PaddleDefaultHeight, GameConstants.PaddleDefaultSpeed);
            PaddleTop.Name = "PaddleTop";

            PaddleBottom.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = screenBounds.Bottom - PaddleBottom.Height;

            PaddleTop.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleTop.Y = screenBounds.Top;


            Ball = new Ball(GameConstants.DefaultBallSize, GameConstants.DefaultInitialBallSpeed, GameConstants.DefaultIBallBumpSpeedIncreaseFactor)
            {
                X = screenBounds.Width / 2,
                Y = screenBounds.Height / 2,
            };


            scoreTop    = 0;
            scoreBottom = 0;


            Background = new Background(screenBounds.Width, screenBounds.Height);

            Walls = new List <Wall>()
            {
                new Wall(-GameConstants.WallDefaultSize, 0, GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize, screenBounds.Height),
            };
            Goals = new List <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width, GameConstants.WallDefaultSize),
                new Wall(0, -GameConstants.WallDefaultSize, screenBounds.Width, GameConstants.WallDefaultSize),
            };
            // Add our game objects to the sprites that should be drawn collection .
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);
            base.Initialize();
        }
示例#22
0
 public static void ListExampleGenerics(IGenericList <string> listOfGenerics)
 {
     listOfGenerics.Add("a");                                     // [a]
     listOfGenerics.Add("b");                                     // [a,b]
     listOfGenerics.Add("car");                                   // [a,b,car]
     listOfGenerics.Add("house");                                 // [a,b,car,house]
     listOfGenerics.Add("roof");                                  // [a,b,car,house,roof]
     listOfGenerics.RemoveAt(0);                                  // [b,car,house,roof]
     listOfGenerics.Remove("house");                              //[b,car,house]
     Console.WriteLine(listOfGenerics.Count);                     // 3
     Console.WriteLine(listOfGenerics.Remove("nonExistingWord")); // false
     Console.WriteLine(listOfGenerics.RemoveAt(5));               // false
     listOfGenerics.Clear();                                      // []
     Console.WriteLine(listOfGenerics.Count);                     // 0
 }
示例#23
0
 public static void ListExample(IGenericList <int> listOfIntegers)
 {
     listOfIntegers.Add(1);                         // [1]
     listOfIntegers.Add(2);                         // [1 ,2]
     listOfIntegers.Add(3);                         // [1 ,2 ,3]
     listOfIntegers.Add(4);                         // [1 ,2 ,3 ,4]
     listOfIntegers.Add(5);                         // [1 ,2 ,3 ,4 ,5]
     listOfIntegers.RemoveAt(0);                    // [2 ,3 ,4 ,5]
     listOfIntegers.Remove(5);                      //[2 ,3 ,4]
     Console.WriteLine(listOfIntegers.Count);       // 3
     Console.WriteLine(listOfIntegers.Remove(100)); // false
     Console.WriteLine(listOfIntegers.RemoveAt(5)); // false
     listOfIntegers.Clear();                        // []
     Console.WriteLine(listOfIntegers.Count);       // 0
 }
示例#24
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details . Use this information to set up game objects
            // positions.
            _screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = _screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = _screenBounds.Bottom - PaddleBottom.Height;

            PaddleTop = new Paddle(GameConstants.PaddleDefaultWidth,
                                   GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleTop.X = _screenBounds.Width / 2f - PaddleTop.Width / 2f;
            PaddleTop.Y = _screenBounds.Top;

            Ball = new Ball(GameConstants.DefaultBallSize, GameConstants.DefaultInitialBallSpeed,
                            GameConstants.DefaultBallBumpSpeedIncreaseFactor)
            {
                X = _screenBounds.Width / 2f - GameConstants.DefaultBallSize / 2f,
                Y = _screenBounds.Bottom / 2f - GameConstants.DefaultBallSize / 2f
            };

            Background = new Background(_screenBounds.Width, _screenBounds.Height);

            // Add our game objects to the sprites that should be drawn collection .
            _spritesForDrawList.Add(Background);
            _spritesForDrawList.Add(PaddleBottom);
            _spritesForDrawList.Add(PaddleTop);
            _spritesForDrawList.Add(Ball);

            Walls = new GenericList <Wall>()
            {
                new Wall(_screenBounds.Left, _screenBounds.Top,
                         GameConstants.WallDefaultSize, _screenBounds.Height),
                new Wall(_screenBounds.Right - GameConstants.WallDefaultSize, _screenBounds.Top,
                         GameConstants.WallDefaultSize, _screenBounds.Height),
            };
            Goals = new GenericList <Wall>()
            {
                new Wall(_screenBounds.Left, _screenBounds.Top,
                         _screenBounds.Width, GameConstants.WallDefaultSize),
                new Wall(_screenBounds.Left, _screenBounds.Bottom - GameConstants.WallDefaultSize,
                         _screenBounds.Width, GameConstants.WallDefaultSize),
            };

            base.Initialize();
        }
示例#25
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = 150;
            PaddleBottom.Y = 880;

            PaddleTop = new Paddle(GameConstants.PaddleDefaultWidth,
                                   GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleTop.X = 150;
            PaddleTop.Y = 0;

            Ball = new Ball(GameConstants.DefaultBallSize,
                            GameConstants.DefaultInitialBallSpeed,
                            GameConstants.DefaultBallBumpSpeedIncreaseFactor)
            {
                X = 230,
                Y = 430
            };

            Background = new Background(500, 900);

            Walls = new List <Wall>()
            {
                new Wall(-GameConstants.WallDefaultSize, 0,
                         GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize,
                         screenBounds.Height),
            };

            Goals = new List <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width,
                         GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize,
                         screenBounds.Width, GameConstants.WallDefaultSize),
            };

            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);

            base.Initialize();
        }
示例#26
0
 public static void ListOfExamples(IGenericList <double> listOfIntegers)
 {
     listOfIntegers.Add(1.3);                       // [1]
     listOfIntegers.Add(2.2);                       // [1 ,2]
     listOfIntegers.Add(3.4);                       // [1 ,2 ,3]
     listOfIntegers.Add(4.5);                       // [1 ,2 ,3 ,4]
     listOfIntegers.Add(5.2);                       // [1 ,2 ,3 ,4 ,5]
     listOfIntegers.RemoveAt(0);                    // [2 ,3 ,4 ,5]
     listOfIntegers.Remove(5.2);
     Console.WriteLine(listOfIntegers.Count);       // 3
     Console.WriteLine(listOfIntegers.Remove(100)); // false
     Console.WriteLine(listOfIntegers.RemoveAt(5)); // false
     listOfIntegers.Clear();                        // []
     Console.WriteLine(listOfIntegers.Count);       // 0
     Console.ReadLine();
 }
示例#27
0
 public static void ListExample(IGenericList <string> list)
 {
     list.Add("1a");
     list.Add("2b");
     list.Add("3c");
     list.Add("4d");
     list.Add("5e");
     list.RemoveAt(0);
     list.Remove("5e");
     WriteLine(list.GetElement(2));
     WriteLine(list.Count);
     WriteLine(list.Remove("100"));
     WriteLine(list.RemoveAt(5));
     list.Clear();
     WriteLine(list.Count);
 }
示例#28
0
 /// <summary>
 /// Adds item into collection(space issue is solved).
 /// </summary>
 /// <param name="todoItem"></param>
 public void Add(TodoItem todoItem)
 {
     if (!_inMemoryToDoDatabase.Contains(todoItem))
     {
         _inMemoryToDoDatabase.Add(todoItem);
     }
 }
示例#29
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Screen bounds details . Use this information to set up game objects positions.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            PaddleBottom = new Paddle(GameConstants.PaddleDefaultWidth,
                                      GameConstants.PaddleDefaulHeight, GameConstants.PaddleDefaulSpeed);
            PaddleBottom.X = screenBounds.Width / 2f - PaddleBottom.Width / 2f;
            PaddleBottom.Y = screenBounds.Bottom - PaddleBottom.Height;
            PaddleTop      = new Paddle(GameConstants.PaddleDefaultWidth, GameConstants.PaddleDefaulHeight,
                                        GameConstants.PaddleDefaulSpeed)
            {
                X = screenBounds.Width / 2f - PaddleBottom.Width / 2f,
                Y = screenBounds.Top
            };
            Ball = new Ball(GameConstants.DefaultBallSize, GameConstants.DefaultInitialBallSpeed,
                            GameConstants.DefaultBallBumpSpeedIncreaseFactor);

            Ball.X         = (screenBounds.Width - Ball.Width) / 2f;
            Ball.Y         = (screenBounds.Height - Ball.Height) / 2f;
            Ball.Direction = Direction.SouthEast;

            Walls = new List <Wall>()
            {
                // try with 100 for default wall size !
                new Wall(-GameConstants.WallDefaultSize, 0,
                         GameConstants.WallDefaultSize, screenBounds.Height),
                new Wall(screenBounds.Right, 0, GameConstants.WallDefaultSize,
                         screenBounds.Height),
            };
            Goals = new List <Wall>()
            {
                new Wall(0, screenBounds.Height, screenBounds.Width,
                         GameConstants.WallDefaultSize),
                new Wall(screenBounds.Top, -GameConstants.WallDefaultSize,
                         screenBounds.Width, GameConstants.WallDefaultSize),
            };

            Background = new Background(screenBounds.Width, screenBounds.Height);
            // Add our game objects to the sprites that should be drawn collection .
            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);
            base.Initialize();
        }
示例#30
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Ask graphics device about screen bounds we are using.
            var screenBounds = GraphicsDevice.Viewport.Bounds;

            // Load paddle texture using Content.Load static method
            Texture2D paddleTexture = Content.Load <Texture2D>("paddle");

            // Create bottom and top paddles and set their initial position
            PaddleBottom = new Paddle(paddleTexture);
            PaddleTop    = new Paddle(paddleTexture);

            // Position both paddles with help screenBounds object
            PaddleBottom.Position = new Vector2(screenBounds.Bottom - PaddleBottom.Size.Height);
            System.Console.WriteLine(PaddleBottom.Size.Y);
            PaddleTop.Position = new Vector2(screenBounds.Top);

            // Load ball texture
            Texture2D ballTexture = Content.Load <Texture2D>("ball");

            // Create new ball object and set its initial position
            Ball          = new Ball(ballTexture);
            Ball.Position = screenBounds.Center.ToVector2();

            // Load background texture and create a new background object
            Texture2D backgroundTexture = Content.Load <Texture2D>("background");

            Background = new Background(backgroundTexture, screenBounds.Width, screenBounds.Height);

            // Load sounds
            HitSound = Content.Load <SoundEffect>("hit");
            Music    = Content.Load <Song>("music");
            MediaPlayer.IsRepeating = true;

            // Start playing background music
            MediaPlayer.Play(Music);


            SpritesForDrawList.Add(Background);
            SpritesForDrawList.Add(PaddleBottom);
            SpritesForDrawList.Add(PaddleTop);
            SpritesForDrawList.Add(Ball);
        }