public Game(ref Player playerA,ref Player playerB,Difficulty difficulty,GameMode gameMode) { current_game = this; board = new PlayerType[3,3]{{PlayerType.NONE,PlayerType.NONE,PlayerType.NONE}, {PlayerType.NONE,PlayerType.NONE,PlayerType.NONE}, {PlayerType.NONE,PlayerType.NONE,PlayerType.NONE}}; this.playerA = playerA; this.playerA.score = 0; this.playerB = playerB; this.difficulty = difficulty; this.game_mode = gameMode; if (game_mode == GameMode.SINGLE_PLAYER) { //playerA.name = "User"; playerB.name = "Computer"; playerA.moveAllowed = true; playerB.moveAllowed = false; }else if(game_mode == GameMode.MULTI_PLAYER_STANDALONE){ //playerA.name = "Ball"; playerB.name = "Cross"; //playerA.moveAllowed = true; playerB.moveAllowed = false; this.difficulty = Difficulty.NONE; } else if (game_mode == GameMode.MULTI_PLAYER) { this.difficulty = Difficulty.NONE; } this.current_player = playerA; this.connected = false; }
private void btnLoadGame_Click(object sender, EventArgs e) { if(cmbProfile.Items.Count != 0 && cmbProfile.SelectedItem != null) { tmp = new Player(); tmp = playerList[cmbProfile.SelectedIndex]; this.Hide(); new PlayerForm().Show(); } }
public void initGame(GameMode gameMode) { //Initialize game for default state Player playerA = new Player(PlayerType.BALL); Player playerB = new Player(PlayerType.CROSS); game = new Game(playerA, playerB, Difficulty.NORMAL, gameMode); game.chanceOfPlayerAI = true; game.chanceOfPlayerA = false; lblPlayerA.Text = game.playerA.name; lblPlayerB.Text = game.playerB.name; update(); }
//bool playerA = true; public void initGame(GameMode gameMode) { //Initialize game for default state //Player playerA = new Player(PlayerType.BALL); PlayerForm.form = this; Player playerA = Start.getLoadPlayer(); Player playerB = new Player(PlayerType.CROSS); game = new Game(ref playerA,ref playerB, Difficulty.NORMAL, gameMode); Player tmp = Start.getLoadPlayer(); //game.chanceOfPlayerAI = true; //game.chanceOfPlayerA = false; lblPlayerA.Text = game.playerA.name; lblPlayerB.Text = game.playerB.name; update(); }
private void btnNewGame_Click(object sender, EventArgs e) { if (txtNewPlayer.Text == "") { MessageBox.Show("Please enter player name!"); } else { tmp = new Player(); tmp.name = txtNewPlayer.Text; tmp.id = new PlayerController().count()+1; PlayerDAO playerDAO = new PlayerDAO(); playerDAO.save(tmp); txtNewPlayer.Text = ""; this.Hide(); new PlayerForm().Show(); } }
public List<Player> selectAllPlayers() { string query = "SELECT * FROM player"; List<Player> list = new List<Player>(); if(this.openConnection() == true){ MySqlCommand cmd = new MySqlCommand(query, connection); MySqlDataReader dataReader = cmd.ExecuteReader(); while(dataReader.Read()){ Player tmp = new Player(); tmp.id = Int32.Parse(dataReader["id"].ToString()); tmp.name = dataReader["name"].ToString(); list.Add(tmp); } dataReader.Close(); this.closeConnection(); } return list; }