Compare commits

..

2 Commits

4 changed files with 36 additions and 17 deletions

View File

@ -23,8 +23,8 @@ onready var animated_sprite : AnimatedSprite = $AnimatedSprite_StateReceiver
## Multiplayer Variables
puppet var puppet_pos = Vector2()
puppet var puppet_anim_sprite_frame :int
puppet var puppet_anim_sprite_name :String
#puppet var puppet_anim_sprite_frame :int
#puppet var puppet_anim_sprite_name :String
puppet var puppet_transform: Transform2D
##TODO:
@ -34,24 +34,24 @@ puppet var puppet_transform: Transform2D
# interfaces for the state machines.
func _ready() -> void:
puppet_anim_sprite_name = animated_sprite.animation
puppet_anim_sprite_frame = animated_sprite.frame
# puppet_anim_sprite_name = animated_sprite.animation
# puppet_anim_sprite_frame = animated_sprite.frame
puppet_transform = transform
## Disable Process and Physics on puppets
if not is_network_master():
animated_sprite.set_process(false)
animated_sprite.set_physics_process(false)
# if not is_network_master():
# animated_sprite.set_process(false)
# animated_sprite.set_physics_process(false)
#movement_state_machine.init_animated_actor(self)
#movement_component.attack_function = funcref(self, "attack")
# movement_component.player_number = player_number
func _process(delta):
if is_network_master():
rset("puppet_anim_sprite_name", animated_sprite.animation)
rset("puppet_anim_sprite_frame", animated_sprite.frame)
else:
animated_sprite.animation = puppet_anim_sprite_name
animated_sprite.frame = puppet_anim_sprite_frame
#func _process(delta):
# if is_network_master():
# rset("puppet_anim_sprite_name", animated_sprite.animation)
# rset("puppet_anim_sprite_frame", animated_sprite.frame)
# else:
# animated_sprite.animation = puppet_anim_sprite_name
# animated_sprite.frame = puppet_anim_sprite_frame
func _unhandled_input(event: InputEvent) -> void:
if is_network_master():

View File

@ -80,6 +80,9 @@ func change_state(new_state: State) -> void:
current_state = new_state
current_state.enter()
#puppet puppet_change_state(new_state: State) -> void:
# pass
# Seems like I don't have to do this every state change!
# if(state_modifiers.size() > 0):
# print("Active Modifiers:")
@ -90,7 +93,7 @@ func change_state(new_state: State) -> void:
emit_signal("state_changed",current_state_name,current_state)
func change_to_known_state(new_state_name: String) -> void:
puppet func puppet_change_to_known_state(new_state_name: String) -> void:
if new_state_name.empty() == false:
if states_index.has(new_state_name):
change_state(states_index[new_state_name])
@ -98,6 +101,16 @@ func change_to_known_state(new_state_name: String) -> void:
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
change_state(states_index["default"])
func change_to_known_state(new_state_name: String) -> void:
if is_network_master():
if new_state_name.empty() == false:
if states_index.has(new_state_name):
change_state(states_index[new_state_name])
else:
push_warning(get_parent().name + ": Attempt to switch state to unknown: " + new_state_name)
change_state(states_index["default"])
rpc("puppet_change_to_known_state", new_state_name)
#func check_parent_before_state_change(new_state_name: String) -> bool:
# ##TODO: Make this a verifiable funcref or something
# if get_parent().has_method("check_state_change"):

View File

@ -14,6 +14,9 @@ func _ready():
else:
var desktop_path = OS.get_system_dir(0).replace("\\", "/").split("/")
$Connect/Name.text = desktop_path[desktop_path.size() - 2]
$Connect/Join.grab_focus()
func _on_host_pressed():
@ -28,7 +31,7 @@ func _on_host_pressed():
var player_name = $Connect/Name.text
NetworkManager.host_game(player_name)
refresh_lobby()
$Players/Start.grab_focus()
func _on_join_pressed():
if $Connect/Name.text == "":
@ -43,6 +46,7 @@ func _on_join_pressed():
$Connect/ErrorLabel.text = ""
$Connect/Host.disabled = true
$Connect/Join.disabled = true
$Players/Start.grab_focus()
var player_name = $Connect/Name.text
NetworkManager.join_game(ip, player_name)

View File

@ -129,13 +129,14 @@ margin_bottom = 109.0
size_flags_horizontal = 2
size_flags_vertical = 2
custom_fonts/font = ExtResource( 2 )
text = "127.0.0.1"
text = "192.168.0.133"
[node name="Host" type="Button" parent="Connect"]
margin_left = 181.0
margin_top = 31.0
margin_right = 246.0
margin_bottom = 51.0
focus_neighbour_bottom = NodePath("../Join")
size_flags_horizontal = 2
size_flags_vertical = 2
custom_fonts/font = ExtResource( 2 )
@ -146,6 +147,7 @@ margin_left = 181.0
margin_top = 87.0
margin_right = 246.0
margin_bottom = 107.0
focus_neighbour_top = NodePath("../Host")
size_flags_horizontal = 2
size_flags_vertical = 2
custom_fonts/font = ExtResource( 2 )