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()
|
||||
|
|
|
|||
|
|
@ -17,11 +17,13 @@ class_name NPCShip
|
|||
var state = "idle"
|
||||
var shooting = false
|
||||
var allow_shooting = true
|
||||
signal destroyed
|
||||
|
||||
func _ready():
|
||||
destination_timer.timeout.connect(switchdestination)
|
||||
target_snap.mouse_entered.connect(get_tree().current_scene.addtargetlist.bind(self))
|
||||
target_snap.mouse_exited.connect(get_tree().current_scene.removetargetlist.bind(self))
|
||||
destroyed.connect(get_tree().current_scene.enemydestroyed)
|
||||
|
||||
func _physics_process(_delta):
|
||||
match state:
|
||||
|
|
@ -80,3 +82,4 @@ func destroy():
|
|||
bounty_inst.amount = randi_range(bounty_min, bounty_max)
|
||||
bounty_inst.text.text = str(bounty_inst.amount) + " MU"
|
||||
global_position = Vector2(randi_range(-4096, 4096), randi_range(-4096, 4096))
|
||||
destroyed.emit(self)
|
||||
|
|
|
|||
|
|
@ -15,6 +15,8 @@ var id : String = "SingleLaserMk1"
|
|||
|
||||
var deviation : float = deg_to_rad(spread)
|
||||
|
||||
signal weapon_shooted
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
if ship is MainShip:
|
||||
|
|
@ -23,6 +25,7 @@ func _ready():
|
|||
shoot_action = "shootprimary"
|
||||
"SecondaryWeapon":
|
||||
shoot_action = "shootsecondary"
|
||||
weapon_shooted.connect(ship.quest._restriction_no_weapon)
|
||||
elif ship is NPCShip:
|
||||
shoot_action = "npc"
|
||||
|
||||
|
|
@ -43,3 +46,4 @@ func shoot():
|
|||
proj_inst.global_rotation = spawner.global_rotation + randf_range(-deviation/2, deviation/2)
|
||||
proj_inst.faction = ship.faction
|
||||
proj_inst.modulate = ship.modulate
|
||||
weapon_shooted.emit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue