예제 #1
0
        //sets up boards
        private void game_setUp()
        {
            int    Xcord = 0;
            int    Ycord = 0;
            char   boxName;
            string imageFileName;

            //stops timer if some one starts new game with it runing
            buttonTimer.Stop();
            nextStepButton.BackgroundImage = null;

            //sets BackgroundImages to empty
            playerSHPPanel.BackgroundImage     = null;
            playerATKPanel.BackgroundImage     = null;
            undoPegPlaceButton.BackgroundImage = null;

            //Sets the ships health
            makeGame.setShipSet();

            //sets playerBoard to empty
            for (int loopnum = 0; loopnum != Globals.playerBoard.Length; ++loopnum)
            {
                Globals.playerBoard[loopnum] = OPENWATER;
            }

            //resets info for new game
            Globals.gameMode   = false;
            Globals.pegPlaced  = false;
            Globals.AttackSpot = -1;

            //destroys all PBs in panels if there is any, so new grid can be made
            destroy_Grid();

            //sets all rotation buttons to false
            for (int loopnum = 0; loopnum != Globals.rotateButton.Length; ++loopnum)
            {
                Globals.rotateButton[loopnum] = false;
            }

            //sets action label to say place ships
            playerActionLabel.Text = Globals.stringTheme[0];

            //make board for ATKPANEL
            boxName           = ATKBX;
            imageFileName     = ATTACKBOX;
            Globals.boardSize = NORMAL * NORMAL;
            createPBox(Xcord, Ycord, boxName, imageFileName);

            //SHPPANEL's boards size based on difficulty
            switch (Globals.difficulty)
            {
            case NORMAL:
                Ycord             = 0;
                Xcord             = 0;
                Globals.boardSize = NORMAL * NORMAL;
                break;

            case HARD:
                Xcord             = PICBOXSIZE / 2;
                Ycord             = PICBOXSIZE / 2;
                Globals.boardSize = HARD * HARD;
                break;

            case BRUTAL:
                Ycord             = PICBOXSIZE;
                Xcord             = PICBOXSIZE;
                Globals.boardSize = BRUTAL * BRUTAL;
                break;
            }

            //make board for SHPPANEL
            boxName       = SHPBX;
            imageFileName = SHIPBOX;
            createPBox(Xcord, Ycord, boxName, imageFileName);
        }