Ejemplo n.º 1
0
 public GameGrid Clone()
 {
     return(new GameGrid(Width, Height)
     {
         gameArea = (Tile[, ])gameArea.Clone(),
     });
 }
Ejemplo n.º 2
0
        public void clear(Tile t)
        {
            oldGlyphs = (Tile[, ])glyphs.Clone();

            cursorX = 0;
            cursorY = 0;

            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    glyphs[i, j] = t;
                }
            }
        }
Ejemplo n.º 3
0
    void ShuffleGrid()
    {
        List <XY> xyList = new List <XY>();

        Tile[,] tempGrid = (Tile[, ])Grid.Clone();
        for (int x = 0; x < GridWidth; x++)
        {
            for (int y = 0; y < GridWidth; y++)
            {
                xyList.Add(new XY(x, y));
            }
        }

        for (int x = 0; x < GridWidth; x++)
        {
            for (int y = 0; y < GridWidth; y++)
            {
                System.Random rnd   = new System.Random();
                int           index = rnd.Next(xyList.Count);
                XY            xy    = xyList[index];
                Grid[x, y].TileControl.Move(xy);
                //tiles for sure need to instantaneously switch, so i need a dummy grid
                tempGrid[xy.X, xy.Y] = Grid[x, y];
                //
                xyList.RemoveAt(index);
            }
        }
        Grid = (Tile[, ])tempGrid.Clone(); //endlessly shuffling grid is f****n solved mate
    }
Ejemplo n.º 4
0
    private void CycleArray(Tile[,] array, byte piecesIndex)
    {
        Tile[,] tempArray = (Tile[, ])array.Clone();
        byte arrayIndex = piecesIndex;

        for (byte i = 0; i < tempArray.GetLength(0); i++)
        {
            for (byte j = 0; j < tempArray.GetLength(1); j++)
            {
                if (tempArray[i, j].placeble && !CheckForKills(tempArray, pieces[arrayIndex], new Vector2(i, j)))
                {
                    tempArray[i, j].placeble      = false;
                    tempArray[i, j].pieceAttached = pieces[arrayIndex];

                    if (arrayIndex + 1 < pieces.Count)
                    {
                        CycleArray(PlacePieceOnBoard(tempArray, pieces[arrayIndex], new Vector2(i, j)), (byte)(arrayIndex + 1));
                    }
                    else
                    {
                        Tile[,] addArray = (Tile[, ])tempArray.Clone();
                        possibilities.Add(addArray);
                    }

                    tempArray[i, j].placeble      = true;
                    tempArray[i, j].pieceAttached = null;
                }
            }
        }
    }
    public GameState Duplicate()
    {
        GameState newGameState = new GameState(Tiles.Clone() as Tile[, ]);

        newGameState.Width  = Width;
        newGameState.Height = Height;
        newGameState.Moves  = new List <Move>(Moves);
        return(newGameState);
    }
Ejemplo n.º 6
0
 private Tile[,] SetMovementPiecePlacement(List <Vector2> directions, Tile[,] tiles, Vector2 position)
 {
     Tile[,] tempTiles = (Tile[, ])tiles.Clone();
     for (byte i = 0; i < directions.Count; i++)
     {
         Vector2 temp = position + directions[i];
         if (temp.x >= 0 && temp.x < tempTiles.GetLength(0) && temp.y >= 0 && temp.y < tempTiles.GetLength(1))
         {
             tempTiles[(int)temp.x, (int)temp.y].placeble = false;
         }
     }
     return(tempTiles);
 }
Ejemplo n.º 7
0
 private Tile[,] PlacePieceOnBoard(Tile[,] tiles, ChessPieceClass piece, Vector2 position)
 {
     Tile[,] tempArray = (Tile[, ])tiles.Clone();
     if (piece.pieceName == "King" || piece.pieceName == "Knight")
     {
         tempArray = SetMovementPiecePlacement(piece.moveDir, tempArray, position);
     }
     else
     {
         tempArray = DirectionalPiecePlacement(piece.moveDir, tempArray, position);
     }
     return(tempArray);
 }
Ejemplo n.º 8
0
        public object Clone()
        {
            var result = (GameState)MemberwiseClone();

            result.Map            = (Tile[, ])Map.Clone();
            result.Foods          = new List <Food>(Foods.Select(f => (Food)f.Clone()));
            result.MyAnts         = new List <MyAnt>(MyAnts.Select(a => (MyAnt)a.Clone()));
            result.MyAntPositions = new List <Location>(MyAntPositions.Select(ap => (Location)ap.Clone()));
            result.EnemyAnts      = new List <Ant>(EnemyAnts.Select(a => (Ant)a.Clone()));
            result.Hills          = new List <Hill>(Hills.Select(h => (Hill)h.Clone()));
            result.EnemyHills     = new List <Hill>(EnemyHills.Select(h => (Hill)h.Clone()));
            return(result);
        }
Ejemplo n.º 9
0
 public void embaralhar()
 {
     Tile[,] TilesCopia = (Tile[, ])tiles.Clone(); //aqui fez um clone da variavel de arrays tiles?sim    // aqui o shuffle embaralha a matriz, dai tem q fazer a copia para embaralhar no mundo
     Utilities.Shuffle <Tile>(TilesCopia);         //aqui o clone pode ou não estar vazio?  //falta fazer
                                                   //aqui os Tiles são GameObjects?
     for (int i = 0; i < tiles.GetLength(0); i++)
     {
         for (int j = 0; j < tiles.GetLength(1); j++)
         {
             if (TilesCopia != null) //este null quer dizer q a caixa tem lugar para guardar coisas?
             {
                 if (TilesCopia.Length > 0)
                 {
                     tiles[i, j].transform.position = TilesCopia[i, j].transform.position; //para embaralhar neste caso pega o array matriz tiles e o iguala a sua copia?
                 }
             }
         }
     }
 }
Ejemplo n.º 10
0
    public void shuffle()
    {
        Tile[,] tilesCopia = (Tile[, ])tiles.Clone(); // aqui fez um clone do array Tile[,])tiles?

        Utilities.Shuffle <Tile>(tiles);

        /*for (int i = 0; i < tiles.GetLength(0); i++)
         * {
         *  for (int j = 0; j < tiles.GetLength(1); j++)
         *  {
         *      if (tilesCopia != null)
         *      {
         *          if (tilesCopia.Length > 0)
         *          {
         *              tiles[i, j].transform.position = tilesCopia[i, j].transform.position;
         *          }
         *      }
         *  }
         * }*/
    }
Ejemplo n.º 11
0
        public Game Move(Move move)
        {
            Tile[,] tiles = Tiles.Clone() as Tile[, ];
            var game = new Game
            {
                Tiles = tiles
            };

            if (move == null)
            {
                return(game);
            }

            if (move is Move)
            {
                var tile = game.GetTile(move.From);
                game.Set(move.From, Tile.Empty);
                game.Set(move.To, tile);
            }

            if (move is Eat)
            {
                foreach (var toEat in (move as Eat).Eaten)
                {
                    game.Set(toEat, Tile.Empty);
                }
            }

            //Make a queen
            if (move.To.Row == 7 && game.GetTile(move.To) == Tile.White)
            {
                game.Set(move.To, Tile.QueenWhite);
            }
            if (move.To.Row == 0 && game.GetTile(move.To) == Tile.Black)
            {
                game.Set(move.To, Tile.QueenBlack);
            }

            return(game);
        }
Ejemplo n.º 12
0
 private Tile[,] DirectionalPiecePlacement(List <Vector2> directions, Tile[,] tiles, Vector2 position)
 {
     Tile[,] tempTiles = (Tile[, ])tiles.Clone();
     for (byte i = 0; i < directions.Count; i++)
     {
         bool outOfBounds = false;
         int  multiplier  = 1;
         while (!outOfBounds)
         {
             Vector2 temp = position + (directions[i] * multiplier);
             if (temp.x >= 0 && temp.x < tempTiles.GetLength(0) && temp.y >= 0 && temp.y < tempTiles.GetLength(1))
             {
                 tempTiles[(int)temp.x, (int)temp.y].placeble = false;
                 multiplier++;
             }
             else
             {
                 outOfBounds = true;
             }
         }
     }
     return(tempTiles);
 }
Ejemplo n.º 13
0
    void AumentarIlhas()
    {
        //CLONAR O MUNDO PARA UM NOVO ARRAY

        Tile[,] mundoBack = (Tile[, ])mundo.Clone();

        //LOOP PARA PERCORRER E ENCONTRAR APENAS AS ILHAS INICIAIS

        for (int x = 0; x < tamanho; x++)
        {
            for (int y = 0; y < tamanho; y++)
            {
                if (mundoBack[x, y].tipo == tilesTipos[1])
                {
                    //INICIAR O METODO RECURSIVO NUMA DAS ILHAS INICIAIS, PARA COM SORTE CRIAR OS CONTINENTES GRANDES
                    //ESTA AQUI O UNICO SITIO ONDE COLOCAMOS O BOOL FORCE COMO TRUE PORQUE O METODO RECURSIVO
                    //SO VERIFICA SE O TILE E AGUA, MAS AQUI FORÇAMOS A VERIFICAÇAO APESAR DE SER TILE DE TERRA

                    mundo[x, y].AlterarTipo(this, x, y, tamanho, true);
                }
            }
        }
    }
Ejemplo n.º 14
0
 /// <summary>
 /// Initializes a new map layer with an existing map
 /// </summary>
 /// <param name="map"></param>
 public MapLayer(TileMap parent, Tile[,] map)
 {
     this.parent = parent;
     this.map    = (Tile[, ])map.Clone();
 }
Ejemplo n.º 15
0
        //read map file and init game class
        public void Load()
        {
            string[] line = File.ReadAllLines(@"Resources\map.txt");
            H = line.Length;
            foreach (string str in line)
            {
                if (str.Length > W)
                    W = str.Length;
            }
            map = new Tile[H, W];
            for (int i = 0; i < H; i++)
                for (int j = 0; j < W; j++)
                    map[i, j] = Tile.SPACE;

            for (int i = 0; i < line.Length; i++)
                for (int j = 0; j < line[i].Length; j++)
                {
                    switch (line[i][j])
                    {
                        case '#':
                            map[i, j] = Tile.WALL;
                            break;
                        case '$':
                            map[i, j] = Tile.BOX;
                            break;
                        case '.':
                            map[i, j] = Tile.GOAL;
                            break;
                        case '@':
                            map[i, j] = Tile.SPACE;
                            px = ox = j;
                            py = oy = i;
                            break;
                    }
                }

            initmap = (Tile[,]) map.Clone();
            loadAtlas();
            cha = char1[Move.STOP];
            time = DateTime.Now;
        }
Ejemplo n.º 16
0
 public Tile[,] GetDataClone()
 {
     return((Tile[, ])m_data.Clone());
 }
 /// <summary>constructs a tilemaps from a Tile[][].</summary>
 /// <param name="m"> a matrix of Tiles.</param>
 public TileMapImpl(Tile[,] m)
 {
     map = (Tile[, ])m.Clone();
 }
Ejemplo n.º 18
0
 public TileMap(int width, int height, Tile[,] tiles)
 {
     this.width  = width;
     this.height = height;
     this.tiles  = (Tile[, ])tiles.Clone();
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Get a 2D byte array of 0s and 1s corresponding to floors and walls respectively.
 /// </summary>
 public byte[,] ToByteArray()
 {
     return((byte[, ])grid.Clone());
 }
Ejemplo n.º 20
0
 public MapLayer(Tile[,] map)
 {
     this.map = map.Clone() as Tile[, ];
 }
Ejemplo n.º 21
0
 public Tile[,] TilesClone()
 {
     return(tiles.Clone() as Tile[, ]);
 }
Ejemplo n.º 22
0
 public MapLayer(Tile[,] map)
 {
     this.map = (Tile[, ])map.Clone();
 }
Ejemplo n.º 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MapLayer"/> class.
 /// </summary>
 /// <param name="layerName"> The name of the layer. </param>
 /// <param name="map"> The map to make a layer from. </param>
 public MapLayer(string layerName, Tile[,] map)
 {
     this.LayerName = layerName;
     this.map       = (Tile[, ])map.Clone();
 }