generated from krampus/template-godot4
Milestones have effects
This commit is contained in:
parent
5dba027b4c
commit
ed303fce4b
@ -34,6 +34,11 @@ func idle() -> void:
|
||||
_idle()
|
||||
|
||||
|
||||
## Is this tool available to the player?
|
||||
func unlocked() -> bool:
|
||||
return true
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if hud_tool:
|
||||
var weight := 1 - exp(-hud_accel * delta)
|
||||
|
@ -15,6 +15,10 @@ const BRUSH_SCALE := 0.2
|
||||
@onready var resting_position: Marker3D = %RestingPosition
|
||||
|
||||
|
||||
func unlocked() -> bool:
|
||||
return Game.manager.toothbrush_unlocked
|
||||
|
||||
|
||||
func _fire() -> void:
|
||||
if raycast.is_colliding() and not Game.manager.is_tank_full():
|
||||
brush_animation.play("brush")
|
||||
|
@ -23,8 +23,11 @@ signal player_dead
|
||||
|
||||
const MAX_ALERT := 6
|
||||
|
||||
const BASE_TANK_LIMIT := 96000
|
||||
const BIG_TANK_LIMIT := 198000
|
||||
|
||||
## Maximum amount of grunk the player can carry in their tank.
|
||||
@export var grunk_tank_limit := 120000
|
||||
@export var grunk_tank_limit := BASE_TANK_LIMIT
|
||||
|
||||
# TODO figure this out
|
||||
@export var grunk_quota := 2000000
|
||||
@ -32,10 +35,19 @@ const MAX_ALERT := 6
|
||||
## Grunk collection milestones
|
||||
@export var vault_milestones: Dictionary[int, Milestone]
|
||||
|
||||
@export_group("Progress")
|
||||
@export var mp3_player_unlocked := false
|
||||
@export var toothbrush_unlocked := false
|
||||
@export var stickers_unlocked := false
|
||||
|
||||
var debug_emit_alert_signal: int:
|
||||
set(value):
|
||||
alert_raised.emit(value)
|
||||
|
||||
var debug_unlock_milestone: Milestone:
|
||||
set(value):
|
||||
milestone_reached.emit(value)
|
||||
|
||||
## Amount of grunk the player is currently carrying.
|
||||
var grunk_tank := 0.0
|
||||
|
||||
@ -123,6 +135,18 @@ func next_milestone_amount() -> int:
|
||||
return -1
|
||||
|
||||
|
||||
func _on_milestone(milestone: Milestone) -> void:
|
||||
if milestone.mp3_player:
|
||||
mp3_player_unlocked = true
|
||||
elif milestone.toothbrush:
|
||||
toothbrush_unlocked = true
|
||||
elif milestone.stickers:
|
||||
stickers_unlocked = true
|
||||
elif milestone.big_tank:
|
||||
grunk_tank_limit = BIG_TANK_LIMIT
|
||||
# TODO the rest
|
||||
|
||||
|
||||
## Called by Player on death.
|
||||
func on_player_death() -> void:
|
||||
player_dead.emit()
|
||||
|
@ -8,6 +8,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "[no reward]"
|
||||
message = "Check the MANUAL for SWEET TIPZ
|
||||
from the GRUNKIN' MASTERS!"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_b83gw"]
|
||||
@ -15,6 +24,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "MP3 PLAYER"
|
||||
message = "MP3 PLAYER DECRYPTED. Enjoy some
|
||||
light music whilst you GRUNK."
|
||||
bonus_track = false
|
||||
mp3_player = true
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_o6um0"]
|
||||
@ -22,6 +40,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "TOOTHBRUSH"
|
||||
message = "TOOTHBRUSH DECRYPTED.
|
||||
Enjoy teethbrushing in moderation!"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = true
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vebb4"]
|
||||
@ -29,6 +56,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "BONUS TRACK"
|
||||
message = "BONUS TRACK DELIVERED
|
||||
[TODO]"
|
||||
bonus_track = true
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_aolyc"]
|
||||
@ -36,6 +72,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "WELLNESS SEMINAR"
|
||||
message = "SEMINAR DECRYPTED.
|
||||
The FUTURE of WELLNESS is TODAY!"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = true
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_36cpv"]
|
||||
@ -43,6 +88,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "EL TANK GRANDE"
|
||||
message = "\"EL TANK GRANDE\" DECRYPTED.
|
||||
GRUNK carrying capacity increased."
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = true
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pfnwj"]
|
||||
@ -50,6 +104,15 @@ script = ExtResource("2_b83gw")
|
||||
name = "STICKER PACK"
|
||||
message = "NOW PRINTING... You can use
|
||||
STICKERS to EXPRESS your \"SELF\""
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = true
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_p7jc6"]
|
||||
@ -57,23 +120,49 @@ script = ExtResource("2_b83gw")
|
||||
name = "QUOTA"
|
||||
message = "QUOTA SATISFIED.
|
||||
FINE WORK GRUNKER !"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = true
|
||||
mystery = false
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2eyq5"]
|
||||
script = ExtResource("2_b83gw")
|
||||
name = "???"
|
||||
message = "????? ?"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = true
|
||||
fiesta = false
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_2qxxw"]
|
||||
script = ExtResource("2_b83gw")
|
||||
name = "TACO FIESTA"
|
||||
name = "taco fiesta"
|
||||
message = "ENJOY THE FIESTA GRUNKER !"
|
||||
bonus_track = false
|
||||
mp3_player = false
|
||||
toothbrush = false
|
||||
seminar = false
|
||||
big_tank = false
|
||||
stickers = false
|
||||
quota = false
|
||||
mystery = false
|
||||
fiesta = true
|
||||
metadata/_custom_type_script = "uid://ufxoxupdvyd5"
|
||||
|
||||
[node name="GameManager" type="Node"]
|
||||
script = ExtResource("1_08e4a")
|
||||
grunk_tank_limit = 96000
|
||||
vault_milestones = Dictionary[int, ExtResource("2_b83gw")]({
|
||||
0: SubResource("Resource_h4r54"),
|
||||
100000: SubResource("Resource_b83gw"),
|
||||
@ -91,3 +180,5 @@ vault_milestones = Dictionary[int, ExtResource("2_b83gw")]({
|
||||
4200000: SubResource("Resource_vebb4"),
|
||||
6400000: SubResource("Resource_2qxxw")
|
||||
})
|
||||
|
||||
[connection signal="milestone_reached" from="." to="." method="_on_milestone"]
|
||||
|
@ -3,3 +3,14 @@ class_name Milestone extends Resource
|
||||
|
||||
@export var name: String
|
||||
@export_multiline var message: String
|
||||
|
||||
@export_group("Effects")
|
||||
@export var bonus_track := false
|
||||
@export var mp3_player := false
|
||||
@export var toothbrush := false
|
||||
@export var seminar := false
|
||||
@export var big_tank := false
|
||||
@export var stickers := false
|
||||
@export var quota := false
|
||||
@export var mystery := false
|
||||
@export var fiesta := false
|
||||
|
@ -75,6 +75,7 @@ static var instance: Player
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Game.manager.milestone_reached.connect(_on_milestone)
|
||||
instance = self
|
||||
|
||||
|
||||
@ -157,6 +158,20 @@ func get_grabbed() -> void:
|
||||
camera_pivot.reset_pitch(0.4)
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Event Handlers
|
||||
|
||||
|
||||
func _on_milestone(milestone: Milestone) -> void:
|
||||
if milestone.mp3_player:
|
||||
pass # TODO equip mp3 player
|
||||
if milestone.toothbrush:
|
||||
tool_mount.set_active(toothbrush)
|
||||
if milestone.stickers:
|
||||
pass # TODO equip stickers
|
||||
|
||||
|
||||
func _signal_death() -> void:
|
||||
# Called from the death animation
|
||||
Game.manager.on_player_death()
|
||||
|
@ -18,7 +18,11 @@ func get_active() -> Tool:
|
||||
## Sets the given tool as active.
|
||||
##
|
||||
## The tool should be a child of this mount.
|
||||
func set_active(tool: Tool) -> void:
|
||||
## If the tool is not unlocked and `force` is false, this will have no effect.
|
||||
func set_active(tool: Tool, force: bool = false) -> void:
|
||||
if not force and not tool.unlocked():
|
||||
return
|
||||
|
||||
for c: Node3D in get_children():
|
||||
c.visible = false
|
||||
# TODO unequip animation?
|
||||
@ -32,5 +36,12 @@ func set_active(tool: Tool) -> void:
|
||||
## Use this for "select next/prev tool" functions.
|
||||
func set_active_relative(delta: int) -> void:
|
||||
var active_idx := _active.get_index()
|
||||
var new_idx := wrapi(active_idx + delta, 0, get_child_count())
|
||||
set_active(get_child(new_idx) as Tool)
|
||||
while true:
|
||||
var new_idx := wrapi(active_idx + delta, 0, get_child_count())
|
||||
var tool := get_child(new_idx) as Tool
|
||||
if tool.unlocked():
|
||||
set_active(tool)
|
||||
return
|
||||
# If the next tool is not unlocked, try the one after
|
||||
# NOTE: this will loop forever if the player has no tools unlocked!
|
||||
active_idx = new_idx
|
||||
|
Loading…
x
Reference in New Issue
Block a user