Implemented Pillbug/Mosquito actions. Implemented pre-game settings. TODO: Game settings + bug testing

This commit is contained in:
Sch1nken 2024-03-30 01:43:38 +01:00
parent 397082f966
commit 2343638749
15 changed files with 477 additions and 70 deletions

View file

@ -2,7 +2,22 @@ extends ActionBehaviour
class_name ActionBehaviourMosquito
func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void:
pass
# if target only has move, just do move as
#source_tile.temporary_action_behaviour = action_tile.resource.action_behaviour
#source_tile.temporary_movement_behaviour = action_tile.resource.movement_behaviour
source_tile.temporary_resource = action_tile.resource
GameEvents.insect_tile_selected.emit(source_tile)
#if action_tile.resource.action_behaviour == null:
# map.do_move_as(source_tile, action_tile)
#else:
# Copy and offer MOVE and Action (basically pillbug)
# Starting to think it would be easier to temporarily change action_behaviour resource
# pass
# GameEvents.insect_tiles_selected_for_action
func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
@ -10,7 +25,6 @@ func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
# so we can't use our action unless we're on layer 0
# TODO: Update movement selection
if source_pos.w > 0:
map.debug_label(Vector3(source_pos.x, source_pos.y, source_pos.z), "TODO: Implement Beetle Movement")
return []
var neighbours = map.get_neighbours(source_pos)
@ -20,7 +34,10 @@ func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
var tile = map.get_tile(neighbour)
if tile != null:
# TODO: Find better way to see what tile we have...
if not tile.resource.movement_behaviour is MovementBehaviourMosquito:
if tile.resource.movement_behaviour is MovementBehaviourMosquito:
continue
if tile.resource.movement_behaviour.get_available_spaces(source_pos, map).size() > 0:
possible_action_targets.push_back(tile)
#GameEvents.insect_tiles_selected_for_action.emit(source_pos, possible_action_targets)

View file

@ -1,18 +1,52 @@
extends ActionBehaviour
class_name ActionBehaviourPillbug
func can_move_through(cellA: Vector4i, cellB: Vector4i, map: HexGrid) -> bool:
cellA.w = 1
cellB.w = 1
return map.get_same_neighbours(cellA, cellB).size() < 2
func do_action(source_tile: InsectTile, action_tile: InsectTile, map: HexGrid) -> void:
pass
# get action tile
# place hex outline for action tile around source_tile
var tiles: Array[Vector4i] = map.get_empty_neighbours(source_tile.coordinates)
var possible_tiles: Array[Vector4i] = []
for tile in tiles:
if can_move_through(source_tile.coordinates, tile, map):
possible_tiles.push_back(tile)
map.create_move_tiles(action_tile, possible_tiles)
func get_targets(source_pos: Vector4i, map: HexGrid) -> Array[InsectTile]:
var neighbours = map.get_neighbours(source_pos)
var possible_action_targets: Array[InsectTile] = []
var tiles: Array[Vector4i] = map.get_empty_neighbours(source_pos)
var possible_tiles: Array[Vector4i] = []
if tiles.is_empty():
# no empty spaces left to move to
print("no spaces left")
return []
for tile in tiles:
if can_move_through(source_pos, tile, map):
possible_tiles.push_back(tile)
if possible_tiles.size() == 0:
print("no possible tiles?")
# no possible spaces to move TO
return []
for neighbour in neighbours:
var tile = map.get_tile(neighbour)
if tile != null:
if not tile.is_in_stack() and tile.can_move():
possible_action_targets.push_back(tile)
if can_move_through(source_pos, neighbour, map):
# this tile can be picked up
possible_action_targets.push_back(tile)
#GameEvents.insect_tiles_selected_for_action.emit(source_pos, possible_action_targets)

View file

@ -19,7 +19,7 @@ func _ready():
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
#multiplayer.server_disconnected.connect(_on_server_disconnected)
GameEvents.game_started.emit()
#GameEvents.game_started.emit()
@rpc("any_peer", "call_local")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=24 format=3 uid="uid://bx0bbrwdr0h40"]
[gd_scene load_steps=26 format=3 uid="uid://bx0bbrwdr0h40"]
[ext_resource type="Script" path="res://Game.gd" id="1_dgt1j"]
[ext_resource type="Script" path="res://CameraPivot.gd" id="2_71xp1"]
@ -15,6 +15,7 @@
[ext_resource type="Script" path="res://addons/awesome_input_icons/classes/InputIconTextureRect.gd" id="13_mbmni"]
[ext_resource type="Texture2D" uid="uid://20wqrthwoqr0" path="res://addons/awesome_input_icons/assets/keyboard and mouse vector/mouse_move.svg" id="14_t8b21"]
[ext_resource type="Script" path="res://UI/ActionMoveMenu.gd" id="15_gc6p8"]
[ext_resource type="Script" path="res://UI/GameSettings.gd" id="16_uww8u"]
[sub_resource type="PlaneMesh" id="PlaneMesh_cu5ir"]
material = ExtResource("5_u4p4p")
@ -56,6 +57,9 @@ texture = SubResource("GradientTexture2D_tjcjh")
axis_stretch_vertical = 2
modulate_color = Color(1, 1, 1, 0.639216)
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_51vcp"]
bg_color = Color(0.345098, 0.345098, 0.345098, 1)
[node name="Game" type="Node3D"]
script = ExtResource("1_dgt1j")
@ -532,6 +536,88 @@ layout_mode = 2
layout_mode = 2
text = "Cancel"
[node name="GameSettings" type="CanvasLayer" parent="."]
[node name="GameSettings" type="Control" parent="GameSettings"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("16_uww8u")
[node name="PanelContainer" type="PanelContainer" parent="GameSettings/GameSettings"]
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
theme_override_styles/panel = SubResource("StyleBoxFlat_51vcp")
[node name="VBoxContainer" type="VBoxContainer" parent="GameSettings/GameSettings/PanelContainer"]
layout_mode = 2
size_flags_horizontal = 4
size_flags_vertical = 4
[node name="HBoxContainer" type="HBoxContainer" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HostColorLabel" type="Label" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
size_flags_horizontal = 3
text = "Host color"
[node name="HostColorOption" type="OptionButton" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer"]
layout_mode = 2
item_count = 3
selected = 0
allow_reselect = true
popup/item_0/text = "White"
popup/item_0/id = 0
popup/item_1/text = "Black"
popup/item_1/id = 1
popup/item_2/text = "Random"
popup/item_2/id = 2
[node name="HBoxContainer2" type="HBoxContainer" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HostColorLabel" type="Label" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
size_flags_horizontal = 3
text = "Use Ladybug expansion?"
[node name="LadybugCheckbutton" type="CheckButton" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
[node name="HBoxContainer3" type="HBoxContainer" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HostColorLabel" type="Label" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer3"]
layout_mode = 2
size_flags_horizontal = 3
text = "Use Mosquito expansion?"
[node name="MosquitoCheckbutton" type="CheckButton" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer3"]
layout_mode = 2
[node name="HBoxContainer4" type="HBoxContainer" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HostColorLabel" type="Label" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer4"]
layout_mode = 2
size_flags_horizontal = 3
text = "Use Pillbug expansion?"
[node name="PillbugCheckbutton" type="CheckButton" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer4"]
layout_mode = 2
[node name="StartGameButton" type="Button" parent="GameSettings/GameSettings/PanelContainer/VBoxContainer"]
layout_mode = 2
text = "Start"
[connection signal="pressed" from="MenuButtons/VBoxContainer/MenuButton" to="MenuButtons" method="_on_menu_button_pressed"]
[connection signal="pressed" from="MenuButtons/VBoxContainer/PassRoundButton" to="MenuButtons" method="_on_pass_round_button_pressed"]
[connection signal="pressed" from="MenuButtons/VBoxContainer/SurrenderButton" to="MenuButtons" method="_on_surrender_button_pressed"]
@ -541,3 +627,8 @@ text = "Cancel"
[connection signal="pressed" from="CanvasLayer/ActionMoveMenu/PanelContainer/MarginContainer/VBoxContainer/MoveButton" to="CanvasLayer/ActionMoveMenu" method="_on_move_button_pressed"]
[connection signal="pressed" from="CanvasLayer/ActionMoveMenu/PanelContainer/MarginContainer/VBoxContainer/ActionButton" to="CanvasLayer/ActionMoveMenu" method="_on_action_button_pressed"]
[connection signal="pressed" from="CanvasLayer/ActionMoveMenu/PanelContainer/MarginContainer/VBoxContainer/CancelButton" to="CanvasLayer/ActionMoveMenu" method="_on_cancel_button_pressed"]
[connection signal="item_selected" from="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer/HostColorOption" to="GameSettings/GameSettings" method="_on_host_color_option_item_selected"]
[connection signal="toggled" from="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer2/LadybugCheckbutton" to="GameSettings/GameSettings" method="_on_ladybug_checkbutton_toggled"]
[connection signal="toggled" from="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer3/MosquitoCheckbutton" to="GameSettings/GameSettings" method="_on_mosquito_checkbutton_toggled"]
[connection signal="toggled" from="GameSettings/GameSettings/PanelContainer/VBoxContainer/HBoxContainer4/PillbugCheckbutton" to="GameSettings/GameSettings" method="_on_pillbug_checkbutton_toggled"]
[connection signal="pressed" from="GameSettings/GameSettings/PanelContainer/VBoxContainer/StartGameButton" to="GameSettings/GameSettings" method="_on_start_game_button_pressed"]

View file

@ -12,6 +12,12 @@ var allow_selecting_in_stack: bool = false
var lobby_code: String = ""
var is_host_black: bool = false
var use_ladybug_extension: bool = false
var use_mosquito_extension: bool = false
var use_pillbug_extension: bool = false
# false as key = white
# true as key = black
@ -27,3 +33,7 @@ func reset() -> void:
disconnect_reason = ""
bees_placed = {}
peer_id = 1
use_ladybug_extension = false
use_mosquito_extension = false
use_pillbug_extension = false
is_host_black = false

View file

@ -19,6 +19,8 @@ signal choose_action_or_move(tile, has_action_targets, has_move_targets)
signal insect_tile_move_started(tile)
signal insect_tile_action_started(tile)
signal show_move_error(error)
# Turn started could work implicitly? We'll see...
signal pass_round
signal turn_started(turn_num, map, is_blacks_turn)

View file

@ -293,7 +293,7 @@ func can_move(tile: InsectTile) -> bool:
if not can_hive_exist_without_tile(tile):
return false
var spaces = tile.resource.movement_behaviour.get_available_spaces(tile.coordinates, self)
var spaces = tile.get_movement_behaviour().get_available_spaces(tile.coordinates, self)
if spaces.is_empty():
return false
@ -301,10 +301,10 @@ func can_move(tile: InsectTile) -> bool:
return true
func has_action_targets(tile: InsectTile) -> bool:
if tile.resource.action_behaviour == null:
if tile.get_action_behaviour() == null:
return false
var targets: Array[InsectTile] = tile.resource.action_behaviour.get_targets(tile.coordinates, self)
var targets: Array[InsectTile] = tile.get_action_behaviour().get_targets(tile.coordinates, self)
return !targets.is_empty()
@ -315,13 +315,110 @@ func _on_insect_tile_move_started(tile: InsectTile) -> void:
do_move(tile)
func do_action(tile: InsectTile) -> void:
# get possible targets, pass the resource action callable with binds of source and target tile
var targets = tile.get_action_behaviour().get_targets(tile.coordinates, self)
for target in targets:
print("target?")
target.action_callback = tile.get_action_behaviour().do_action.bind(tile, target, self)
target.selected_for_action = true
target.highlight_for_action()
pass
pass
func do_move_as(source: InsectTile, copy: InsectTile) -> void:
if not can_hive_exist_without_tile(source):
print("Cant to do move as. Cant exist without hive")
return
for child in placement_visualizer.get_children():
child.queue_free()
var spaces = copy.get_movement_behaviour().get_available_spaces(source.coordinates, self)
if spaces.is_empty():
print("empty?")
#GameEvents.insect_tile_selection_request_failed.emit(tile)
return
for space in spaces:
var neighbours = get_neighbours(space)
var non_empty_neighbours = neighbours.filter(is_cell_not_empty)
if non_empty_neighbours.size() == 1:
# NOTE: This is correct! But seemed wrong when testing the beetle movement
# If there are only two tiles (beetle + some other) the beetle can't climb ontop of the other
# tile. (would not necessarily split the hive, but the simple logic I use thinks so).
# This fixes itself automatically when there are more than two tiles present
# And since you can't move unless you place the bee, there will always be at least 3 tiles
# before you can move your beetle
# NOTE: This MIGHT result in a bug when you stack beetles... but no I don't think so
# You'd need to have a bee to be able to move, so yeah
var occupied_neighbour = non_empty_neighbours.front()
if occupied_neighbour == source.coordinates:
# TODO: Check if this is stil correct?
continue
var layer: int = 0
var temp_tile: InsectTile = null
if is_cell_not_empty(space):
temp_tile = used_cells.get(space)
layer = 1
while temp_tile.hat != null:
layer += 1
temp_tile = temp_tile.hat
#print(layer)
space.w = layer
var outline = HEX_OUTLINE.instantiate()
var hex_pos = cube_to_world_pos(space) # flat_hex_to_world_position(AxialCoordinates.new(space.x, space.y))
outline.position = Vector3(hex_pos.x, layer * layer_height, hex_pos.y)
outline.coordinates = space
outline.visible = true
outline.insect_tile = source
outline.is_moving = true
outline.insect_resource = source.resource
outline.is_black = source.is_black
placement_visualizer.add_child(outline)
placements[space] = outline
func create_move_tiles(tile: InsectTile, coords: Array[Vector4i]) -> void:
for space in coords:
var layer: int = 0
var temp_tile: InsectTile = null
if is_cell_not_empty(space):
temp_tile = used_cells.get(space)
layer = 1
while temp_tile.hat != null:
layer += 1
temp_tile = temp_tile.hat
space.w = layer
var outline = HEX_OUTLINE.instantiate()
var hex_pos = cube_to_world_pos(space) # flat_hex_to_world_position(AxialCoordinates.new(space.x, space.y))
outline.position = Vector3(hex_pos.x, layer * layer_height, hex_pos.y)
outline.coordinates = space
outline.visible = true
outline.insect_tile = tile
outline.is_moving = true
outline.insect_resource = tile.resource
outline.is_black = tile.is_black
placement_visualizer.add_child(outline)
placements[space] = outline
func do_move(tile: InsectTile) -> void:
for child in placement_visualizer.get_children():
child.queue_free()
var spaces = tile.resource.movement_behaviour.get_available_spaces(tile.coordinates, self)
var spaces = tile.get_movement_behaviour().get_available_spaces(tile.coordinates, self)
if spaces.is_empty():
print("empty?")
@ -384,7 +481,7 @@ func _on_insect_tile_selected(tile: InsectTile) -> void:
return
else:
# if tile has an action
if tile.resource.action_behaviour != null:
if tile.get_action_behaviour() != null:
GameEvents.choose_action_or_move.emit(tile, has_action_targets(tile), can_move(tile))
return

View file

@ -210,6 +210,6 @@ func _on_pressed():
release_focus()
func _input(event):
if Input.is_action_just_pressed("ui_accept"):
if Input.is_action_just_pressed("deselect_tile"):
release_focus()
return

View file

@ -1,8 +1,39 @@
extends MovementBehaviour
class_name MovementBehaviourMosquito
@export var max_movement_reach: int = 1
func simulate_move_recursive(start: Vector4i, max_num: int, map: HexGrid, visited_cells: Array[Vector4i] = []) -> Array[Vector4i]:
var visited = visited_cells.duplicate()
var possible: Array[Vector4i] = []
visited.append(start)
if max_num < 1:
return [start]
for neighbour in map.get_neighbours(start, true):
if neighbour in visited:
continue
# can reach... can_reach should only apply to our current level
#if not map.can_reach(start, neighbour):
# continue
visited.append(neighbour)
possible.append_array(simulate_move_recursive(neighbour, max_num - 1, map, visited))
return possible
func get_available_spaces(pos: Vector4i, map: HexGrid) -> Array[Vector4i]:
return []
if pos.w == 0:
return []
var possible_places: Array[Vector4i] = []
possible_places = simulate_move_recursive(pos, max_movement_reach, map)
return possible_places
#var target_spaces: Array[Vector4i] = []
#
#for neighbour in map.get_neighbours(pos):

View file

@ -3,16 +3,19 @@ extends MeshInstance3D
var mat: ShaderMaterial
# Called when the node enters the scene tree for the first time.
func _ready():
GameEvents.game_started.connect(_on_game_started)
mat = get_active_material(0)
mat.set_shader_parameter("distance_fade_max", -1.0)
mat.set_shader_parameter("distance_fade_min", 0.0)
func _on_game_started() -> void:
var tween = get_tree().create_tween()
tween.set_parallel(true)
tween.tween_method(tween_inner, -1.0, 10.0, 3.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
tween.tween_method(tween_outer, 0.0, 25.0, 3.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_CIRC)
pass # Replace with function body.
func tween_inner(value: float) -> void:
mat.set_shader_parameter("distance_fade_max", value)

View file

@ -12,6 +12,7 @@ script = ExtResource("1_v5wo0")
[sub_resource type="Resource" id="Resource_0j1qw"]
script = ExtResource("3_gkh5p")
max_movement_reach = 1
[resource]
script = ExtResource("3_5xhnv")

View file

@ -2,44 +2,54 @@ extends Area3D
class_name InsectTile
var map_reference: HexGrid
var is_blacks_turn: bool = false
var coordinates: Vector4i
@export var is_black: bool = false
@export var resource: TileResource
var temporary_resource: TileResource = null
@onready var hexagon_small = $HexagonSmall
var hat: InsectTile = null
var build_in_progress: bool = false
var move_in_progress: bool = false
var deactivated: bool = false
var hovered: bool = false
var selected: bool = false
var hover_shader: ShaderMaterial = preload("res://InsectTiles/HoverShader.tres")
#const SELECTION_FAILED_MAT: ShaderMaterial = preload("res://InsectTiles/SelectionFailedMat.tres")
#const ACTION_SHADER = preload("res://InsectTiles/ActionShader.tres")
var mat: StandardMaterial3D
var tween: Tween
var tweening: bool = false
var selected_for_action: bool = false
var action_callback: Callable = Callable()
var can_be_selected: bool = false
var move_round_penalty: int = 0
func get_action_behaviour() -> ActionBehaviour:
if temporary_resource == null:
return resource.action_behaviour
return temporary_resource.action_behaviour
func get_movement_behaviour() -> MovementBehaviour:
if temporary_resource == null:
return resource.movement_behaviour
return temporary_resource.movement_behaviour
func get_resource() -> TileResource:
if temporary_resource == null:
return resource
return temporary_resource
func is_in_stack() -> bool:
return hat != null or coordinates.w != 0
@ -84,20 +94,20 @@ func _ready() -> void:
GameEvents.insect_selected.connect(_on_insect_selected)
GameEvents.insect_tile_selecetion_failed.connect(_on_selection_failed)
GameEvents.insect_placed.connect(_on_insect_placed)
GameEvents.insect_placement_cancelled.connect(_on_insect_placement_cancelled, CONNECT_DEFERRED)
GameEvents.insect_placement_cancelled.connect(_on_insect_placement_cancelled)
GameEvents.insect_tile_selected.connect(_on_insect_tile_selected)
GameEvents.insect_tile_deselected.connect(_on_insect_tile_deselected)
GameEvents.insect_tile_moved.connect(_on_insect_tile_moved)
GameEvents.insect_tiles_selected_for_action.connect(_on_tiles_selected_for_action)
#GameEvents.insect_tiles_selected_for_action.connect(_on_tiles_selected_for_action)
GameEvents.insect_action_cancelled.connect(_on_action_cancelled)
GameEvents.turn_started.connect(_on_turn_started)
func _on_action_cancelled() -> void:
selected_for_action = false
move_in_progress = false
selected = false
action_callback = Callable()
if hovered:
hover()
@ -126,38 +136,60 @@ func _on_turn_started(turn_num: int, map: HexGrid, _is_blacks_turn: bool) -> voi
if turn_num >= 7 and not GameData.bees_placed.has(is_black):
can_be_selected = true
func _on_tiles_selected_for_action(source_pos: Vector4i, targets: Array[InsectTile]) -> void:
if self in targets:
selected_for_action = true
if tween != null:
tween.kill()
if can_be_selected:
tween_normal()
else:
tween_disabled()
tween = get_tree().create_tween()
#tween.tween_property(self, "position", Vector3(0, 0, 5), 0.5).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING)
tween.tween_method(tween_shader, Color(0, 0.6, 0, 0), Color(0, 0.6, 0, 0.8), 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
return
func tween_disabled() -> void:
if tween != null:
tween.kill()
deactivated = true
tween = get_tree().create_tween()
tween.tween_method(tween_shader, mat.next_pass.get_shader_parameter("albedo"), Color(0, 0, 0, 1), 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
func tween_normal() -> void:
if tween != null:
tween.kill()
tween = get_tree().create_tween()
tween.tween_method(tween_shader, mat.next_pass.get_shader_parameter("albedo"), Color(1, 1, 1, 0), 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
func highlight_for_action() -> void:
selected_for_action = true
if tween != null:
tween.kill()
tween = get_tree().create_tween()
#tween.tween_property(self, "position", Vector3(0, 0, 5), 0.5).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING)
tween.tween_method(tween_shader, Color(0, 0.6, 0, 0), Color(0, 0.6, 0, 0.8), 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
func _on_insect_tile_moved(tile: InsectTile, to: Vector4i) -> void:
move_in_progress = false
selected = false
deactivated = false
temporary_resource = null
action_callback = Callable()
if tile == self:
move_round_penalty == 2
func _on_insect_tile_deselected(tile: InsectTile) -> void:
move_in_progress = false
selected = false
deactivated = false
temporary_resource = null
action_callback = Callable()
if can_be_selected:
tween_normal()
else:
tween_disabled()
if hovered:
hover()
else:
if tween != null:
tween.kill()
#else:
#if tween != null:
#tween.kill()
#tween.tween_method(tween_shader, mat.next_pass.get_shader_parameter("albedo"), Color(1, 1, 1, 0), 0.5).set_ease(Tween.EASE_IN_OUT).set_trans(Tween.TRANS_EXPO)
@ -168,28 +200,37 @@ func _on_insect_tile_selected(tile: InsectTile) -> void:
return
func _on_insect_placed(resource: TileResource, is_black: bool, pos: Vector4i) -> void:
build_in_progress = false
deactivated = false
func _on_insect_placement_cancelled() -> void:
build_in_progress = false
deactivated = false
temporary_resource = null
action_callback = Callable()
if can_be_selected:
tween_normal()
else:
tween_disabled()
func _on_insect_selected(button: InsectButton, is_black: bool) -> void:
build_in_progress = true
deactivated = true
#func _process(delta):
func _input_event(camera, event, position, normal, shape_idx):
if Input.is_action_just_pressed("place_tile"):
if selected_for_action and not action_callback.is_null():
action_callback.call()
action_callback = Callable()
if deactivated:
return
if not can_be_selected:
return
if not hovered:
return
#if not hovered:
#return
if not is_owner():
return
@ -243,19 +284,23 @@ func unhover() -> void:
func _on_mouse_entered():
return
if hat != null:
return
hovered = true
if not deactivated and not selected_for_action:
if not deactivated:
hover()
func _on_mouse_exited():
return
if hat != null:
return
hovered = false
if not selected and not selected_for_action:
if not selected:
unhover()

View file

@ -42,10 +42,10 @@ func _on_tile_deselected(tile: InsectTile) -> void:
func _on_choose_action_or_move(tile: InsectTile, has_action_targets: bool, can_move: bool) -> void:
current_tile = tile
move_button.text = "Move as %s" % tile.resource.tile_name
move_button.text = "Move as %s" % tile.get_resource().tile_name
move_button.disabled = !can_move
action_button.text = "Use action of %s" % tile.resource.tile_name
action_button.text = "Use action of %s" % tile.get_resource().tile_name
action_button.disabled = !has_action_targets
show_panel()
pass

View file

@ -11,9 +11,9 @@ const default_insects = {
preload("res://Tile/Prefabs/Beetle.tres"): 2,
preload("res://Tile/Prefabs/Grasshopper.tres"): 3,
preload("res://Tile/Prefabs/Spider.tres"): 2,
preload("res://Tile/Prefabs/Ladybug.tres"): 1,
preload("res://Tile/Prefabs/Mosquito.tres"): 1,
preload("res://Tile/Prefabs/Pillbug.tres"): 1
#preload("res://Tile/Prefabs/Ladybug.tres"): 1,
#preload("res://Tile/Prefabs/Mosquito.tres"): 1,
#preload("res://Tile/Prefabs/Pillbug.tres"): 1
}
var local_bee_button: InsectButton
@ -96,19 +96,33 @@ func setup_colors(is_host_black: bool) -> void:
# Called when the node enters the scene tree for the first time.
func _ready():
GameEvents.game_started.connect(_on_game_started)
func _on_game_started() -> void:
if multiplayer.is_server():
setup_colors.rpc(false)
print("HOST BLACK?")
print(GameData.is_host_black)
setup_colors.rpc(GameData.is_host_black)
add_insect.rpc("res://Tile/Prefabs/Bee.tres", 1, false, 1)
add_spacer.rpc(false, 1)
add_insect.rpc("res://Tile/Prefabs/Bee.tres", 1, GameData.is_host_black, 1)
add_spacer.rpc(GameData.is_host_black, 1)
add_insect.rpc("res://Tile/Prefabs/Bee.tres", 1, true, GameData.peer_id)
add_spacer.rpc(true, GameData.peer_id)
add_insect.rpc("res://Tile/Prefabs/Bee.tres", 1, !GameData.is_host_black, GameData.peer_id)
add_spacer.rpc(!GameData.is_host_black, GameData.peer_id)
var insects = default_insects.duplicate()
if GameData.use_ladybug_extension:
insects[preload("res://Tile/Prefabs/Ladybug.tres")] = 1
if GameData.use_mosquito_extension:
insects[preload("res://Tile/Prefabs/Mosquito.tres")] = 1
if GameData.use_pillbug_extension:
insects[preload("res://Tile/Prefabs/Pillbug.tres")] = 1
#remote_bee_button.set_authority.rpc(GameData.peer_id)
for key in default_insects.keys():
add_insect.rpc(key.get_path(), default_insects[key], false, 1)
add_insect.rpc(key.get_path(), default_insects[key], true, GameData.peer_id)
for key in insects.keys():
add_insect.rpc(key.get_path(), insects[key], GameData.is_host_black, 1)
add_insect.rpc(key.get_path(), insects[key], !GameData.is_host_black, GameData.peer_id)
#add_insect.rpc("res://Tile/Prefabs/Ant.tres", 1, false, GameData.peer_id)
reverse_enemy_list.rpc()
@ -150,8 +164,7 @@ func _ready():
if multiplayer.is_server():
btn.set_authority.rpc(GameData.peer_id)
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
func _input(event):
if Input.is_action_just_pressed("deselect_tile"):
GameEvents.insect_placement_cancelled.emit()
pass

63
UI/GameSettings.gd Normal file
View file

@ -0,0 +1,63 @@
extends Control
@onready var host_color_option = $PanelContainer/VBoxContainer/HBoxContainer/HostColorOption
@onready var ladybug_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer2/LadybugCheckbutton
@onready var mosquito_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer3/MosquitoCheckbutton
@onready var pillbug_checkbutton = $PanelContainer/VBoxContainer/HBoxContainer4/PillbugCheckbutton
@onready var start_game_button = $PanelContainer/VBoxContainer/StartGameButton
func _ready() -> void:
if not multiplayer.is_server():
host_color_option.disabled = true
ladybug_checkbutton.disabled = true
mosquito_checkbutton.disabled = true
pillbug_checkbutton.disabled = true
start_game_button.disabled = true
@rpc("any_peer", "call_local")
func start_game() -> void:
visible = false
GameEvents.game_started.emit()
func _on_start_game_button_pressed():
GameData.use_ladybug_extension = ladybug_checkbutton.button_pressed
GameData.use_mosquito_extension = mosquito_checkbutton.button_pressed
GameData.use_pillbug_extension = pillbug_checkbutton.button_pressed
match host_color_option.get_selected_id():
0: #white
GameData.is_host_black = false
1: #black
GameData.is_host_black = true
2: #random
if randi_range(0, 1) == 0:
GameData.is_host_black = false
else:
GameData.is_host_black = true
start_game.rpc()
@rpc("any_peer")
func update_button_state(button: NodePath, is_checked: bool) -> void:
get_node(button).button_pressed = is_checked
@rpc("any_peer")
func update_host_color_option(index: int) -> void:
host_color_option.select(index)
func _on_host_color_option_item_selected(index):
if multiplayer.is_server():
update_host_color_option.rpc(index)
func _on_ladybug_checkbutton_toggled(toggled_on):
if multiplayer.is_server():
update_button_state.rpc(ladybug_checkbutton.get_path(), toggled_on)
func _on_mosquito_checkbutton_toggled(toggled_on):
if multiplayer.is_server():
update_button_state.rpc(mosquito_checkbutton.get_path(), toggled_on)
func _on_pillbug_checkbutton_toggled(toggled_on):
if multiplayer.is_server():
update_button_state.rpc(pillbug_checkbutton.get_path(), toggled_on)