示例#1
0
        public QuatroInterface(QuatroPlayer player1, QuatroPlayer player2, QuatroOptions options)
        {
            InitializeComponent();

            this.player1 = player1;
            this.player2 = player2;

            player1.mainThread = this.Dispatcher;
            player2.mainThread = this.Dispatcher;

            player1Control.Content = player1.GetFeedbackControl();
            player2Control.Content = player2.GetFeedbackControl();

            this.options = options;

            fieldUI = new Button[7, 9];

            //visual initialization
            StackPanel columnStacks = new StackPanel();
            columnStacks.Orientation = Orientation.Horizontal;
            playGrid.Children.Add(columnStacks);

            for(int i=0;i<9;i++)
            {
                StackPanel column = new StackPanel();
                column.Orientation = Orientation.Vertical;

                columnStacks.Children.Add(column);

                for(int j=6;j>=0;j--)
                {
                    Button slot = new Button();
                    slot.Width = 50;
                    slot.Height = 50;
                    fieldUI[j, i] = slot;
                    GameCoords coords = new GameCoords(j, i);

                    slot.DataContext = coords;
                    slot.Click += slot_Click;
                    slot.Content = "(" + j + "," + i + ")";

                    column.Children.Add(slot);
                }

                Label columnNumber = new Label();
                columnNumber.Content = "" + i;
                columnNumber.FontSize = 16;
                columnNumber.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center;
                column.Children.Add(columnNumber);
            }

            slotImage = new BitmapImage(new Uri("s0.png", UriKind.Relative));
            p1Image = new BitmapImage(new Uri("s1.png", UriKind.Relative));
            p2Image = new BitmapImage(new Uri("s2.png", UriKind.Relative));

            player1ScoreLabel.Content = "0";
            player2ScoreLabel.Content = "0";

            StartNewGame();
        }
示例#2
0
        public QuatroGame(QuatroPlayer player1, QuatroPlayer player2, QuatroOptions options)
        {
            this.options = options;
            turnTime = (int)(options.turnSeconds * 100);

            state = QuatroGameState.Idle;

            this.player1 = player1;
            this.player2 = player2;

            //time mechanics
            dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
            dispatcherTimer.Tick += UpdateTimer;
            dispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 10);

            field = new QuatroField();

            player1.StartGame();
            player2.StartGame();

            if (options.automaticPlay != QuatroOptions.AutomaticPlay.StepAnalysis)
                NextGameStep();
        }
示例#3
0
        public void StartGame()
        {
            state = ManagerState.Playing;
            ManagerInterface.SelectedIndex = 1;

            //fecth selection
            int AI1 = player1AIs.SelectedIndex;
            int AI2 = player2AIs.SelectedIndex;

            //In case of unselected AI's, go with first one
            if (AI1 == -1)
                AI1 = 0;
            if (AI2 == -1)
                AI2 = 0;

            QuatroPlayer player1 = allAIs[AI1].creator();
            QuatroPlayer player2 = allAIs[AI2].creator();

            QuatroOptions options = new QuatroOptions();
            switch(automaticComboBox.SelectedIndex)
            {
                case 0:
                    options.automaticPlay = QuatroOptions.AutomaticPlay.StepAnalysis;
                    break;
                case 1:
                    options.automaticPlay = QuatroOptions.AutomaticPlay.Regular;
                    break;
                case 2:
                    options.automaticPlay = QuatroOptions.AutomaticPlay.Automatic;
                    break;
            }
            options.turnSeconds = 10f;

            quatroInterface = new QuatroInterface(player1, player2, options);
            quatroInterface.Finished += GoToAIPanel;

            GameControl.Content = quatroInterface;
        }