Пример #1
0
 private void generateBoard()
 {
     Random rnd = new Random();
     for (int x = 0; x < BOARDSIZEX; x++)
     {
         for (int y = 0; y < BOARDSIZEY; y++)
         {
             if ((x + y) >= (BOARDSIZEX + BOARDSIZEY) / 2)
             {
                 Texture2D rndText = defaultUrbanTextures[rnd.Next(0, defaultUrbanTextures.Count)];
                 board[x, y] = new Tile(x, y, true, rndText, rnd.Next(0, 1000000));
             }
             else if ((x + y) < (BOARDSIZEX + BOARDSIZEY) / 2)
             {
                 Texture2D rndText = defaultForestTextures[rnd.Next(0, defaultForestTextures.Count)];
                 board[x, y] = new Tile(x, y, false, rndText, rnd.Next(0, 1000000));
             }
         }
     }
 }
Пример #2
0
        private void performClickAction(Vector2 coords)
        {
            Thread thread;

            if (selectedTile != null && coords.X == -1) // Narrow clicked
            {
                thread = new Thread(new ThreadStart(narrowAttack));
                thread.Start();
            }
            else if (selectedTile != null && coords.X == -2) // Broad clicked
            {
                thread = new Thread(new ThreadStart(broadAttack));
                thread.Start();
            }
            else if (selectedTile != null && coords.X == -3) // Fire clicked
            {
                thread = new Thread(new ThreadStart(fireAttack));
                thread.Start();
            }
            else if (selectedTile != null && coords.X == -4) // Water clicked
            {
                thread = new Thread(new ThreadStart(waterAttack));
                thread.Start();
            }
            else if (selectedTile != null && coords.X == -5) // Upgrade clicked
            {
                thread = new Thread(new ThreadStart(upgradeUnit));
                thread.Start();
            }
            else if (coords.X >= 0 ) // Tile clicked
            {
                if (board[(int)coords.X, (int)coords.Y].faction == thisPlayer.faction)
                selectedTile = board[(int)coords.X, (int)coords.Y];
            }
            else
            {
                selectedTile = null;
            }
        }
Пример #3
0
        private void checkForMouseClicks()
        {
            currMouseState = Mouse.GetState();

            if (prevMouseState.LeftButton == ButtonState.Released && currMouseState.LeftButton == ButtonState.Pressed)
            {
                performClickAction(detectTileClicked(prevMouseState.X, prevMouseState.Y));
            }
            else if (prevMouseState.RightButton == ButtonState.Released && currMouseState.RightButton == ButtonState.Pressed)
            {
                selectedTile = null;
            }
            prevMouseState = Mouse.GetState();
        }