1 | package com.medievaltech.advancewars;
|
---|
2 |
|
---|
3 | import android.graphics.Canvas;
|
---|
4 | import android.graphics.Paint;
|
---|
5 | import android.graphics.Point;
|
---|
6 |
|
---|
7 | import com.medievaltech.unit.*;
|
---|
8 | import com.medievaltech.advancewars.Enum.*;
|
---|
9 |
|
---|
10 | public class Tile {
|
---|
11 | TerrainType type;
|
---|
12 | public double moveCoefficent;
|
---|
13 | public Unit currentUnit;
|
---|
14 | public City currentBuilding;
|
---|
15 | public Point point;
|
---|
16 | private Paint p;
|
---|
17 |
|
---|
18 | public Tile(Paint p, TerrainType type) {
|
---|
19 | this.p = p;
|
---|
20 | this.type = type;
|
---|
21 | this.currentUnit = null;
|
---|
22 | this.currentBuilding = null;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public Tile(Tile t, Point point) {
|
---|
26 | this.type = t.type;
|
---|
27 | this.moveCoefficent = t.moveCoefficent;
|
---|
28 | this.p = t.p;
|
---|
29 | this.point = point;
|
---|
30 | }
|
---|
31 |
|
---|
32 | public void addUnit(Unit unit) {
|
---|
33 | currentUnit = unit;
|
---|
34 | unit.location = point;
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void removeUnit() {
|
---|
38 | if(currentUnit != null) {
|
---|
39 | currentUnit = null;
|
---|
40 | }
|
---|
41 |
|
---|
42 | }
|
---|
43 |
|
---|
44 | public void addBuilding(City c) {
|
---|
45 | currentBuilding = c;
|
---|
46 | c.location = point;
|
---|
47 | }
|
---|
48 |
|
---|
49 | public void draw(Canvas c, int x, int y) {
|
---|
50 | c.drawRect(x, y, x+50, y+50, p);
|
---|
51 | }
|
---|
52 |
|
---|
53 | public void drawUnit(Canvas c, int x, int y) {
|
---|
54 | if(currentUnit != null)
|
---|
55 | currentUnit.draw(c, x+25, y+25);
|
---|
56 | }
|
---|
57 |
|
---|
58 | public void drawBuilding(Canvas c, int x, int y) {
|
---|
59 | if(currentBuilding != null)
|
---|
60 | currentBuilding.draw(c, x+25, y+25);
|
---|
61 | }
|
---|
62 | }
|
---|