Changeset 41c11dd in advance-wars for src/com/medievaltech/advancewars/GameView.java
- Timestamp:
- Aug 27, 2011, 1:56:46 AM (13 years ago)
- Branches:
- master
- Children:
- 331d180
- Parents:
- 511177b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/medievaltech/advancewars/GameView.java
r511177b r41c11dd 22 22 23 23 //maybe make this private and make an accessor for it 24 public Map mMap;24 //public Map mMap; 25 25 26 26 public Tile grassTile, oceanTile; … … 83 83 mSelectionPaint.setAntiAlias(true); 84 84 mSelectionPaint.setARGB(255, 255, 127, 0); 85 86 Player.neutralColor = new Paint(); 87 Player.neutralColor.setAntiAlias(true); 88 Player.neutralColor.setARGB(255, 127, 127, 127); 85 89 86 90 wndMainMenu = new com.medievaltech.gui.Window(0, 0, 320, 450);; … … 94 98 oceanTile = new Tile(mTilePaint2, TerrainType.SEA); 95 99 96 mMap = new Map(grassTile, 6, 8, new Point(10, 25));100 Static.map = new Map(grassTile, 6, 8, new Point(10, 25)); 97 101 98 102 boolean land = true; 99 103 100 for(int x=0; x< mMap.getWidth(); x++) {101 for(int y=0; y< mMap.getHeight(); y++) {104 for(int x=0; x<Static.map.getWidth(); x++) { 105 for(int y=0; y<Static.map.getHeight(); y++) { 102 106 if(land) 103 mMap.setTile(x, y, new Tile(grassTile, new Point(x, y)));107 Static.map.setTile(x, y, new Tile(grassTile, new Point(x, y))); 104 108 else 105 mMap.setTile(x, y, new Tile(oceanTile, new Point(x, y)));109 Static.map.setTile(x, y, new Tile(oceanTile, new Point(x, y))); 106 110 land = !land; 107 111 } … … 112 116 enemy = new Player("Comp", mUnitPaint2); 113 117 114 mMap.getTile(0, 0).addUnit(new Soldier(enemy)); 115 mMap.getTile(2, 3).addUnit(new Soldier(humanPlayer)); 116 mMap.getTile(5, 6).addUnit(new Soldier(humanPlayer)); 118 Static.map.getTile(0, 0).addUnit(new Soldier(enemy)); 119 Static.map.getTile(2, 3).addUnit(new Soldier(humanPlayer)); 120 Static.map.getTile(5, 6).addUnit(new Soldier(humanPlayer)); 121 122 Static.map.getTile(4, 4).addBuilding(new City()); 117 123 118 124 mTurn = Turn.YOUR_TURN; … … 201 207 202 208 //any unit that's in the way is removed (needs to be changed eventuallyy) 203 thread.mMap.getTile(x, y).removeUnit();204 thread.mMap.getTile(x, y+1).addUnit(cur);209 Static.map.getTile(x, y).removeUnit(); 210 Static.map.getTile(x, y+1).addUnit(cur); 205 211 } 206 212 Log.i("AdvanceWars", "finished moving enemy units"); … … 226 232 mTextPaint.setTextSize(12); 227 233 228 mMap.draw(canvas);234 Static.map.draw(canvas); 229 235 230 236 if(selectedUnit != null) { … … 234 240 } 235 241 236 mMap.drawUnits(canvas); 242 Static.map.drawBuildings(canvas); 243 Static.map.drawUnits(canvas); 237 244 238 245 break; … … 291 298 int offsetY = Integer.parseInt(offset.substring(offset.indexOf("x")+1)); 292 299 293 thread.mMap = new Map(thread.grassTile, width, height, new Point(offsetX, offsetY));300 Static.map = new Map(thread.grassTile, width, height, new Point(offsetX, offsetY)); 294 301 295 302 Log.i("GameSave", "Created the map"); … … 302 309 TerrainType type = TerrainType.values()[Integer.parseInt(arr[y])]; 303 310 if(type.equals(TerrainType.LAND)) 304 thread.mMap.setTile(x, y, new Tile(thread.grassTile, new Point(10, 25)));311 Static.map.setTile(x, y, new Tile(thread.grassTile, new Point(10, 25))); 305 312 else 306 thread.mMap.setTile(x, y, new Tile(thread.oceanTile, new Point(10, 25)));313 Static.map.setTile(x, y, new Tile(thread.oceanTile, new Point(10, 25))); 307 314 } 308 315 } … … 316 323 Player humanPlayer = new Player("Human", mGame.mThread.mUnitPaint1); 317 324 318 mGame.mThread.mMap.getTile(x, y).addUnit(new Soldier(humanPlayer));325 Static.map.getTile(x, y).addUnit(new Soldier(humanPlayer)); 319 326 } 320 327 … … 331 338 Log.i("AdvanceWars", "Touch event detected on battle map"); 332 339 333 if(event.getX() >= thread.mMap.offset.x && event.getY() >= thread.mMap.offset.y) {334 int x = ((int)event.getX() - thread.mMap.offset.x) / 50;335 int y = ((int)event.getY() - thread.mMap.offset.y) / 50;340 if(event.getX() >= Static.map.offset.x && event.getY() >= Static.map.offset.y) { 341 int x = ((int)event.getX() - Static.map.offset.x) / 50; 342 int y = ((int)event.getY() - Static.map.offset.y) / 50; 336 343 337 Unit target = thread.mMap.getTile(x, y).currentUnit;344 Unit target = Static.map.getTile(x, y).currentUnit; 338 345 339 346 if(thread.selectedUnit != null && thread.selectedUnit.getMovementRange().contains(new Point(x, y))) { 340 347 if(target == null || target == thread.selectedUnit) { 341 thread.mMap.getTile(thread.selectedUnit.location.x, thread.selectedUnit.location.y).removeUnit();342 thread.mMap.getTile(x, y).addUnit(thread.selectedUnit);348 Static.map.getTile(thread.selectedUnit.location.x, thread.selectedUnit.location.y).removeUnit(); 349 Static.map.getTile(x, y).addUnit(thread.selectedUnit); 343 350 }else { 344 351 // the target contains another unit. If the unit is enemy-controlled, attack it
Note:
See TracChangeset
for help on using the changeset viewer.