示例#1
0
        public void setup(TetrisForm form, bool ismultiplayer, Random ownRandom, Random otherRandom)
        {
            tetrisForm = form;

            //Set multiplayer
            isMultiplayer = ismultiplayer;

            //Set gamesize
            gameSize = new Size(10, 15); // sideways, downwards

            //Set tetrisForm size
            tetrisForm.setGameSize(gameSize, isMultiplayer);

            //Get local box
            localPlayer = new TetrisPlayer(tetrisForm.getLocalPlayerBox(), gameSize, ownRandom);

            //Set paint event
            tetrisForm.getLocalPlayerBox().Paint += (o, args) => paintForPlayer(args, localPlayer, true);

            //Set keypress event
            tetrisForm.getPreviewPanel().Paint += paintPreview;
            tetrisForm.KeyPress += keyBoardHandler;

            //If multiplayer active create other player and set paint event
            if (isMultiplayer)
            {
                otherPlayer = new TetrisPlayer(tetrisForm.getOtherPlayerBox(), gameSize, otherRandom);
                tetrisForm.getOtherPlayerBox().Paint += (o, args) => paintForPlayer(args, otherPlayer, false);
            }

            //Start timer
            startTimer();
        }
示例#2
0
        //Hide form and start tetris
        public void onTetrisRun(Random ownRandom, Random otherRandom)
        {
            clientForm.Hide();
            var          form           = new TetrisForm();
            TetrisClient attachedClient = (!mpButton.Checked) ? this : null;

            currentEngine = new TetrisEngine(form, !mpButton.Checked, attachedClient, ownRandom, otherRandom);
        }
示例#3
0
 public TetrisEngine(TetrisForm form, bool ismultiplayerm, TetrisClient client, Random ownRandom, Random otherRandom)
 {
     tetrisClient = client;
     setup(form, ismultiplayerm, ownRandom, otherRandom);
 }