Esempio n. 1
0
 public void Setup()
 {
     _world = A.Fake<IWorld>();
     _world.Width = 100;
     _world.Height = 100;
     _testee = new Beetle(50, 50, _testeeColor);
 }
Esempio n. 2
0
        public void SpawnAt(System.Windows.Point position, System.Windows.Media.Color color)
        {
            if (GameType == GameType.GameOfLife)
            {
                Random r = new Random();

                for (int i = 0; i < 5; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        if (r.Next(2) == 0)
                            SetAt((int)(position.X / Values.Scalefactor) + i, (int)(position.Y / Values.Scalefactor) + j, Color.Black);
                    }
                }
            }
            else
            {
                Task task = new Task(
                    () =>
                    {
                        lock (Beetles)
                        {
                            Beetle beetle = new Beetle((int)(position.X / Values.Scalefactor), (int)(position.Y / Values.Scalefactor), Color.FromArgb(color.A, color.R, color.G, color.B));
                            Beetles.Add(beetle);

                            //for (int i = 0; i < World.Width; i += 2)
                            //{
                            //    World.Beetles.Add(new Beetle(i, 50, Color.FromArgb(i * 5 % 255, i * 5 % 255, i * 5 % 255)));
                            //}
                        }
                    });
                BeetleTasks.Add(task);
                task.Start();
            }
        }