Changeset c3ad11c in advance-wars for src/com/medievaltech/advancewars/GameView.java
- Timestamp:
- Aug 26, 2011, 9:54:05 PM (13 years ago)
- Branches:
- master
- Children:
- 511177b
- Parents:
- 99433bb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/medievaltech/advancewars/GameView.java
r99433bb rc3ad11c 2 2 3 3 import java.io.*; 4 import java.util.*; 4 5 5 6 import com.medievaltech.advancewars.Enum.*; … … 27 28 public Turn mTurn; 28 29 29 //temporary variable to let the enemy control a specific unit 30 //ownership of units hasn't been implemented yet 31 public Unit enemyUnit; 30 public Player enemy; 31 private Unit selectedUnit; 32 32 33 33 private int mCanvasHeight = 1; … … 35 35 36 36 private Paint mLinePaint, mTextPaint, mButtonPaint, mTilePaint1, 37 mTilePaint2, mSelectionPaint, mUnitPaint ;37 mTilePaint2, mSelectionPaint, mUnitPaint1, mUnitPaint2; 38 38 39 39 /** Indicate whether the surface has been created & is ready to draw */ … … 44 44 45 45 private com.medievaltech.gui.Window wndMainMenu; 46 private Unit selectedUnit;47 46 48 47 public DrawingThread(SurfaceHolder surfaceHolder, Context context, Handler handler) { … … 73 72 mTilePaint2.setARGB(255, 0, 0, 255); 74 73 75 mUnitPaint = new Paint(); 76 mUnitPaint.setAntiAlias(true); 77 mUnitPaint.setARGB(255, 255, 0, 0); 74 mUnitPaint1 = new Paint(); 75 mUnitPaint1.setAntiAlias(true); 76 mUnitPaint1.setARGB(255, 255, 0, 0); 77 78 mUnitPaint2 = new Paint(); 79 mUnitPaint2.setAntiAlias(true); 80 mUnitPaint2.setARGB(255, 160, 160, 255); 78 81 79 82 mSelectionPaint = new Paint(); … … 106 109 } 107 110 108 enemyUnit = new Soldier(mUnitPaint); 109 110 mMap.getTile(0, 0).addUnit(enemyUnit); 111 mMap.getTile(2, 3).addUnit(new Soldier(mUnitPaint)); 112 mMap.getTile(5, 6).addUnit(new Soldier(mUnitPaint)); 111 Player humanPlayer = new Player("Human", mUnitPaint1); 112 enemy = new Player("Comp", mUnitPaint2); 113 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)); 113 117 114 118 mTurn = Turn.YOUR_TURN; … … 184 188 switch(mGameState) { 185 189 case BATTLE_MAP: 186 int x = thread.enemyUnit.location.x; 187 int y = thread.enemyUnit.location.y; 188 thread.mMap.getTile(x, y).removeUnit(); 189 thread.mMap.getTile(x, y+1).addUnit(thread.enemyUnit); 190 mTurn = Turn.YOUR_TURN; 190 Iterator<Unit> iter = enemy.getControlledUnits().iterator(); 191 Unit cur; 192 int x, y; 193 194 Log.i("AdvanceWars", "starting to move enemy units"); 195 while(iter.hasNext()) { 196 cur = iter.next(); 197 x = cur.location.x; 198 y = cur.location.y; 199 200 Log.i("AdvanceWars", "moving enemy unit"); 201 202 //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); 205 } 206 Log.i("AdvanceWars", "finished moving enemy units"); 207 208 209 mTurn = Turn.YOUR_TURN; 191 210 break; 192 211 } … … 295 314 int y = Integer.parseInt(unit.substring(unit.indexOf(",")+1)); 296 315 297 mGame.mThread.mMap.getTile(x, y).addUnit(new Soldier(mGame.mThread.mUnitPaint)); 316 Player humanPlayer = new Player("Human", mGame.mThread.mUnitPaint1); 317 318 mGame.mThread.mMap.getTile(x, y).addUnit(new Soldier(humanPlayer)); 298 319 } 299 320 … … 328 349 } 329 350 351 Log.i("AdvanceWars", "Touch event handling finished"); 352 330 353 break; 331 354 }
Note:
See TracChangeset
for help on using the changeset viewer.