diff options
| author | Jérémy Zurcher <jeremy@asynk.ch> | 2021-08-28 11:07:19 +0200 | 
|---|---|---|
| committer | Jérémy Zurcher <jeremy@asynk.ch> | 2021-08-28 11:07:19 +0200 | 
| commit | 54311e2b4194ccad0d28b60a718da8cb01c89f80 (patch) | |
| tree | a2a8d7be55566b26c00df04df872590cadbea60a /addons/hexgrid/Tile.gd | |
| parent | 5dc80e37eb13931f3bdbacffaad5a945732e1209 (diff) | |
| download | godot-hexgrid-54311e2b4194ccad0d28b60a718da8cb01c89f80.zip godot-hexgrid-54311e2b4194ccad0d28b60a718da8cb01c89f80.tar.gz | |
set addons/hexgrid, closess #2
Diffstat (limited to 'addons/hexgrid/Tile.gd')
| -rw-r--r-- | addons/hexgrid/Tile.gd | 49 | 
1 files changed, 49 insertions, 0 deletions
| diff --git a/addons/hexgrid/Tile.gd b/addons/hexgrid/Tile.gd new file mode 100644 index 0000000..b9463eb --- /dev/null +++ b/addons/hexgrid/Tile.gd @@ -0,0 +1,49 @@ +#warning-ignore-all:unused_argument +extends Node2D + +class_name Tile, "res://addons/hexgrid/Tile.png" + +var coords : Vector2 +var blocked : bool +var on_map : bool = false + +var acc : int +var f : float +var parent : Tile +var road_march : bool +var search_count : int + +func configure(p : Vector2, c: Vector2, o :Array) -> void: +	position = p +	coords = c +	on_map = true +	for t in o: +		var s :Sprite = Sprite.new() +		s.texture = load(t) +		s.visible = false +		add_child(s) +	visible = false + +# is there a road with given orientation that drives out of that Tile +func has_road(orientation : int) -> bool: +	print("Tile#has_road() must be overriden in a subclass") +	return false + +# is the line of sight blocked from a Tile to another, d beeing the distance between from and to, +# dt beeing the distance between from and this Tile +func block_los(from : Tile, to : Tile, d : float, dt : float) -> bool: +	print("Tile#block_los() must be overriden in a subclass") +	return false + +func enable_overlay(i :int, v : bool) -> void: +	get_child(i).visible = v +	if v: visible = true +	else : +		visible = false +		for o in get_children(): +			if o.visible: +				visible = true +				break + +func is_overlay_on(i) -> bool: +	return get_child(i).visible | 
