public Player(String name, Floor floor, Coordinate coord, ArrayList items) { this.name = name; this.floor = floor; this.coord = coord; this.inventory = new ArrayList(items); this.cameFrom = -1; }
private void setupFloors(GameState gs) { floors = new Floor[Globals.NUM_FLOORS]; //Creating 10 foors Constants.taken = new bool[Globals.FLOOR_LENGTH, Globals.FLOOR_WIDTH]; Coordinate[] elevCoord = new Coordinate[Constants.NUM_ELEVATORS]; for (int i = 0; i < Globals.NUM_FLOORS; i++) { //Get the elevator coordinates, pass them to Floor constructor for (int j = 0; j < Constants.NUM_ELEVATORS; j++) { if(j == 0) //Stored at index 0, the correct elevator elevCoord[j] = correct_elevator[i].getCoord(); else elevCoord[j] = wrong_elevator[i].getCoord(); } if (gs.floorNumber == i + 1) //Only restore settings of one floor floors[i] = new Floor(i + 1, gs.pc, gs.have, elevCoord, gs); else floors[i] = new Floor(i + 1, null, null, elevCoord, gs); } }
//helper for architect private static void buildWalls(Floor f, Coordinate[] place) { Tile[,] floor = f.floor; ArrayList coordinates = f.coordinates; for (int i = 0; i < place.GetUpperBound(0) + 1; i++) { int x = place[i].x; int y = place[i].y; floor[x, y].Obj = new Wall(); coordinates.Add(new NamedCoord("Wall", new Coordinate(x,y), 0)); } }
private static void architect3(Floor f, bool[,] taken) { architect1(f, taken); architect2(f, taken); int mid = Globals.FLOOR_WIDTH / 2; int end = Globals.FLOOR_LENGTH - 1; //other end //Build a simple wall Coordinate[] takenList = { new Coordinate(end, mid), new Coordinate(end-1, mid), new Coordinate(end-2, mid), new Coordinate(end-3, mid) }; if(!markTaken(taken, takenList)) return; buildWalls(f, takenList); }
private static void architect2(Floor f, bool[,] taken) { //too small to design on that floor if (Globals.FLOOR_LENGTH < 10 || Globals.FLOOR_WIDTH < 10) return; int fw = Globals.FLOOR_WIDTH - 1; //floor width index based Coordinate[] takenList = { new Coordinate(0,fw - 3), new Coordinate(1,fw - 3), new Coordinate(1,fw - 2), new Coordinate(1,fw - 4), new Coordinate(2,fw - 3), new Coordinate(3,fw - 3), new Coordinate(3,fw - 2), new Coordinate(3,fw - 1), new Coordinate(3,fw - 0), }; if(!markTaken(taken, takenList)) return; Coordinate[] wallList = { new Coordinate(0,fw - 3), new Coordinate(2,fw - 3), new Coordinate(3,fw - 3), new Coordinate(3,fw - 2), new Coordinate(3,fw - 1), new Coordinate(3,fw - 0) }; buildWalls(f, wallList); }
//prototype for making floors complex with rooms //NOTE: Buggy, elevators are placed where there are walls //TODO find a better way to create this private static void architect1(Floor f, bool[,] taken) { //too small to design on that floor if (Globals.FLOOR_LENGTH < 10 || Globals.FLOOR_WIDTH < 10) return; Coordinate[] takenList = { new Coordinate(0,3), new Coordinate(1,3), new Coordinate(1,2), new Coordinate(1,4), new Coordinate(2,3), new Coordinate(3,3), new Coordinate(3,2), new Coordinate(3,1), new Coordinate(3,0), }; //Check to see if elevator is on building coordinate //If so, we can't build if(!markTaken(taken, takenList)) return; Coordinate[] wallList = { new Coordinate(0,3), new Coordinate(2,3), new Coordinate(3,3), new Coordinate(3,2), new Coordinate(3,1), new Coordinate(3,0) }; buildWalls(f, wallList); }