Esempio n. 1
0
        public Player(Color col, string name, Key[] control)
        {
            if (control.Length != 5)
            {
                throw new Exception("Controls must be 5");
            }
            pen       = new Pen(col);
            controls  = control;
            this.name = name;
            speed     = 30;
            alive     = false;
            all.Add(this);
            Random rnd = new Random(Guid.NewGuid().ToByteArray().Sum(x => x));

            try
            {
                Point p = new Point(rnd.Next(40, Balls.BoundsForReflect().Item1 - 70), rnd.Next(40, Balls.BoundsForReflect().Item2 - 70));
                area = new Rectangle(p, new Size(50, 50));
            }
            catch (ArgumentOutOfRangeException)
            {
                Point p = new Point(rnd.Next(40, Screen.PrimaryScreen.Bounds.Width - 70), rnd.Next(40, Screen.PrimaryScreen.Bounds.Height - 70));
                area = new Rectangle(p, new Size(50, 50));
            }
        }
Esempio n. 2
0
        public Player(Color col, string name)
        {
            pen       = new Pen(col);
            controls  = new Key[] { Key.W, Key.D, Key.S, Key.A, Key.LeftShift };
            this.name = name;
            alive     = false;
            speed     = 30;
            Random rnd = new Random(Guid.NewGuid().ToByteArray().Sum(x => x));
            Point  p;

            try
            {
                p = new Point(rnd.Next(0, Balls.BoundsForReflect().Item1 - 70), rnd.Next(0, Balls.BoundsForReflect().Item2 - 70));
            }
            catch (ArgumentOutOfRangeException)
            {
                p = new Point(rnd.Next(0, Screen.PrimaryScreen.Bounds.Width - 70), rnd.Next(0, Screen.PrimaryScreen.Bounds.Height - 70));
            }
            catch (Exception)
            {
                p = new Point(rnd.Next(0, Screen.PrimaryScreen.Bounds.Width - 70), rnd.Next(0, Screen.PrimaryScreen.Bounds.Height - 70));
            }
            area = new Rectangle(p, new Size(50, 50));
            all.Add(this);
        }
Esempio n. 3
0
 public static void NewRound()
 {
     foreach (var element in all)
     {
         element.currentscore = 0;
         element.alive        = true;
         Random rnd = new Random(Guid.NewGuid().ToByteArray().Sum(x => x));
         Point  p   = new Point(rnd.Next(0, Balls.BoundsForReflect().Item1 - 70), rnd.Next(0, Balls.BoundsForReflect().Item2 - 70));
         element.area = new Rectangle(p, new Size(50, 50));
     }
 }