Last change
on this file since 113d7cf was 113d7cf, checked in by dportnoy <devnull@…>, 14 years ago |
Implemented saving/loading of the map and the units on it. Also did some package refactoring (renamed com.medievaltech.game to com.medievaltech.unit and moved some classes into com.medievaltech.advancewars)
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | package com.medievaltech.advancewars;
|
---|
2 |
|
---|
3 | import com.medievaltech.unit.Unit;
|
---|
4 |
|
---|
5 | import android.graphics.Canvas;
|
---|
6 | import android.graphics.Paint;
|
---|
7 | import android.graphics.Point;
|
---|
8 |
|
---|
9 | public class Tile {
|
---|
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;
|
---|
19 | private Paint p;
|
---|
20 |
|
---|
21 | public Tile(Paint p, TerrainType type) {
|
---|
22 | this.p = p;
|
---|
23 | this.type = type;
|
---|
24 | this.currentUnit = null;
|
---|
25 | }
|
---|
26 |
|
---|
27 | public Tile(Tile t, Point point) {
|
---|
28 | this.type = t.type;
|
---|
29 | this.moveCoefficent = t.moveCoefficent;
|
---|
30 | this.p = t.p;
|
---|
31 | this.point = point;
|
---|
32 | }
|
---|
33 |
|
---|
34 | public void addUnit(Unit unit) {
|
---|
35 | currentUnit = unit;
|
---|
36 | unit.location = point;
|
---|
37 | }
|
---|
38 |
|
---|
39 | public void removeUnit(Unit unit) {
|
---|
40 | if(currentUnit != null) {
|
---|
41 | currentUnit = null;
|
---|
42 | }
|
---|
43 |
|
---|
44 | }
|
---|
45 |
|
---|
46 | public void draw(Canvas c, int x, int y) {
|
---|
47 | c.drawRect(x, y, x+50, y+50, p);
|
---|
48 | }
|
---|
49 |
|
---|
50 | public void drawUnit(Canvas c, int x, int y) {
|
---|
51 | if(currentUnit != null)
|
---|
52 | currentUnit.draw(c, x+25, y+25);
|
---|
53 | }
|
---|
54 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.