public void Reset() { myState = AIState.Idle; stuckPlayer = null; crate = null; chasePlayer = null; hasBombPlayer = null; myLSB = null; theirLSB = null; movementFrozen = false; lastNode = null; //bools for timers wasMovingRight = false; wasMovingLeft = false; justJumped = false; justThrew = false; //timers for firing events freezeTimer = new AITimer(45); throwTimer = new AITimer(40); jumpTimer = new AITimer(20); playerChaseTimer = new AITimer(60); confusedTimer = new AITimer(30); directionSwitchedCount = 0; }
private void Check()// проверка на комбинации кнопок { if (button1.Text == "X" && button2.Text == "X" && button3.Text == "X" && button4.Text == "X" || button7.Text == "X" && button5.Text == "X" && button6.Text == "X" && button8.Text == "X" || button9.Text == "X" && button10.Text == "X" && button11.Text == "X" && button12.Text == "X" || button13.Text == "X" && button14.Text == "X" && button15.Text == "X" && button16.Text == "X" || button1.Text == "X" && button8.Text == "X" && button12.Text == "X" && button16.Text == "X" || button2.Text == "X" && button7.Text == "X" && button11.Text == "X" && button15.Text == "X" || button3.Text == "X" && button6.Text == "X" && button10.Text == "X" && button14.Text == "X" || button4.Text == "X" && button5.Text == "X" && button9.Text == "X" && button13.Text == "X" || button1.Text == "X" && button7.Text == "X" && button10.Text == "X" && button13.Text == "X" || button4.Text == "X" && button6.Text == "X" && button11.Text == "X" && button16.Text == "X" ) { AITimer.Stop(); // остановка таймера компьютера MessageBox.Show("Игрок победил!"); playerWins++; // прибавление к Игроку 1 победы label4.Text = "" + playerWins; //вывод в Label resetGame(); // автоперезапуск уровня } else if (button1.Text == "O" && button2.Text == "O" && button3.Text == "O" && button4.Text == "O" || button7.Text == "O" && button5.Text == "O" && button6.Text == "O" && button8.Text == "O" || button9.Text == "O" && button10.Text == "O" && button11.Text == "O" && button12.Text == "O" || button13.Text == "O" && button14.Text == "O" && button15.Text == "O" && button16.Text == "O" || button1.Text == "O" && button8.Text == "O" && button12.Text == "O" && button16.Text == "O" || button2.Text == "O" && button7.Text == "O" && button11.Text == "O" && button15.Text == "O" || button3.Text == "O" && button6.Text == "O" && button10.Text == "O" && button14.Text == "O" || button4.Text == "O" && button5.Text == "O" && button9.Text == "O" && button13.Text == "O" || button1.Text == "O" && button7.Text == "O" && button10.Text == "O" && button13.Text == "O" || button4.Text == "O" && button6.Text == "O" && button11.Text == "O" && button16.Text == "O") { AITimer.Stop(); MessageBox.Show("Компьютер победил!"); computerWins++;// прибавление к Компьютеру 1 победы label5.Text = "" + computerWins; // resetGame();// см. выше } else if (!(button1.Text == "X" && button2.Text == "X" && button3.Text == "X" && button4.Text == "X" || button7.Text == "X" && button5.Text == "X" && button6.Text == "X" && button8.Text == "X" || button9.Text == "X" && button10.Text == "X" && button11.Text == "X" && button12.Text == "X" || button13.Text == "X" && button14.Text == "X" && button15.Text == "X" && button16.Text == "X" || button1.Text == "X" && button8.Text == "X" && button12.Text == "X" && button16.Text == "X" || button2.Text == "X" && button7.Text == "X" && button11.Text == "X" && button15.Text == "X" || button3.Text == "X" && button6.Text == "X" && button10.Text == "X" && button14.Text == "X" || button4.Text == "X" && button5.Text == "X" && button9.Text == "X" && button13.Text == "X" || button1.Text == "X" && button7.Text == "X" && button10.Text == "X" && button13.Text == "X" || button4.Text == "X" && button6.Text == "X" && button11.Text == "X" && button16.Text == "X") && !(button1.Text == "O" && button2.Text == "O" && button3.Text == "O" && button4.Text == "O" || button7.Text == "O" && button5.Text == "O" && button6.Text == "O" && button8.Text == "O" || button9.Text == "O" && button10.Text == "O" && button11.Text == "O" && button12.Text == "O" || button13.Text == "O" && button14.Text == "O" && button15.Text == "O" && button16.Text == "O" || button1.Text == "O" && button8.Text == "O" && button12.Text == "O" && button16.Text == "O" || button2.Text == "O" && button7.Text == "O" && button11.Text == "O" && button15.Text == "O" || button3.Text == "O" && button6.Text == "O" && button10.Text == "O" && button14.Text == "O" || button4.Text == "O" && button5.Text == "O" && button9.Text == "O" && button13.Text == "O" || button1.Text == "O" && button7.Text == "O" && button10.Text == "O" && button13.Text == "O" || button4.Text == "O" && button6.Text == "O" && button11.Text == "O" && button16.Text == "O")) { } }
private void Check()// проверка на комбинации кнопок { curretPlayer = Player.X; if (button1.Text == "X" && button2.Text == "X" && button3.Text == "X" || button4.Text == "X" && button5.Text == "X" && button6.Text == "X" || button7.Text == "X" && button9.Text == "X" && button8.Text == "X" || button1.Text == "X" && button4.Text == "X" && button7.Text == "X" || button2.Text == "X" && button5.Text == "X" && button8.Text == "X" || button3.Text == "X" && button6.Text == "X" && button9.Text == "X" || button1.Text == "X" && button5.Text == "X" && button9.Text == "X" || button3.Text == "X" && button5.Text == "X" && button7.Text == "X") { AITimer.Stop(); // остановка таймера компьютера MessageBox.Show("Игрок победил!"); playerWins++; // прибавление к Игроку 1 победы label3.Text = "" + playerWins; //вывод в Label resetGame(); // автоперезапуск уровня } else if (button1.Text == "O" && button2.Text == "O" && button3.Text == "O" || button4.Text == "O" && button5.Text == "O" && button6.Text == "O" || button7.Text == "O" && button9.Text == "O" && button8.Text == "O" || button1.Text == "O" && button4.Text == "O" && button7.Text == "O" || button2.Text == "O" && button5.Text == "O" && button8.Text == "O" || button3.Text == "O" && button6.Text == "O" && button9.Text == "O" || button1.Text == "O" && button5.Text == "O" && button9.Text == "O" || button3.Text == "O" && button5.Text == "O" && button7.Text == "O") { AITimer.Stop(); MessageBox.Show("Компьютер победил!"); computerWins++; // прибавление к Компьютеру 1 победы label2.Text = "" + computerWins; resetGame(); // см. выше } else if ((curretPlayer.ToString()) /*&& (!(button1.Text == "O" && button2.Text == "O" && button3.Text == "O" || * * button4.Text == "O" && button5.Text == "O" && button6.Text == "O" || * button7.Text == "O" && button9.Text == "O" && button8.Text == "O" || * button1.Text == "O" && button4.Text == "O" && button7.Text == "O" || * button2.Text == "O" && button5.Text == "O" && button8.Text == "O" || * button3.Text == "O" && button6.Text == "O" && button9.Text == "O" || * button1.Text == "O" && button5.Text == "O" && button9.Text == "O" || * button3.Text == "O" && button5.Text == "O" && button7.Text == "O"))&&( * !(button1.Text == "X" && button2.Text == "X" && button3.Text == "X" || * button4.Text == "X" && button5.Text == "X" && button6.Text == "X" || * button7.Text == "X" && button9.Text == "X" && button8.Text == "X" || * button1.Text == "X" && button4.Text == "X" && button7.Text == "X" || * button2.Text == "X" && button5.Text == "X" && button8.Text == "X" || * button3.Text == "X" && button6.Text == "X" && button9.Text == "X" || * button1.Text == "X" && button5.Text == "X" && button9.Text == "X" || * button3.Text == "X" && button5.Text == "X" && button7.Text == "X"))*/) { MessageBox.Show("ничья"); } }
private void playerClick(object sender, EventArgs e)// проверк анажатий на кнопки { var button = (Button)sender; curretPlayer = Player.X; button.Text = curretPlayer.ToString();//установка параметра отображения на кнопки button.Enabled = false; buttons.Remove(button); Check(); AITimer.Start(); }
private void buttonClick(object sender, EventArgs e) { var button = (Button)sender; currentPlayer = Player.X; button.Text = currentPlayer.ToString(); button.Enabled = false; button.BackColor = System.Drawing.Color.LightBlue; Check(); AITimer.Start(); }
private void AITimer_Tick(object sender, EventArgs e) { if (buttons.Count > 0) { int index = rand.Next(buttons.Count); buttons[index].Enabled = false; curretPlayer = Player.O; buttons[index].Text = curretPlayer.ToString(); buttons.RemoveAt(index); Check(); AITimer.Stop(); } }
private void playAI(object sender, EventArgs e) { foreach (Control x in this.Controls) { if (x is Button && x.Text == "?" && x.Enabled) { x.Enabled = false; currentPlayer = Player.O; x.Text = currentPlayer.ToString(); x.BackColor = System.Drawing.Color.LightGoldenrodYellow; AITimer.Stop(); Check(); break; } else { AITimer.Stop(); } } }