complete, step before doing ai
This commit is contained in:
56
Box.cs
Normal file
56
Box.cs
Normal file
@@ -0,0 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TicTacToe
|
||||
{
|
||||
public class Box
|
||||
{
|
||||
public Action<int> Pressed;
|
||||
public int Index;
|
||||
public bool BotOwned = false;
|
||||
private Button _button;
|
||||
public bool Filled = false;
|
||||
|
||||
public Box(Button button, int index)
|
||||
{
|
||||
_button = button;
|
||||
Index = index;
|
||||
button.Click += Clicked;
|
||||
_button.Text = "";
|
||||
}
|
||||
|
||||
private void Clicked(object sender, EventArgs e)
|
||||
{
|
||||
Pressed.Invoke(Index);
|
||||
}
|
||||
|
||||
public void Destroy()
|
||||
{
|
||||
_button.Text = "";
|
||||
_button.Click -= Clicked;
|
||||
}
|
||||
|
||||
public void SetEnabled(bool value)
|
||||
{
|
||||
_button.Enabled = value;
|
||||
}
|
||||
|
||||
public void PlayerClaim(bool bot)
|
||||
{
|
||||
Filled = true;
|
||||
BotOwned = bot;
|
||||
if (bot)
|
||||
{
|
||||
_button.Text = "O";
|
||||
}
|
||||
else
|
||||
{
|
||||
_button.Text = "X";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user