Пример #1
0
        private void SetupShips()
        {
            for (int i = 0; i < amount; i++)
            {
                players[i] = new Player(pCoordinates[i][0], pCoordinates[i][1], i);
                enemies[i] = new Computer(eCoordinates[i][0], eCoordinates[i][1], i, 180, 0);
                #region Set Handlers
                (players[i]).hit.spriteButton.Click += (players[i]).Player_Click;
                (players[i]).alive.spriteButton.Click += (players[i]).Player_Click;
                #endregion
                gameobjects.Add(players[i]);
                gameobjects.Add(enemies[i]);

            }
        }
Пример #2
0
        public override void Init()
        {
             #region Setup Display

            #region Window
            menuScreen = new Canvas();
            menuScreen.Height = Constants.ScreenHeight;
            menuScreen.Width = Constants.ScreenWidth;
            menuScreen.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            menuScreen.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            background = new Background(Constants.MenuBackgroundPath);
            menuScreen.Background = background.GetBrush();
            title = new Title();
            title.Margin = new Thickness(Constants.ScreenWidth / 2 -430, Constants.ScreenHeight / 2 - 320, 0, 0);
            title.HorizontalAlignment = System.Windows.HorizontalAlignment.Center;
            title.VerticalAlignment = System.Windows.VerticalAlignment.Center;
             #endregion

            #region Panel
            buttons = new MenuPanel(this);
            buttons.Margin = new Thickness(Constants.ScreenWidth / 2 - buttons.width / 2, Constants.ScreenHeight - (buttons.height * 1.5), 0, 0);
            #endregion

             #endregion

            #region Setup Decoration

            #region Random
            r = new Randomizer();
            angle = new Randomizer(r.Next());
            speed = new Randomizer(r.Next() * angle.Next());
            xpos = new Randomizer(r.Next() * speed.Next());
            ypos = new Randomizer(r.Next() * xpos.Next());
            Constants.SelectedEnemy = xpos.Next(0, 1);
            Constants.SelectedShip = ypos.Next(0, 1);
            #endregion

            #region Create decor
            int amount = r.Next(10, 20);
            int pamount = amount / 2;
            int eamount = amount - pamount;
            players = new Player[pamount];
            enemies = new Computer[eamount];
            list = new List<GameObject>();

            for (int i = 0; i < players.Length; i++)
            {
                players[i] = new Player(xpos.Next(128, Constants.ScreenWidth - 128), ypos.Next(64, Constants.ScreenHeight - 64), i);
                players[i].SetAngle(angle.Next(0, 360));
                players[i].SetSpeed(speed.Next(3, 6));
                players[i].UpdateMovement();
                list.Add(players[i]);
               
            }
            for (int i = 0; i < enemies.Length; i++)
            {
                enemies[i] = new Computer(xpos.Next(128, Constants.ScreenWidth - 128), ypos.Next(64, Constants.ScreenHeight - 64), i);
                enemies[i].SetAngle(angle.Next(0, 360));
                enemies[i].SetSpeed(speed.Next(3, 6));
                enemies[i].UpdateMovement();
                list.Add(enemies[i]);
               
            }
            #endregion

            Constants.SelectedEnemy = 0;
            Constants.SelectedShip = 0;
            #endregion

        }