source: advance-wars/src/com/medievaltech/advancewars/Tile.java

Last change on this file was 41c11dd, checked in by dportnoy <devnull@…>, 13 years ago

Added cities to the game, moved the map to a new static class, and added incomplete support for capturing cities with soldiers.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1package com.medievaltech.advancewars;
2
3import android.graphics.Canvas;
4import android.graphics.Paint;
5import android.graphics.Point;
6
7import com.medievaltech.unit.*;
8import com.medievaltech.advancewars.Enum.*;
9
10public 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}
Note: See TracBrowser for help on using the repository browser.