Beispiel #1
0
        private void startbtn_Click(object sender, EventArgs e)
        {
            try
            {
                ExitAllPlayer();

                Task.WaitAll(Task.Delay(TimeSpan.FromSeconds(1)));
                var processes = StartPlayersByConsole();
                var l         = processes.Length;
                for (var i = 0; i < l; i++)
                {
                    var process = processes[i];
                    var index   = i;
                    var thread  = new Thread(() =>
                    {
                        var opera = new GameOperator(process, index);
                    });

                    thread.Start();
                    _threads.Add(thread);
                }
            }
            catch (Exception ex)
            {
                ExitAllPlayer();
                MessageBox.Show(ex.Message);
                LogHelper.LogError(ex);
            }
        }
 void Awake()
 {
     if (Instance == null)
     {
         Instance = this;
     }
 }
Beispiel #3
0
 public Match()
 {
     gameOperator         = new GameOperator();
     spriteBatch          = new SpriteBatch(Global.Instance.Graphics);
     returnToMenu         = new Button();
     continueGame         = new Button();
     setting              = new Button();
     save                 = new Button();
     pauseScreen          = new BasicEntity();
     playerOneInstruction = new TextEntity();
     playerTwoInstruction = new TextEntity();
 }
Beispiel #4
0
 public Match()
 {
     gameOperator = new GameOperator();
     returnToMenu = new Button();
 }
Beispiel #5
0
        public bool PlayMove(int column, int line, bool isWhite)
        {
            Dictionary <Tuple <int, int>, HashSet <Tuple <int, int> > > listPossibleMoves = GameOperator.GetPossibleMoves(board, isWhite);
            Tuple <int, int> position = new Tuple <int, int>(column, line);

            if (!listPossibleMoves.ContainsKey(position))
            {
                return(false);
            }

            HashSet <Tuple <int, int> > discsToFlip = listPossibleMoves[position];
            int value = isWhite ? GameProperties.WHITE : GameProperties.BLACK;

            foreach (Tuple <int, int> disc in discsToFlip)
            {
                board[disc.Item1, disc.Item2] = value;
            }
            return(true);
        }
Beispiel #6
0
 public bool IsPlayable(int column, int line, bool isWhite)
 {
     return(GameOperator.ValidateMove(board, new Tuple <int, int>(column, line), isWhite?GameProperties.WHITE:GameProperties.BLACK));
 }
Beispiel #7
0
 public int GetWhiteScore()
 {
     return(GameOperator.GetDiscs(board, GameProperties.WHITE).Count);
 }
Beispiel #8
0
 public int GetBlackScore()
 {
     return(GameOperator.GetDiscs(board, GameProperties.BLACK).Count);
 }
Beispiel #9
0
 // Use this for initialization
 void Start()
 {
     GameOperator.instance = this.gameObject.GetComponent<GameOperator>();
     this.Mode = OperatorMode.IDLE;
 }