More multiplayer work. Colors, usernames, and upgrades should be pretty
set for the current system. Double lasers now available in upgrade menu
This commit is contained in:
parent
64f72abe3d
commit
eddcd6d388
9
Main.gd
9
Main.gd
|
@ -35,7 +35,7 @@ var rectangle_opacity = 1
|
||||||
var bad_spawning_enabled = true
|
var bad_spawning_enabled = true
|
||||||
var player_info
|
var player_info
|
||||||
var touchy_shooty = false
|
var touchy_shooty = false
|
||||||
var my_info = { name = "sagethesagesage", color = "D2691E" }
|
var my_info = { name = "sagethesagesage", color = "FFFFFF" }
|
||||||
var mainmenu
|
var mainmenu
|
||||||
|
|
||||||
const BADDIE_WAIT_TIME_DEFAULT = 5
|
const BADDIE_WAIT_TIME_DEFAULT = 5
|
||||||
|
@ -217,6 +217,10 @@ func other_ship_color_change(id, other_color):
|
||||||
prints("Other player color change")
|
prints("Other player color change")
|
||||||
get_node(str(id)).modulate(other_color)
|
get_node(str(id)).modulate(other_color)
|
||||||
|
|
||||||
|
func double_laser_upgrade(id):
|
||||||
|
prints("Double laser upgrade for", id)
|
||||||
|
get_node(str(id)).double_laser = true
|
||||||
|
|
||||||
# Show other player's movement
|
# Show other player's movement
|
||||||
func _on_Player_multiplayer_movement(id, position, is_shooting):
|
func _on_Player_multiplayer_movement(id, position, is_shooting):
|
||||||
get_node(str(id)).position = position
|
get_node(str(id)).position = position
|
||||||
|
@ -253,8 +257,9 @@ func _launch_boss():
|
||||||
|
|
||||||
# Currently same as regular enemy death
|
# Currently same as regular enemy death
|
||||||
func _on_boss_death(kill_money):
|
func _on_boss_death(kill_money):
|
||||||
# Give players appropriate money
|
# Give players appropriate money, and restart spawns
|
||||||
$Player.money += kill_money
|
$Player.money += kill_money
|
||||||
|
bad_spawning_enabled = true
|
||||||
|
|
||||||
# Begins screen-flashing process
|
# Begins screen-flashing process
|
||||||
func _flash_screen():
|
func _flash_screen():
|
||||||
|
|
|
@ -39,6 +39,7 @@ RectangleBoss = ExtResource( 5 )
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite" parent="." index="0"]
|
[node name="Sprite" type="Sprite" parent="." index="0"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
z_index = -5
|
z_index = -5
|
||||||
texture = SubResource( 1 )
|
texture = SubResource( 1 )
|
||||||
_sections_unfolded = [ "Z Index" ]
|
_sections_unfolded = [ "Z Index" ]
|
||||||
|
@ -59,6 +60,7 @@ autostart = false
|
||||||
|
|
||||||
[node name="Mothership" parent="." index="3" instance=ExtResource( 8 )]
|
[node name="Mothership" parent="." index="3" instance=ExtResource( 8 )]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
position = Vector2( 18.327, 304.835 )
|
position = Vector2( 18.327, 304.835 )
|
||||||
|
|
||||||
[node name="Line2D" type="Line2D" parent="Mothership" index="2"]
|
[node name="Line2D" type="Line2D" parent="Mothership" index="2"]
|
||||||
|
@ -178,6 +180,8 @@ _sections_unfolded = [ "Visibility" ]
|
||||||
|
|
||||||
[connection signal="body_entered" from="Player" to="Player" method="_on_Player_body_entered"]
|
[connection signal="body_entered" from="Player" to="Player" method="_on_Player_body_entered"]
|
||||||
|
|
||||||
|
[connection signal="double_laser_upgrade" from="Player" to="." method="double_laser_upgrade"]
|
||||||
|
|
||||||
[connection signal="multiplayer_movement" from="Player" to="." method="_on_Player_multiplayer_movement"]
|
[connection signal="multiplayer_movement" from="Player" to="." method="_on_Player_multiplayer_movement"]
|
||||||
|
|
||||||
[connection signal="other_ship_color_change" from="Player" to="." method="other_ship_color_change"]
|
[connection signal="other_ship_color_change" from="Player" to="." method="other_ship_color_change"]
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
extends Area2D
|
extends Area2D
|
||||||
|
|
||||||
|
slave var slave_health
|
||||||
|
|
||||||
signal game_over
|
signal game_over
|
||||||
export (PackedScene) var Laser
|
export (PackedScene) var Laser
|
||||||
# class member variables go here, for example:
|
# class member variables go here, for example:
|
||||||
|
@ -44,30 +46,16 @@ func _ready():
|
||||||
# add_child(timer)
|
# add_child(timer)
|
||||||
|
|
||||||
func _process(delta):
|
func _process(delta):
|
||||||
pass
|
if get_tree().has_network_peer() && not get_tree().is_network_server():
|
||||||
|
#health = slave_health
|
||||||
# # Called every frame. Delta is time since last frame.
|
pass
|
||||||
# # Update game logic here.
|
|
||||||
# pass
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#func _on_GunAimNode_area_entered(area):
|
|
||||||
# for i in range(20):
|
|
||||||
# #var laser = Laser.instance()
|
|
||||||
# #get_node("../").add_child(laser)
|
|
||||||
# #laser.position.y = position.y - 27
|
|
||||||
# #laser.position.x = position.x + 46
|
|
||||||
# if double_laser == true:
|
|
||||||
# var laser2 = Laser.instance()
|
|
||||||
# get_node("../").add_child(laser2)
|
|
||||||
# laser2.position.y = position.y + 28
|
|
||||||
# laser2.position.x = position.x + 46
|
|
||||||
# can_shoot = false
|
|
||||||
# timer.start()
|
|
||||||
|
|
||||||
func _on_Mothership_area_shape_entered(area_id, area, area_shape, self_shape):
|
func _on_Mothership_area_shape_entered(area_id, area, area_shape, self_shape):
|
||||||
health -= 50
|
if not get_tree().has_network_peer():
|
||||||
|
health -= 50
|
||||||
|
if get_tree().is_network_server():
|
||||||
|
health -= 50
|
||||||
|
rset("slave_health", health)
|
||||||
prints(health)
|
prints(health)
|
||||||
var health_bar = Vector2(((health * (.8)) + 100), 200)
|
var health_bar = Vector2(((health * (.8)) + 100), 200)
|
||||||
$Line2D.set_point_position( 1, health_bar )
|
$Line2D.set_point_position( 1, health_bar )
|
||||||
|
|
|
@ -26,7 +26,7 @@ var my_ip
|
||||||
var peer
|
var peer
|
||||||
var player_info = {}
|
var player_info = {}
|
||||||
var incoming_name
|
var incoming_name
|
||||||
var my_info = { name = "", color = "green" }
|
var my_info = { name = "", color = "FFFFFF" }
|
||||||
var server_ip
|
var server_ip
|
||||||
|
|
||||||
var test_id
|
var test_id
|
||||||
|
@ -148,6 +148,8 @@ func _on_BackToMain_pressed():
|
||||||
$ServerAcceptIcon.visible = false
|
$ServerAcceptIcon.visible = false
|
||||||
$EnterIP.visible = false
|
$EnterIP.visible = false
|
||||||
$ConnectTo.visible = false
|
$ConnectTo.visible = false
|
||||||
|
$UsernameLabel.visible = false
|
||||||
|
$Lobby/RichTextLabel.visible = false
|
||||||
|
|
||||||
func _on_UsernameEntry_text_changed(new_text):
|
func _on_UsernameEntry_text_changed(new_text):
|
||||||
my_info = {name = new_text, color = my_info.color}
|
my_info = {name = new_text, color = my_info.color}
|
||||||
|
@ -175,6 +177,8 @@ func startGame():
|
||||||
rpc("yeeper")
|
rpc("yeeper")
|
||||||
|
|
||||||
sync func yeeper():
|
sync func yeeper():
|
||||||
|
$BackToMain.visible = false
|
||||||
|
$BackIcon.visible = false
|
||||||
_on_BackToMain_pressed()
|
_on_BackToMain_pressed()
|
||||||
emit_signal("start_multiplayer_game")
|
emit_signal("start_multiplayer_game")
|
||||||
$StartGame.visible = false
|
$StartGame.visible = false
|
|
@ -99,7 +99,7 @@ animations = [ {
|
||||||
"speed": 5.0
|
"speed": 5.0
|
||||||
} ]
|
} ]
|
||||||
|
|
||||||
[node name="Networking" type="Node"]
|
[node name="Networking" type="Node" index="0"]
|
||||||
|
|
||||||
pause_mode = 2
|
pause_mode = 2
|
||||||
script = ExtResource( 1 )
|
script = ExtResource( 1 )
|
||||||
|
|
15
Player.gd
15
Player.gd
|
@ -26,6 +26,7 @@ signal shooting_speed_upgrade # signals that a shooting speed upgrade has occure
|
||||||
signal ship_speed_upgrade
|
signal ship_speed_upgrade
|
||||||
signal other_shooting_upgrade
|
signal other_shooting_upgrade
|
||||||
signal other_ship_speed_upgrade
|
signal other_ship_speed_upgrade
|
||||||
|
signal double_laser_upgrade
|
||||||
signal other_ship_color_change
|
signal other_ship_color_change
|
||||||
signal shooting_speed_fully_upgraded
|
signal shooting_speed_fully_upgraded
|
||||||
signal ship_speed_fully_upgraded
|
signal ship_speed_fully_upgraded
|
||||||
|
@ -57,6 +58,9 @@ const BULLET_DELAY_TIER3_COST = 200
|
||||||
const BULLET_DELAY_TIER4_COST = 400
|
const BULLET_DELAY_TIER4_COST = 400
|
||||||
const BULLET_DELAY_TIER5_COST = 1000
|
const BULLET_DELAY_TIER5_COST = 1000
|
||||||
|
|
||||||
|
# double laser cost
|
||||||
|
const DOUBLE_LASER_COST = 20
|
||||||
|
|
||||||
# the 5 tiers of ship speed
|
# the 5 tiers of ship speed
|
||||||
const SHIP_SPEED_TIER1 = 150
|
const SHIP_SPEED_TIER1 = 150
|
||||||
const SHIP_SPEED_TIER2 = 200
|
const SHIP_SPEED_TIER2 = 200
|
||||||
|
@ -213,6 +217,7 @@ func upgradeBulletDelay():
|
||||||
|
|
||||||
# upgrades the speed at which the ship moves
|
# upgrades the speed at which the ship moves
|
||||||
# not relevant for touchscreen users
|
# not relevant for touchscreen users
|
||||||
|
# may be deprecated
|
||||||
func upgradeShipSpeed():
|
func upgradeShipSpeed():
|
||||||
prints("func upgradeShipSpeed():")
|
prints("func upgradeShipSpeed():")
|
||||||
if (ship_speed == SHIP_SPEED_TIER1 && money >= SHIP_SPEED_TIER2_COST):
|
if (ship_speed == SHIP_SPEED_TIER1 && money >= SHIP_SPEED_TIER2_COST):
|
||||||
|
@ -238,6 +243,12 @@ func upgradeShipSpeed():
|
||||||
|
|
||||||
prints(ship_speed)
|
prints(ship_speed)
|
||||||
|
|
||||||
|
func doubleLaserUpgrade():
|
||||||
|
if money >= DOUBLE_LASER_COST:
|
||||||
|
money -= DOUBLE_LASER_COST
|
||||||
|
double_laser = true
|
||||||
|
rpc("double_laser_upgrade", get_tree().get_network_unique_id())
|
||||||
|
|
||||||
######################
|
######################
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
|
@ -306,6 +317,8 @@ remote func other_shooting_speed_upgrade(id, bullet_delay):
|
||||||
remote func _change_color(id, color):
|
remote func _change_color(id, color):
|
||||||
emit_signal("other_ship_color_change", id, color)
|
emit_signal("other_ship_color_change", id, color)
|
||||||
|
|
||||||
|
remote func double_laser_upgrade(id):
|
||||||
|
emit_signal("double_laser_upgrade", id)
|
||||||
|
|
||||||
# the player's movement vector
|
# the player's movement vector
|
||||||
var velocity = Vector2()
|
var velocity = Vector2()
|
||||||
|
@ -337,7 +350,7 @@ func _process(delta):
|
||||||
|
|
||||||
# if in multiplayer mode, push position and shooting status as often as possible
|
# if in multiplayer mode, push position and shooting status as often as possible
|
||||||
if get_tree().has_network_peer():
|
if get_tree().has_network_peer():
|
||||||
rpc_unreliable("move_player", get_tree().get_network_unique_id(), position, is_shooting)
|
rpc("move_player", get_tree().get_network_unique_id(), position, is_shooting)
|
||||||
|
|
||||||
# if shoot button is pressed, try shooting
|
# if shoot button is pressed, try shooting
|
||||||
if Input.is_action_pressed("ui_accept"):
|
if Input.is_action_pressed("ui_accept"):
|
||||||
|
|
|
@ -23,6 +23,7 @@ signal refund
|
||||||
signal speed_upgrade
|
signal speed_upgrade
|
||||||
signal bullet_delay_upgrade
|
signal bullet_delay_upgrade
|
||||||
signal ship_speed_upgrade
|
signal ship_speed_upgrade
|
||||||
|
signal double_laser_upgrade
|
||||||
signal add_laser
|
signal add_laser
|
||||||
signal plasma_lasers
|
signal plasma_lasers
|
||||||
signal menu_closed
|
signal menu_closed
|
||||||
|
@ -75,6 +76,10 @@ func _on_ShipSpeedUpgrade_pressed():
|
||||||
prints("UPGRADE SHIP SPEED SIGNAL EMITTED")
|
prints("UPGRADE SHIP SPEED SIGNAL EMITTED")
|
||||||
ship_speed_tier = get_parent().ship_speed_tier
|
ship_speed_tier = get_parent().ship_speed_tier
|
||||||
|
|
||||||
|
func _on_DoubleLaserUpgrade_pressed():
|
||||||
|
get_tree().paused = false
|
||||||
|
emit_signal("double_laser_upgrade")
|
||||||
|
prints("UPGRADE SHIP SPEED SIGNAL EMITTED")
|
||||||
|
|
||||||
func _on_Goldenrod_pressed():
|
func _on_Goldenrod_pressed():
|
||||||
emit_signal("change_color", "daa520")
|
emit_signal("change_color", "daa520")
|
||||||
|
|
|
@ -143,6 +143,8 @@ animation = "default"
|
||||||
|
|
||||||
[node name="ShipSpeedUpgrade" type="Node" parent="." index="4"]
|
[node name="ShipSpeedUpgrade" type="Node" parent="." index="4"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
|
|
||||||
[node name="Button" type="Button" parent="ShipSpeedUpgrade" index="0"]
|
[node name="Button" type="Button" parent="ShipSpeedUpgrade" index="0"]
|
||||||
|
|
||||||
anchor_left = 0.0
|
anchor_left = 0.0
|
||||||
|
@ -176,6 +178,8 @@ animation = "New Anim"
|
||||||
|
|
||||||
[node name="ColorSelect" type="Node2D" parent="." index="5"]
|
[node name="ColorSelect" type="Node2D" parent="." index="5"]
|
||||||
|
|
||||||
|
editor/display_folded = true
|
||||||
|
|
||||||
[node name="ColorSelectBG" type="Sprite" parent="ColorSelect" index="0"]
|
[node name="ColorSelectBG" type="Sprite" parent="ColorSelect" index="0"]
|
||||||
|
|
||||||
position = Vector2( 150, 210 )
|
position = Vector2( 150, 210 )
|
||||||
|
@ -398,7 +402,37 @@ group = null
|
||||||
flat = true
|
flat = true
|
||||||
align = 1
|
align = 1
|
||||||
|
|
||||||
[connection signal="button_down" from="Resume" to="." method="_on_Resume_button_down"]
|
[node name="DoubleLaserUpgrade" type="Node2D" parent="." index="6"]
|
||||||
|
|
||||||
|
[node name="Button" type="Button" parent="DoubleLaserUpgrade" index="0"]
|
||||||
|
|
||||||
|
anchor_left = 0.0
|
||||||
|
anchor_top = 0.0
|
||||||
|
anchor_right = 0.0
|
||||||
|
anchor_bottom = 0.0
|
||||||
|
margin_left = 860.0
|
||||||
|
margin_top = 80.0
|
||||||
|
margin_right = 1000.0
|
||||||
|
margin_bottom = 180.0
|
||||||
|
rect_pivot_offset = Vector2( 0, 0 )
|
||||||
|
rect_clip_content = false
|
||||||
|
focus_mode = 2
|
||||||
|
mouse_filter = 0
|
||||||
|
mouse_default_cursor_shape = 0
|
||||||
|
size_flags_horizontal = 1
|
||||||
|
size_flags_vertical = 1
|
||||||
|
toggle_mode = false
|
||||||
|
enabled_focus_mode = 2
|
||||||
|
shortcut = null
|
||||||
|
group = null
|
||||||
|
text = "Double Lasers!"
|
||||||
|
flat = false
|
||||||
|
align = 1
|
||||||
|
|
||||||
|
[node name="Icon" type="AnimatedSprite" parent="DoubleLaserUpgrade" index="1"]
|
||||||
|
|
||||||
|
visible = false
|
||||||
|
animation = "default"
|
||||||
|
|
||||||
[connection signal="pressed" from="Resume" to="." method="_on_Button_pressed"]
|
[connection signal="pressed" from="Resume" to="." method="_on_Button_pressed"]
|
||||||
|
|
||||||
|
@ -426,4 +460,6 @@ align = 1
|
||||||
|
|
||||||
[connection signal="pressed" from="ColorSelect/ColorSelectBG/DeepSkyBlue" to="." method="_on_DeepSkyBlue_pressed"]
|
[connection signal="pressed" from="ColorSelect/ColorSelectBG/DeepSkyBlue" to="." method="_on_DeepSkyBlue_pressed"]
|
||||||
|
|
||||||
|
[connection signal="pressed" from="DoubleLaserUpgrade/Button" to="." method="_on_DoubleLaserUpgrade_pressed"]
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue