Changeset 41c11dd in advance-wars
- Timestamp:
- Aug 27, 2011, 1:56:46 AM (13 years ago)
- Branches:
- master
- Children:
- 331d180
- Parents:
- 511177b
- Location:
- src/com/medievaltech
- Files:
-
- 1 added
- 11 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/com/medievaltech/advancewars/Game.java
r511177b r41c11dd 51 51 try { 52 52 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt")); 53 mThread.mMap.save(p);53 Static.map.save(p); 54 54 p.close(); 55 55 }catch(IOException ioe) { -
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 -
src/com/medievaltech/advancewars/Map.java
r511177b r41c11dd 80 80 grid[x][y].drawUnit(c, offset.x+50*x, offset.y+50*y); 81 81 } 82 83 public void drawBuildings(Canvas c) { 84 for(int x=0; x<getWidth(); x++) 85 for(int y=0; y<getHeight(); y++) 86 grid[x][y].drawBuilding(c, offset.x+50*x, offset.y+50*y); 87 } 82 88 } -
src/com/medievaltech/advancewars/Player.java
r511177b r41c11dd 1 package com.medievaltech. unit;1 package com.medievaltech.advancewars; 2 2 3 3 import java.util.*; 4 5 import com.medievaltech.unit.Unit; 4 6 5 7 import android.graphics.Paint; … … 9 11 private Paint color; 10 12 private ArrayList<Unit> units; 13 public static Paint neutralColor; 11 14 12 15 public Player(String name, Paint color) { -
src/com/medievaltech/advancewars/Tile.java
r511177b r41c11dd 12 12 public double moveCoefficent; 13 13 public Unit currentUnit; 14 public City currentBuilding; 14 15 public Point point; 15 16 private Paint p; … … 19 20 this.type = type; 20 21 this.currentUnit = null; 22 this.currentBuilding = null; 21 23 } 22 24 … … 40 42 } 41 43 44 public void addBuilding(City c) { 45 currentBuilding = c; 46 c.location = point; 47 } 48 42 49 public void draw(Canvas c, int x, int y) { 43 50 c.drawRect(x, y, x+50, y+50, p); … … 48 55 currentUnit.draw(c, x+25, y+25); 49 56 } 57 58 public void drawBuilding(Canvas c, int x, int y) { 59 if(currentBuilding != null) 60 currentBuilding.draw(c, x+25, y+25); 61 } 50 62 } -
src/com/medievaltech/unit/Artillery.java
r511177b r41c11dd 5 5 import android.graphics.Point; 6 6 7 import com.medievaltech.advancewars.Player; 7 8 import com.medievaltech.advancewars.Enum.*; 8 9 -
src/com/medievaltech/unit/Mech.java
r511177b r41c11dd 5 5 import android.graphics.Point; 6 6 7 import com.medievaltech.advancewars.Player; 7 8 import com.medievaltech.advancewars.Enum.*; 8 9 -
src/com/medievaltech/unit/Recon.java
r511177b r41c11dd 5 5 import android.graphics.Point; 6 6 7 import com.medievaltech.advancewars.Player; 7 8 import com.medievaltech.advancewars.Enum.*; 8 9 -
src/com/medievaltech/unit/SmTank.java
r511177b r41c11dd 5 5 import android.graphics.Point; 6 6 7 import com.medievaltech.advancewars.Player; 7 8 import com.medievaltech.advancewars.Enum.*; 8 9 -
src/com/medievaltech/unit/Soldier.java
r511177b r41c11dd 5 5 import android.graphics.Point; 6 6 7 import com.medievaltech.advancewars.Player; 8 import com.medievaltech.advancewars.Static; 9 import com.medievaltech.advancewars.Tile; 7 10 import com.medievaltech.advancewars.Enum.*; 8 11 … … 27 30 @Override 28 31 public void attack(Point point) { 29 // TODO Auto-generated method stub 30 32 Tile t = Static.map.getTile(point); 33 34 if(t.currentUnit == null && t.currentBuilding != null) { 35 t.currentBuilding.currentHealth -= this.currentHealth; 36 37 if(t.currentBuilding.currentHealth <= 0) { 38 t.currentBuilding.owner = this.owner; 39 t.currentBuilding.currentHealth = t.currentBuilding.maxHealth; 40 } 41 } 31 42 } 32 43 -
src/com/medievaltech/unit/Transport.java
r511177b r41c11dd 1 1 package com.medievaltech.unit; 2 3 import com.medievaltech.advancewars.Player; 2 4 3 5 public abstract class Transport extends Unit { -
src/com/medievaltech/unit/Unit.java
r511177b r41c11dd 5 5 import android.graphics.*; 6 6 7 import com.medievaltech.advancewars.Player; 7 8 import com.medievaltech.advancewars.Enum.*; 8 9
Note:
See TracChangeset
for help on using the changeset viewer.