Last change
on this file since ebaddd9 was ebaddd9, checked in by dportnoy <devnull@…>, 14 years ago |
Added code to draw a unit's possible movement options on the map.
|
-
Property mode
set to
100644
|
File size:
903 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 | if(currentUnit != null)
|
---|
47 | currentUnit.draw(c, x+25, y+25);
|
---|
48 | }
|
---|
49 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.