2018-05-29 00:08:30 -04:00
|
|
|
#
|
|
|
|
# Copyright (C) 2018 Sage Vaillancourt, sagev9000@gmail.com
|
|
|
|
#
|
|
|
|
# This file is part of Fronter.
|
|
|
|
#
|
|
|
|
# Fronter is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Fronter is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Fronter. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
extends Node
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
export (PackedScene) var FirstBad
|
2018-05-23 03:57:15 -04:00
|
|
|
export (PackedScene) var BlobBad
|
2018-05-26 02:55:17 -04:00
|
|
|
export (PackedScene) var LaserBad
|
2018-06-03 11:11:27 -04:00
|
|
|
export (PackedScene) var Prison
|
2018-05-27 19:22:11 -04:00
|
|
|
export (PackedScene) var RectangleBoss
|
2018-11-14 20:36:02 -05:00
|
|
|
export (PackedScene) var RectangleReturn
|
2018-06-03 11:11:27 -04:00
|
|
|
export (PackedScene) var BlackHole
|
2018-05-23 03:57:15 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
var players = {}
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
var position = Vector2(200, 200)
|
2018-05-27 19:22:11 -04:00
|
|
|
var bads_this_round = 0
|
2018-05-23 01:40:45 -04:00
|
|
|
var upgrade_cost = 50
|
2018-05-26 02:55:17 -04:00
|
|
|
var booting = true
|
2018-05-29 00:08:30 -04:00
|
|
|
var screen_flashing = false
|
2018-05-26 02:55:17 -04:00
|
|
|
var rectangle_opacity = 1
|
2018-05-27 19:22:11 -04:00
|
|
|
var bad_spawning_enabled = true
|
2018-05-29 00:08:30 -04:00
|
|
|
var player_info
|
|
|
|
var touchy_shooty = false
|
2018-05-29 02:39:43 -04:00
|
|
|
var my_info = { name = "sagethesagesage", color = "FFFFFF" }
|
2018-05-29 00:08:30 -04:00
|
|
|
var mainmenu
|
2018-11-12 23:17:53 -05:00
|
|
|
var current_round = 1
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-11-12 23:17:53 -05:00
|
|
|
var spawning_done = false
|
2018-06-03 11:11:27 -04:00
|
|
|
var not_loading = false
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _ready():
|
2018-05-29 00:08:30 -04:00
|
|
|
# Prepare black rectangle for fading in
|
2018-05-27 02:20:51 -04:00
|
|
|
$ColorRect.visible = true
|
2018-05-29 00:08:30 -04:00
|
|
|
|
2018-06-03 11:11:27 -04:00
|
|
|
if OS.has_touchscreen_ui_hint():
|
2018-11-12 23:17:53 -05:00
|
|
|
$HowTos/HowTo.visible = true
|
2018-06-03 11:11:27 -04:00
|
|
|
else:
|
2018-11-12 23:17:53 -05:00
|
|
|
$HowTos/HowToDesktop.visible = true
|
2018-06-03 11:11:27 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Launch the main menu on boot and pause the game
|
|
|
|
mainmenu = preload("res://MainMenu.tscn").instance()
|
2018-05-24 04:19:59 -04:00
|
|
|
add_child(mainmenu)
|
2018-05-26 02:55:17 -04:00
|
|
|
mainmenu.connect("multiplayer_menu", self, "_open_multiplayer_menu")
|
2018-11-12 23:17:53 -05:00
|
|
|
mainmenu.connect("start_game", self, "rounds")
|
2018-05-24 04:19:59 -04:00
|
|
|
get_tree().paused = true
|
2018-11-12 23:17:53 -05:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Seed randi for randomizing enemy spawn locations
|
2018-05-23 01:40:45 -04:00
|
|
|
randomize()
|
2018-11-12 23:17:53 -05:00
|
|
|
updatePoints()
|
|
|
|
|
|
|
|
const DEFAULT_SPAWN_SPEED = 5
|
|
|
|
func rounds(round_number):
|
|
|
|
$BG.visible = true
|
|
|
|
|
|
|
|
##### WEAKER, LESS VALUABLE ENEMIES, AT HIGHER VOLUME, MAY BE MORE ENGAGING
|
|
|
|
|
|
|
|
# health, time, bad1s, badblobs, badlasers, badprisons
|
|
|
|
match round_number:
|
|
|
|
1:
|
2018-11-29 16:04:22 -05:00
|
|
|
# roundOfEnemies(.6,DEFAULT_SPAWN_SPEED*.75,5,0,0,0) # default
|
|
|
|
roundOfEnemies(0.1,DEFAULT_SPAWN_SPEED,1,0,0,0)
|
2018-11-12 23:17:53 -05:00
|
|
|
rpc("set_wave_name", "Wave 1: Learning to fly")
|
|
|
|
2:
|
2018-11-29 16:04:22 -05:00
|
|
|
#roundOfEnemies(.6,DEFAULT_SPAWN_SPEED*.75,4,1,0,0)
|
|
|
|
if get_tree().is_network_server() == true:
|
|
|
|
rpc("bossMode", 2)
|
|
|
|
else:
|
|
|
|
bossMode(2)
|
2018-11-12 23:17:53 -05:00
|
|
|
rpc("set_wave_name", "Wave 2: Any colour you like")
|
|
|
|
3:
|
|
|
|
roundOfEnemies(.6,DEFAULT_SPAWN_SPEED*.75,8,2,0,0)
|
|
|
|
rpc("set_wave_name", "Wave 3: Money")
|
|
|
|
4:
|
|
|
|
roundOfEnemies(.6,DEFAULT_SPAWN_SPEED*.75,12,3,1,0)
|
|
|
|
rpc("set_wave_name", "Wave 4: YOU CAN BLOCK ENEMY LASERS WITH YOUR SHIP")
|
|
|
|
5:
|
|
|
|
roundOfEnemies(.6,DEFAULT_SPAWN_SPEED*.5,15,3,0,0)
|
|
|
|
rpc("set_wave_name", "Wave 5: One of These Days")
|
|
|
|
6:
|
|
|
|
roundOfEnemies(.7,DEFAULT_SPAWN_SPEED*.5,18,6,1,0)
|
|
|
|
rpc("set_wave_name", "Wave 6: Seamus")
|
|
|
|
7:
|
|
|
|
roundOfEnemies(.8,DEFAULT_SPAWN_SPEED*.5,21,7,1,0)
|
|
|
|
rpc("set_wave_name", "Wave 7: ")
|
|
|
|
8:
|
|
|
|
roundOfEnemies(.8,DEFAULT_SPAWN_SPEED*.75/(8/4),20,6,0,floor(8/8))
|
|
|
|
rpc("set_wave_name", "Wave 8: Free Four")
|
|
|
|
9:
|
|
|
|
roundOfEnemies(.9, DEFAULT_SPAWN_SPEED*(0.5), 9*3, 9, floor(9/4), floor(9/8))
|
|
|
|
rpc("set_wave_name", str("Wave 9"))
|
|
|
|
10:
|
|
|
|
rpc("set_wave_name", "Wave 10: What do you want from me?")
|
|
|
|
if get_tree().is_network_server() == true:
|
|
|
|
rpc("bossMode", 0)
|
|
|
|
else:
|
|
|
|
bossMode(0)
|
|
|
|
11:
|
|
|
|
roundOfEnemies(1,DEFAULT_SPAWN_SPEED*.75/(11/4),11*3,11,floor(11/4),floor(11/8))
|
|
|
|
$WaveLabel.text = str("Wave ", 11)
|
|
|
|
$BG/Sun.visible = true
|
|
|
|
15:
|
|
|
|
rpc("set_wave_name", "Wave 15: Eclipse")
|
|
|
|
if get_tree().is_network_server() == true:
|
|
|
|
rpc("bossMode", 1)
|
|
|
|
else:
|
|
|
|
bossMode(1)
|
|
|
|
20:
|
|
|
|
roundOfEnemies((1+(20-11)/10), (DEFAULT_SPAWN_SPEED*(0.5)), 20*3, 20, floor(20/4), floor(20/8))
|
|
|
|
var roundNo:
|
|
|
|
############### health ##### spawn speed #################### bad1s#### blobs # lasers ######### prisons ######
|
|
|
|
roundOfEnemies((1+(roundNo-11)/10), (DEFAULT_SPAWN_SPEED*(0.5)), roundNo*3, roundNo, floor(roundNo/4), floor(roundNo/8))
|
|
|
|
rpc("set_wave_name", str("Wave ", roundNo))
|
|
|
|
|
|
|
|
### Wave names ###
|
|
|
|
### on rectangle's return: The Hero's Return
|
|
|
|
### on Black boss appearance: Eclipse
|
|
|
|
|
|
|
|
sync func set_wave_name(name):
|
|
|
|
$WaveLabel.text = str(name)
|
2018-05-26 02:55:17 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Open the multiplayer section of the menu and pause the game
|
2018-05-26 02:55:17 -04:00
|
|
|
func _open_multiplayer_menu():
|
|
|
|
var multiplayer = preload("res://Networking.tscn").instance()
|
2018-05-29 00:08:30 -04:00
|
|
|
multiplayer.connect("player_info", self, "_load_players")
|
|
|
|
multiplayer.connect("start_multiplayer_game", self, "_start_multiplayer_game")
|
2018-05-26 02:55:17 -04:00
|
|
|
add_child(multiplayer)
|
2018-05-29 00:08:30 -04:00
|
|
|
multiplayer.setName(my_info.name)
|
2018-05-26 02:55:17 -04:00
|
|
|
get_tree().paused = true
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _process(delta):
|
2018-05-29 00:08:30 -04:00
|
|
|
# If L+R+A+Start is pressed on a controller, quit
|
2018-05-23 01:40:45 -04:00
|
|
|
if (Input.is_action_pressed("ctlr_l")):
|
|
|
|
if (Input.is_action_pressed("ctlr_r")):
|
|
|
|
if (Input.is_action_pressed("ctlr_a")):
|
|
|
|
if (Input.is_action_pressed("ctlr_start")):
|
|
|
|
get_tree().quit()
|
2018-05-29 00:08:30 -04:00
|
|
|
# If the quit button is pressed, do it
|
2018-05-23 01:40:45 -04:00
|
|
|
if (Input.is_action_pressed("ui_quit")):
|
|
|
|
get_tree().quit()
|
2018-05-29 00:08:30 -04:00
|
|
|
|
2018-06-03 11:11:27 -04:00
|
|
|
if Input.is_action_pressed("ui_right") || Input.is_action_pressed("ui_left"):
|
|
|
|
_on_HideHowTo_pressed()
|
|
|
|
if Input.is_action_pressed("ui_down") || Input.is_action_pressed("ui_up"):
|
|
|
|
_on_HideHowTo_pressed()
|
|
|
|
if Input.is_action_pressed("ui_accept"):
|
|
|
|
_on_HideHowTo_pressed()
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# If you're in multiplayer,
|
2018-05-26 04:15:20 -04:00
|
|
|
if get_tree().has_network_peer():
|
2018-05-29 00:08:30 -04:00
|
|
|
# and not the host
|
2018-05-26 04:15:20 -04:00
|
|
|
if !get_tree().is_network_server():
|
2018-05-29 00:08:30 -04:00
|
|
|
# Stop spawning bads
|
2018-11-12 23:17:53 -05:00
|
|
|
#$BaddieTimer.stop()
|
|
|
|
pass
|
2018-05-26 04:15:20 -04:00
|
|
|
|
2018-05-26 02:55:17 -04:00
|
|
|
if (touchy_feely && (abs(touchy_feely.position.x - $Player.position.x) > 1)):
|
|
|
|
if (touchy_feely.position.x < 800):
|
|
|
|
$Player.moveto(touchy_feely.position)
|
|
|
|
|
|
|
|
if (touchy_shooty && $Player.can_shoot):
|
|
|
|
$Player.shoot()
|
2018-05-29 00:08:30 -04:00
|
|
|
|
|
|
|
# If we're in the booting process, fade out the rectangle
|
2018-05-26 02:55:17 -04:00
|
|
|
if booting == true:
|
|
|
|
$ColorRect.color = Color(0, 0, 0, rectangle_opacity)
|
|
|
|
rectangle_opacity -= delta/1.25
|
|
|
|
if rectangle_opacity <= 0:
|
|
|
|
booting = false
|
|
|
|
$ColorRect.visible = false
|
2018-11-12 23:17:53 -05:00
|
|
|
$Music.playing = true
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Flash the screen white
|
2018-05-27 19:22:11 -04:00
|
|
|
if screen_flashing == true:
|
|
|
|
$ColorRect.color = Color(1, 1, 1, rectangle_opacity)
|
2018-11-12 23:17:53 -05:00
|
|
|
rectangle_opacity -= delta/3
|
2018-05-27 19:22:11 -04:00
|
|
|
if rectangle_opacity <= 0:
|
|
|
|
screen_flashing = false
|
|
|
|
$ColorRect.visible = false
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# When an enemy dies
|
2018-05-23 03:57:15 -04:00
|
|
|
func _on_bad_death(kill_money):
|
2018-05-29 00:08:30 -04:00
|
|
|
# Give players appropriate money
|
2018-05-23 01:40:45 -04:00
|
|
|
$Player.money += kill_money
|
2018-11-12 23:17:53 -05:00
|
|
|
updatePoints()
|
|
|
|
|
|
|
|
print(current_round)
|
|
|
|
|
|
|
|
if get_tree().is_network_server() || not get_tree().has_network_peer():
|
|
|
|
if get_tree().get_nodes_in_group("enemies").size() == 1 && spawning_done == true:
|
|
|
|
rpc("openPlayerMenu")
|
|
|
|
current_round +=1
|
|
|
|
|
|
|
|
sync func openPlayerMenu():
|
|
|
|
$Player.upgradeMenu()
|
|
|
|
|
|
|
|
func startNextRound():
|
|
|
|
if get_tree().is_network_server() || not get_tree().has_network_peer():
|
|
|
|
rounds(current_round)
|
|
|
|
|
|
|
|
func roundOfEnemies(bad_health_multi, spawn_time, bad1s, badblobs, badlasers, badprisons):
|
|
|
|
spawning_done = false
|
|
|
|
# each enemy type comes in as an integer
|
|
|
|
# randomly dole out enemies until each is at 0
|
|
|
|
yield(get_tree().create_timer(1), "timeout")
|
|
|
|
var enemiesToBeSpawned = bad1s+badblobs+badlasers+badprisons
|
|
|
|
if enemiesToBeSpawned == 0:
|
|
|
|
return false
|
|
|
|
|
|
|
|
var bad_type
|
|
|
|
var badposition = Vector2()
|
|
|
|
|
|
|
|
while enemiesToBeSpawned > 0:
|
|
|
|
var nextEnemy = randi()%5
|
|
|
|
if (nextEnemy == 0 || nextEnemy == 4) && bad1s > 0 && get_tree().paused == false:
|
|
|
|
bad_type = 0
|
|
|
|
bad1s -= 1
|
|
|
|
yield(get_tree().create_timer(spawn_time), "timeout")
|
|
|
|
elif (nextEnemy == 1) && badblobs > 0 && get_tree().paused == false:
|
|
|
|
bad_type = 1
|
|
|
|
badblobs -= 1
|
|
|
|
yield(get_tree().create_timer(spawn_time), "timeout")
|
|
|
|
elif (nextEnemy == 2) && badlasers > 0 && get_tree().paused == false:
|
|
|
|
bad_type = 2
|
|
|
|
badlasers -= 1
|
|
|
|
yield(get_tree().create_timer(spawn_time), "timeout")
|
|
|
|
elif (nextEnemy == 3) && badprisons > 0 && get_tree().paused == false:
|
|
|
|
bad_type = 3
|
|
|
|
badprisons -= 1
|
|
|
|
yield(get_tree().create_timer(spawn_time), "timeout")
|
|
|
|
else: bad_type = 50000
|
|
|
|
|
|
|
|
enemiesToBeSpawned = bad1s+badblobs+badlasers+badprisons
|
|
|
|
|
|
|
|
if get_tree().paused == true:
|
|
|
|
yield(get_tree().create_timer(1), "timeout")
|
|
|
|
|
|
|
|
if bad_type < 50000:
|
|
|
|
badposition.x = 1100
|
|
|
|
badposition.y = (randi()%410) + 50
|
|
|
|
rpc("spawnBad", bad_type, badposition, bad_health_multi)
|
|
|
|
|
|
|
|
spawning_done = true
|
|
|
|
#$Player.upgradeMenu()
|
|
|
|
|
|
|
|
func upgradeTurret(position):
|
|
|
|
print("upgradeTurret()")
|
|
|
|
rpc("remoteUpgradeTurret", position)
|
|
|
|
|
|
|
|
####################
|
|
|
|
# UPGRADE A TURRET #
|
|
|
|
remote func remoteUpgradeTurret(position):
|
|
|
|
for child in get_children():
|
|
|
|
if "turret" in child.get_name():
|
|
|
|
print("turret")
|
|
|
|
if child.position == position:
|
|
|
|
child.upgradeTurret()
|
|
|
|
#child.damage = damage
|
|
|
|
#child.get_node("Range").scale = t_range
|
|
|
|
#child.get_node("ReloadTimer").wait_time = reload_time
|
|
|
|
print(child.damage, child.get_node("Range").scale, child.get_node("ReloadTimer").wait_time)
|
|
|
|
break
|
|
|
|
# UPGRADE A TURRET #
|
|
|
|
####################
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-06-03 11:11:27 -04:00
|
|
|
#########################
|
|
|
|
# ENEMY SPAWNING SCRIPT #
|
|
|
|
#########################
|
|
|
|
var bad_health_multi = 1.5
|
2018-05-23 01:40:45 -04:00
|
|
|
|
2018-11-12 23:17:53 -05:00
|
|
|
sync func spawnBad(bad_type, badposition, health_multi):
|
2018-05-26 15:34:41 -04:00
|
|
|
var bad
|
|
|
|
if bad_type == 0:
|
|
|
|
bad = FirstBad.instance()
|
|
|
|
if bad_type == 1:
|
|
|
|
bad = BlobBad.instance()
|
|
|
|
if bad_type == 2:
|
|
|
|
bad = LaserBad.instance()
|
2018-06-03 11:11:27 -04:00
|
|
|
if bad_type == 3:
|
|
|
|
bad = Prison.instance()
|
|
|
|
|
|
|
|
# Increase BG speed with each enemy spawned
|
|
|
|
$BG.fly_speed *= 1.01
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-05-26 15:34:41 -04:00
|
|
|
add_child(bad)
|
|
|
|
bad.connect("dead", self, "_on_bad_death")
|
2018-06-03 11:11:27 -04:00
|
|
|
if bad_type == 3:
|
|
|
|
bad.connect("health_up", self, "_on_health_up")
|
2018-05-27 02:20:51 -04:00
|
|
|
bad.health_multi = health_multi
|
2018-11-12 23:17:53 -05:00
|
|
|
bad.position = badposition
|
2018-05-26 15:34:41 -04:00
|
|
|
|
2018-06-03 11:11:27 -04:00
|
|
|
func _on_health_up(hp_increase):
|
|
|
|
$Mothership.health += hp_increase
|
|
|
|
$Mothership._update_health_bar()
|
|
|
|
|
2018-05-23 01:40:45 -04:00
|
|
|
func _on_PauseButton_pressed():
|
2018-11-12 23:17:53 -05:00
|
|
|
$Player.pauseMenu()
|
|
|
|
$ColorRect.visible = false
|
2018-05-23 03:57:15 -04:00
|
|
|
|
|
|
|
func updatePoints():
|
2018-11-12 23:17:53 -05:00
|
|
|
$MoneyDisplay.text = str("$", $Player.money)
|
|
|
|
#$MoneyDisplay.text = str($Player.money, " points")
|
2018-05-23 21:35:16 -04:00
|
|
|
|
|
|
|
func _on_Mothership_game_over():
|
2018-11-12 23:17:53 -05:00
|
|
|
for child in self.get_children():
|
|
|
|
print(child, child.name)
|
|
|
|
if ("Bad" in child.name):
|
|
|
|
child.queue_free()
|
|
|
|
elif (child.has_method("bossHealth")):
|
|
|
|
child.queue_free()
|
2018-05-23 21:35:16 -04:00
|
|
|
$Player.gameOver()
|
|
|
|
|
|
|
|
func _on_Player_restart_game():
|
2018-11-12 23:17:53 -05:00
|
|
|
print("_on_Player_restart_game()")
|
|
|
|
"""
|
2018-05-23 21:35:16 -04:00
|
|
|
for child in self.get_children():
|
2018-11-12 23:17:53 -05:00
|
|
|
print(child, child.name)
|
|
|
|
if ("Bad" in child.name):
|
2018-06-03 11:11:27 -04:00
|
|
|
child.queue_free()
|
2018-11-12 23:17:53 -05:00
|
|
|
elif (child.has_method("bossHealth")):
|
|
|
|
child.queue_free()"""
|
|
|
|
current_round = 1
|
|
|
|
spawning_done = true
|
|
|
|
updatePoints()
|
|
|
|
if get_tree().is_network_server() || not get_tree().has_network_peer():
|
|
|
|
rpc("hideGameOver")
|
|
|
|
rpc("openPlayerMenu")
|
|
|
|
|
|
|
|
remote func hideGameOver():
|
|
|
|
$Player.restart_game()
|
2018-05-26 02:55:17 -04:00
|
|
|
|
|
|
|
var touchy_feely
|
|
|
|
|
|
|
|
var touchscreen_on = false
|
|
|
|
func _input(event):
|
|
|
|
if (event is InputEventScreenTouch || event is InputEventScreenDrag):
|
|
|
|
touchscreen_on = true
|
2018-11-12 23:17:53 -05:00
|
|
|
if event.position.x < 800:
|
2018-05-26 02:55:17 -04:00
|
|
|
$Player.position.x = event.position.x + 100*(event.position.x/800)
|
|
|
|
$Player.position.y = event.position.y - 100
|
|
|
|
else:
|
2018-05-26 04:15:20 -04:00
|
|
|
touchy_shooty = true
|
|
|
|
|
2018-05-27 02:20:51 -04:00
|
|
|
func other_shooting_upgrade(id, other_bullet_delay):
|
|
|
|
prints("Other player shooting speed upgrade")
|
2018-05-29 00:08:30 -04:00
|
|
|
get_node(str(id)).timer.set_wait_time(other_bullet_delay)
|
|
|
|
|
2018-11-12 23:17:53 -05:00
|
|
|
func other_damage_upgrade(id, other_laser_damage):
|
|
|
|
get_node(str(id)).laser_damage = other_laser_damage
|
|
|
|
|
|
|
|
func other_laser_penetration_upgrade(id, other_laser_penetration):
|
|
|
|
get_node(str(id)).laser_penetration = other_laser_penetration
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
func other_ship_color_change(id, other_color):
|
|
|
|
prints("Other player color change")
|
|
|
|
get_node(str(id)).modulate(other_color)
|
2018-05-27 02:20:51 -04:00
|
|
|
|
2018-05-29 02:39:43 -04:00
|
|
|
func double_laser_upgrade(id):
|
|
|
|
prints("Double laser upgrade for", id)
|
|
|
|
get_node(str(id)).double_laser = true
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Show other player's movement
|
2018-06-03 11:11:27 -04:00
|
|
|
func _on_Player_multiplayer_movement(id, pos, other_is_shooting):
|
|
|
|
get_node(str(id)).position = pos
|
2018-11-12 23:17:53 -05:00
|
|
|
get_node(str(id)).is_shooting = other_is_shooting
|
2018-05-27 19:22:11 -04:00
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# BOSS MODE #
|
|
|
|
# Disable enemy spawning
|
|
|
|
# Wait a few seconds for enemies to clear
|
|
|
|
# Call for boss launch
|
2018-06-03 11:11:27 -04:00
|
|
|
var bosstimer = null
|
2018-11-12 23:17:53 -05:00
|
|
|
sync func bossMode(boss_type):
|
2018-06-03 11:11:27 -04:00
|
|
|
prints("bossMode()")
|
|
|
|
bosstimer = Timer.new()
|
2018-11-12 23:17:53 -05:00
|
|
|
"""bosstimer.connect("timeout",self,"_launch_boss", boss_type)
|
2018-05-27 19:22:11 -04:00
|
|
|
add_child(bosstimer) #to process
|
2018-11-12 23:17:53 -05:00
|
|
|
bosstimer.wait_time = 3
|
2018-05-27 19:22:11 -04:00
|
|
|
bosstimer.one_shot = true
|
2018-11-12 23:17:53 -05:00
|
|
|
bosstimer.start() #to start"""
|
|
|
|
yield(get_tree().create_timer(3), "timeout")
|
|
|
|
|
|
|
|
|
|
|
|
prints("_launch_boss(",boss_type,")")
|
|
|
|
var bad
|
|
|
|
if boss_type == 0:
|
|
|
|
bad = RectangleBoss.instance()
|
|
|
|
elif boss_type == 1:
|
|
|
|
bad = BlackHole.instance()
|
2018-11-14 20:36:02 -05:00
|
|
|
elif boss_type == 2:
|
|
|
|
bad = RectangleReturn.instance()
|
2018-11-13 19:31:59 -05:00
|
|
|
$Music.volume_db = -40
|
2018-11-12 23:17:53 -05:00
|
|
|
add_child(bad)
|
|
|
|
|
|
|
|
# Flash screen when signalled
|
|
|
|
bad.connect("flash", self, "_flash_screen")
|
|
|
|
bad.show_behind_parent = true
|
|
|
|
|
|
|
|
# Boss death functions the same as regular death
|
|
|
|
bad.connect("dead", self, "_on_boss_death")
|
|
|
|
|
|
|
|
# Get boss health
|
|
|
|
bad.connect("boss_health", self, "getBossHealth")
|
|
|
|
"""
|
2018-05-29 00:08:30 -04:00
|
|
|
# Spawn the first boss
|
2018-11-12 23:17:53 -05:00
|
|
|
func _launch_boss(boss_type):
|
|
|
|
prints("_launch_boss(",boss_type,")")
|
2018-05-27 19:22:11 -04:00
|
|
|
var bad
|
2018-11-12 23:17:53 -05:00
|
|
|
if boss_type == 0:
|
2018-06-05 16:31:55 -04:00
|
|
|
bad = RectangleBoss.instance()
|
2018-11-12 23:17:53 -05:00
|
|
|
elif boss_type == 1:
|
2018-06-05 16:31:55 -04:00
|
|
|
bad = BlackHole.instance()
|
2018-11-12 23:17:53 -05:00
|
|
|
$Music.volume_db = -20
|
2018-05-27 19:22:11 -04:00
|
|
|
add_child(bad)
|
2018-05-29 00:08:30 -04:00
|
|
|
|
|
|
|
# Flash screen when signalled
|
2018-05-27 19:22:11 -04:00
|
|
|
bad.connect("flash", self, "_flash_screen")
|
|
|
|
bad.show_behind_parent = true
|
|
|
|
|
2018-05-29 00:08:30 -04:00
|
|
|
# Boss death functions the same as regular death
|
|
|
|
bad.connect("dead", self, "_on_boss_death")
|
2018-06-03 11:11:27 -04:00
|
|
|
|
|
|
|
# Get boss health
|
|
|
|
bad.connect("boss_health", self, "getBossHealth")
|
2018-11-12 23:17:53 -05:00
|
|
|
"""
|
2018-06-03 11:11:27 -04:00
|
|
|
func getBossHealth(currentHealth, totalHealth):
|
|
|
|
totalHealth = float(totalHealth)
|
|
|
|
var health_bar = Vector2(((currentHealth/totalHealth)*800)+100, 50)
|
|
|
|
$BossHealth.set_point_position(1, health_bar)
|
|
|
|
$BossHealth.default_color.a = 1
|
|
|
|
if currentHealth <= 0:
|
|
|
|
$BossHealth.default_color.a = 0
|
|
|
|
pass
|
2018-05-29 00:08:30 -04:00
|
|
|
|
|
|
|
# Currently same as regular enemy death
|
|
|
|
func _on_boss_death(kill_money):
|
2018-05-29 02:39:43 -04:00
|
|
|
# Give players appropriate money, and restart spawns
|
2018-05-29 00:08:30 -04:00
|
|
|
$Player.money += kill_money
|
2018-11-12 23:17:53 -05:00
|
|
|
updatePoints()
|
2018-05-29 02:39:43 -04:00
|
|
|
bad_spawning_enabled = true
|
2018-06-03 11:11:27 -04:00
|
|
|
bosstimer.stop()
|
2018-11-12 23:17:53 -05:00
|
|
|
rpc("openPlayerMenu")
|
|
|
|
current_round +=1
|
|
|
|
$Music.volume_db = 0
|
2018-05-29 00:08:30 -04:00
|
|
|
|
|
|
|
# Begins screen-flashing process
|
2018-05-27 19:22:11 -04:00
|
|
|
func _flash_screen():
|
|
|
|
prints("_flash_screen")
|
|
|
|
screen_flashing = true
|
|
|
|
rectangle_opacity = 1
|
2018-05-29 00:08:30 -04:00
|
|
|
$ColorRect.visible = true
|
|
|
|
|
|
|
|
func _load_players(id, info):
|
|
|
|
player_info = info
|
2018-06-03 11:11:27 -04:00
|
|
|
prints("_load_players", player_info)
|
2018-05-29 00:08:30 -04:00
|
|
|
|
|
|
|
func _start_multiplayer_game():
|
2018-06-03 11:11:27 -04:00
|
|
|
print(player_info)
|
2018-05-29 00:08:30 -04:00
|
|
|
mainmenu.now_quitting = true
|
|
|
|
for peer_id in player_info:
|
|
|
|
if peer_id != get_tree().get_network_unique_id():
|
|
|
|
var player = preload("res://OtherPlayer.tscn").instance()
|
|
|
|
player.set_name(str(peer_id))
|
|
|
|
prints(str(peer_id), "yeetert")
|
|
|
|
add_child(player)
|
2018-06-03 11:11:27 -04:00
|
|
|
player.setUsername(player_info[peer_id].name)
|
2018-11-12 23:17:53 -05:00
|
|
|
if get_tree().is_network_server():
|
|
|
|
rounds(1)
|
2018-06-03 11:11:27 -04:00
|
|
|
|
|
|
|
func _on_HideHowTo_pressed():
|
2018-11-12 23:17:53 -05:00
|
|
|
$HowTos.visible = false
|
2018-06-03 11:11:27 -04:00
|
|
|
|
|
|
|
func _on_Player_other_ship_enable_rainbow(id):
|
|
|
|
prints("Other player entered rainbow mode")
|
2018-11-12 23:17:53 -05:00
|
|
|
get_node(str(id)).enable_the_rainbow()
|
|
|
|
|
|
|
|
func _on_Player_buy_turret(id, turret_position):
|
|
|
|
print("Main:buyTurret", turret_position)
|
|
|
|
var turret = preload("res://Turret.tscn").instance()
|
|
|
|
turret.connect("upgrade_turret", self, "upgradeTurret")
|
|
|
|
turret.set_name(str(id,"turret"))
|
|
|
|
add_child(turret)
|
|
|
|
turret.position = turret_position
|
|
|
|
turret.scale.x = 0.25
|
2018-11-29 16:04:22 -05:00
|
|
|
turret.scale.y = 0.25
|
|
|
|
|
|
|
|
func _exit_tree():
|
|
|
|
print("EXITING AND STUFF")
|