Exemplo n.º 1
0
        private bool VerifierRow(Button mybutton)
        {
            int    indexCase = Convert.ToInt32(mybutton.Name.Replace("Button", ""));
            int    indexRow  = indexCase % 10;
            Button btn1      = (Button)GridGame.FindName("Button" + indexRow);
            Button btn2      = (Button)GridGame.FindName("Button" + (indexRow + 10));
            Button btn3      = (Button)GridGame.FindName("Button" + (indexRow + 20));
            int    somme     = (btn1.Content.ToString() == morpion[0]) ? 0 : (btn1.Content.ToString() == morpion[1]) ? 1 : 4;

            somme += (btn2.Content.ToString() == morpion[0]) ? 0 : (btn2.Content.ToString() == morpion[1]) ? 1 : 4;
            somme += (btn3.Content.ToString() == morpion[0]) ? 0 : (btn3.Content.ToString() == morpion[1]) ? 1 : 4;
            //Winner.Text = "R : " + somme + " - " + (somme < 4 && somme % 3 == 0).ToString();
            //Winner.Text += "\n" + btn1.Content;
            //Winner.Text += " - " + btn2.Content;
            //Winner.Text += " - " + btn3.Content;
            if (somme < 4 && somme % 3 == 0)
            {
                if (winner != 0)
                {
                    btn1.Foreground = new SolidColorBrush(Colors.Gold);
                    btn2.Foreground = new SolidColorBrush(Colors.Gold);
                    btn3.Foreground = new SolidColorBrush(Colors.Gold);
                }
                return(true);
            }


            return(false);
        }
Exemplo n.º 2
0
 public void Initialize(Score score, Preview preview, GridGame gridGame, List <Dictionary <ControlType, KeyCode> > controlKey)
 {
     m_score      = score;
     m_preview    = preview;
     m_gridGame   = gridGame;
     m_controlKey = controlKey;
 }
Exemplo n.º 3
0
 private Button JeuDifficile()
 {
     if (buttonsIndex.Count > 0 && buttonsIndex.Count < 8)
     {
         foreach (int index in buttonsIndex)
         {
             Button btn        = (Button)GridGame.FindName("Button" + (index));
             string btnContent = btn.Content.ToString();
             btn.Content = morpion[morpionIndex % 2];
             if (VerifierColumn(btn) || VerifierRow(btn) || VerifierDiagonal(btn))
             {
                 return(btn);
             }
             else
             {
                 btn.Content = btnContent;
             }
         }
         foreach (int index in buttonsIndex)
         {
             Button btn        = (Button)GridGame.FindName("Button" + (index));
             string btnContent = btn.Content.ToString();
             btn.Content = morpion[(morpionIndex + 1) % 2];
             if (VerifierColumn(btn) || VerifierRow(btn) || VerifierDiagonal(btn))
             {
                 return(btn);
             }
             else
             {
                 btn.Content = btnContent;
             }
         }
     }
     return(JeuFacile());
 }
Exemplo n.º 4
0
        public GameHubProcessor(
            ILogger <GameHubProcessor> logger,
            FilePluginLoader <IProcessorPlugin <IProcessorData <CommandModel> > > commandPluginLoader,
            FilePluginLoader <IEventPlugin> eventLoader,
            IServiceProvider serviceProvider,
            IGame game
            )
        {
            _logger = logger;
            _game   = (GridGame)game;


            eventLoader.LoadPlugins("./plugins/");
            var _eventPlugins = eventLoader.Plugins.ToList();

            _eventPlugins.ForEach((eplugin) => {
                _logger.LogDebug($"Configure Event Plugin {eplugin.Name}");
                eplugin.Configure(_game, serviceProvider);
            });

            commandPluginLoader.LoadPlugins("./plugins/");
            _commandPlugins = commandPluginLoader.Plugins;
            _commandPlugins.ToList().ForEach((plugin) =>
            {
                _logger.LogDebug($"Configure Command Plugin {plugin.Name}");
                plugin.Configure(game, serviceProvider);
            });
        }
Exemplo n.º 5
0
 public void Configure(IGame game, IServiceProvider serviceProvider)
 {
     Game                = (GridGame)game;
     _logger             = (ILogger <AfterPlayerDeathPlugin>)serviceProvider.GetService(typeof(ILogger <AfterPlayerDeathPlugin>));
     Game.PlayerAdded   += PlayerLoggedIn;
     Game.PlayerRemoved += PlayerLoggedOut;
 }
Exemplo n.º 6
0
    public void Initialize(GridGame gridGame)
    {
        m_gridGame = gridGame;
        //подписка на событие методом, который будет исполнятся по заполнению линии
        m_gridGame.LineFull += ClearedLine;

        Plus  += Up;
        Minus += Down;
    }
Exemplo n.º 7
0
 private Button JeuExpert()
 {
     if (buttonsIndex.Count > 7)
     {
         int index = (buttonsIndex.Contains(11)) ? 11 : (buttonsIndex.Contains(0)) ? 0 : 22;
         return((Button)GridGame.FindName("Button" + (index)));
     }
     return(JeuDifficile());
 }
Exemplo n.º 8
0
        public ActionResult Reset()
        {
            var game = new GridGame();

            game.Randomize();
            Session["GridGame"] = game;

            return(View("ShowGrid", game));
        }
Exemplo n.º 9
0
        void checkGameOver(GridGame game, int player, Move m)
        {
            int winner;
            GameOver = CheckGameOver(game.Board, out winner);

            if (GameOver)
                Winner = winner;

            setValidNextMoves();
        }
Exemplo n.º 10
0
    public void Initialize(Vector3 position, List <Dictionary <ControlType, KeyCode> > controlKey)
    {
        GridGame gridGame = Instantiate(gridGamePrefab, position + gridPosition, Quaternion.identity, transform);
        Score    score    = Instantiate(scorePrefab, 22 * position + scorePosition, Quaternion.identity, canvas);

        score.Initialize(gridGame);
        Preview preview = Instantiate(previewPrefab, position + previewPosition, Quaternion.identity, transform);

        preview.Initialize(score, gridGame, controlKey);
    }
Exemplo n.º 11
0
        void checkGameOver(GridGame game, int movingPlayer, int curPlayer, Move m)
        {
			int winner;
			GameOver = CheckGameOver(Board, out winner);
			
            if(GameOver)
                Winner = winner;

            setValidNextMoves();
        }
Exemplo n.º 12
0
        void checkGameOver(GridGame game, int movingPlayer, int curPlayer, Move m)
        {
            int winner;
            GameOver = CheckGameOver(Board, out winner);

            if (GameOver)
                Winner = winner;

            // if the game is not over, set the valid next moves
            setValidNextMoves();
        }
Exemplo n.º 13
0
        public GameService(IOptions <GameServiceSettings> settings,
                           ILogger <GameService> logger,
                           IGame game,
                           GameHubProcessor gameHubProcessor)
        {
            _logger = logger;
            _logger.LogDebug($"ctor {nameof(GameService)}");
            _settings = settings.Value;

            Game = (GridGame)game;
        }
Exemplo n.º 14
0
 public FrmMain()
 {
     BmclCore.NIcon.MainWindow = this;
     BmclCore.MainWindow       = this;
     InitializeComponent();
     Title = "BMCL Ver." + BmclCore.BmclVersion;
     LoadConfig();
     GridGame.ReFlushlistver();
     GridGame.listVer.SelectedItem = BmclCore.Config.LastPlayVer;
     BmclCore.SingleInstance(this);
 }
Exemplo n.º 15
0
        private void tabMain_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (_lasttabMainSelectIndex == TabMain.SelectedIndex)
            {
                return;
            }
            _lasttabMainSelectIndex = TabMain.SelectedIndex;
            if (!LoadOk)
            {
                return;
            }
            var da1 = new DoubleAnimation(0, TabMain.ActualWidth, new Duration(new TimeSpan(0, 0, 0, 0, 100)));
            var da2 = new DoubleAnimation(0, TabMain.ActualHeight, new Duration(new TimeSpan(0, 0, 0, 0, 100)));

            switch (TabMain.SelectedIndex)
            {
            case 0:
                GridGame.BeginAnimation(FrameworkElement.WidthProperty, da1); GridGame.BeginAnimation(FrameworkElement.HeightProperty, da2);
                break;

            case 1:
                GridConfig.BeginAnimation(FrameworkElement.WidthProperty, da1); GridConfig.BeginAnimation(FrameworkElement.HeightProperty, da2);
                break;

            case 2:
                GridVersion.BeginAnimation(FrameworkElement.WidthProperty, da1); GridVersion.BeginAnimation(FrameworkElement.HeightProperty, da2);
                if (GridVersion.btnRefreshRemoteVer.IsEnabled && GridVersion.listRemoteVer.HasItems == false)
                {
                    GridVersion.RefreshVersion();
                }
                break;

            case 3:
                GridForge.BeginAnimation(FrameworkElement.WidthProperty, da1); GridForge.BeginAnimation(FrameworkElement.HeightProperty, da2);
                if (GridForge.btnReForge.IsEnabled && GridForge.treeForgeVer.HasItems == false)
                {
                    GridForge.RefreshForge();
                }
                break;

            case 4:
                GridServer.BeginAnimation(FrameworkElement.WidthProperty, da1); GridServer.BeginAnimation(FrameworkElement.HeightProperty, da2);
                if (GridServer.btnReflushServer.IsEnabled && GridServer.listServer.HasItems == false)
                {
                    GridServer.ReflushSever();
                }
                break;

            case 5:
                gridUpdateInfo.BeginAnimation(FrameworkElement.WidthProperty, da1);
                gridUpdateInfo.BeginAnimation(FrameworkElement.HeightProperty, da2);
                break;
            }
        }
Exemplo n.º 16
0
 public FrmMain()
 {
     BmclCore.NIcon.MainWindow = this;
     BmclCore.MainWindow       = this;
     InitializeComponent();
     this.Title = "BMCL V2 Ver." + BmclCore.BmclVersion;
     this.LoadConfig();
     GridGame.ReFlushlistver();
     GridGame.listVer.SelectedItem         = BmclCore.Config.LastPlayVer;
     GridConfig.checkCheckUpdate.IsChecked = BmclCore.Config.CheckUpdate;
 }
Exemplo n.º 17
0
 private Button JeuFacile()
 {
     if (buttonsIndex.Count > 0)
     {
         var    rand        = new Random();
         int    buttonIndex = rand.Next(buttonsIndex.Count);
         Button btn         = (Button)GridGame.FindName("Button" + (buttonsIndex[buttonIndex]));
         return(btn);
     }
     return(null);
 }
Exemplo n.º 18
0
 public void Configure(IGame game, IServiceProvider serviceProvider)
 {
     Game              = (GridGame)game;
     Game.PlayerAdded += AfterPlayerLogin;
 }
Exemplo n.º 19
0
 public static void Main(string[] args)
 {
     using (var game = new GridGame())
         game.Run();
 }
Exemplo n.º 20
0
 void agentPassed(GridGame game, int movingPlayer, int curPlayer)
 {
     setValidNextMoves();
 }
Exemplo n.º 21
0
        private async void btnStart_Click(object sender, RoutedEventArgs e)
        {
            //TODO 分离launcher方法
            if (GridConfig.txtUserName.Text == "!!!")
            {
                MessageBox.Show(this, "请先修改用户名");
                TabMain.SelectedIndex = 1;
                GridConfig.txtUserName.Focus();
                return;
            }
            GridConfig.SaveConfig();
            var somethingBad = false;

            try
            {
                var selectedVersion = GridGame.GetSelectedVersion();
                Logger.Info($"正在启动{selectedVersion},使用的登陆方式为{GridConfig.listAuth.SelectedItem}");
                _frmPrs = new FrmPrs(LangManager.GetLangFromResource(selectedVersion));
                _frmPrs.Show();
                _frmPrs.ChangeStatus(LangManager.GetLangFromResource("LauncherAuth"));
                var launcher = await BmclCore.GameManager.LaunchGame(selectedVersion, false);

                if (launcher == null)
                {
                    _frmPrs.Close();
                    _frmPrs = null;
                    return;
                }
                launcher.OnGameLaunch += Launcher_OnGameLaunch;
                launcher.OnGameStart  += Game_GameStartUp;
                launcher.OnGameExit   += launcher_gameexit;
                await launcher.Start();
            }
            catch (NoSelectGameException exception)
            {
                Logger.Fatal(exception);
                somethingBad = true;
                MessageBox.Show(this, exception.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (NoJavaException exception)
            {
                Logger.Fatal(exception);
                somethingBad = true;
                MessageBox.Show(this, exception.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (AnotherGameRunningException exception)
            {
                Logger.Fatal(exception);
                somethingBad = true;
                MessageBox.Show(this, exception.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            catch (DownloadLibException exception)
            {
                Logger.Fatal(exception);
                somethingBad = true;
                MessageBox.Show(this, exception.Message, Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                if (somethingBad)
                {
                    _frmPrs?.Close();
                    _frmPrs = null;
                }
            }
        }
Exemplo n.º 22
0
        private void 排块游戏ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GridGame gg = new GridGame();

            gg.Show();
        }
Exemplo n.º 23
0
 void flipPiecesAndCheckGameOver(GridGame game, int movingPlayer, int curPlayer, Move m)
 {
     FlipPieces(movingPlayer, m, Board);
     checkGameOver(game, movingPlayer, m);
 }
Exemplo n.º 24
0
        static void Main(string[] args)
        {
            GridGame  game = new GridGame();
            Player    p1   = new Player('X');
            Player    p2   = new Player('O');
            IAManager IA   = new IAManager();

            int menu;

            do
            {
                Console.WriteLine(" 1 - Jogar vs IA");
                Console.WriteLine(" 2 - Jogar vs Player");
                Console.WriteLine(" 0 - Sair");

                Console.Write(" Escolha: ");
                menu = int.Parse(Console.ReadLine());

                Console.Clear();

                switch (menu)
                {
                // Versus IA
                case 1: {
                    char turn = 'X';
                    while (p1.SetName())
                    {
                        Console.Clear();
                    }

                    game.InitiateGrid();

                    do
                    {
                        Console.Clear();
                        Console.WriteLine(game);

                        switch (turn)
                        {
                        case 'X': {
                            turn = p1.Move(game);
                            break;
                        }

                        case 'O': {
                            turn = IA.Move(game);
                            break;
                        }
                        }

                        Console.Clear();
                    } while (GameManager.Verify(game, p1.Name, IA.Name) >= 3);

                    Console.Clear();
                    break;
                }

                // Versus Player
                case 2: {
                    char turn = 'X';
                    while (p1.SetName())
                    {
                        Console.Clear();
                    }
                    while (p2.SetName())
                    {
                        Console.Clear();
                    }

                    game.InitiateGrid();

                    do
                    {
                        Console.Clear();
                        Console.WriteLine(game);

                        switch (turn)
                        {
                        case 'X': {
                            turn = p1.Move(game);
                            break;
                        }

                        case 'O': {
                            turn = p2.Move(game);
                            break;
                        }
                        }

                        Console.Clear();
                    } while (GameManager.Verify(game, p1.Name, p2.Name) >= 3);

                    Console.Clear();
                    break;
                }
                }
            } while (menu != 0);
        }
Exemplo n.º 25
0
        public void WhenGridIsCreatedThenIsNotNull()
        {
            var grid = new GridGame(5, 5);

            Assert.IsNotNull(grid);
        }
Exemplo n.º 26
0
 public void Configure(IGame game, IServiceProvider serviceProvider)
 {
     Game = (GridGame)game;
     Game.World.PlayerMoved += HandleMapChanged;
 }