Quests system + Elimination quest
This commit is contained in:
parent
30e53f858f
commit
2bca6b2fe5
6 changed files with 92 additions and 0 deletions
|
|
@ -14,6 +14,19 @@ class_name MainShip
|
|||
var allow_shooting = true
|
||||
var faction = "player"
|
||||
var money : float = 1000
|
||||
var quest : Quest = Quest.new()
|
||||
|
||||
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, 1, 100)
|
||||
|
||||
func _process(_delta):
|
||||
if hull.hp < 0: destroy()
|
||||
|
|
@ -27,3 +40,24 @@ func destroy():
|
|||
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:
|
||||
money += quest.reward_money
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue