Quests system + Elimination quest
This commit is contained in:
parent
30e53f858f
commit
2bca6b2fe5
6 changed files with 92 additions and 0 deletions
|
|
@ -73,6 +73,7 @@ text = "About this station"
|
|||
script = ExtResource("3_63o1s")
|
||||
|
||||
[node name="Footer" type="Label" parent="MainMenu"]
|
||||
layout_mode = 0
|
||||
offset_top = 576.0
|
||||
offset_right = 640.0
|
||||
offset_bottom = 640.0
|
||||
|
|
@ -118,6 +119,7 @@ offset_right = 320.0
|
|||
offset_bottom = 512.0
|
||||
|
||||
[node name="BuyList" type="ItemList" parent="TradingMenu"]
|
||||
layout_mode = 0
|
||||
offset_left = 320.0
|
||||
offset_top = 64.0
|
||||
offset_right = 640.0
|
||||
|
|
@ -133,6 +135,7 @@ placeholder_text = "Amount to buy"
|
|||
alignment = 1
|
||||
|
||||
[node name="BuyInput" type="LineEdit" parent="TradingMenu"]
|
||||
layout_mode = 0
|
||||
offset_left = 320.0
|
||||
offset_top = 512.0
|
||||
offset_right = 480.0
|
||||
|
|
@ -149,6 +152,7 @@ offset_bottom = 576.0
|
|||
text = "Buy selected item"
|
||||
|
||||
[node name="SellButton" type="Button" parent="TradingMenu"]
|
||||
layout_mode = 0
|
||||
offset_left = 480.0
|
||||
offset_top = 512.0
|
||||
offset_right = 639.0
|
||||
|
|
|
|||
|
|
@ -16,6 +16,8 @@ var color_enemy
|
|||
@onready var bases = $Bases
|
||||
@onready var enemy_faction = $EnemyFaction
|
||||
|
||||
signal enemy_destroyed
|
||||
|
||||
func _ready():
|
||||
randomize()
|
||||
recolor()
|
||||
|
|
@ -26,6 +28,7 @@ func _ready():
|
|||
ship.camera.limit_right = map_width/2.0
|
||||
ship.camera.limit_top = -map_height/2.0
|
||||
ship.camera.limit_bottom = map_height/2.0
|
||||
enemy_destroyed.connect(ship.enemy_destroyed)
|
||||
|
||||
if Game.profile.profile_meta.has('game_load'):
|
||||
Game.profile.profile_meta.erase('game_load')
|
||||
|
|
@ -90,3 +93,6 @@ func recolor():
|
|||
var menu = get_node_or_null("MainShip/GUI/StarterBaseMenu")
|
||||
if menu != null:
|
||||
menu.modulate = bases.modulate
|
||||
|
||||
func enemydestroyed(enemy):
|
||||
enemy_destroyed.emit(enemy)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
41
scripts/quest.gd
Normal file
41
scripts/quest.gd
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
class_name Quest
|
||||
|
||||
enum TYPE {ELIMINATION, DELIVERY, ESCORT, RACE, DIVERSE}
|
||||
enum RESTRICTIONS{NO_DEATHS,NO_WEAPON,TIMER}
|
||||
|
||||
var type : Quest.TYPE = Quest.TYPE.ELIMINATION
|
||||
var progress_max : int = 1
|
||||
var progress : int = 0
|
||||
var reward_money : float
|
||||
var restrictions : Array[RESTRICTIONS] = []
|
||||
var data : Dictionary = {}
|
||||
var new : bool = true
|
||||
|
||||
signal quest_added
|
||||
signal quest_ended
|
||||
signal quest_failed
|
||||
|
||||
func create(type : TYPE, progress_max : int, reward_money : float, restrictions : Array[RESTRICTIONS] = [], data : Dictionary = {}) -> void:
|
||||
self.type = type
|
||||
self.progress_max = progress_max
|
||||
self.reward_money = reward_money
|
||||
self.restrictions = restrictions
|
||||
self.data = data
|
||||
quest_added.emit(self)
|
||||
self.new = false
|
||||
|
||||
func do_progress() -> void:
|
||||
progress += 1
|
||||
if progress >= progress_max:
|
||||
quest_ended.emit(true)
|
||||
|
||||
func fail() -> void:
|
||||
quest_failed.emit(false)
|
||||
|
||||
func _restriction_no_deaths():
|
||||
if restrictions.has(RESTRICTIONS.NO_DEATHS):
|
||||
fail()
|
||||
|
||||
func _restriction_no_weapon():
|
||||
if restrictions.has(RESTRICTIONS.NO_WEAPON):
|
||||
fail()
|
||||
Loading…
Add table
Add a link
Reference in a new issue