Skip to content

Commit

Permalink
adding UWP tower, and support for unselectable buildings
Browse files Browse the repository at this point in the history
  • Loading branch information
lucky-bai committed Aug 19, 2014
1 parent b82c7ad commit ea95952
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 2 deletions.
21 changes: 21 additions & 0 deletions deprecated/locations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Note that this is only necessary if there's connections to other buildings. Otherwise it's completely unused.
# - main_floor[n]: nth floor is main floor. Defaults to 1.
# - has_basement: index starts at 0 instead of 1
# - unselectable
#
#
# 2. Paths
Expand Down Expand Up @@ -147,6 +148,11 @@ location PAC 2168 1044
floors 3
main_floor 2
;
location TOWER 2688 1561
floors 3
main_floor 1
unselectable
;



Expand Down Expand Up @@ -515,6 +521,10 @@ path UWP RING_ROAD_CPH_S
;
path E5 RING_ROAD_E3_NE
;
path TOWER UWP
p 2750 1508
p 2798 1595
;



Expand Down Expand Up @@ -663,6 +673,17 @@ path DWE CPH
p 2603 1514
p 2621 1499
;
path CPH TOWER
type indoor_tunnel
connects 3 3
p 2629 1500
;
path DWE TOWER
type indoor_tunnel
connects 2 3
p 2603 1514
p 2625 1503
;

# SW neglected corner
path EV3 EV2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private static void handleCommandLocation(Map map, Scanner scanner){
int num_floors = 1;
int main_floor = 1;
boolean zero_indexed = false;
boolean selectable = true;

while(true){
if(!scanner.hasNext()) break;
Expand All @@ -83,9 +84,13 @@ private static void handleCommandLocation(Map map, Scanner scanner){
if(s.equals("has_basement")){
zero_indexed = true;
}

if(s.equals("unselectable")){
selectable = false;
}
}

Building building = new Building(name, new Waypoint(pos_x, pos_y), num_floors, main_floor, zero_indexed);
Building building = new Building(name, new Waypoint(pos_x, pos_y), num_floors, main_floor, zero_indexed, selectable);

map.addBuilding(building);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public class Building {
// Which of the floors is the main floor? By default, 1
private int main_floor;

// Show an icon on the map to select it?
private boolean selectable;


/**
* Constructor. Assumes all floors have this same position, main_floor <= num_floors
Expand All @@ -38,13 +41,16 @@ public class Building {
* @param num_floors number of floors, including basement if there is one
* @param main_floor the floor which you are in when you walk into the building
* @param zero_indexed start counting floors from 0 instead of 1
* @param selectable show selection icon on the map for building
*/
public Building(String name, Waypoint position, int num_floors, int main_floor, boolean zero_indexed){
public Building(String name, Waypoint position, int num_floors, int main_floor,
boolean zero_indexed, boolean selectable){

this.name = name;
this.position = position;
this.main_floor = main_floor;
this.num_floors = num_floors;
this.selectable = selectable;

// Populate list of floors
floors = new ArrayList<>();
Expand Down Expand Up @@ -106,6 +112,10 @@ public int getNumberOfFloors(){
return num_floors;
}

public boolean isSelectable(){
return selectable;
}

public String toString(){
return floors.toString();
}
Expand Down
21 changes: 21 additions & 0 deletions workspace/WATisRain/assets/locations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# Note that this is only necessary if there's connections to other buildings. Otherwise it's completely unused.
# - main_floor[n]: nth floor is main floor. Defaults to 1.
# - has_basement: index starts at 0 instead of 1
# - unselectable
#
#
# 2. Paths
Expand Down Expand Up @@ -147,6 +148,11 @@ location PAC 2168 1044
floors 3
main_floor 2
;
location TOWER 2688 1561
floors 3
main_floor 1
unselectable
;



Expand Down Expand Up @@ -515,6 +521,10 @@ path UWP RING_ROAD_CPH_S
;
path E5 RING_ROAD_E3_NE
;
path TOWER UWP
p 2750 1508
p 2798 1595
;



Expand Down Expand Up @@ -663,6 +673,17 @@ path DWE CPH
p 2603 1514
p 2621 1499
;
path CPH TOWER
type indoor_tunnel
connects 3 3
p 2629 1500
;
path DWE TOWER
type indoor_tunnel
connects 2 3
p 2603 1514
p 2625 1503
;

# SW neglected corner
path EV3 EV2
Expand Down
6 changes: 6 additions & 0 deletions workspace/WATisRain/src/com/lucky/watisrain/map/MapView.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ protected void onDraw(Canvas canvas) {

// Draw all locations
for(Building building : map.getBuildings()){

if(!building.isSelectable()) continue;

Waypoint pos = building.getMainFloor().getPostion();
mapdraw.drawImageOnMap(imgs.get("default_location.png"),pos.getX(),pos.getY(),120);
}
Expand Down Expand Up @@ -276,6 +279,9 @@ private Building determineBuildingFromPosition(float x, float y, float threshold
float closest_dist = Float.MAX_VALUE;

for(Building building : buildings){

if(!building.isSelectable()) continue;

float dist = (float)building.getMainFloor().getPostion().distanceTo(new Waypoint((int)x,(int)y));
if(dist < closest_dist){
closest = building;
Expand Down

0 comments on commit ea95952

Please sign in to comment.