basic tile placement, TODO: check valid placement with color, turn based placement
This commit is contained in:
parent
2a8bd73d07
commit
cabc35394f
97 changed files with 1348 additions and 948 deletions
53
HexOutline.gd
Normal file
53
HexOutline.gd
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
extends Area3D
|
||||
|
||||
var hovered: bool = false
|
||||
|
||||
var insect_resource: TileResource
|
||||
var is_black: bool = false
|
||||
|
||||
var hex_pos: Vector2i = Vector2i.ZERO
|
||||
|
||||
var tile: Node3D
|
||||
|
||||
const BUILD_GHOST = preload("res://InsectTiles/BuildGhost.tscn")
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
if insect_resource == null:
|
||||
print("Should not happen!")
|
||||
return
|
||||
|
||||
GameEvents.insect_placed.connect(_on_insect_placed)
|
||||
|
||||
func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector2i) -> void:
|
||||
queue_free()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
if Input.is_action_just_pressed("place_tile"):
|
||||
if hovered:
|
||||
GameEvents.insect_placed.emit(insect_resource, is_black, hex_pos)
|
||||
print("Place me pls")
|
||||
pass
|
||||
|
||||
|
||||
func _on_mouse_entered():
|
||||
hovered = true
|
||||
|
||||
tile = BUILD_GHOST.instantiate()
|
||||
tile.resource = insect_resource
|
||||
tile.is_black = is_black
|
||||
|
||||
|
||||
add_child(tile)
|
||||
|
||||
|
||||
func _on_input_event(camera, event, position, normal, shape_idx):
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
func _on_mouse_exited():
|
||||
hovered = false
|
||||
|
||||
if tile:
|
||||
tile.queue_free()
|
||||
tile = null
|
||||
Loading…
Add table
Add a link
Reference in a new issue