Exemplo n.º 1
0
        public GameScreen()
        {
            InitializeComponent();


            //Initialize target grid
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PlanningButton b = new PlanningButton((short)i, (short)j);
                    b.Name      = string.Format("TargetButton{0}{1}", i, j);
                    b.Text      = string.Format("{0}{1}", i, j);
                    b.Dock      = DockStyle.Fill;
                    b.BackColor = Color.LightSkyBlue;
                    TargetingTable.Controls.Add(b, i, j);
                    b.Click += (sender, e) => ShipTargetButton_Click(sender, e, b.xCoord, b.yCoord);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PlanningButton b = new PlanningButton((short)i, (short)j);
                    b.Name      = string.Format("PlayerButton{0}{1}", i, j);
                    b.Text      = string.Format("{0}{1}", i, j);
                    b.Dock      = DockStyle.Fill;
                    b.Enabled   = false;
                    b.BackColor = Color.LightSkyBlue;
                    PlayerShipTable.Controls.Add(b, i, j);
                }
            }
            FireButton.Enabled = false;
        }
        public void InitializeStates()
        {
            shipList = new List <PlanningShip>
            {
                new PlanningShip(5),
                new PlanningShip(4),
                new PlanningShip(3),
                new PlanningShip(3),
                new PlanningShip(2)
            };

            currentShip = shipList[0];


            shipRadioList = new List <RadioButton>
            {
                CarrierRadio,
                BattleshipRadio,
                CruiserRadio,
                SubRadio,
                DestroyerRadio
            };

            CarrierRadio.Checked = true;

            shipCheckList = new List <Label>
            {
                CarrierCheck,
                BattleshipCheck,
                CruiserCheck,
                SubCheck,
                DestroyerCheck
            };

            HorizontalRadio.Checked = true;

            //Initialize button grid
            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    PlanningButton b = new PlanningButton((short)i, (short)j);
                    b.Name = string.Format("Button{0}{1}", i, j);
                    b.Text = string.Format("{0}{1}", i, j);
                    b.Dock = DockStyle.Fill;
                    PlanningTable.Controls.Add(b, i, j);
                    b.Click += (sender, e) => ShipCoordButton_Click(sender, e, b.xCoord, b.yCoord);
                }
            }
        }