From 560b2702f1dfe2836c7127dbae7f7d3b515510c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Fri, 10 Jul 2020 10:33:35 +0200 Subject: Hex : reorder overlays, add move --- Hex.gd | 30 ++++++++++++++++-------------- assets/move.png | Bin 0 -> 5145 bytes 2 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 assets/move.png 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) diff --git a/assets/move.png b/assets/move.png new file mode 100644 index 0000000..01db48d Binary files /dev/null and b/assets/move.png differ -- cgit v1.1-2-g2b99