Beispiel #1
0
        /// <summary>
        /// Choose a random powerup.
        /// </summary>
        /// <returns>A random powerup</returns>
        public static PowerUp ChooseRandomPowerUp(int width, int height, Data.Setup s)
        {
            PowerUp powerUp;
            Random  random = new Random();
            double  x      = random.Next(width / 4, width / 4 * 3);
            double  y      = random.Next(height / 5, height / 5 * 4);

            switch (random.Next(5))
            {
            case 0:
                powerUp = new HealthPowerUp(x, y, 40, s.HealingShield);
                break;

            case 1:
                powerUp = new SpeedPowerUp(x, y, 40, s.SpeedBallPercent);
                break;

            case 2:
                powerUp = new ReversePowerUp(x, y, 40, s.ReverseTime);
                break;

            case 3:
                powerUp = new MultiBallPowerUp(x, y, 40);
                break;

            default:
                powerUp = new BombPowerUp(x, y, 40, s.DamageBomb);
                break;
            }
            return(powerUp);
        }
Beispiel #2
0
        public gameData(List <Ball> balls, List <Player> players, List <PowerUp> powerups, Data.Setup setup)
        {
            InitializeComponent();
            this.balls    = balls;
            this.players  = players;
            this.powerups = powerups;
            this.setup    = setup;
            fullscreen    = false;

            // Fill with player info
            int x = 0;

            foreach (Player p in players)
            {
                listViewPlayers.Items.Add(new ListViewItem(new[] { setup.PlayerNames[x], p.Health.ToString(), p.Score.ToString() }));
                x++;
            }

            // Fill with ball info
            foreach (Ball b in balls)
            {
                listViewBalls.Items.Add(new ListViewItem(new[] { b.X.ToString(), b.Y.ToString(), b.SpeedX.ToString(), b.SpeedY.ToString() }));
            }

            // Fill with powerup info
            foreach (PowerUp p in powerups)
            {
                listViewPowerups.Items.Add(new ListViewItem(new[] { p.Name, p.X.ToString(), p.Y.ToString() }));
            }
        }
Beispiel #3
0
 public Projection(Data.Setup s)
 {
     InitializeComponent();
     setup                = s;
     rectangles           = new List <Rectangle>();
     rectanglesUnscaled   = new List <Rectangle>();
     camera               = new CameraIO(setup);
     pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
     Application.Idle    += new EventHandler(this.Application_Idle);
 }
Beispiel #4
0
 public thirdStep(Data.Setup setup)
 {
     InitializeComponent();
     this.setup = setup;
     device     = setup.Device;
     if (device != null)
     {
         device.NewFrame += new NewFrameEventHandler(updatePictureBox);
     }
     device.Start();
 }
Beispiel #5
0
        /// <summary>
        /// Constructor from the second setup window.
        /// </summary>
        /// <param name="setup">Setup class for saved data</param>
        public secondStep(Data.Setup setup)
        {
            InitializeComponent();
            this.setup = setup;
            this.FillComboBox();
            this.btnStartStop.IsEnabled   = false;
            this.buttonContinue.IsEnabled = false;
            this.mirrorChecked            = false;
            //this.FormClosing += new FormClosingEventHandler(form_Closing);
            Timer timer = new Timer();

            timer.Interval = 1000;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();
            this.threshold = (int)sliderThreshold.Value;
        }
Beispiel #6
0
        public MainWindow()
        {
            InitializeComponent();
            setup = new Data.Setup();

            powerupsTimer.Elapsed  += new ElapsedEventHandler(Timer_Elapsed);
            powerupsTimer.Interval  = 5000;
            powerupsTimer.AutoReset = true;

            // Start setup - first screen: number of players + name
            Window window1 = new Window
            {
                Title   = "Pong setup - Names",
                Content = new firstStep(setup),
                Width   = 600,
                Height  = 400,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window1.ShowDialog();
            window1.Close();

            // Continue setup - second screen: select camera
            Window window2 = new Window
            {
                Title   = "Pong setup - Camera Setup",
                Content = new secondStep(setup),
                Width   = 600,
                Height  = 800,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window2.ShowDialog();
            window2.Close();

            // Continue setup - third screen: select hand zones
            Window window3 = new Window
            {
                Title   = "Pong setup - Hand Zone Selection",
                Content = new thirdStep(setup),
                Width   = 600,
                Height  = 700,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window3.ShowDialog();
            window3.Close();

            // Continue + exit setup - fourth screen: general settings
            Window window4 = new Window
            {
                Title   = "Pong setup - General settings",
                Content = new fourthStep(setup),
                Width   = 600,
                Height  = 700,
                WindowStartupLocation = WindowStartupLocation.CenterScreen
            };

            window4.ShowDialog();
            window4.Close();

            this.Closed           += new EventHandler(Window_Closed);
            this.KeyDown          += new KeyEventHandler(Window_KeyDown);
            this.MouseDoubleClick += new MouseButtonEventHandler(Window_DoubleClick);

            camera = new CameraIO(setup);

            timeRemaining = setup.TimeLimit * 60;
            balls         = new List <Ball>();
            players       = Helper.CreatePlayers(setup.Rectangles, (int)this.Width, (int)this.Height, camera.Size, setup);
            goals         = Helper.GetGoals(setup.Rectangles, (int)this.Width, (int)this.Height, camera.Size);
            balls.Add(Helper.CreateBall(setup.StartVelocity, (int)(this.Width / 2) - 20, (int)(this.Height / 2) - 20));

            powerups = new List <PowerUp>();

            for (int i = 0; i < players.Count; i++)
            {
                Player p = players[i];
                Canvas.SetLeft(p.ScoreLabel, (this.Width / (players.Count + 1)) * (i + 1));
                Canvas.SetTop(p.ScoreLabel, 10);
                World.Children.Add(p.Beam.Shape);
                World.Children.Add(p.ScoreLabel);
            }

            fullscreen = false;

            foreach (Ball ball in balls)
            {
                World.Children.Add(ball.Shape);
            }

            startWidth  = this.Width;
            startHeight = this.Height;

            // Open gamedata
            gameData = new gameData(balls, players, powerups, setup);
            gameData.Show();
            gameData.SendToBack();
        }
Beispiel #7
0
 public firstStep(Data.Setup setup)
 {
     InitializeComponent();
     this.setup = setup;
     Initialize();
 }
Beispiel #8
0
 public fourthStep(Data.Setup setup)
 {
     InitializeComponent();
     this.setup = setup;
 }
Beispiel #9
0
        public void Execute(string conn)
        {
            try
            {
                Tz.Data.Setup s = new Data.Setup(conn);
                try
                {
                    s.CreateAccount();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateClient();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateUser();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateServer();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateTable();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }


                try
                {
                    s.CreateField();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateClientServer();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateDataScript();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateScriptIntend();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
                try
                {
                    s.CreateImportEvents();
                }
                catch (Exception ex)
                {
                    if (ex.Message.IndexOf("exist") == 0)
                    {
                        throw ex;
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #10
0
 public void Reset(string conn)
 {
     Tz.Data.Setup s = new Data.Setup(conn);
     s.Clear();
 }
Beispiel #11
0
        public void ExecuteClientSetup(string conn)
        {
            Tz.Data.Setup s = new Data.Setup(conn);
            try
            {
                s.CreateComponent();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentAttribute();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentModal();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentModalItem();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentModalRelation();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentLookup();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
            try
            {
                s.CreateComponentLookUpItem();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }

            try
            {
                s.CreateTable();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }


            try
            {
                s.CreateField();
            }
            catch (Exception ex)
            {
                if (ex.Message.IndexOf("exist") == 0)
                {
                    throw ex;
                }
            }
        }
Beispiel #12
0
        /// <summary>
        /// Creates players according to the selected areas
        /// </summary>
        /// <param name="areas">List of selected areas</param>
        /// <param name="width">Width of the playing field</param>
        /// <param name="height">Height of the playing field</param>
        /// <param name="size">Resolution of the camera</param>
        /// <param name="setup">Setup parameters</param>
        /// <returns>A list of players, positioned where the user probably wanted them to be (best guess)</returns>
        public static List <Player> CreatePlayers(List <Rectangle> areas, int width, int height, Size size, Data.Setup setup)
        {
            List <Player> players = new List <Player>();

            for (int i = 0; i < areas.Count; i++)
            {
                Rectangle r = areas.ElementAt(i);
                //X or Y oriented
                if (r.Width < r.Height)
                {
                    //left or right side
                    if (r.X < size.Width / 2)
                    {
                        //left, Y
                        Beam   b = new Beam(35, (height / 2) - 50, 20, 100);
                        Player p = new Player(setup.StartHealth, b, 'Y');
                        players.Add(p);
                    }
                    else
                    {
                        //right, Y
                        Beam   b = new Beam(width - 55, (height / 2) - 50, 20, 100);
                        Player p = new Player(setup.StartHealth, b, 'Y');
                        players.Add(p);
                    }
                }
                else
                {
                    if (r.Y < size.Height / 2)
                    {
                        //top, X
                        Beam   b = new Beam((width / 2) - 50, 35, 100, 20);
                        Player p = new Player(setup.StartHealth, b, 'X');
                        players.Add(p);
                    }
                    else
                    {
                        //bottom, X
                        Beam   b = new Beam((width / 2) - 50, height - 55, 100, 20);
                        Player p = new Player(setup.StartHealth, b, 'X');
                        players.Add(p);
                    }
                }
            }
            return(players);
        }