Esempio n. 1
0
 public Door(Tile tile, bool isVertical)
     : base("door", 43, Color.FromArgb(200,200,200))
 {
     this.isVertical = isVertical;
     this.isOpen = false;
     tile.isTransparent = false;
     tile.isPassable = false;
     tile.isDoor = true;
 }
Esempio n. 2
0
        public void Close(Tile tile, Level currentLevel)
        {
            foreach (Creature c in currentLevel.creatures)
                if (currentLevel.tileArray[(int)tile.pos.X, (int)tile.pos.Y].pos == c.pos)
                    return; //Stop if a creature's blocking it.

            this.isOpen = false;
            base.imageIndex = 43;
            tile.isTransparent = false;
            tile.isPassable = false;
        }
Esempio n. 3
0
        public void Open(Tile tile, Level currentLevel)
        {
            this.isOpen = true;

            if (isVertical)
                base.imageIndex = 45; // "|"
            else
                base.imageIndex = 124; // "-"

            tile.isTransparent = true;
            tile.isPassable = true;
        }
Esempio n. 4
0
 public void CloseDoor(Tile tile, Level currentLevel)
 {
     Door door = (Door)tile.fixtureLibrary[0];
     door.Close(tile, currentLevel);
 }
Esempio n. 5
0
 public void OpenDoor(Tile tile, Level currentLevel)
 {
     if (isDextrous == true)
     {
         Door door = (Door)tile.fixtureLibrary[0];
         door.Open(tile, currentLevel);
     }
     else
     {
         message.Add("Opposable thumbs would be helpful here.");
     }
 }
Esempio n. 6
0
        public bool CanDigRoom(Room room, Tile[,] tileArray)
        {
            for (int y = room.y; y <= room.y + room.height; y++) //For every tile in room's height...
                for (int x = room.x; x <= room.x + room.width; x++) //...and width.
                {
                    if (tileArray[x, y].isCorridorEdge || tileArray[x, y].adjacentToRoomN > 0)
                        return false;
                }

            return true;
        }
Esempio n. 7
0
        public bool CanDigCorridor(Vector2 pointA, Vector2 pointB, Tile[,] tileArray)
        {
            #region Variables
            int xa = (int)pointA.X;
            int xb = (int)pointB.X;
            int ya = (int)pointA.Y;
            int yb = (int)pointB.Y;

            //Error-catching
            if (xa < 1 || xa > GRIDW || xb < 1 || xb > GRIDW || ya < 1 || ya > GRIDH || yb < 1 || yb > GRIDH)
                return false;

            bool steep = (Math.Abs(yb - ya) > Math.Abs(xb - xa));
            #endregion

            #region If Steep
            if (steep)
            {
                //swap(xa, ya)
                int ca = xa;
                xa = ya;
                ya = ca;

                //swap(x1, y1)
                int cb = xb;
                xb = yb;
                yb = cb;
            }
            #endregion

            #region If xa > xb
            if (xa > xb)
            {
                //swap(x0, x1)
                int xc = xa;
                xa = xb;
                xb = xc;

                //swap(y0, y1)
                int yc = ya;
                ya = yb;
                yb = yc;
            }
            #endregion

            #region More variable tomfoolery
            int deltax = xb - xa;
            int deltay = Math.Abs(yb - ya);
            int error = deltax / 2;
            int ystep;
            int y = ya;
            #endregion

            #region If/else ya < yb
            if (ya < yb)
            {
                ystep = 1;
            }
            else
            {
                ystep = -1;
            }
            #endregion

            #region For x from xa to xb
            for (int x = xa; x <= xb; x++) //for x from x0 to x1
            {
                if (steep)
                {
                    //plot (y,x)
                    //for (int adjY = y - 1; adjY <= y + 1; adjY++)
                    //    for (int adjX = x - 1; adjX <= x + 1; adjX++)
                    //        if (tileArray[adjY, adjX].isCorridorEdge)
                    //          return false;

                    if (!(tileArray[y, x - 1].isPassable && tileArray[y, x + 1].isPassable)) // If we've haven't hit a horizontal corridor
                    {
                        if ((tileArray[y - 1, x - 1].isPassable || tileArray[y + 1, x - 1].isPassable) &&
                            (tileArray[y - 1, x + 1].isPassable || tileArray[y + 1, x + 1].isPassable)) // If we're adjacent to a vertical corridor
                        {
                            return false;
                        }
                    }

                    if (tileArray[y, x].adjacentToRoomN > 0)
                        return false;
                }
                else
                {
                    //plot(x,y)
                    //for (int adjY = y - 1; adjY <= y + 1; adjY++)
                    //    for (int adjX = x - 1; adjX <= x + 1; adjX++)
                    //        if (tileArray[adjX, adjY].isCorridorEdge)
                    //            return false;

                    if (!(tileArray[x - 1, y].isPassable && tileArray[x + 1, y].isPassable)) // If we've haven't hit a horizontal corridor
                    {
                        if ((tileArray[x - 1, y - 1].isPassable || tileArray[x - 1, y + 1].isPassable) &&
                            (tileArray[x + 1, y - 1].isPassable || tileArray[x + 1, y + 1].isPassable)) // If we're adjacent to a vertical corridor
                        {
                            return false;
                        }
                    }

                    if (tileArray[x, y].adjacentToRoomN > 0)
                        return false;
                }

                error = error - deltay;

                if (error < 0)
                {
                    y = y + ystep;
                    error = error + deltax;
                }
            }
            #endregion

            return true;
        }
Esempio n. 8
0
        protected void FillWithFreshTiles(bool open)
        {
            int x,y;
            for (y = 0; y < GRIDH; y++) //Repeat gridSizeY lines...
                for (x = 0; x < GRIDW; x++) //...by gridSizeX lines...
                {
                    tileArray[x, y] = null; //Set all tiles as nothing
                }

            for (y = 0; y < GRIDH; y++) //Repeat gridSizeY lines...
            {
                for (x = 0; x < GRIDW; x++) //...by gridSizeX lines...
                {
                    if (open)
                    {
                        tileArray[x, y] = new Tile(true, Adventurer.air, 2, true, true); //Set all tiles as roomable solid rock
                        tileArray[x, y].isWall = false;
                    }
                    else
                    {
                        tileArray[x, y] = new Tile(false, Adventurer.rock, 2, true, false); //Set all tiles as roomable solid rock
                        tileArray[x, y].isWall = true;
                    }
                    tileArray[x, y].isRoomEdge = false;
                }
            }
        }
Esempio n. 9
0
 public void DigRoom(Room room, Tile[,] tileArray)
 {
     for (int y = room.y; y <= room.y + room.height; y++) //For every tile in room's height...
         for (int x = room.x; x <= room.x + room.width; x++) //...and width.
         {
             if (y == room.y || y == room.y + room.height ||
                 x == room.x || x == room.x + room.width) //If edge of room
             {
                 tileArray[x, y].adjacentToRoomN = room.roomNumber; //Remember what room this edge is next to
                 tileArray[x, y].isWall = true;
                 tileArray[x, y].isTransparent = false;
                 tileArray[x, y].isPassable = false;
                 tileArray[x, y].material = Adventurer.rock;
                 tileArray[x, y].fixtureLibrary.Clear();
             }
             else
             {
                 tileArray[x, y].isPassable = true; //Is passable
                 tileArray[x, y].isWall = false; //Is not a wall
                 tileArray[x, y].material = Adventurer.air; //Air is not diggable
                 tileArray[x, y].tileImage = 46; //Is drawn as open space
                 tileArray[x, y].isTransparent = true; //Can see through it
                 tileArray[x, y].fixtureLibrary.Clear();
             }
         }
 }
Esempio n. 10
0
 public Tile(Tile t)
 {
 }