internal TileInstance(Tile Tile, int X, int Y, int Z)
 {
     this.Tile = Tile;
     this.X = X;
     this.Y = Y;
     this.Z = Z;
 }
예제 #2
0
        private PassCode pc; //passcode for case

        #endregion Fields

        #region Constructors

        /*
         * Gives each place in the Floor a Tile class
         *
         * See Tile for more information
         */
        public Floor(int number, PassCode pc, bool[] have, Coordinate[] elevators, GameState gs)
        {
            this.number = number;
            this.floor = new Tile[Globals.FLOOR_LENGTH, Globals.FLOOR_WIDTH];
            this.doorPC = null;
            this.elevators = new Coordinate[Constants.NUM_ELEVATORS];
            this.coordinates = new ArrayList();

            //Prevent certain items from overlapping on the same tile

            for (int i = 0; i < Globals.FLOOR_LENGTH; i++)
                for (int j = 0; j < Globals.FLOOR_WIDTH; j++)
                {
                    floor[i, j] = new Tile();
                    Constants.taken[i, j] = false;
                }

            for (int i = 0; i < Constants.NUM_ELEVATORS; i++)
            {
                Constants.taken[elevators[i].x, elevators[i].y] = true;
            }

            //Call a random architect function
            int x = Constants.randGen.Next(0, architect.GetUpperBound(0) + 1);
            architect[x](this, Constants.taken);

            if (number == 1) firstFloorSetup(Constants.taken);

            storeElevatorCoords(Constants.taken, elevators);
            setUpPassCode(pc);

            putItems(Constants.taken, have);
            putHourglasses(Constants.taken);
        }
예제 #3
0
        public Board(int x, int y)
        {
            height = x;
            length = y;

            //Sets the tile to the x and y coordinates
            board = new Tile [x, y];

            //Nested for loops that creates the 2d array of # as a game board
            for (int i = 0; i <= x - 1; i++){
               for (int j = 0; j <= y - 1; j++ ){
                    board[i,j] = new Tile ("#",ConsoleColor.Blue, true);
                    board[i, j].isPassable = false;
                }
             }

            //Creates the room and sets the bar
            if (checkRoom(1, 1, 17, 37))
            {
                createRoom(1, 1, 17, 37);
            }
            //Loop for creating a pool table
            for (int index = 0; index < 1; index++)
            {
                int poolx = StaticRandom.Instance.Next(2, height - 3);
                int pooly = StaticRandom.Instance.Next(2, length - 3);
                int poolh = 2;
                int pooll = 3;

                //Creates the pool table if coordinates are available.
                if (checkBar(poolx + 2, pooly + 2, poolh + 2, pooll + 2))
                {
                    createPoolTable(poolx, pooly, poolh, pooll);
                }
                else
                {
                    index--;
                }
            }
            if (checkBar(2, 3, 2, 8))
            {
                createBar(2, 3, 2, 8);
            }

            //For loop to generate 4 tables randomly
            for (int index = 0; index <= 4; index++)
            {
                int tablex = StaticRandom.Instance.Next(3, height - 2);
                int tabley = StaticRandom.Instance.Next(3, length - 2);
                if (checkTable(tablex, tabley, 1, 3))
                {
                    createTable(tablex, tabley, 1, 3);
                }
                else
                {
                    index--;
                }
            }
        }
예제 #4
0
        public override void setTile(Tile tile)
        {
            if (this.current_tile != null) {
                this.current_tile.character = null;
            }
            this.current_tile = tile;
            this.current_tile.character = this;

            this.move_range = Grid.getMovementRange(grid, this);
        }
예제 #5
0
 public static List<Tile> getNeighboringTiles(Grid grid, Tile tile)
 {
     List<Tile> neighbors = new List<Tile> ();
     int x = tile.grid_x, y = tile.grid_y;
     for (int i = x-1; i < x+2; i+=2) {
         //If within bounds of grid
         if (inBounds(grid, i, y)) {
     //					//TODO: Pathabilty
             neighbors.Add (grid.tiles[i][y]);
         }
     }
     for (int j = y-1; j < y+2; j+=2) {
         //If within bounds of grid
         if (inBounds(grid, x, j)) {
             //TODO: Pathabilty
             neighbors.Add (grid.tiles[x][j]);
         }
     }
     return neighbors;
 }
예제 #6
0
        public void LoadMapTiles(string mapName, Graphics device)
        {
            MapTiles.Clear();
            Reader = new StreamReader(@"..\..\Assets\Maps\" + mapName + ".map");
            Bitmap walkableAreas = new Bitmap(@"..\..\Assets\Maps\" + mapName + ".walkable");

            int y = 0;

            while (!Reader.EndOfStream)
            {
                string line = Reader.ReadLine();

                for (int x = 0; x < line.Length; x++)
                {
                    Tile t = new Tile();
                    t.loc = new Point(x * 10, y * 10);
                    PixelColor = walkableAreas.GetPixel(x * 10, y * 10);

                    if (PixelColor == WalkableColor) //if (line[x].ToString() == "1")
                    {
                        t.color = Color.Green;
                        t.walkable = true;
                    }
                    if (PixelColor == NonWalkableColor) //if (line[x].ToString() == "0")
                    {
                        t.color = Color.Cyan;
                        t.walkable = false;
                    }

                    MapTiles.Add(t);
                }

                y++;
            }

            // Once the tilelist is full, preform an initial drawing of the grid
            GridCalculatedImage = new Bitmap(this.MapImageWidth, this.MapImageHeight);
            GridGraphicsDevice = Graphics.FromImage(this.GridCalculatedImage);

            foreach (Tile tile in MapTiles)
            {
                pen.Color = tile.color;
                GridGraphicsDevice.DrawRectangle(pen, 0 + tile.loc.X, 0 + tile.loc.Y, 10, 10);
            }
        }
예제 #7
0
파일: Layer.cs 프로젝트: remy22/game-1
        /// <summary>
        /// Adds a tile to the vertex array. 
        /// </summary>
        /// <param name="x">x offset</param>
        /// <param name="y">y offset</param>
        /// <param name="id">the tile ID</param>
        public void PlaceTile(int x, int y, int id)
        {
            if (id <= 0) return; // 0 is a blank tile, ignore
            if (tiles[x, y] != null) return; // Do not replace existing tiles

            // Find tile image in the tileset texture
            Tileset tileset = Map.GetOwningTileset(id);
            int ti = (int) ((id - tileset.FirstID) % (tileset.Texture.Size.X / tileset.TileSize.X));
            int tj = (int) ((id - tileset.FirstID) / (tileset.Texture.Size.X / tileset.TileSize.X));
            int tw = tileset.TileSize.X;
            int th = tileset.TileSize.Y;

            // Add the tile the correct vertex array
            if (!verts.ContainsKey(tileset.FirstID))
                verts[tileset.FirstID] = new VertexArray(PrimitiveType.Quads);
            verts[tileset.FirstID].Append(new Vertex(new Vector2f(x * tw, y * th), new Vector2f(ti * tw, tj * th)));
            verts[tileset.FirstID].Append(new Vertex(new Vector2f((x + 1) * tw, y * th), new Vector2f((ti + 1) * tw, tj * th)));
            verts[tileset.FirstID].Append(new Vertex(new Vector2f((x + 1) * tw, (y + 1) * th), new Vector2f((ti + 1) * tw, (tj + 1) * th)));
            verts[tileset.FirstID].Append(new Vertex(new Vector2f(x * tw, (y + 1) * th), new Vector2f(ti * tw, (tj + 1) * th)));

            tiles[x, y] = new Tile(id);
        }
예제 #8
0
파일: Board.cs 프로젝트: Blecki/coerceo
 public Board WithTile(byte Index, Tile Tile)
 {
     var r = new Board(this);
     r.Data[Index + 1] = Tile.Data;
     return r;
 }
예제 #9
0
파일: Tile.cs 프로젝트: Blecki/CCDC
 public virtual bool Combinable(Tile Other)
 {
     return Object.ReferenceEquals(this.Texture, Other.Texture);
 }
예제 #10
0
        private void setHighlight(Informant informant, bool highlight)
        {
            if (IsSameOrSubclass(typeof(GridThing), informant.GetType())) {
                GridThing gridThing = informant as GridThing;
                gridThing.setHighlighted(highlight);

                // If tile, that contains a character, set highlight for character as well
                if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
                    Tile tile = informant as Tile;
                    if (tile.character) {
                        setHighlight(tile.character, highlight);
                    }
                }

                // If character, highlight tiles in movement range
                if (IsSameOrSubclass(typeof(Character), informant.GetType())) {
                    Character character = informant as Character;
                    foreach (var tile in character.move_range) {
                        tile.setWalkableForHighlightedCharacter(highlight);
                    }
                }
            }

            // Display Path UI during Move Action
            if (highlight && mode == UI_Mode.player_unit_turn_during_action && action == UI_Action.move) {
                if (IsSameOrSubclass(typeof(Tile), informant.GetType())) {
                    Tile tile = informant as Tile;
                    if (tile != goal) {
                        updateMovePath();
                        goal = tile;
                    }
                }
            }
        }
예제 #11
0
 public override void setTile(Tile tile)
 {
     // I AM a tile so stfu
 }
예제 #12
0
 // Inform a tile that this objects grid position has been set to this tile's
 public virtual void setTile(Tile tile)
 {
     // All extending objects should overwrite this
 }
예제 #13
0
파일: Tables.cs 프로젝트: Blecki/coerceo
        public static void Initialize()
        {
            var hexSystem = new HexDemo.Hex(1.0f);

            //           The starting board - 19 tiles
            //       __               __
            //    __/00\__         __/00\__    Neighbor
            // __/01\__/02\__     /01\__/05\    Directions
            ///03\__/04\__/05\    \__/  \__/
            //\__/06\__/07\__/    /02\__/04\
            ///08\__/09\__/0A\    \__/03\__/
            //\__/0B\__/0C\__/       \__/
            ///0D\__/0E\__/0F\
            //\__/10\__/11\__/
            //   \__/12\__/
            //      \__/

            HexWorldPositions = new Vector2[]
            {
              hexSystem.TileOrigin(0, 2),
              hexSystem.TileOrigin(-1, 1),
              hexSystem.TileOrigin(1, 1),
              hexSystem.TileOrigin(-2, 1),
              hexSystem.TileOrigin(0, 1),
              hexSystem.TileOrigin(2, 1),
              hexSystem.TileOrigin(-1, 0),
              hexSystem.TileOrigin(1, 0),
              hexSystem.TileOrigin(-2, 0),
              hexSystem.TileOrigin(0, 0),
              hexSystem.TileOrigin(2, 0),
              hexSystem.TileOrigin(-1, -1),
              hexSystem.TileOrigin(1, -1),
              hexSystem.TileOrigin(-2, -1),
              hexSystem.TileOrigin(0, -1),
              hexSystem.TileOrigin(2, -1),
              hexSystem.TileOrigin(-1, -2),
              hexSystem.TileOrigin(1, -2),
              hexSystem.TileOrigin(0, -2)
            };

            InitialBoard = Board.Empty().WithHeader(new StateHeader(0));
            for (var x = 0; x < 19; ++x)
            {
                var tile = new Tile((byte)x, 0x00);
                foreach (var item in InitialPiecePlacements[x])
                    tile = tile.WithTriangle(item, 0x01);
                InitialBoard = InitialBoard.WithTile((byte)x, tile);
            }
        }
예제 #14
0
 public void UpdateSurrounding(Tile tile)
 {
     if (tile.Mines == 0)
     {
         for (int x = tile.X - 1; x <= tile.X + 1 &&  x <_row ; x++)
         {
             for (int y = tile.Y - 1; y <= tile.Y + 1 && y < _col; y++)
             {
                 if (x >= 0 && y >= 0 && _tileArray[x + y * _col] != tile)
                 {
                     if (_tileArray[x + y * _col].Mines == 0 && !_tileArray[x + y * _col].State)
                     {
                         _tileArray[x + y * _col].State = true;
                         UpdateSurrounding(_tileArray[x + y * _col]);
                     }
                     _tileArray[x + y * _col].State = true;
                 }
             }
         }
     }
 }
예제 #15
0
 public bool IsSameTile(Tile rhs)
 {
     return Position == rhs.Position;
 }
예제 #16
0
 public Tile(Tile src)
 {
     this.Position = src.Position;
 }