Changeset bdd63ba in advance-wars for src


Ignore:
Timestamp:
Jun 4, 2011, 6:55:31 PM (13 years ago)
Author:
dportnoy <devnull@…>
Branches:
master
Children:
379005b
Parents:
113d7cf
Message:

Clicking on a unit and then clicking on a tile in its range will move the unit there, provided there is no other unit currently on that tile.

Location:
src/com/medievaltech/advancewars
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/com/medievaltech/advancewars/GameView.java

    r113d7cf rbdd63ba  
    464464                                int y = ((int)event.getY() - thread.mMap.offset.y) / 50;
    465465                               
    466                                 thread.selectedUnit = thread.mMap.getTile(x, y).currentUnit;
     466                                Unit target = thread.mMap.getTile(x, y).currentUnit;
     467                               
     468                                if(thread.selectedUnit != null && thread.selectedUnit.getMovementRange().contains(new Point(x, y))) {
     469                                        if(target == null || target == thread.selectedUnit) {
     470                                                        thread.mMap.getTile(thread.selectedUnit.location.x, thread.selectedUnit.location.y).removeUnit();
     471                                                        thread.mMap.getTile(x, y).addUnit(thread.selectedUnit);
     472                                        }else {
     473                                                // the target contains another unit. If the unit is enemy-controlled, attack it
     474                                        }
     475                                        thread.selectedUnit = null;
     476                                }else
     477                                        thread.selectedUnit = target;
    467478                        }
    468479                       
  • src/com/medievaltech/advancewars/Tile.java

    r113d7cf rbdd63ba  
    3737        }
    3838       
    39         public void removeUnit(Unit unit) {
     39        public void removeUnit() {
    4040                if(currentUnit != null) {
    4141                        currentUnit = null;
Note: See TracChangeset for help on using the changeset viewer.