source: advance-wars/src/com/medievaltech/advancewars/Tile.java@ bdd63ba

Last change on this file since bdd63ba was bdd63ba, checked in by dportnoy <devnull@…>, 14 years ago

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.

  • Property mode set to 100644
File size: 1.0 KB
RevLine 
[113d7cf]1package com.medievaltech.advancewars;
2
3import com.medievaltech.unit.Unit;
[a0f5455]4
[2e798d9]5import android.graphics.Canvas;
6import android.graphics.Paint;
[a0f5455]7import android.graphics.Point;
[2e798d9]8
9public class Tile {
[a0f5455]10 public enum TerrainType
11 {
12 LAND, SEA
13 }
14
15 TerrainType type;
16 public double moveCoefficent;
17 public Unit currentUnit;
18 public Point point;
[1a1e8c7]19 private Paint p;
[a0f5455]20
[113d7cf]21 public Tile(Paint p, TerrainType type) {
[1a1e8c7]22 this.p = p;
[113d7cf]23 this.type = type;
[1a1e8c7]24 this.currentUnit = null;
25 }
26
[ebaddd9]27 public Tile(Tile t, Point point) {
[1a1e8c7]28 this.type = t.type;
29 this.moveCoefficent = t.moveCoefficent;
30 this.p = t.p;
[ebaddd9]31 this.point = point;
[1a1e8c7]32 }
33
34 public void addUnit(Unit unit) {
[ebaddd9]35 currentUnit = unit;
36 unit.location = point;
[a0f5455]37 }
38
[bdd63ba]39 public void removeUnit() {
[1a1e8c7]40 if(currentUnit != null) {
[a0f5455]41 currentUnit = null;
42 }
43
44 }
[2e798d9]45
46 public void draw(Canvas c, int x, int y) {
47 c.drawRect(x, y, x+50, y+50, p);
[b97a618]48 }
49
50 public void drawUnit(Canvas c, int x, int y) {
[1a1e8c7]51 if(currentUnit != null)
52 currentUnit.draw(c, x+25, y+25);
[2e798d9]53 }
54}
Note: See TracBrowser for help on using the repository browser.