|
Last change
on this file since ae564dc was b97a618, checked in by dportnoy <devnull@…>, 15 years ago |
|
Touching a unit now displays its movement area. Touching a square without a unit will stop displaying any previously displayed movement area. THe movement area is now drawn under the unit itself.
|
-
Property mode
set to
100644
|
|
File size:
955 bytes
|
| Line | |
|---|
| 1 | package com.medievaltech.game;
|
|---|
| 2 |
|
|---|
| 3 | import android.graphics.Canvas;
|
|---|
| 4 | import android.graphics.Paint;
|
|---|
| 5 | import android.graphics.Point;
|
|---|
| 6 |
|
|---|
| 7 | public class Tile {
|
|---|
| 8 | public enum TerrainType
|
|---|
| 9 | {
|
|---|
| 10 | LAND, SEA
|
|---|
| 11 | }
|
|---|
| 12 |
|
|---|
| 13 | TerrainType type;
|
|---|
| 14 | public double moveCoefficent;
|
|---|
| 15 | public Unit currentUnit;
|
|---|
| 16 | public Point point;
|
|---|
| 17 | private Paint p;
|
|---|
| 18 |
|
|---|
| 19 | public Tile(Paint p) {
|
|---|
| 20 | this.p = p;
|
|---|
| 21 | this.currentUnit = null;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | public Tile(Tile t, Point point) {
|
|---|
| 25 | this.type = t.type;
|
|---|
| 26 | this.moveCoefficent = t.moveCoefficent;
|
|---|
| 27 | this.p = t.p;
|
|---|
| 28 | this.point = point;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | public void addUnit(Unit unit) {
|
|---|
| 32 | currentUnit = unit;
|
|---|
| 33 | unit.location = point;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | public void removeUnit(Unit unit) {
|
|---|
| 37 | if(currentUnit != null) {
|
|---|
| 38 | currentUnit = null;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | public void draw(Canvas c, int x, int y) {
|
|---|
| 44 | c.drawRect(x, y, x+50, y+50, p);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | public void drawUnit(Canvas c, int x, int y) {
|
|---|
| 48 | if(currentUnit != null)
|
|---|
| 49 | currentUnit.draw(c, x+25, y+25);
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.