Changeset fea4b77 in advance-wars
- Timestamp:
- Jun 6, 2011, 6:07:43 PM (13 years ago)
- Branches:
- master
- Children:
- 99433bb
- Parents:
- b660017
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
res/values/strings.xml
rb660017 rfea4b77 3 3 <string name="hello">Hello World, advancewars!</string> 4 4 <string name="app_name">Advance Wars</string> 5 <string name="menu_end_turn">End Turn</string> 5 6 <string name="menu_save">Save</string> 6 7 <string name="menu_main">Main Menu</string> -
src/com/medievaltech/advancewars/Game.java
rb660017 rfea4b77 15 15 16 16 public class Game extends Activity { 17 private static final int MENU_SAVE = 1;18 private static final int MENU_MAIN = 2;19 private static final int MENU_EXIT = 3;20 21 /** A handle to the thread that's actually running the animation. */22 17 public DrawingThread mThread; 23 24 /** A handle to the View in which the game is running. */25 18 private GameView mGameView; 26 19 … … 35 28 super.onCreateOptionsMenu(menu); 36 29 37 menu.add(0, MENU_SAVE, 0, R.string.menu_save); 38 menu.add(0, MENU_MAIN, 0, R.string.menu_main); 39 menu.add(0, MENU_EXIT, 0, R.string.menu_exit); 30 menu.add(0, MenuOption.END_TURN.ordinal(), 0, R.string.menu_end_turn); 31 menu.add(0, MenuOption.SAVE.ordinal(), 0, R.string.menu_save); 32 menu.add(0, MenuOption.MAIN.ordinal(), 0, R.string.menu_main); 33 menu.add(0, MenuOption.EXIT.ordinal(), 0, R.string.menu_exit); 40 34 return true; 41 35 } … … 50 44 @Override 51 45 public boolean onOptionsItemSelected(MenuItem item) { 52 switch (item.getItemId()) {53 case MENU_SAVE:54 try{55 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt"));56 mThread.mMap.save(p);57 p.close();58 }catch(IOException ioe) {59 ioe.printStackTrace();60 }61 break;62 case MENU_MAIN:63 mThread.mGameState = GameState.MAIN_MENU;64 break;65 case MENU_EXIT:66 finish();67 break;46 int i = item.getItemId(); 47 48 if(i == MenuOption.END_TURN.ordinal()) { 49 mThread.mTurn = Turn.ENEMY_TURN; 50 }else if(i == MenuOption.SAVE.ordinal()) { 51 try { 52 PrintWriter p = new PrintWriter(new FileWriter(android.os.Environment.getExternalStorageDirectory()+"/save.txt")); 53 mThread.mMap.save(p); 54 p.close(); 55 }catch(IOException ioe) { 56 ioe.printStackTrace(); 57 } 58 }else if(i == MenuOption.MAIN.ordinal()) { 59 mThread.mGameState = GameState.MAIN_MENU; 60 }else if(i == MenuOption.EXIT.ordinal()) { 61 finish(); 68 62 } 69 63 -
src/com/medievaltech/advancewars/GameView.java
rb660017 rfea4b77 19 19 class DrawingThread extends Thread { 20 20 public GameState mGameState; 21 22 /* 23 * Member (state) fields 24 */ 25 21 22 //maybe make this private and make an accessor for it 23 public Map mMap; 24 25 public Tile grassTile, oceanTile; 26 27 public Turn mTurn; 28 29 //temporary variable to let the enemy control a specific unit 30 //ownership of units hasn't been implemented yet 31 public Unit enemyUnit; 32 26 33 private int mCanvasHeight = 1; 27 34 private int mCanvasWidth = 1; 28 35 29 /** Paint to draw the lines on screen. */ 30 private Paint mLinePaint, mTextPaint, mButtonPaint, mTilePaint1, mTilePaint2, mSelectionPaint, 31 mUnitPaint; 32 33 //maybe make this private and make an accessor for it 34 public Map mMap; 35 36 public Tile grassTile, oceanTile; 36 private Paint mLinePaint, mTextPaint, mButtonPaint, mTilePaint1, 37 mTilePaint2, mSelectionPaint, mUnitPaint; 37 38 38 39 /** Indicate whether the surface has been created & is ready to draw */ … … 105 106 } 106 107 108 enemyUnit = new Soldier(mUnitPaint); 109 110 mMap.getTile(0, 0).addUnit(enemyUnit); 107 111 mMap.getTile(2, 3).addUnit(new Soldier(mUnitPaint)); 108 112 mMap.getTile(5, 6).addUnit(new Soldier(mUnitPaint)); 113 114 mTurn = Turn.YOUR_TURN; 109 115 110 116 mGameState = GameState.MAIN_MENU; … … 129 135 c = mSurfaceHolder.lockCanvas(null); 130 136 synchronized(mSurfaceHolder) { 137 doLogic(); 131 138 doDraw(c); 132 139 } … … 169 176 Log.i("AdvanceWars", "width: "+mCanvasWidth+", height: "+mCanvasHeight); 170 177 } 178 } 179 180 private void doLogic() { 181 if(mTurn == Turn.YOUR_TURN) 182 return; 183 184 switch(mGameState) { 185 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; 191 break; 192 } 171 193 } 172 194 -
src/com/medievaltech/unit/Artillery.java
rb660017 rfea4b77 5 5 import android.graphics.Paint; 6 6 import android.graphics.Point; 7 8 import com.medievaltech.advancewars.Enum.*; 7 9 8 10 public class Artillery extends Unit{ … … 13 15 move = 3; 14 16 15 type = Type.LAND;17 type = UnitType.LAND; 16 18 minAttackRange = 2; 17 19 maxAttackRange = 4; -
src/com/medievaltech/unit/Mech.java
rb660017 rfea4b77 5 5 import android.graphics.Paint; 6 6 import android.graphics.Point; 7 8 import com.medievaltech.advancewars.Enum.*; 7 9 8 10 public class Mech extends Unit{ … … 13 15 move = 2; 14 16 15 type = Type.LAND;17 type = UnitType.LAND; 16 18 minAttackRange = 1; 17 19 maxAttackRange = 1; -
src/com/medievaltech/unit/Recon.java
rb660017 rfea4b77 5 5 import android.graphics.Paint; 6 6 import android.graphics.Point; 7 8 import com.medievaltech.advancewars.Enum.*; 7 9 8 10 public class Recon extends Unit{ … … 13 15 move = 8; 14 16 15 type = Type.LAND;17 type = UnitType.LAND; 16 18 minAttackRange = 1; 17 19 maxAttackRange = 1; -
src/com/medievaltech/unit/SmTank.java
rb660017 rfea4b77 5 5 import android.graphics.Paint; 6 6 import android.graphics.Point; 7 8 import com.medievaltech.advancewars.Enum.*; 7 9 8 10 public class SmTank extends Unit{ … … 13 15 move = 7; 14 16 15 type = Type.LAND;17 type = UnitType.LAND; 16 18 minAttackRange = 1; 17 19 maxAttackRange = 1; -
src/com/medievaltech/unit/Soldier.java
rb660017 rfea4b77 5 5 import android.graphics.Paint; 6 6 import android.graphics.Point; 7 8 import com.medievaltech.advancewars.Enum.*; 7 9 8 10 public class Soldier extends Unit{ … … 13 15 move = 3; 14 16 15 type = Type.LAND;17 type = UnitType.LAND; 16 18 minAttackRange = 1; 17 19 maxAttackRange = 1; -
src/com/medievaltech/unit/Unit.java
rb660017 rfea4b77 2 2 3 3 import java.util.*; 4 4 5 import android.graphics.*; 5 6 6 public abstract class Unit 7 { 8 public enum Type 9 { 10 LAND,SEA,AIR 11 } 7 import com.medievaltech.advancewars.Enum.*; 12 8 9 public abstract class Unit { 13 10 private Paint p; 14 11 15 public Type type;12 public UnitType type; 16 13 //public Player owner; 17 14
Note:
See TracChangeset
for help on using the changeset viewer.