- Timestamp:
- Aug 26, 2011, 9:54:05 PM (13 years ago)
- Branches:
- master
- Children:
- 511177b
- Parents:
- 99433bb
- Location:
- src/com/medievaltech
- Files:
-
- 9 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 } -
src/com/medievaltech/advancewars/Map.java
r99433bb rc3ad11c 62 62 Unit u = grid[x][y].currentUnit; 63 63 //p.println(u.type); 64 //we also need to save the owner of the unit 64 65 p.println(u.location.x+","+u.location.y); 65 66 } -
src/com/medievaltech/unit/Artillery.java
r99433bb rc3ad11c 3 3 import java.util.List; 4 4 5 import android.graphics.Paint;6 5 import android.graphics.Point; 7 6 … … 9 8 10 9 public class Artillery extends Unit{ 11 public Artillery(P aintp)10 public Artillery(Player p) 12 11 { 13 12 super(p); -
src/com/medievaltech/unit/Mech.java
r99433bb rc3ad11c 3 3 import java.util.List; 4 4 5 import android.graphics.Paint;6 5 import android.graphics.Point; 7 6 … … 9 8 10 9 public class Mech extends Unit{ 11 public Mech(P aintp)10 public Mech(Player p) 12 11 { 13 12 super(p); -
src/com/medievaltech/unit/Recon.java
r99433bb rc3ad11c 3 3 import java.util.List; 4 4 5 import android.graphics.Paint;6 5 import android.graphics.Point; 7 6 … … 9 8 10 9 public class Recon extends Unit{ 11 public Recon(P aintp)10 public Recon(Player p) 12 11 { 13 12 super(p); -
src/com/medievaltech/unit/SmTank.java
r99433bb rc3ad11c 3 3 import java.util.List; 4 4 5 import android.graphics.Paint;6 5 import android.graphics.Point; 7 6 … … 9 8 10 9 public class SmTank extends Unit{ 11 public SmTank(P aintp)10 public SmTank(Player p) 12 11 { 13 12 super(p); -
src/com/medievaltech/unit/Soldier.java
r99433bb rc3ad11c 3 3 import java.util.List; 4 4 5 import android.graphics.Paint;6 5 import android.graphics.Point; 7 6 … … 9 8 10 9 public class Soldier extends Unit{ 11 public Soldier(P aintp)10 public Soldier(Player p) 12 11 { 13 12 super(p); -
src/com/medievaltech/unit/Transport.java
r99433bb rc3ad11c 1 1 package com.medievaltech.unit; 2 3 import android.graphics.Paint;4 2 5 3 public abstract class Transport extends Unit { 6 4 public Unit storedUnit; 7 5 8 public Transport(P aintp) {6 public Transport(Player p) { 9 7 super(p); 10 8 } -
src/com/medievaltech/unit/Unit.java
r99433bb rc3ad11c 8 8 9 9 public abstract class Unit { 10 private Paint p;11 12 10 public UnitType type; 13 //public Player owner;11 public Player owner; 14 12 15 13 public int maxHealth; … … 26 24 public Point location; 27 25 28 public Unit(P aintp)26 public Unit(Player p) 29 27 { 30 this.p = p; 28 p.addUnit(this); 29 30 owner = p; 31 31 maxHealth = 10; 32 32 currentHealth = 10; 33 34 33 } 35 34 … … 87 86 88 87 public void draw(Canvas c, int x, int y) { 89 c.drawCircle(x, y, 20, p);88 c.drawCircle(x, y, 20, owner.getColor()); 90 89 } 91 90 }
Note:
See TracChangeset
for help on using the changeset viewer.