source: advance-wars/src/com/medievaltech/game/Tile.java@ 1a1e8c7

Last change on this file since 1a1e8c7 was 1a1e8c7, checked in by dportnoy <devnull@…>, 14 years ago

Added a basic draw function to Unit and made some other minor code changes.

  • Property mode set to 100644
File size: 842 bytes
Line 
1package com.medievaltech.game;
2
3import android.graphics.Canvas;
4import android.graphics.Paint;
5import android.graphics.Point;
6
7public 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) {
25 this.type = t.type;
26 this.moveCoefficent = t.moveCoefficent;
27 this.p = t.p;
28 }
29
30 public void addUnit(Unit unit) {
31 currentUnit = unit;
32 }
33
34 public void removeUnit(Unit unit) {
35 if(currentUnit != null) {
36 currentUnit = null;
37 }
38
39 }
40
41 public void draw(Canvas c, int x, int y) {
42 c.drawRect(x, y, x+50, y+50, p);
43
44 if(currentUnit != null)
45 currentUnit.draw(c, x+25, y+25);
46 }
47}
Note: See TracBrowser for help on using the repository browser.