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(); }
//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); }
public TetrisEngine(TetrisForm form, bool ismultiplayerm, TetrisClient client, Random ownRandom, Random otherRandom) { tetrisClient = client; setup(form, ismultiplayerm, ownRandom, otherRandom); }