public Door(string textureKey, bool isVertical, Coord position, Coord[] linkedRooms) { this.textureKey = textureKey; this.isVertical = isVertical; gap = 0; this.position = position; this.connectingRooms = linkedRooms; if (isVertical) { this.hitbox = new Hitbox(new Rectangle((int)position.x - 8, (int)position.y - 64, 16, 128)); } else { this.hitbox = new Hitbox(new Rectangle((int)position.x - 64, (int)position.y - 8, 128, 16)); } }
/// <summary> /// Returns whether or not the specified position is occupied, preventing movement. /// This could also potentially be moved to Level /// </summary> /// <param name="position">Coordinates in the level to test</param> /// <returns></returns> public bool IsSolid(Coord position) { Room room; room = getRoom((int)Math.Floor(position.x / (16 * 32)), (int)Math.Floor(position.y / (16 * 32)));//MB: get the room at those coordinates Tile tile; tile = room.tiles[(int)Math.Floor((position.x % (16 * 32)) / 32), (int)Math.Floor((position.y % (16 * 32)) / 32)];//MB: get the tile at those coordinates if (Hitbox.IsIn(tile.hitbox, new Coord(position.x % 32, position.y % 32))) { return(true); } foreach (Door door in doors) { if (Hitbox.IsIn(door.hitbox, position)) { return(true); } } return(false); }
public void Update(Coord playerPos) { if (gap > 0 && gap < 48) { gap++; if (isVertical) { this.hitbox = new Hitbox(new Rectangle((int)position.x - 8, (int)position.y - 64, 16, 64 - gap)); hitbox.Add(new Rectangle((int)position.x - 8, (int)position.y + gap, 16, 64 - gap)); } else { this.hitbox = new Hitbox(new Rectangle((int)position.x - 64, (int)position.y - 8, 64 - gap, 16)); hitbox.Add(new Rectangle((int)position.x + gap, (int)position.y - 8, 64 - gap, 16)); } } if ((playerPos - position).ToVector2().Length() < 64) { if (gap == 0) { gap = 1; } } }
string textureKey; //MB: Used with a texture dictionary to get the texture of this tile // - - - - - - - - - - - - - - - - - - - public Tile(string textureKey, Hitbox hitbox) { this.textureKey = textureKey; this.hitbox = hitbox; }