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