summaryrefslogtreecommitdiffstats
path: root/Hex.gd
diff options
context:
space:
mode:
Diffstat (limited to 'Hex.gd')
-rw-r--r--Hex.gd30
1 files changed, 16 insertions, 14 deletions
diff --git a/Hex.gd b/Hex.gd
index f6b615d..d53730e 100644
--- a/Hex.gd
+++ b/Hex.gd
@@ -3,37 +3,35 @@ extends Tile
class_name Hex, "res://godot/Tile.png"
-var type : int = 0
+var type : int = -1
func _ready() -> void:
type = -1
func inspect() -> String:
var s : String = 'plain'
- if type == 2: s = 'city'
- elif type == 3: s = 'wood'
- elif type == 4: s = 'mountain'
+ if type == 0: s = 'city'
+ elif type == 1: s = 'wood'
+ elif type == 2: s = 'mountain'
return "%s e:%d h:%d c:%d\n -> [%d;%d]\n -> (%d;%d)" % [s, elevation(), height(), cost(), coords.x, coords.y, position.x, position.y]
func change() -> void:
- type += 1
- if type < 2: type = 2
- if type > 4: type = -1
- for i in range(2, 5):
- enable_overlay(i, i == type)
+ type = (type + 2) % 4 - 1
+ for i in range(3):
+ enable_overlay(i + 2, i == type)
func cost() -> int:
if type == -1: return 1
- return type - 1
+ return type + 1
func height() -> int:
- if type == 2: return 2
- elif type == 3: return 1
- elif type == 4: return 0
+ if type == 0: return 2
+ elif type == 1: return 1
+ elif type == 2: return 0
return 0
func elevation() -> int:
- if type == 4: return 2
+ if type == 2: return 2
return 0
func block_los(from : Tile, to : Tile, d : float, dt : float) -> bool:
@@ -51,3 +49,7 @@ func show_los(b) -> void:
else:
enable_overlay(0, false)
enable_overlay(1, false)
+
+func show_move(b) -> void:
+ if 5 < get_child_count():
+ enable_overlay(5, b)