static public Vector3 GetSidePosition(DungeonTileSideType side) { switch (side) { case DungeonTileSideType.Ceiling: return(new Vector3(0.0f, 1.0f, 0.0f)); case DungeonTileSideType.Floor: return(new Vector3(0.0f, 0.0f, 0.0f)); case DungeonTileSideType.WallNorth: return(new Vector3(0.0f, 0.5f, 0.5f)); case DungeonTileSideType.WallSouth: return(new Vector3(0.0f, 0.5f, -0.5f)); case DungeonTileSideType.WallEast: return(new Vector3(0.5f, 0.5f, 0.0f)); case DungeonTileSideType.WallWest: return(new Vector3(-0.5f, 0.5f, 0.0f)); default: return(Vector3.zero); } }
static public Quaternion GetSideRotation(DungeonTileSideType side) { switch (side) { case DungeonTileSideType.Ceiling: return(Quaternion.Euler(0.0f, 0.0f, 0.0f)); case DungeonTileSideType.Floor: return(Quaternion.Euler(0.0f, 0.0f, 0.0f)); case DungeonTileSideType.WallNorth: return(Quaternion.Euler(90.0f, 0.0f, 0.0f)); case DungeonTileSideType.WallSouth: return(Quaternion.Euler(-90.0f, 0.0f, 0.0f)); case DungeonTileSideType.WallEast: return(Quaternion.Euler(0.0f, 0.0f, -90.0f)); case DungeonTileSideType.WallWest: return(Quaternion.Euler(0.0f, 0.0f, 90.0f)); default: return(Quaternion.identity); } }
private DungeonTileSideUnity AddSide(string id, DungeonTileSideType sideType) { if (string.IsNullOrEmpty(id)) { return(null); } if (!IsSideNonSolid(dungeonUnity.dungeon, position, sideType)) { return(null); } DungeonTileSideUnity side = dungeonUnity.tilesSideFactory.GetSide(id); side.trans.parent = trans; side.trans.localPosition = GetSidePosition(sideType); side.trans.localRotation = GetSideRotation(sideType); return(side); }
static public bool IsSideNonSolid(DungeonMap dungeon, DungeonVector2 position, DungeonTileSideType sideType) { switch (sideType) { case DungeonTileSideType.WallSouth: if (position.y > 0 && dungeon.GetTile(position.x, position.y - 1).solid) { return(false); } break; case DungeonTileSideType.WallNorth: if (position.y + 1 < dungeon.SizeY && dungeon.GetTile(position.x, position.y + 1).solid) { return(false); } break; case DungeonTileSideType.WallWest: if (position.x > 0 && dungeon.GetTile(position.x - 1, position.y).solid) { return(false); } break; case DungeonTileSideType.WallEast: if (position.x + 1 < dungeon.SizeX && dungeon.GetTile(position.x + 1, position.y).solid) { return(false); } break; } return(true); }