Implemented Pillbug/Mosquito actions. Implemented pre-game settings. TODO: Game settings + bug testing
This commit is contained in:
parent
397082f966
commit
2343638749
15 changed files with 477 additions and 70 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
63
UI/GameSettings.gd
Normal 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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue