* modification de certains assets * optimisation de chunks * ajout d'un SceneManager * ajout d'un premier dialogue avec Demeter * changement des jour en charge * mise en place d'un système de run * etc...
108 lines
3.4 KiB
GDScript
108 lines
3.4 KiB
GDScript
extends Resource
|
|
class_name RunData
|
|
|
|
const RUN_POINT_POSITION_DERIVATION = 70
|
|
const DIFFICULTY_INCREASE_BY_LEVEL = 1
|
|
const RUN_POINTS_NEXT_NUMBER :Array[int] = [2,3]
|
|
const RUN_POINT_MAX_LEVEL = 10
|
|
|
|
signal run_point_changed
|
|
|
|
var run_seed = randi()
|
|
@export var next_run_points : Array[RunPoint] = [generate_first_run_point()]
|
|
@export var current_run_point : RunPoint = null
|
|
@export var visited_run_points : Array[RunPoint] = []
|
|
|
|
#region ------------------ Generation ------------------
|
|
|
|
func generate_first_run_point() -> RunPoint:
|
|
return RunPoint.new(0, PlanetParameter.new())
|
|
|
|
func generate_next_run_points(run_point : RunPoint) -> Array[RunPoint]:
|
|
var nb_next_run_points = RUN_POINTS_NEXT_NUMBER.pick_random()
|
|
if run_point.level == RUN_POINT_MAX_LEVEL - 1 or run_point.level == -1:
|
|
nb_next_run_points = 1
|
|
elif run_point.level == RUN_POINT_MAX_LEVEL:
|
|
nb_next_run_points = 0
|
|
|
|
next_run_points = []
|
|
|
|
for i in range(nb_next_run_points):
|
|
next_run_points.append(
|
|
generate_next_run_point(run_point)
|
|
)
|
|
|
|
return next_run_points
|
|
|
|
|
|
func generate_next_run_point(run_point : RunPoint) -> RunPoint:
|
|
return RunPoint.new(
|
|
run_point.level + 1,
|
|
generate_difficulty_increased_planet_parameter(run_point.planet_parameter, DIFFICULTY_INCREASE_BY_LEVEL),
|
|
(run_point.position + randi_range(-RUN_POINT_POSITION_DERIVATION, RUN_POINT_POSITION_DERIVATION)) % 360
|
|
)
|
|
|
|
func generate_difficulty_increased_planet_parameter(
|
|
planet_parameter : PlanetParameter,
|
|
difficulty : int = 1
|
|
) -> PlanetParameter:
|
|
var i_diff := difficulty
|
|
var new_planet_parameter = PlanetParameter.new(
|
|
planet_parameter.charges,
|
|
planet_parameter.objective
|
|
)
|
|
while i_diff > 0:
|
|
|
|
var available_difficulty_modifier = [
|
|
DifficultyDecreaseCharge.new(),
|
|
DifficultyIncreaseObjective.new()
|
|
].filter(
|
|
func (mod : DifficultyModifier):
|
|
return mod.get_difficulty_cost() <= i_diff and mod.can_modifiy(new_planet_parameter)
|
|
)
|
|
|
|
var selected_difficulty_modifier = available_difficulty_modifier.pick_random()
|
|
|
|
selected_difficulty_modifier.modify(new_planet_parameter)
|
|
|
|
i_diff -= max(1,selected_difficulty_modifier.get_difficulty_cost())
|
|
return new_planet_parameter
|
|
|
|
#endregion
|
|
|
|
func get_next_run_points() -> Array[RunPoint]:
|
|
return next_run_points
|
|
|
|
func get_current_planet_data() -> PlanetData:
|
|
if current_run_point:
|
|
return current_run_point.planet_data
|
|
else:
|
|
return null
|
|
|
|
func choose_next_run_point(run_point : RunPoint) -> RunPoint:
|
|
if current_run_point:
|
|
visited_run_points.append(current_run_point)
|
|
current_run_point = run_point
|
|
next_run_points = generate_next_run_points(current_run_point)
|
|
return current_run_point
|
|
|
|
class DifficultyModifier:
|
|
func modify(_planet_parameter : PlanetParameter):
|
|
pass
|
|
|
|
func can_modifiy(_planet_parameter : PlanetParameter) -> bool:
|
|
return true
|
|
|
|
func get_difficulty_cost() -> int:
|
|
return 1
|
|
|
|
class DifficultyIncreaseObjective extends DifficultyModifier:
|
|
func modify(planet_parameter : PlanetParameter):
|
|
planet_parameter.objective += 1
|
|
|
|
class DifficultyDecreaseCharge extends DifficultyModifier:
|
|
func modify(planet_parameter : PlanetParameter):
|
|
planet_parameter.charges -= 1
|
|
|
|
func can_modifiy(planet_parameter : PlanetParameter) -> bool:
|
|
return planet_parameter.charges >= 3 |