Esempio n. 1
0
        public void PlacePiece(Vec2 position)
        {
            if (IsValidPlacement(position))
            {
                Grid[position.x, position.y] = CurrentPlayerPiece;
                CheckForCapture(position);

                Player current = turnCount % 2 == 0 ? p1 : p2;

                if (CheckForWin(position))
                {
                    GamePente.instance?.PlayByPlayList.Add($"{current.Name} Won!");

                    GamePente.instance.dispatcherTimer.Stop();
                    GamePente.Winscreen(current);

                    GamePente.LeaveGame();
                    return; // this ends the game HAHAHA
                }

                //check for tessera

                if (CheckForPattern(position, Tessera.GetPatternFor(CurrentPlayerPiece), false))
                {
                    GamePente.instance?.PlayByPlayList.Add($"{current.Name} made a Tessera!");
                }

                //check for tria

                if (CheckForPattern(position, Tria.GetPatternFor(CurrentPlayerPiece), true))
                {
                    GamePente.instance?.PlayByPlayList.Add($"{current.Name} made a Tria!");
                }

                GamePente.timerF = 20;
                turnCount++;

                if (p2.GetType() == typeof(Computer) && turnCount % 2 == 1)
                {
                    PlacePiece((p2 as Computer).TakeTurn());
                }
            }
        }
Esempio n. 2
0
        public GamePente()
        {
            PlayByPlayList = new ObservableCollection <string>();
            DataContext    = this;

            InitializeComponent();
            GamePente.instance = this;
            BoardControl.InitializeBoard();

            Player1.SetPlayer(ref Manager.instance.p1);
            Player2.SetPlayer(ref Manager.instance.p2);

            dispatcherTimer          = new DispatcherTimer();
            dispatcherTimer.Tick    += new EventHandler(dispatcherTimer_Tick);
            dispatcherTimer.Interval = new TimeSpan(0, 0, 1);
            dispatcherTimer.Start();

            time += "s";
            Timer.DataContext = time;
        }