système de sauvegarde, scène 3D de test sur la base astra et passage en forward+
This commit is contained in:
@@ -97,6 +97,7 @@ func is_full():
|
||||
return true
|
||||
|
||||
func clear():
|
||||
print("clearing inventory")
|
||||
for i in range(len(items)):
|
||||
items[i] = null
|
||||
updated.emit(self)
|
||||
|
||||
@@ -6,11 +6,11 @@ const ACTION_ICON = preload("res://common/icons/swipe-down.svg")
|
||||
const ENERGY_ICON = preload("res://common/icons/bolt.svg")
|
||||
const ONE_TIME_ICON = preload("res://common/icons/circle-number-1.svg")
|
||||
|
||||
var name: String : get = get_item_name
|
||||
var description: String : get = get_description
|
||||
var icon: Texture2D : get = get_icon
|
||||
var usage_zone_radius: int = 5 : get = get_usage_zone_radius
|
||||
var energy_usage : int = 1 : get = get_energy_used
|
||||
@export var name: String : get = get_item_name
|
||||
@export var description: String : get = get_description
|
||||
@export var icon: Texture2D : get = get_icon
|
||||
@export var usage_zone_radius: int = 5 : get = get_usage_zone_radius
|
||||
@export var energy_usage : int = 1 : get = get_energy_used
|
||||
|
||||
func get_item_name() -> String:
|
||||
return name
|
||||
@@ -51,19 +51,11 @@ func card_info() -> CardInfo:
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
tr("COST_%d_ENERGY") % energy_usage,
|
||||
str(energy_usage),
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
if is_one_time_use():
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
tr("ONE_TIME_USE"),
|
||||
ONE_TIME_ICON
|
||||
)
|
||||
)
|
||||
|
||||
var effect_section = CardSectionInfo.new(
|
||||
tr("EFFECT"),
|
||||
get_description()
|
||||
|
||||
@@ -13,8 +13,8 @@ const SCORE_ICON = preload("res://common/icons/growth.svg")
|
||||
@export var random_seed : int
|
||||
|
||||
func _init(
|
||||
_plant_name : String,
|
||||
_plant_archetype : PlantArchetype,
|
||||
_plant_name : String = "",
|
||||
_plant_archetype : PlantArchetype = PlantArchetype.get_random(),
|
||||
_plant_mutations : Array[PlantMutation] = [],
|
||||
):
|
||||
plant_name = _plant_name
|
||||
@@ -27,23 +27,27 @@ static func generate_from_parent(plant_data : PlantData) -> Seed:
|
||||
return Seed.new(
|
||||
plant_data.plant_name,
|
||||
plant_data.archetype,
|
||||
mutate(plant_data.mutations)
|
||||
mutate_mutations(plant_data)
|
||||
)
|
||||
else :
|
||||
# TODO
|
||||
return Seed.new(
|
||||
plant_data.plant_name,
|
||||
plant_data.archetype,
|
||||
mutate(plant_data.mutations)
|
||||
plant_data.mutations.duplicate_deep()
|
||||
)
|
||||
|
||||
static func generate_random() -> Seed:
|
||||
return Seed.new(
|
||||
Random.generate_random_name(),
|
||||
PlantArchetype.new(),
|
||||
var new_seed = Seed.new(
|
||||
Random.generate_random_word(),
|
||||
PlantArchetype.get_random(),
|
||||
[]
|
||||
)
|
||||
if randf() > MUTATION_PROBABILITY:
|
||||
new_seed.plant_mutations.append(
|
||||
new_seed.plant_archetype.available_mutations.pick_random().duplicate_deep()
|
||||
)
|
||||
|
||||
return new_seed
|
||||
func get_item_name() -> String:
|
||||
return tr("%s_SEED") % plant_name
|
||||
|
||||
@@ -102,19 +106,11 @@ func card_info() -> CardInfo:
|
||||
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
tr("COST_%d_ENERGY") % energy_usage,
|
||||
str(energy_usage),
|
||||
ENERGY_ICON
|
||||
)
|
||||
)
|
||||
|
||||
if is_one_time_use():
|
||||
info.stats.append(
|
||||
CardStatInfo.new(
|
||||
tr("ONE_TIME_USE"),
|
||||
ONE_TIME_ICON
|
||||
)
|
||||
)
|
||||
|
||||
var effect_section = CardSectionInfo.new(
|
||||
tr("EFFECT"),
|
||||
get_description()
|
||||
@@ -127,10 +123,6 @@ func card_info() -> CardInfo:
|
||||
info.sections.append(effect_section)
|
||||
|
||||
if len(plant_mutations) != 0:
|
||||
var rarest : int = plant_mutations.map(
|
||||
func(m : PlantMutation) : return m.get_rarity()
|
||||
).max()
|
||||
info.bg_color = PlantMutation.get_rarity_color(rarest)
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
@@ -149,69 +141,67 @@ func get_particles() -> Array[Particles.Parameters]:
|
||||
|
||||
return param
|
||||
|
||||
static func mutate(parent_mutation : Array[PlantMutation] = []) -> Array[PlantMutation]:
|
||||
static func mutate_mutations(parent : PlantData) -> Array[PlantMutation]:
|
||||
|
||||
# TODO
|
||||
# var possible_mutations_change : Array[MutationPossibility] = [
|
||||
# AddMutation.new()
|
||||
# ]
|
||||
var mutation_possibility : Array[MutationPossibility] = [
|
||||
AddMutation.new()
|
||||
]
|
||||
|
||||
# if (
|
||||
# len(parent_mutation) >= 2
|
||||
# ):
|
||||
# possible_mutations_change = [
|
||||
# UpgradeMutation.new(),
|
||||
# RemoveMutation.new(),
|
||||
# ]
|
||||
# elif len(parent_mutation) > 0:
|
||||
# possible_mutations_change = [
|
||||
# AddMutation.new(),
|
||||
# UpgradeMutation.new(),
|
||||
# RemoveMutation.new(),
|
||||
# ]
|
||||
if (
|
||||
len(parent.mutations) >= GameInfo.game_data.max_mutations_by_plant
|
||||
):
|
||||
mutation_possibility = [
|
||||
UpgradeMutation.new(),
|
||||
RemoveMutation.new(),
|
||||
]
|
||||
elif len(parent.mutations) > 0:
|
||||
mutation_possibility = [
|
||||
AddMutation.new(),
|
||||
UpgradeMutation.new(),
|
||||
RemoveMutation.new(),
|
||||
]
|
||||
|
||||
# var chosen_mutation = possible_mutations_change.pick_random()
|
||||
var chosen_mutation_possibility = mutation_possibility.pick_random()
|
||||
|
||||
return parent_mutation
|
||||
return chosen_mutation_possibility.mutate(parent)
|
||||
|
||||
class MutationPossibility:
|
||||
func mutate(_parent : PlantData)-> Array[PlantMutation]:
|
||||
return []
|
||||
|
||||
# class MutationPossibility:
|
||||
# func mutate(_parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
# return []
|
||||
class AddMutation extends MutationPossibility:
|
||||
func mutate(parent : PlantData)-> Array[PlantMutation]:
|
||||
var new_mutations = parent.mutations.duplicate_deep()
|
||||
var possible_new_mutations = parent.archetype.available_mutations.duplicate_deep()
|
||||
|
||||
# class AddMutation extends MutationPossibility:
|
||||
# func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
# var new_mutations = parent_mutation.duplicate_deep()
|
||||
# var mut = PlantMutation.random_mutation(parent_mutation)
|
||||
possible_new_mutations = possible_new_mutations.filter(
|
||||
func (m : PlantMutation):
|
||||
return parent.mutations.find_custom(func(m2: PlantMutation): return m2.name == m.name) == -1
|
||||
)
|
||||
|
||||
if len(possible_new_mutations):
|
||||
new_mutations.append(possible_new_mutations.pick_random())
|
||||
|
||||
# if mut:
|
||||
# var existing_mut_id = new_mutations.find_custom(func(m:PlantMutation): return m.get_mutation_name() == mut.get_mutation_name())
|
||||
|
||||
# if existing_mut_id >= 0:
|
||||
# new_mutations[existing_mut_id].level += 1
|
||||
# else :
|
||||
# new_mutations.append(mut)
|
||||
return new_mutations
|
||||
|
||||
# return new_mutations
|
||||
class UpgradeMutation extends MutationPossibility:
|
||||
func mutate(
|
||||
parent : PlantData
|
||||
) -> Array[PlantMutation]:
|
||||
var new_mutations = parent.mutations.duplicate_deep()
|
||||
|
||||
# class UpgradeMutation extends MutationPossibility:
|
||||
# func mutate(
|
||||
# parent_mutation : Array[PlantMutation] = []
|
||||
# ) -> Array[PlantMutation]:
|
||||
# var new_mutations = parent_mutation.duplicate_deep()
|
||||
new_mutations.pick_random().level += 1
|
||||
|
||||
# new_mutations.pick_random().level += 1
|
||||
return new_mutations
|
||||
|
||||
# return new_mutations
|
||||
class RemoveMutation extends MutationPossibility:
|
||||
func mutate(parent : PlantData)-> Array[PlantMutation]:
|
||||
var new_mutations = parent.mutations.duplicate_deep()
|
||||
|
||||
# class RemoveMutation extends MutationPossibility:
|
||||
# func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
# var new_mutations :Array[PlantMutation] = parent_mutation.duplicate_deep()
|
||||
var mut_to_remove = new_mutations.pick_random()
|
||||
if mut_to_remove.level > 1:
|
||||
mut_to_remove.level -= 1
|
||||
else:
|
||||
new_mutations.remove_at(new_mutations.find(mut_to_remove))
|
||||
|
||||
# var mut_to_remove = new_mutations.pick_random()
|
||||
# if mut_to_remove.level > 1:
|
||||
# mut_to_remove.level -= 1
|
||||
# else:
|
||||
# new_mutations.remove_at(new_mutations.find(mut_to_remove))
|
||||
|
||||
# return new_mutations
|
||||
return new_mutations
|
||||
|
||||
@@ -182,6 +182,7 @@ func use_item(item : Item):
|
||||
data.energy -= item.energy_usage
|
||||
if item.is_one_time_use():
|
||||
data.inventory.remove_item(item)
|
||||
region.save()
|
||||
|
||||
func upgrade_max_energy(amount = 1):
|
||||
data.max_energy += amount
|
||||
|
||||
Reference in New Issue
Block a user