private void makeFood() { hungerLevel = 0; for (String key : inventory.keySet()) { if (inventory.get(key) > 0) { inventory.put(key, inventory.get(key) - 1); break; } } if (personGui.isInBedroom()) { personGui.DoAlmostWall(); try { isMoving.acquire(); } catch (InterruptedException e) { e.printStackTrace(); } personGui.DoGoToWall(); try { isMoving.acquire(); } catch (InterruptedException e) { // e.printStackTrace(); } } personGui.DoGoToRefridgerator(); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } personGui.DoGoToStove(); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } timer.schedule( new TimerTask() { public void run() { homeState = HomeState.onCouch; isMoving.release(); } }, 5000); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } }
protected void leaveHome() { currentBuilding = cityData.buildings.get(home.buildingNumber); if (personGui.isInBedroom()) { personGui.DoAlmostWall(); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } personGui.DoGoToWall(); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } } if (home instanceof Home) { personGui.DoGoToEntrance(); atEntrance.drainPermits(); try { atEntrance.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } personGui.DoLeaveBuilding(); currentBuilding.LeaveBuilding(this); } if (home instanceof Apartment) { Apartment a = (Apartment) home; personGui.DoGoToEntrance(); try { isMoving.acquire(); } catch (InterruptedException e1) { // Auto-generated catch block e1.printStackTrace(); } a.rooms.get(roomNumber).LeaveBuilding(this); personGui.DoGoToHallway(); try { isMoving.acquire(); } catch (InterruptedException e) { // Auto-generated catch block e.printStackTrace(); } personGui.DoLeaveBuilding(); a.LeaveBuilding(this); } bigState = BigState.doingNothing; }