64 lines
1.5 KiB
GDScript
64 lines
1.5 KiB
GDScript
extends CharacterBody2D
|
|
|
|
class_name MainShip
|
|
|
|
@onready var engine = $Engine
|
|
@onready var hull = $Hull
|
|
@onready var shield = $Shield
|
|
@onready var pause_controller = $GUI/Interface/PauseController
|
|
@onready var minimap = $CanvasLayer/Control/Minimap
|
|
@onready var camera = $Camera
|
|
@onready var primary_slot = $PrimaryWeapon
|
|
@onready var secondary_slot = $SecondaryWeapon
|
|
|
|
var allow_shooting = true
|
|
var faction = "player"
|
|
var money : float = 1000
|
|
var quest : Quest = Quest.new()
|
|
var quest_completed : bool = false
|
|
|
|
signal destroyed
|
|
|
|
func _ready():
|
|
quest.quest_added.connect(add_quest)
|
|
quest.quest_ended.connect(kill_quest)
|
|
quest.quest_failed.connect(kill_quest)
|
|
destroyed.connect(quest._restriction_no_deaths)
|
|
|
|
secondary_slot.add_child(Game.get_weapon("SingleRocketMk1").instantiate())
|
|
|
|
quest.create(Quest.TYPE.ELIMINATION, 2, 200)
|
|
|
|
func _process(_delta):
|
|
if hull.hp < 0: destroy()
|
|
|
|
func changeinterfacecolor():
|
|
$GUI/Interface.modulate = modulate
|
|
|
|
func destroy():
|
|
hull.hp = hull.max_hp
|
|
shield.capacity = shield.max_capacity
|
|
global_position = Vector2.ZERO
|
|
engine.speed = 0
|
|
engine.turbo_enabled = false
|
|
destroyed.emit()
|
|
|
|
func add_quest(quest : Quest):
|
|
if quest.restrictions.has(Quest.RESTRICTIONS.TIMER):
|
|
get_tree().create_timer(quest.data['timer']).timeout.connect(timer_failed)
|
|
|
|
func kill_quest(success : bool):
|
|
if success:
|
|
quest_completed = true
|
|
quest.new = true
|
|
|
|
func timer_failed():
|
|
if quest.new:
|
|
return
|
|
kill_quest(false)
|
|
|
|
func enemy_destroyed(enemy):
|
|
if quest.new:
|
|
return
|
|
if quest.type == quest.TYPE.ELIMINATION:
|
|
quest.do_progress()
|