Ajout d'un mode infini
This commit is contained in:
@@ -1,16 +1,28 @@
|
||||
extends Resource
|
||||
class_name GameData
|
||||
|
||||
enum GameMode {STORY}
|
||||
enum Mode {STORY, INFINITE}
|
||||
|
||||
signal current_run_updated(r : RunData)
|
||||
signal current_region_data_updated(p : RegionData)
|
||||
|
||||
|
||||
func _init(
|
||||
_game_mode : Mode = Mode.STORY
|
||||
):
|
||||
game_mode = _game_mode
|
||||
if game_mode == Mode.STORY:
|
||||
progression_data = StoryProgressionData.new()
|
||||
elif game_mode == Mode.INFINITE:
|
||||
progression_data = InfiniteProgressionData.new()
|
||||
|
||||
|
||||
@export var game_mode : Mode = GameData.Mode.STORY
|
||||
|
||||
@export var player_data : PlayerData = PlayerData.new()
|
||||
|
||||
@export var progression_data : ProgressionData = ProgressionData.new()
|
||||
@export var progression_data : ProgressionData
|
||||
|
||||
@export var current_run : RunData = start_run() :
|
||||
@export var current_run : RunData :
|
||||
set(v):
|
||||
current_run = v
|
||||
current_run_updated.emit(v)
|
||||
@@ -30,8 +42,6 @@ signal current_region_data_updated(p : RegionData)
|
||||
|
||||
@export var item_announced = []
|
||||
|
||||
@export var game_mode : GameMode = GameMode.STORY
|
||||
|
||||
@export var dialogs_done : Array[String] = [] #Chemin des dialogues terminés
|
||||
@export var tutorials_done : Array[String] = []
|
||||
|
||||
@@ -39,7 +49,7 @@ func start_run() -> RunData:
|
||||
player_data.clear_inventory()
|
||||
player_data.update_with_artefacts([])
|
||||
current_run = RunData.new()
|
||||
current_run.story_step = progression_data.story_step.duplicate_deep()
|
||||
current_run.story_step = progression_data.get_story_step().duplicate_deep()
|
||||
current_run.generate_next_run_points()
|
||||
current_run.current_run_point_changed.connect(
|
||||
func(rp : RunPoint):
|
||||
@@ -59,12 +69,14 @@ func start_region(region_param : RegionParameter):
|
||||
current_region_data = RegionData.new(region_param)
|
||||
|
||||
func give_up():
|
||||
progression_data.finish_run(current_run)
|
||||
current_region_data = null
|
||||
current_run = null
|
||||
start_run()
|
||||
SceneManager.change_to_scene(progression_data.story_step.get_respawn_scene())
|
||||
SceneManager.change_to_scene(progression_data.get_story_step().get_respawn_scene())
|
||||
|
||||
func finish_story_step():
|
||||
progression_data.finish_run(current_run)
|
||||
progression_data.next_story_step()
|
||||
current_region_data = null
|
||||
start_run()
|
||||
|
||||
29
common/game_data/scripts/infinite_progression_data.gd
Normal file
29
common/game_data/scripts/infinite_progression_data.gd
Normal file
@@ -0,0 +1,29 @@
|
||||
extends ProgressionData
|
||||
class_name InfiniteProgressionData
|
||||
|
||||
func get_story_step() -> StoryStep:
|
||||
return InfiniteStoryStep.new(run_number)
|
||||
|
||||
func get_story_progression() -> float:
|
||||
return 0.
|
||||
|
||||
func discover_mutation(_pm : PlantMutation) -> void:
|
||||
pass
|
||||
|
||||
func get_mutations_discovered() -> Array[String]:
|
||||
var mutation_discovered : Array[String] = []
|
||||
for m in get_all_mutations():
|
||||
mutation_discovered.append(m.get_mutation_id())
|
||||
return mutation_discovered
|
||||
|
||||
func next_story_step() -> void:
|
||||
pass
|
||||
|
||||
func are_all_mutations_unlocked() -> bool:
|
||||
return true
|
||||
|
||||
func unlock_new_mutation() -> PlantMutation:
|
||||
return null
|
||||
|
||||
func get_available_mutations() -> Array[PlantMutation]:
|
||||
return get_all_mutations()
|
||||
@@ -0,0 +1 @@
|
||||
uid://iigxgqiyn0p4
|
||||
@@ -1,25 +1,25 @@
|
||||
@abstract
|
||||
extends Resource
|
||||
class_name ProgressionData
|
||||
|
||||
@export var planted_mutation_ids: Array[String] = []
|
||||
@export var story_step_i := 0
|
||||
@export var mutations_unlocked = 8
|
||||
@export var run_number : int = 0
|
||||
@export var best_run : int = 0
|
||||
|
||||
var all_mutations: Array[PlantMutation] : get = get_all_mutations
|
||||
var available_mutations: Array[PlantMutation] : get = get_available_mutations
|
||||
var available_artefacts: Array[Artefact] : get = get_all_artifacts
|
||||
var story_step : StoryStep : get = get_story_step
|
||||
@abstract func get_story_step() -> StoryStep
|
||||
|
||||
func get_story_step() -> StoryStep:
|
||||
return get_all_story_steps()[story_step_i]
|
||||
@abstract func get_story_progression() -> float
|
||||
|
||||
func next_story_step() -> void:
|
||||
get_story_step()._on_finish()
|
||||
if story_step_i + 1 < len(get_all_story_steps()):
|
||||
story_step_i += 1
|
||||
@abstract func next_story_step() -> void
|
||||
|
||||
func get_available_mutations() -> Array[PlantMutation]:
|
||||
return get_all_mutations().slice(0, mutations_unlocked)
|
||||
@abstract func get_available_mutations() -> Array[PlantMutation]
|
||||
|
||||
@abstract func are_all_mutations_unlocked() -> bool
|
||||
|
||||
@abstract func discover_mutation(_pm : PlantMutation) -> void
|
||||
|
||||
@abstract func get_mutations_discovered() -> Array[String]
|
||||
|
||||
@abstract func unlock_new_mutation() -> PlantMutation
|
||||
|
||||
func get_all_mutations() -> Array[PlantMutation]:
|
||||
return [
|
||||
@@ -49,7 +49,6 @@ func get_all_artifacts() -> Array[Artefact]:
|
||||
TalionSoilArtifact.new(),
|
||||
]
|
||||
|
||||
|
||||
func get_all_story_steps() -> Array[StoryStep]:
|
||||
return [
|
||||
TutorialStoryStep.new(),
|
||||
@@ -57,3 +56,7 @@ func get_all_story_steps() -> Array[StoryStep]:
|
||||
MercuryStoryStep.new(),
|
||||
BoreaStoryStep.new()
|
||||
]
|
||||
|
||||
func finish_run(run : RunData):
|
||||
run_number += 1
|
||||
best_run = max(best_run, run.level)
|
||||
|
||||
36
common/game_data/scripts/story/infinite_story_step.gd
Normal file
36
common/game_data/scripts/story/infinite_story_step.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
@tool
|
||||
extends StoryStep
|
||||
class_name InfiniteStoryStep
|
||||
|
||||
var run_number := 0
|
||||
|
||||
func _init(
|
||||
_run_number := 0
|
||||
):
|
||||
run_number = _run_number
|
||||
|
||||
|
||||
func get_respawn_scene() -> Scene:
|
||||
return RelayBaseScene.new(
|
||||
"INFINITE_MODE",
|
||||
str(run_number),
|
||||
true
|
||||
)
|
||||
|
||||
func get_cave_occurence(_level : int) -> int:
|
||||
return 0
|
||||
|
||||
func is_region_sequence_infinite() -> bool:
|
||||
return true
|
||||
|
||||
func get_region_sequence_length() -> int:
|
||||
return 1000
|
||||
|
||||
func is_run_point_dangerous(level : int) -> bool:
|
||||
return level%6 == 0 and level != 0
|
||||
|
||||
func get_destination_text() -> String:
|
||||
return tr("INFINITE")
|
||||
|
||||
func get_destination_scene() -> Scene:
|
||||
return BoreaScene.new()
|
||||
@@ -0,0 +1 @@
|
||||
uid://bdonub7t01xmi
|
||||
@@ -12,6 +12,8 @@ func get_destination_scene() -> Scene:
|
||||
return BoreaScene.new()
|
||||
|
||||
func get_run_progress(level : int) -> int:
|
||||
if is_region_sequence_infinite():
|
||||
return 0
|
||||
return get_region_sequence_length() - level
|
||||
|
||||
func get_ship_dialog_path(_level : int, _ship_in_space := true) -> String:
|
||||
@@ -19,8 +21,13 @@ func get_ship_dialog_path(_level : int, _ship_in_space := true) -> String:
|
||||
#region ------------------ Run ------------------
|
||||
|
||||
func is_run_finished(level : int) -> bool:
|
||||
if is_region_sequence_infinite():
|
||||
return false
|
||||
return level == get_region_sequence_length() - 1
|
||||
|
||||
func is_region_sequence_infinite() -> bool:
|
||||
return false
|
||||
|
||||
func get_region_sequence_length() -> int:
|
||||
return 7
|
||||
|
||||
@@ -48,6 +55,8 @@ func get_charge_number(_level : int) -> int:
|
||||
return 10
|
||||
|
||||
func is_run_point_dangerous(level : int) -> bool:
|
||||
if is_region_sequence_infinite():
|
||||
return false
|
||||
return level == get_region_sequence_length() - 2
|
||||
|
||||
func get_objective_for_region(level : int) -> int:
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
@tool
|
||||
extends StoryStep
|
||||
class_name MercuryStoryStep
|
||||
|
||||
|
||||
36
common/game_data/scripts/story_progression_data.gd
Normal file
36
common/game_data/scripts/story_progression_data.gd
Normal file
@@ -0,0 +1,36 @@
|
||||
extends ProgressionData
|
||||
class_name StoryProgressionData
|
||||
|
||||
@export var planted_mutation_ids: Array[String] = []
|
||||
@export var story_step_i := 0
|
||||
@export var mutations_unlocked = 8
|
||||
|
||||
func get_story_step() -> StoryStep:
|
||||
return get_all_story_steps()[story_step_i]
|
||||
|
||||
func get_story_progression() -> float:
|
||||
return max(0,float(story_step_i)) / len(
|
||||
get_all_story_steps()
|
||||
)
|
||||
|
||||
func discover_mutation(pm : PlantMutation) -> void:
|
||||
planted_mutation_ids.append(pm.id)
|
||||
|
||||
func get_mutations_discovered() -> Array[String]:
|
||||
return planted_mutation_ids
|
||||
|
||||
func next_story_step() -> void:
|
||||
get_story_step()._on_finish()
|
||||
if story_step_i + 1 < len(get_all_story_steps()):
|
||||
story_step_i += 1
|
||||
|
||||
func get_available_mutations() -> Array[PlantMutation]:
|
||||
return get_all_mutations().slice(0, mutations_unlocked)
|
||||
|
||||
func are_all_mutations_unlocked() -> bool:
|
||||
return mutations_unlocked >= len(get_all_mutations())
|
||||
|
||||
func unlock_new_mutation() -> PlantMutation:
|
||||
var new_mutation = get_all_mutations()[mutations_unlocked]
|
||||
mutations_unlocked += 1
|
||||
return new_mutation
|
||||
1
common/game_data/scripts/story_progression_data.gd.uid
Normal file
1
common/game_data/scripts/story_progression_data.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://vcoy8pt780cl
|
||||
Reference in New Issue
Block a user