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

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

Touching a unit now displays its movement area. Touching a square without a unit will stop displaying any previously displayed movement area. THe movement area is now drawn under the unit itself.

  • Property mode set to 100644
File size: 955 bytes
RevLine 
[1a1e8c7]1package com.medievaltech.game;
[a0f5455]2
[2e798d9]3import android.graphics.Canvas;
4import android.graphics.Paint;
[a0f5455]5import android.graphics.Point;
[2e798d9]6
7public class Tile {
[a0f5455]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;
[1a1e8c7]17 private Paint p;
[a0f5455]18
[1a1e8c7]19 public Tile(Paint p) {
20 this.p = p;
21 this.currentUnit = null;
22 }
23
[ebaddd9]24 public Tile(Tile t, Point point) {
[1a1e8c7]25 this.type = t.type;
26 this.moveCoefficent = t.moveCoefficent;
27 this.p = t.p;
[ebaddd9]28 this.point = point;
[1a1e8c7]29 }
30
31 public void addUnit(Unit unit) {
[ebaddd9]32 currentUnit = unit;
33 unit.location = point;
[a0f5455]34 }
35
[1a1e8c7]36 public void removeUnit(Unit unit) {
37 if(currentUnit != null) {
[a0f5455]38 currentUnit = null;
39 }
40
41 }
[2e798d9]42
43 public void draw(Canvas c, int x, int y) {
44 c.drawRect(x, y, x+50, y+50, p);
[b97a618]45 }
46
47 public void drawUnit(Canvas c, int x, int y) {
[1a1e8c7]48 if(currentUnit != null)
49 currentUnit.draw(c, x+25, y+25);
[2e798d9]50 }
51}
Note: See TracBrowser for help on using the repository browser.