ajout du déblocage/évolutions des plantes (#89) et fix divers
This commit is contained in:
parent
11ae967845
commit
ed675ed532
@ -21,7 +21,6 @@ func _init():
|
||||
@export var truck_data : TruckData = TruckData.new()
|
||||
|
||||
func set_default_unlocked():
|
||||
unlocked_plant_types = all_plant_types()
|
||||
unlocked_plant_mutations = all_plant_mutations()
|
||||
unlocked_machines = all_machines()
|
||||
|
||||
@ -39,6 +38,25 @@ func reset_all():
|
||||
reset_player()
|
||||
reset_truck()
|
||||
|
||||
unlocked_plant_types = []
|
||||
|
||||
func unlock_plant_type(new_plant_type : PlantType):
|
||||
if not is_plant_type_unlocked(new_plant_type):
|
||||
unlocked_plant_types.append(new_plant_type.duplicate_deep())
|
||||
|
||||
func get_locked_plant_types() -> Array[PlantType]:
|
||||
var locked_plant_type : Array[PlantType] = []
|
||||
|
||||
for pt in GameInfo.game_data.all_plant_types():
|
||||
if not is_plant_type_unlocked(pt):
|
||||
locked_plant_type.append(pt)
|
||||
|
||||
return locked_plant_type
|
||||
|
||||
func is_plant_type_unlocked(new_plant_type : PlantType):
|
||||
return unlocked_plant_types.find_custom(
|
||||
func (upt : PlantType): return new_plant_type.name == upt.name
|
||||
) != -1
|
||||
|
||||
|
||||
func all_plant_types() -> Array[PlantType]:
|
||||
|
||||
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/ambiance_phase_1.ogg-4ec046572bfe46745950c2c7
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@ -12,7 +12,7 @@ dest_files=["res://.godot/imported/ambiance_phase_2.ogg-2260c3829d7e53dd94462ea7
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
|
||||
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/ambiance_phase_3.ogg-b221fd161951d0874f6a08d4
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/forest_phase_1.ogg-6bf54bf177c3c359a54aab9723
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/forest_phase_2.ogg-0fc72a5b1a0f8f7e98246db80e
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@ -12,8 +12,8 @@ dest_files=["res://.godot/imported/truck_music.ogg-cb4f770bcd6358719b9d817459f5f
|
||||
|
||||
[params]
|
||||
|
||||
loop=false
|
||||
loop_offset=0
|
||||
bpm=0
|
||||
loop=true
|
||||
loop_offset=0.0
|
||||
bpm=0.0
|
||||
beat_count=0
|
||||
bar_beats=4
|
||||
|
||||
@ -48,7 +48,6 @@ func get_all_audio_stream() -> Array[AudioStreamPlayer]:
|
||||
var all_children = %Ambiance.get_children()
|
||||
all_children.append_array(%Musics.get_children())
|
||||
|
||||
print(all_children)
|
||||
for c in all_children:
|
||||
if c is AudioStreamPlayer:
|
||||
all_audio_stream.append(c)
|
||||
@ -60,9 +59,9 @@ func _on_current_planet_data_updated(planet_data : PlanetData):
|
||||
planet_data.updated.connect(update_garden_phase)
|
||||
|
||||
func update_garden_phase(planet_data : PlanetData):
|
||||
var phase : int = 0
|
||||
var phase : int = garden_phase
|
||||
for i in range(len(garden_phases_scores)):
|
||||
if planet_data.garden_score >= garden_phases_scores[i]:
|
||||
if planet_data.garden_score >= garden_phases_scores[i] and i > garden_phase:
|
||||
phase = i
|
||||
|
||||
update_phase()
|
||||
|
||||
@ -1,3 +0,0 @@
|
||||
[gd_resource type="AudioBusLayout" format=3 uid="uid://br1p68sy17lcg"]
|
||||
|
||||
[resource]
|
||||
@ -18,9 +18,10 @@ func get_description() -> String:
|
||||
return "Loot " + str(seeds_number) + " random seeds."
|
||||
|
||||
func reward(objective : Objective):
|
||||
for i in range(seeds_number):
|
||||
objective.terrain.drop_item(
|
||||
Seed.new(GameInfo.game_data.unlocked_plant_types.pick_random()),
|
||||
objective.global_position,
|
||||
REWARD_SEED_RANDOM_DISPLACEMENT_FACTOR
|
||||
)
|
||||
if len(GameInfo.game_data.unlocked_plant_types):
|
||||
for i in range(seeds_number):
|
||||
objective.terrain.drop_item(
|
||||
Seed.new(GameInfo.game_data.unlocked_plant_types.pick_random()),
|
||||
objective.global_position,
|
||||
REWARD_SEED_RANDOM_DISPLACEMENT_FACTOR
|
||||
)
|
||||
@ -24,5 +24,5 @@ default_growing_time = 3
|
||||
seed_texture = SubResource("AtlasTexture_my6by")
|
||||
growing_texture = ExtResource("2_l2hi3")
|
||||
mature_texture = ExtResource("3_y8qve")
|
||||
default_mature_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_cf34j")])
|
||||
mature_effects = Array[ExtResource("1_l2hi3")]([SubResource("Resource_cf34j")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -13,7 +13,7 @@ script = ExtResource("2_prk5s")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_k7yib"]
|
||||
[sub_resource type="Resource" id="Resource_ajihu"]
|
||||
script = ExtResource("3_ajihu")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
@ -29,6 +29,6 @@ description = "This fern use the bas component of the ground to grow."
|
||||
seed_texture = SubResource("AtlasTexture_qt76e")
|
||||
growing_texture = ExtResource("1_prk5s")
|
||||
mature_texture = ExtResource("3_40c3e")
|
||||
default_harvest_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_40c3e")])
|
||||
default_mature_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_k7yib")])
|
||||
harvest_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_40c3e")])
|
||||
mature_effects = Array[ExtResource("1_40c3e")]([SubResource("Resource_ajihu")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bfj6wji21amgk" path="res://entities/plants/assets/sprites/ferno/mature.png" id="5_er4cp"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="7_0y7r8"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0ofiq"]
|
||||
[sub_resource type="Resource" id="Resource_rb4mq"]
|
||||
script = ExtResource("2_rb4mq")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7wddl"]
|
||||
[sub_resource type="Resource" id="Resource_s6g12"]
|
||||
script = ExtResource("3_s6g12")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
@ -29,5 +29,5 @@ description = "This mysterious flower emmit a strong signal in the ground when h
|
||||
seed_texture = SubResource("AtlasTexture_g1td4")
|
||||
growing_texture = ExtResource("4_5qaoo")
|
||||
mature_texture = ExtResource("5_er4cp")
|
||||
default_harvest_effects = Array[ExtResource("1_srjq6")]([SubResource("Resource_0ofiq"), SubResource("Resource_7wddl")])
|
||||
harvest_effects = Array[ExtResource("1_srjq6")]([SubResource("Resource_rb4mq"), SubResource("Resource_s6g12")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://d3apfwbqsg5ha" path="res://entities/plants/assets/sprites/maias/mature.png" id="3_pi4ie"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_mwrj8"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1llfc"]
|
||||
[sub_resource type="Resource" id="Resource_740j2"]
|
||||
script = ExtResource("2_740j2")
|
||||
level = 3
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
@ -23,5 +23,5 @@ description = "This gorgeous flower produce a lot of seeds when harvested."
|
||||
seed_texture = SubResource("AtlasTexture_sri3b")
|
||||
growing_texture = ExtResource("1_vyplc")
|
||||
mature_texture = ExtResource("3_pi4ie")
|
||||
default_harvest_effects = Array[ExtResource("1_740j2")]([SubResource("Resource_1llfc")])
|
||||
harvest_effects = Array[ExtResource("1_740j2")]([SubResource("Resource_740j2")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://bj801geprrhfu" path="res://entities/plants/assets/sprites/philea/mature.png" id="4_cafy4"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_oaspo"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0x8ki"]
|
||||
[sub_resource type="Resource" id="Resource_jyjjp"]
|
||||
script = ExtResource("2_jyjjp")
|
||||
level = 1
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
@ -25,5 +25,5 @@ default_plant_score = 3
|
||||
seed_texture = SubResource("AtlasTexture_ogrgq")
|
||||
growing_texture = ExtResource("3_n0hvm")
|
||||
mature_texture = ExtResource("4_cafy4")
|
||||
default_mature_effects = Array[ExtResource("1_mi4ef")]([SubResource("Resource_0x8ki")])
|
||||
mature_effects = Array[ExtResource("1_mi4ef")]([SubResource("Resource_jyjjp")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -8,12 +8,12 @@
|
||||
[ext_resource type="Script" uid="uid://ceqx5va1ormau" path="res://entities/plants/scripts/plant_effects/produce_seeds.gd" id="3_26e4l"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="5_26e4l"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kidty"]
|
||||
[sub_resource type="Resource" id="Resource_8fstu"]
|
||||
script = ExtResource("3_26e4l")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_8fstu"]
|
||||
[sub_resource type="Resource" id="Resource_26e4l"]
|
||||
script = ExtResource("2_8fstu")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://cgscbuxe4dawb"
|
||||
@ -30,6 +30,6 @@ default_growing_time = 3
|
||||
seed_texture = SubResource("AtlasTexture_kidty")
|
||||
growing_texture = ExtResource("2_k4b1k")
|
||||
mature_texture = ExtResource("3_8fstu")
|
||||
default_harvest_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_kidty")])
|
||||
default_mature_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_8fstu")])
|
||||
harvest_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_8fstu")])
|
||||
mature_effects = Array[ExtResource("1_8fstu")]([SubResource("Resource_26e4l")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
[ext_resource type="Texture2D" uid="uid://b3wom2xu26g43" path="res://entities/plants/assets/sprites/solita/mature.png" id="4_njidq"]
|
||||
[ext_resource type="Texture2D" uid="uid://pltmnkqd5ut2" path="res://entities/plants/assets/sprites/seeds/grille_seeds.png" id="6_yn0yu"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3fdsj"]
|
||||
[sub_resource type="Resource" id="Resource_j4n5p"]
|
||||
script = ExtResource("2_1q5bp")
|
||||
level = 2
|
||||
metadata/_custom_type_script = "uid://ceqx5va1ormau"
|
||||
@ -25,5 +25,5 @@ default_plant_score = 2
|
||||
seed_texture = SubResource("AtlasTexture_auuc2")
|
||||
growing_texture = ExtResource("3_j4n5p")
|
||||
mature_texture = ExtResource("4_njidq")
|
||||
default_harvest_effects = Array[ExtResource("1_mksys")]([SubResource("Resource_3fdsj")])
|
||||
harvest_effects = Array[ExtResource("1_mksys")]([SubResource("Resource_j4n5p")])
|
||||
metadata/_custom_type_script = "uid://jnye5pe1bgqw"
|
||||
|
||||
@ -15,10 +15,6 @@ const LIFETIME_ICON = preload("res://common/icons/calendar-week.svg")
|
||||
const SHOVEL_ICON = preload("res://common/icons/shovel.svg")
|
||||
const GROWING_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/plants/plant_sprite.tscn")
|
||||
|
||||
enum State {PLANTED, GROWING, MATURE}
|
||||
@ -32,9 +28,6 @@ var state: State = State.PLANTED
|
||||
@onready var collision_shape: CollisionShape2D
|
||||
@onready var influence_zone : PlantInfluenceZone
|
||||
|
||||
var harvest_effects = []
|
||||
var mature_effects = []
|
||||
var cyclic_effects = []
|
||||
var plant_score = 0
|
||||
var plant_mutations : Array[PlantMutation] = []
|
||||
|
||||
@ -44,9 +37,6 @@ func _init(
|
||||
_day = 0,
|
||||
):
|
||||
plant_type = _plant_type
|
||||
harvest_effects = plant_type.default_harvest_effects.duplicate_deep()
|
||||
mature_effects = plant_type.default_mature_effects.duplicate_deep()
|
||||
cyclic_effects = plant_type.default_cyclic_effects.duplicate_deep()
|
||||
|
||||
day = _day
|
||||
|
||||
@ -96,8 +86,8 @@ func generate_influence_zone() -> PlantInfluenceZone:
|
||||
func _pass_day():
|
||||
await get_tree().create_timer(randf_range(0., RANDOM_MAX_GROW_INTERVAL)).timeout
|
||||
|
||||
if state == State.MATURE and len(cyclic_effects):
|
||||
for effect in cyclic_effects:
|
||||
if state == State.MATURE and len(plant_type.cyclic_effects):
|
||||
for effect in plant_type.cyclic_effects:
|
||||
effect.effect(self)
|
||||
|
||||
var old_state = state
|
||||
@ -106,9 +96,9 @@ func _pass_day():
|
||||
update_plant()
|
||||
|
||||
if old_state != state and state == State.MATURE:
|
||||
for effect in mature_effects:
|
||||
for effect in plant_type.mature_effects:
|
||||
if effect : effect.effect(self)
|
||||
for effect in cyclic_effects:
|
||||
for effect in plant_type.cyclic_effects:
|
||||
if effect : effect.effect(self)
|
||||
|
||||
func update_plant(with_animation : bool = true):
|
||||
@ -137,7 +127,7 @@ func calculate_grow_time() -> int:
|
||||
for m in plant_mutations:
|
||||
mutated_grow_time = m.mutate_grow_time(self, mutated_grow_time)
|
||||
|
||||
return mutated_grow_time
|
||||
return max(1, mutated_grow_time)
|
||||
|
||||
func change_state(_state: State, with_animation : bool = true):
|
||||
if state != _state:
|
||||
@ -148,7 +138,7 @@ func change_state(_state: State, with_animation : bool = true):
|
||||
|
||||
func harvest():
|
||||
if state == State.MATURE:
|
||||
for effect in harvest_effects:
|
||||
for effect in plant_type.harvest_effects:
|
||||
if effect : effect.effect(self)
|
||||
|
||||
plant_sprite.start_harvest_animation()
|
||||
@ -203,39 +193,10 @@ func card_info() -> CardInfo:
|
||||
for m in plant_mutations:
|
||||
info.sections.append(m.card_section())
|
||||
|
||||
info.sections.append_array(card_effect_sections())
|
||||
info.sections.append_array(PlantEffect.card_effect_sections(
|
||||
plant_type.mature_effects,
|
||||
plant_type.harvest_effects,
|
||||
plant_type.cyclic_effects,
|
||||
))
|
||||
|
||||
return info
|
||||
|
||||
func card_effect_sections() -> Array[CardSectionInfo]:
|
||||
var sections : Array[CardSectionInfo] = []
|
||||
var effects_category = [
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects
|
||||
]
|
||||
var effects_category_labels : Array[String] = [
|
||||
"On mature",
|
||||
"When harvested",
|
||||
"Each day when mature",
|
||||
]
|
||||
var effects_category_icon : Array[Texture] = [
|
||||
MATURE_EFFECT_ICON,
|
||||
HARVEST_EFFECT_ICON,
|
||||
CYCLIC_EFFECT_ICON,
|
||||
]
|
||||
|
||||
for i in range(len(effects_category)):
|
||||
var effects = effects_category[i]
|
||||
if len(effects):
|
||||
var section = CardSectionInfo.new(
|
||||
effects_category_labels[i]
|
||||
)
|
||||
section.title_icon = effects_category_icon[i]
|
||||
var effects_text : Array = effects.map(
|
||||
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
|
||||
)
|
||||
section.text = "\n".join(effects_text)
|
||||
sections.append(section)
|
||||
|
||||
return sections
|
||||
return info
|
||||
@ -2,6 +2,10 @@
|
||||
extends Resource
|
||||
class_name PlantEffect
|
||||
|
||||
const HARVEST_EFFECT_ICON = preload("res://common/icons/shovel.svg")
|
||||
const MATURE_EFFECT_ICON = preload("res://common/icons/chevrons-up.svg")
|
||||
const CYCLIC_EFFECT_ICON = preload("res://common/icons/rotate-rectangle.svg")
|
||||
|
||||
@export var level : int
|
||||
|
||||
func _init(_level : int = 1):
|
||||
@ -15,7 +19,7 @@ func get_effect_description() -> String:
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
return ""
|
||||
|
||||
func effect(plant):
|
||||
func effect(_plant):
|
||||
printerr("Classe abstraite PlantEffect appelée")
|
||||
|
||||
func get_styled_effect_name():
|
||||
@ -31,4 +35,42 @@ func get_styled_effect_name():
|
||||
if level == 1:
|
||||
return levels_bbcode[0] % get_effect_name()
|
||||
else :
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
return levels_bbcode[min(level - 1, len(levels_bbcode) - 1)] % [get_effect_name(), level]
|
||||
|
||||
static func card_effect_sections(
|
||||
mature_effects : Array[PlantEffect],
|
||||
harvest_effects : Array[PlantEffect],
|
||||
cyclic_effects : Array[PlantEffect]
|
||||
) -> Array[CardSectionInfo]:
|
||||
var sections : Array[CardSectionInfo] = []
|
||||
var effects_category = [
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects
|
||||
]
|
||||
var effects_category_labels : Array[String] = [
|
||||
"On mature",
|
||||
"When harvested",
|
||||
"Each day when mature",
|
||||
]
|
||||
var effects_category_icon : Array[Texture] = [
|
||||
MATURE_EFFECT_ICON,
|
||||
HARVEST_EFFECT_ICON,
|
||||
CYCLIC_EFFECT_ICON,
|
||||
]
|
||||
|
||||
for i in range(len(effects_category)):
|
||||
var effects = effects_category[i]
|
||||
|
||||
if len(effects) > 0:
|
||||
var section = CardSectionInfo.new(
|
||||
effects_category_labels[i]
|
||||
)
|
||||
section.title_icon = effects_category_icon[i]
|
||||
var effects_text : Array = effects.map(
|
||||
func (e : PlantEffect): return "[b]%s[/b] %s" % [e.get_styled_effect_name() , e.get_effect_description()]
|
||||
)
|
||||
section.text = "\n".join(effects_text)
|
||||
sections.append(section)
|
||||
|
||||
return sections
|
||||
@ -1,13 +1,6 @@
|
||||
extends Resource
|
||||
class_name PlantMutation
|
||||
|
||||
const BASE_RARITY_CHANCE : Array[float] = [
|
||||
0.75,
|
||||
0.9,
|
||||
1,
|
||||
1,
|
||||
]
|
||||
|
||||
@export var level : int = 1
|
||||
|
||||
func _init(_level : int = 1):
|
||||
@ -78,21 +71,15 @@ static func get_rarity_color(rarity : int) -> Color:
|
||||
|
||||
return rarity_colors[min(rarity, len(rarity_colors) - 1)]
|
||||
|
||||
static func random_rarity() -> int:
|
||||
var random_float = randf()
|
||||
|
||||
for i in range(len(BASE_RARITY_CHANCE) - 1):
|
||||
if random_float < BASE_RARITY_CHANCE[i]:
|
||||
return i
|
||||
return len(BASE_RARITY_CHANCE) - 1
|
||||
|
||||
static func random_mutation(rarity = PlantMutation.random_rarity()) -> PlantMutation:
|
||||
static func random_mutation(except_mutations : Array[PlantMutation] = []) -> PlantMutation:
|
||||
var all_mutations = GameInfo.game_data.unlocked_plant_mutations.duplicate_deep()
|
||||
all_mutations.shuffle()
|
||||
for new_mutation in all_mutations:
|
||||
var level_for_rarity = new_mutation.get_level_for_rarity(rarity)
|
||||
if level_for_rarity >= 1:
|
||||
new_mutation.level = level_for_rarity
|
||||
return new_mutation
|
||||
return null
|
||||
|
||||
all_mutations = all_mutations.filter(
|
||||
func (f1 : PlantMutation):
|
||||
return except_mutations.find_custom(
|
||||
func (f2 : PlantMutation): return f2.get_mutation_name() == f1.get_mutation_name()
|
||||
) == -1
|
||||
)
|
||||
if len(all_mutations):
|
||||
return all_mutations.pick_random()
|
||||
else :
|
||||
return null
|
||||
|
||||
@ -11,6 +11,118 @@ class_name PlantType
|
||||
@export var growing_texture : Texture
|
||||
@export var mature_texture : Texture
|
||||
|
||||
@export var default_harvest_effects : Array[PlantEffect] = []
|
||||
@export var default_mature_effects : Array[PlantEffect] = []
|
||||
@export var default_cyclic_effects : Array[PlantEffect] = []
|
||||
@export var harvest_effects : Array[PlantEffect] = []
|
||||
@export var mature_effects : Array[PlantEffect] = []
|
||||
@export var cyclic_effects : Array[PlantEffect] = []
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
var info = CardInfo.new(
|
||||
name
|
||||
)
|
||||
|
||||
info.important_stat_icon = Plant.PLANT_POINT_ICON
|
||||
info.important_stat_text = "%d" % default_plant_score
|
||||
info.texture = mature_texture
|
||||
info.type_icon = Plant.PLANT_TYPE_ICON
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
"Grow in [b]%d[/b]" % default_growing_time,
|
||||
Plant.GROWING_ICON
|
||||
))
|
||||
|
||||
info.stats.append(CardStatInfo.new(
|
||||
"[b]%d[/b] score when mature" % default_plant_score,
|
||||
Plant.PLANT_POINT_ICON
|
||||
))
|
||||
|
||||
info.sections.append_array(PlantEffect.card_effect_sections(
|
||||
mature_effects,
|
||||
harvest_effects,
|
||||
cyclic_effects,
|
||||
))
|
||||
|
||||
return info
|
||||
|
||||
func get_available_evolution() -> Array[Evolution]:
|
||||
var evolutions : Array[Evolution] = [
|
||||
ScoreEvolution.new(self)
|
||||
]
|
||||
|
||||
if len(mature_effects) > 0:
|
||||
evolutions.append(MatureEffectEvolution.new(self))
|
||||
if len(harvest_effects) > 0:
|
||||
evolutions.append(HarvestEffectEvolution.new(self))
|
||||
if len(cyclic_effects) > 0:
|
||||
evolutions.append(CyclicEffectEvolution.new(self))
|
||||
|
||||
return evolutions
|
||||
|
||||
class Evolution:
|
||||
|
||||
var level : int
|
||||
var plant_type : PlantType
|
||||
|
||||
func _init(_type : PlantType, _l : int = 1):
|
||||
plant_type = _type
|
||||
level = _l
|
||||
|
||||
func get_title():
|
||||
return ""
|
||||
|
||||
func get_description():
|
||||
return ""
|
||||
|
||||
func evolve(_pt : PlantType = plant_type):
|
||||
pass
|
||||
|
||||
class ScoreEvolution extends Evolution:
|
||||
|
||||
func get_title():
|
||||
return "%s score evolution" % plant_type.name
|
||||
|
||||
func get_description():
|
||||
return "Add [b]%s[/b] to the default score of the plant" % level
|
||||
|
||||
func evolve(pt : PlantType = plant_type):
|
||||
pt.default_plant_score += level
|
||||
|
||||
class MatureEffectEvolution extends Evolution:
|
||||
|
||||
var effect_index : int
|
||||
|
||||
func _init(_type : PlantType, _l : int = 1):
|
||||
plant_type = _type
|
||||
level = _l
|
||||
|
||||
pick_effect()
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.mature_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.mature_effects[effect_index]
|
||||
|
||||
func get_title():
|
||||
return "%s %s evolution" % [plant_type.name, get_effect().get_effect_name()]
|
||||
|
||||
func get_description():
|
||||
return "Upgrade the level of %s of %d" % [get_effect().get_effect_name(), level]
|
||||
|
||||
func evolve(pt : PlantType = plant_type):
|
||||
get_effect(pt).level += level
|
||||
|
||||
class HarvestEffectEvolution extends MatureEffectEvolution:
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.harvest_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.harvest_effects[effect_index]
|
||||
|
||||
class CyclicEffectEvolution extends MatureEffectEvolution:
|
||||
|
||||
func pick_effect():
|
||||
effect_index = randi() % len(plant_type.harvest_effects)
|
||||
|
||||
func get_effect(pt : PlantType = plant_type) -> PlantEffect:
|
||||
return pt.harvest_effects[effect_index]
|
||||
@ -5,9 +5,15 @@ signal updated(inventory: Inventory)
|
||||
|
||||
@export var items: Array[Item] = []
|
||||
@export var current_item_ind: int = 0
|
||||
@export var size = 0 :
|
||||
set(s):
|
||||
size = s
|
||||
items.resize(size)
|
||||
updated.emit(self)
|
||||
|
||||
func _init(inventory_size: int = 1):
|
||||
items.resize(inventory_size)
|
||||
size = inventory_size
|
||||
|
||||
|
||||
func get_best_available_slot_ind():
|
||||
if items[current_item_ind] == null:
|
||||
|
||||
@ -33,13 +33,13 @@ func get_usage_object_affected(_i : InspectableEntity) -> bool:
|
||||
func is_one_time_use():
|
||||
return false
|
||||
|
||||
func can_use(_player : Player, zone: Player.ActionZone) -> bool:
|
||||
func can_use(_player : Player, _zone: Player.ActionZone) -> bool:
|
||||
return false
|
||||
|
||||
func use_text() -> String:
|
||||
return ""
|
||||
|
||||
func use(_player : Player, zone: Player.ActionZone):
|
||||
func use(_player : Player, _zone: Player.ActionZone):
|
||||
return false
|
||||
|
||||
func card_info() -> CardInfo:
|
||||
|
||||
@ -29,7 +29,7 @@ func use_text() -> String:
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
func can_use(player : Player, _zone : Player.ActionZone) -> bool:
|
||||
return player.terrain is Planet
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
@ -24,7 +24,7 @@ func use_text() -> String:
|
||||
func is_one_time_use():
|
||||
return true
|
||||
|
||||
func can_use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
func can_use(player : Player, _zone : Player.ActionZone) -> bool:
|
||||
return player.planet != null
|
||||
|
||||
func use(player : Player, zone : Player.ActionZone) -> bool:
|
||||
|
||||
@ -23,7 +23,7 @@ func get_energy_used() -> int:
|
||||
return 1
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 30
|
||||
return 40
|
||||
|
||||
func get_usage_object_affected(i : InspectableEntity) -> bool:
|
||||
return i is Plant
|
||||
@ -137,11 +137,19 @@ static func mutate(parent_mutation : Array[PlantMutation] = []) -> Array[PlantMu
|
||||
AddMutation.new()
|
||||
]
|
||||
|
||||
if len(parent_mutation):
|
||||
possible_mutations.append_array( [
|
||||
if (
|
||||
len(parent_mutation) > 2
|
||||
):
|
||||
possible_mutations = [
|
||||
UpgradeMutation.new(),
|
||||
RemoveMutation.new(),
|
||||
])
|
||||
]
|
||||
elif len(parent_mutation) > 0:
|
||||
possible_mutations = [
|
||||
AddMutation.new(),
|
||||
UpgradeMutation.new(),
|
||||
RemoveMutation.new(),
|
||||
]
|
||||
|
||||
var chosen_mutation = possible_mutations.pick_random()
|
||||
|
||||
@ -159,10 +167,10 @@ class DontMutate extends MutationPossibility:
|
||||
class AddMutation extends MutationPossibility:
|
||||
func mutate(parent_mutation : Array[PlantMutation] = [])-> Array[PlantMutation]:
|
||||
var new_mutations = parent_mutation.duplicate_deep()
|
||||
var mut = PlantMutation.random_mutation()
|
||||
var mut = PlantMutation.random_mutation(parent_mutation)
|
||||
|
||||
if mut:
|
||||
var existing_mut_id = new_mutations.find_custom(func(m:PlantMutation): m.get_mutation_name() == mut.get_mutation_name())
|
||||
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
|
||||
|
||||
@ -187,7 +187,7 @@ func upgrade_max_energy(amount = 1):
|
||||
player_updated.emit(self)
|
||||
|
||||
func upgrade_inventory_size(amount = 1):
|
||||
data.inventory.items.resize(data.inventory.items.size() + amount)
|
||||
data.inventory.size += 1
|
||||
upgraded.emit()
|
||||
player_updated.emit(self)
|
||||
|
||||
|
||||
@ -4,28 +4,11 @@ class_name UndergroundLoot
|
||||
const AREA_WIDTH = 20
|
||||
const LOOTED_ITEM_RANDOM_RANGE = 50
|
||||
|
||||
const SPRITE_SCENE : PackedScene = preload("res://entities/underground_loot/underground_loot_sprite.tscn")
|
||||
|
||||
@export var loot : Array[Item]
|
||||
|
||||
@onready var sprite_object: Node2D = generate_sprite()
|
||||
@onready var collision_shape: CollisionShape2D = generate_collision_shape()
|
||||
|
||||
|
||||
func _init(_loot : Array[Item] = []):
|
||||
loot = _loot
|
||||
default_info_desc = "Contain some random seeds. [b]Dig it with a shovel.[/b]"
|
||||
@export var item_number : int = 1
|
||||
|
||||
func pointer_text() -> String:
|
||||
return "Buried Loot"
|
||||
|
||||
func generate_sprite() -> Node2D:
|
||||
var object = SPRITE_SCENE.instantiate()
|
||||
|
||||
add_child(object)
|
||||
|
||||
return object
|
||||
|
||||
func generate_collision_shape() -> CollisionShape2D:
|
||||
var collision = CollisionShape2D.new()
|
||||
var shape = CircleShape2D.new()
|
||||
@ -36,8 +19,19 @@ func generate_collision_shape() -> CollisionShape2D:
|
||||
|
||||
return collision
|
||||
|
||||
func generate_loot() -> Array[Item]:
|
||||
var seeds : Array[Item] = []
|
||||
if len(GameInfo.game_data.unlocked_plant_types):
|
||||
seeds.append(
|
||||
Seed.new(
|
||||
GameInfo.game_data.unlocked_plant_types.pick_random()
|
||||
)
|
||||
)
|
||||
return seeds
|
||||
|
||||
|
||||
func dig():
|
||||
for item in loot:
|
||||
for item in generate_loot():
|
||||
planet.drop_item(item, global_position, LOOTED_ITEM_RANDOM_RANGE)
|
||||
queue_free()
|
||||
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
extends EntityData
|
||||
class_name UndergroundLootData
|
||||
|
||||
@export var loot : Array[Item]
|
||||
const SCENE = preload("res://entities/underground_loot/underground_loot.tscn")
|
||||
|
||||
@export var item_number : int
|
||||
|
||||
func _init(e : UndergroundLoot):
|
||||
position = e.global_position
|
||||
loot = e.loot
|
||||
position = e.global_position
|
||||
item_number = e.item_number
|
||||
|
||||
func load() -> Entity:
|
||||
return UndergroundLoot.new(loot)
|
||||
var loot : UndergroundLoot = (SCENE.instantiate() as UndergroundLoot)
|
||||
loot.item_number = item_number
|
||||
return loot
|
||||
|
||||
21
entities/underground_loot/underground_loot.tscn
Normal file
21
entities/underground_loot/underground_loot.tscn
Normal file
@ -0,0 +1,21 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://dxjud7bti0na0"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dfd2hh12155lo" path="res://entities/underground_loot/scripts/underground_loot.gd" id="1_knus5"]
|
||||
[ext_resource type="Texture2D" uid="uid://bu26h0iqutnky" path="res://entities/underground_loot/assets/sprites/underground_loot.svg" id="2_jfggo"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_knus5"]
|
||||
radius = 20.09975
|
||||
|
||||
[node name="UndergroundLootSprites" type="Area2D"]
|
||||
script = ExtResource("1_knus5")
|
||||
default_info_title = "Buried Seeds"
|
||||
default_info_desc = "Contain some random seeds. [b]Dig it with a shovel.[/b]"
|
||||
metadata/_custom_type_script = "uid://d3bk52402ylvl"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
modulate = Color(0.286275, 0.219608, 0.313726, 1)
|
||||
scale = Vector2(0.0806452, 0.0806452)
|
||||
texture = ExtResource("2_jfggo")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_knus5")
|
||||
@ -1,10 +0,0 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dxjud7bti0na0"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://bu26h0iqutnky" path="res://entities/underground_loot/assets/sprites/underground_loot.svg" id="1_t1xxm"]
|
||||
|
||||
[node name="UndergroundLootSprites" type="Node2D"]
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
modulate = Color(0.286275, 0.219608, 0.313726, 1)
|
||||
scale = Vector2(0.0806452, 0.0806452)
|
||||
texture = ExtResource("1_t1xxm")
|
||||
@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://753270jjxmfg"]
|
||||
[gd_scene load_steps=26 format=3 uid="uid://753270jjxmfg"]
|
||||
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="1_m317d"]
|
||||
[ext_resource type="Script" uid="uid://b7f10wuounfan" path="res://gui/game/card/scripts/card.gd" id="2_kpm7h"]
|
||||
@ -26,6 +26,30 @@ title_icon = ExtResource("6_7wc8v")
|
||||
text = "Text"
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_kpm7h"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_7wc8v"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_pmldi"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_gibok"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vnqhg"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_on5kv"]
|
||||
script = ExtResource("5_7wc8v")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_plgbn"]
|
||||
script = ExtResource("3_7wc8v")
|
||||
title = "Hello"
|
||||
@ -33,7 +57,7 @@ type_icon = ExtResource("6_7wc8v")
|
||||
texture = ExtResource("7_mwhj8")
|
||||
important_stat_text = "10"
|
||||
important_stat_icon = ExtResource("3_kpm7h")
|
||||
sections = Array[ExtResource("5_7wc8v")]([SubResource("Resource_mwhj8")])
|
||||
sections = Array[ExtResource("5_7wc8v")]([SubResource("Resource_mwhj8"), SubResource("Resource_kpm7h"), SubResource("Resource_7wc8v"), SubResource("Resource_pmldi"), SubResource("Resource_gibok"), SubResource("Resource_vnqhg"), SubResource("Resource_on5kv"), null])
|
||||
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vnqhg"]
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
[gd_scene load_steps=15 format=3 uid="uid://3ss8pvhsackj"]
|
||||
[gd_scene load_steps=22 format=3 uid="uid://3ss8pvhsackj"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://753270jjxmfg" path="res://gui/game/card/card.tscn" id="1_we78f"]
|
||||
[ext_resource type="Shader" uid="uid://bqjwmomh851lc" path="res://common/vfx/materials/shaders/skew.gdshader" id="1_x54se"]
|
||||
[ext_resource type="Script" uid="uid://dj5pld5ragrjp" path="res://gui/game/card/scripts/card_visualiser.gd" id="2_ntbk8"]
|
||||
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="3_5yk1o"]
|
||||
[ext_resource type="Texture2D" uid="uid://bd6qddv5ihkjr" path="res://common/icons/bucket.svg" id="3_r0jrf"]
|
||||
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="4_7xkgc"]
|
||||
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="5_1et8x"]
|
||||
[ext_resource type="Texture2D" uid="uid://bt3g5bmar0icf" path="res://common/icons/growth.svg" id="6_7xkgc"]
|
||||
[ext_resource type="Texture2D" uid="uid://bsvxhafoxwmw0" path="res://common/icons/cube-3d-sphere.svg" id="7_1et8x"]
|
||||
[ext_resource type="Texture2D" uid="uid://df0y0s666ui4h" path="res://icon.png" id="7_6vah0"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_r0jrf"]
|
||||
shader = ExtResource("1_x54se")
|
||||
@ -17,13 +18,41 @@ shader_parameter/y_rot = -6e-45
|
||||
shader_parameter/x_rot = -6e-45
|
||||
shader_parameter/inset = 0.0
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_5yk1o"]
|
||||
viewport_path = NodePath("SubViewport")
|
||||
|
||||
[sub_resource type="Resource" id="Resource_r0jrf"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_6vah0"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_jjqcm"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_lj1tr"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_vabmf"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_1vjtn"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_l3vvu"]
|
||||
script = ExtResource("4_7xkgc")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_bw03i"]
|
||||
script = ExtResource("3_5yk1o")
|
||||
title = "Hello"
|
||||
texture = ExtResource("6_7xkgc")
|
||||
texture = ExtResource("7_6vah0")
|
||||
important_stat_text = "6"
|
||||
important_stat_icon = ExtResource("3_r0jrf")
|
||||
sections = Array[ExtResource("4_7xkgc")]([SubResource("Resource_r0jrf"), SubResource("Resource_6vah0"), SubResource("Resource_jjqcm"), SubResource("Resource_lj1tr"), SubResource("Resource_vabmf"), SubResource("Resource_1vjtn"), SubResource("Resource_l3vvu")])
|
||||
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
|
||||
|
||||
[sub_resource type="Animation" id="Animation_1et8x"]
|
||||
@ -39,31 +68,38 @@ _data = {
|
||||
&"appear": SubResource("Animation_7xkgc")
|
||||
}
|
||||
|
||||
[node name="CardVisualiser" type="TextureRect"]
|
||||
[node name="CardVisualiser" type="SubViewportContainer"]
|
||||
material = SubResource("ShaderMaterial_r0jrf")
|
||||
offset_left = -24.0
|
||||
offset_right = 276.0
|
||||
offset_bottom = 110.0
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -246.0
|
||||
offset_top = -134.0
|
||||
offset_right = 54.0
|
||||
offset_bottom = -24.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
scale = Vector2(1.0000002, 1.0000002)
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
mouse_filter = 2
|
||||
texture = SubResource("ViewportTexture_5yk1o")
|
||||
stretch_mode = 4
|
||||
script = ExtResource("2_ntbk8")
|
||||
small_mode = true
|
||||
card_info = SubResource("Resource_r0jrf")
|
||||
card_info = SubResource("Resource_bw03i")
|
||||
|
||||
[node name="SubViewport" type="SubViewport" parent="."]
|
||||
unique_name_in_owner = true
|
||||
transparent_bg = true
|
||||
handle_input_locally = false
|
||||
size = Vector2i(300, 110)
|
||||
size_2d_override_stretch = true
|
||||
render_target_update_mode = 4
|
||||
|
||||
[node name="CardContainer" type="MarginContainer" parent="SubViewport"]
|
||||
unique_name_in_owner = true
|
||||
clip_contents = true
|
||||
offset_right = 350.0
|
||||
offset_right = 300.0
|
||||
offset_bottom = 110.0
|
||||
size_flags_horizontal = 0
|
||||
theme_override_constants/margin_left = 25
|
||||
theme_override_constants/margin_top = 25
|
||||
theme_override_constants/margin_right = 25
|
||||
@ -73,10 +109,11 @@ theme_override_constants/margin_bottom = 25
|
||||
unique_name_in_owner = true
|
||||
self_modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 4
|
||||
mouse_filter = 2
|
||||
small_mode = true
|
||||
down_arrow = true
|
||||
info = SubResource("Resource_r0jrf")
|
||||
info = SubResource("Resource_bw03i")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
|
||||
@ -1,27 +1,55 @@
|
||||
@tool
|
||||
extends TextureRect
|
||||
extends SubViewportContainer
|
||||
class_name CardVisualiser
|
||||
|
||||
signal clicked(c: CardVisualiser)
|
||||
|
||||
const MAX_ROT = 15
|
||||
const ZOOM_SCALE = 1.0
|
||||
const ZOOM_SCALE = 1.2
|
||||
|
||||
var wanted_rot : Vector2 = Vector2.ZERO
|
||||
var real_rot : Vector2 = Vector2.ZERO
|
||||
var wanted_scale : Vector2 = Vector2.ONE
|
||||
|
||||
var is_ready = false
|
||||
|
||||
@export var small_mode : bool = false :
|
||||
@export var card_width : int = 250 :
|
||||
set(v):
|
||||
card_width = v
|
||||
if is_ready :
|
||||
update()
|
||||
|
||||
@export var small_mode : bool = true :
|
||||
set(v):
|
||||
var old = small_mode
|
||||
small_mode = v
|
||||
if is_ready : update()
|
||||
if is_ready and old != small_mode :
|
||||
update()
|
||||
|
||||
@export var interactive_small_mode : bool = true
|
||||
@export var interactive_zoom : bool = false
|
||||
|
||||
@export var down_arrow : bool = true :
|
||||
set(v):
|
||||
var old = down_arrow
|
||||
down_arrow = v
|
||||
if is_ready and old != down_arrow :
|
||||
update()
|
||||
|
||||
@export var card_info : CardInfo = null :
|
||||
set(v):
|
||||
var old = card_info
|
||||
card_info = v
|
||||
if is_ready : update()
|
||||
if is_ready and old != card_info:
|
||||
update()
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
var updated_on_last_frame = false
|
||||
|
||||
func _input(event):
|
||||
if event.is_action_pressed("action") and is_mouse_over():
|
||||
clicked.emit(self)
|
||||
|
||||
func _ready():
|
||||
material = material.duplicate()
|
||||
update()
|
||||
@ -32,17 +60,21 @@ func _process(_d):
|
||||
|
||||
if is_mouse_over():
|
||||
wanted_rot = center_relative_mouse_position * MAX_ROT
|
||||
small_mode = false
|
||||
if interactive_small_mode: small_mode = false
|
||||
if interactive_zoom: scale = scale.lerp(Vector2.ONE * ZOOM_SCALE, 0.2)
|
||||
else:
|
||||
wanted_rot = Vector2.ZERO
|
||||
small_mode = true
|
||||
if interactive_small_mode: small_mode = true
|
||||
if interactive_zoom: scale = scale.lerp(Vector2.ONE, 0.2)
|
||||
|
||||
real_rot = real_rot.lerp(wanted_rot, 0.1)
|
||||
|
||||
material.set_shader_parameter("y_rot", - real_rot.x)
|
||||
material.set_shader_parameter("x_rot", real_rot.y)
|
||||
|
||||
%SubViewport.size.y = %CardContainer.size.y
|
||||
%Card.custom_minimum_size.x = card_width
|
||||
%CardContainer.size.y = 0
|
||||
%SubViewport.size = %CardContainer.size
|
||||
size = %SubViewport.size
|
||||
|
||||
|
||||
@ -55,8 +87,10 @@ func is_mouse_over() -> bool:
|
||||
)
|
||||
|
||||
func update():
|
||||
|
||||
if card_info:
|
||||
%Card.info = card_info
|
||||
%Card.small_mode = small_mode
|
||||
%Card.down_arrow = down_arrow
|
||||
%Card.update()
|
||||
|
||||
updated_on_last_frame = true
|
||||
|
||||
140
gui/game/quota_reward/quota_reward.tscn
Normal file
140
gui/game/quota_reward/quota_reward.tscn
Normal file
@ -0,0 +1,140 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://doxm7uab8i3tq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://12kjdou2kp5y" path="res://gui/game/quota_reward/scripts/quota_reward.gd" id="1_gye62"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="2_6ibex"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="3_x2kx4"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="4_trw0e"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gy0la"]
|
||||
shader = ExtResource("2_6ibex")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="Theme" id="Theme_7fpy7"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8323k"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RewardChoiceContainer:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("RewardChoiceContainer:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [true]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4f1tl"]
|
||||
resource_name = "show"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath("RewardChoiceContainer:modulate")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0.033333335, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath("RewardChoiceContainer:visible")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0, 0.033333335),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7fpy7"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_8323k"),
|
||||
&"show": SubResource("Animation_4f1tl")
|
||||
}
|
||||
|
||||
[node name="RewardChoice" type="CanvasLayer"]
|
||||
process_mode = 3
|
||||
script = ExtResource("1_gye62")
|
||||
|
||||
[node name="RewardChoiceContainer" type="Control" parent="."]
|
||||
unique_name_in_owner = true
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="RewardChoiceContainer"]
|
||||
material = SubResource("ShaderMaterial_gy0la")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.0352941, 0.0196078, 0.12549, 0.705882)
|
||||
|
||||
[node name="Choice" type="MarginContainer" parent="RewardChoiceContainer"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("3_x2kx4")
|
||||
theme_override_constants/margin_left = 30
|
||||
theme_override_constants/margin_top = 30
|
||||
theme_override_constants/margin_right = 30
|
||||
theme_override_constants/margin_bottom = 30
|
||||
|
||||
[node name="VSplitContainer" type="VBoxContainer" parent="RewardChoiceContainer/Choice"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("3_x2kx4")
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="RewardChoiceContainer/Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_7fpy7")
|
||||
text = "Choose a reward"
|
||||
label_settings = ExtResource("4_trw0e")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="RewardChoiceContainer/Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("3_x2kx4")
|
||||
text = "Discover new plants or evolve discovered ones"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="ChoicesContainer" type="HBoxContainer" parent="RewardChoiceContainer/Choice/VSplitContainer"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
theme = ExtResource("3_x2kx4")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_7fpy7")
|
||||
}
|
||||
@ -0,0 +1,96 @@
|
||||
[gd_scene load_steps=20 format=3 uid="uid://caupeuds0holj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bhhhw2ywxmmba" path="res://gui/game/quota_reward/quota_reward_choice/scripts/quota_reward_choice.gd" id="1_5arw8"]
|
||||
[ext_resource type="LabelSettings" uid="uid://dqwayi8yjwau2" path="res://gui/ressources/title_label_settings.tres" id="1_pjvy1"]
|
||||
[ext_resource type="Script" uid="uid://dj2pv1hiwjfv0" path="res://gui/game/card/scripts/card_info.gd" id="2_0lvi7"]
|
||||
[ext_resource type="PackedScene" uid="uid://3ss8pvhsackj" path="res://gui/game/card/card_visualiser.tscn" id="2_5arw8"]
|
||||
[ext_resource type="Script" uid="uid://bist0wp4nrswp" path="res://gui/game/quota_reward/quota_reward_choice/scripts/quota_reward_choice_info.gd" id="2_hirys"]
|
||||
[ext_resource type="Shader" uid="uid://bqjwmomh851lc" path="res://common/vfx/materials/shaders/skew.gdshader" id="3_07hub"]
|
||||
[ext_resource type="Script" uid="uid://dgbh38j13g5kn" path="res://gui/game/card/scripts/card_section_info.gd" id="3_llc24"]
|
||||
[ext_resource type="Texture2D" uid="uid://0hbdgalf04e" path="res://common/icons/wood.svg" id="4_llc24"]
|
||||
[ext_resource type="Script" uid="uid://b4tkium34c831" path="res://gui/game/card/scripts/card_stat_info.gd" id="4_tsfju"]
|
||||
[ext_resource type="Texture2D" uid="uid://bsvxhafoxwmw0" path="res://common/icons/cube-3d-sphere.svg" id="5_nnvhv"]
|
||||
|
||||
[sub_resource type="Resource" id="Resource_tsfju"]
|
||||
script = ExtResource("3_llc24")
|
||||
title_colored = true
|
||||
title_text = "Hello"
|
||||
title_icon = ExtResource("4_llc24")
|
||||
text = "This is text"
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_llc24"]
|
||||
script = ExtResource("3_llc24")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_nnvhv"]
|
||||
script = ExtResource("3_llc24")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_rnvv6"]
|
||||
script = ExtResource("3_llc24")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_0or1o"]
|
||||
script = ExtResource("3_llc24")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_46ofu"]
|
||||
script = ExtResource("3_llc24")
|
||||
metadata/_custom_type_script = "uid://dgbh38j13g5kn"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_3bvi2"]
|
||||
script = ExtResource("2_0lvi7")
|
||||
title = "Reward"
|
||||
sections = Array[ExtResource("3_llc24")]([SubResource("Resource_tsfju"), SubResource("Resource_llc24"), SubResource("Resource_nnvhv"), SubResource("Resource_rnvv6"), SubResource("Resource_0or1o"), SubResource("Resource_46ofu")])
|
||||
metadata/_custom_type_script = "uid://dj2pv1hiwjfv0"
|
||||
|
||||
[sub_resource type="Resource" id="Resource_apks8"]
|
||||
script = ExtResource("2_hirys")
|
||||
title = "One Reward"
|
||||
text = "Je m"
|
||||
card_info = SubResource("Resource_3bvi2")
|
||||
metadata/_custom_type_script = "uid://bist0wp4nrswp"
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_llc24"]
|
||||
shader = ExtResource("3_07hub")
|
||||
shader_parameter/fov = 90.0
|
||||
shader_parameter/cull_back = true
|
||||
shader_parameter/y_rot = -6e-45
|
||||
shader_parameter/x_rot = -6e-45
|
||||
shader_parameter/inset = 0.0
|
||||
|
||||
[node name="QuotaRewardChoice" type="VBoxContainer"]
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
mouse_filter = 0
|
||||
alignment = 1
|
||||
script = ExtResource("1_5arw8")
|
||||
info = SubResource("Resource_apks8")
|
||||
|
||||
[node name="QuotaRewardTitle" type="Label" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "One Reward"
|
||||
label_settings = ExtResource("1_pjvy1")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="QuotaRewardText" type="RichTextLabel" parent="."]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
bbcode_enabled = true
|
||||
text = "Je m"
|
||||
fit_content = true
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="QuotaRewardCenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="QuotaRewardCard" parent="QuotaRewardCenterContainer" instance=ExtResource("2_5arw8")]
|
||||
unique_name_in_owner = true
|
||||
material = SubResource("ShaderMaterial_llc24")
|
||||
layout_mode = 2
|
||||
small_mode = false
|
||||
interactive_small_mode = false
|
||||
down_arrow = false
|
||||
card_info = SubResource("Resource_3bvi2")
|
||||
@ -0,0 +1,30 @@
|
||||
@tool
|
||||
extends VBoxContainer
|
||||
class_name QuotaRewardChoice
|
||||
|
||||
signal card_clicked(c : VBoxContainer)
|
||||
|
||||
var is_ready = false
|
||||
|
||||
@export var info : QuotaRewardChoiceInfo = null :
|
||||
set(v):
|
||||
info = v
|
||||
if is_ready : update()
|
||||
|
||||
@export_tool_button("Update", "Callable") var update_action = update
|
||||
|
||||
func _ready():
|
||||
update()
|
||||
%QuotaRewardCard.clicked.connect(
|
||||
func (_c : CardVisualiser):
|
||||
card_clicked.emit(self)
|
||||
)
|
||||
is_ready = true
|
||||
|
||||
func update():
|
||||
if info:
|
||||
%QuotaRewardTitle.text = info.title
|
||||
%QuotaRewardText.text = info.text
|
||||
%QuotaRewardCard.card_info = info.card_info
|
||||
%QuotaRewardCard.update()
|
||||
|
||||
@ -0,0 +1 @@
|
||||
uid://bhhhw2ywxmmba
|
||||
@ -0,0 +1,8 @@
|
||||
extends Resource
|
||||
class_name QuotaRewardChoiceInfo
|
||||
|
||||
@export var title : String = ""
|
||||
|
||||
@export var text : String = ""
|
||||
|
||||
@export var card_info : CardInfo = null
|
||||
@ -0,0 +1 @@
|
||||
uid://bist0wp4nrswp
|
||||
122
gui/game/quota_reward/scripts/quota_reward.gd
Normal file
122
gui/game/quota_reward/scripts/quota_reward.gd
Normal file
@ -0,0 +1,122 @@
|
||||
@tool
|
||||
extends CanvasLayer
|
||||
class_name QuotaReward
|
||||
|
||||
const REWARD_CHOICE_SCENE : PackedScene = preload("res://gui/game/quota_reward/quota_reward_choice/quota_reward_choice.tscn")
|
||||
|
||||
signal reward_chosen
|
||||
|
||||
var showing_rewards: bool = false
|
||||
|
||||
var rewards : Array[QuotaReward.RewardData] = []
|
||||
|
||||
func _ready():
|
||||
%RewardChoiceContainer.visible = false
|
||||
|
||||
func show_rewards():
|
||||
showing_rewards = true
|
||||
%AnimationPlayer.play("show")
|
||||
|
||||
func hide_rewards():
|
||||
showing_rewards = false
|
||||
%AnimationPlayer.play_backwards("show")
|
||||
|
||||
func generate_rewards(nb : int = 3):
|
||||
var new_rewards : Array[QuotaReward.RewardData] = []
|
||||
|
||||
var max_retry = 20
|
||||
|
||||
while len(new_rewards) < nb or max_retry < 0:
|
||||
max_retry -= 1
|
||||
|
||||
var new_reward = (
|
||||
generate_discover_plant_reward()
|
||||
if len(GameInfo.game_data.unlocked_plant_types) == 0 or randi() % 2 == 0
|
||||
else generate_evolution_plant_reward()
|
||||
)
|
||||
|
||||
if new_rewards.find_custom(func(r): return r.reward_info().title == new_reward.reward_info().title) == -1:
|
||||
new_rewards.append(new_reward)
|
||||
else :
|
||||
max_retry -= 1
|
||||
|
||||
rewards = new_rewards
|
||||
|
||||
func generate_rewards_choices():
|
||||
for c in %ChoicesContainer.get_children():
|
||||
c.queue_free()
|
||||
|
||||
for r in rewards:
|
||||
var reward_choice : QuotaRewardChoice = REWARD_CHOICE_SCENE.instantiate() as QuotaRewardChoice
|
||||
reward_choice.info = r.reward_info()
|
||||
reward_choice.card_clicked.connect(
|
||||
func (_c):
|
||||
if showing_rewards: choose_reward(r)
|
||||
)
|
||||
%ChoicesContainer.add_child(reward_choice)
|
||||
|
||||
func generate_discover_plant_reward() -> RewardData:
|
||||
return DiscoverPlantReward.new(
|
||||
GameInfo.game_data.get_locked_plant_types().pick_random()
|
||||
)
|
||||
|
||||
func generate_evolution_plant_reward() -> RewardData:
|
||||
return EvolvePlantReward.new(
|
||||
GameInfo.game_data.unlocked_plant_types.pick_random().get_available_evolution().pick_random()
|
||||
)
|
||||
|
||||
func choose_reward(r : RewardData):
|
||||
r.reward()
|
||||
reward_chosen.emit()
|
||||
hide_rewards()
|
||||
|
||||
func trigger_reward():
|
||||
generate_rewards()
|
||||
generate_rewards_choices()
|
||||
show_rewards()
|
||||
|
||||
class RewardData:
|
||||
|
||||
func reward_info() -> QuotaRewardChoiceInfo:
|
||||
return null
|
||||
|
||||
func reward():
|
||||
pass
|
||||
|
||||
class DiscoverPlantReward extends RewardData:
|
||||
|
||||
var new_plant_type : PlantType
|
||||
|
||||
func _init(_new_plant_type):
|
||||
new_plant_type = _new_plant_type
|
||||
|
||||
func reward_info() -> QuotaRewardChoiceInfo:
|
||||
var info = QuotaRewardChoiceInfo.new()
|
||||
info.title = "Discover %s" % new_plant_type.name
|
||||
info.text = "%s seeds can now be found" % new_plant_type.name
|
||||
info.card_info = new_plant_type.card_info()
|
||||
|
||||
return info
|
||||
|
||||
func reward():
|
||||
GameInfo.game_data.unlock_plant_type(new_plant_type)
|
||||
|
||||
class EvolvePlantReward extends RewardData:
|
||||
|
||||
var plant_evolution : PlantType.Evolution
|
||||
|
||||
func _init(_plant_evolution):
|
||||
plant_evolution = _plant_evolution
|
||||
|
||||
func reward_info() -> QuotaRewardChoiceInfo:
|
||||
var info = QuotaRewardChoiceInfo.new()
|
||||
info.title = "Evolve %s" % plant_evolution.plant_type.name
|
||||
info.text = plant_evolution.get_description()
|
||||
var preview_evolved_plant = plant_evolution.plant_type.duplicate_deep()
|
||||
plant_evolution.evolve(preview_evolved_plant)
|
||||
info.card_info = preview_evolved_plant.card_info()
|
||||
|
||||
return info
|
||||
|
||||
func reward():
|
||||
plant_evolution.evolve()
|
||||
@ -1,177 +0,0 @@
|
||||
[gd_scene load_steps=11 format=3 uid="uid://doxm7uab8i3tq"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://12kjdou2kp5y" path="res://gui/game/reward_choice/scripts/reward_choice.gd" id="1_4f1tl"]
|
||||
[ext_resource type="Shader" uid="uid://cuni3ggtw2uuy" path="res://gui/game/pause/resources/blur.gdshader" id="1_iykpa"]
|
||||
[ext_resource type="Theme" uid="uid://bgcmd213j6gk1" path="res://gui/ressources/default_theme.tres" id="2_c278i"]
|
||||
[ext_resource type="FontFile" uid="uid://cpnsnrqhfkj3k" path="res://gui/ressources/fonts/spincycle_ot.otf" id="3_5sqh2"]
|
||||
[ext_resource type="Texture2D" uid="uid://0xg54agef5gh" path="res://common/icons/package.svg" id="4_qmlcw"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_gy0la"]
|
||||
shader = ExtResource("1_iykpa")
|
||||
shader_parameter/strength = 3.3
|
||||
shader_parameter/mix_percentage = 0.3
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_4f1tl"]
|
||||
font = ExtResource("3_5sqh2")
|
||||
font_size = 50
|
||||
|
||||
[sub_resource type="Animation" id="Animation_8323k"]
|
||||
length = 0.001
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 1,
|
||||
"values": [false]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 1
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0),
|
||||
"transitions": PackedFloat32Array(1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0)]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id="Animation_4f1tl"]
|
||||
resource_name = "show"
|
||||
length = 0.3
|
||||
tracks/0/type = "value"
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/path = NodePath(".:visible")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/keys = {
|
||||
"times": PackedFloat32Array(0, 0.0333333),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 1,
|
||||
"values": [false, true]
|
||||
}
|
||||
tracks/1/type = "value"
|
||||
tracks/1/imported = false
|
||||
tracks/1/enabled = true
|
||||
tracks/1/path = NodePath(".:modulate")
|
||||
tracks/1/interp = 2
|
||||
tracks/1/loop_wrap = true
|
||||
tracks/1/keys = {
|
||||
"times": PackedFloat32Array(0.0333333, 0.3),
|
||||
"transitions": PackedFloat32Array(1, 1),
|
||||
"update": 0,
|
||||
"values": [Color(1, 1, 1, 0), Color(1, 1, 1, 1)]
|
||||
}
|
||||
|
||||
[sub_resource type="AnimationLibrary" id="AnimationLibrary_7fpy7"]
|
||||
_data = {
|
||||
&"RESET": SubResource("Animation_8323k"),
|
||||
&"show": SubResource("Animation_4f1tl")
|
||||
}
|
||||
|
||||
[node name="RewardChoice" type="Control"]
|
||||
process_mode = 3
|
||||
visible = false
|
||||
modulate = Color(1, 1, 1, 0)
|
||||
layout_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_4f1tl")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
material = SubResource("ShaderMaterial_gy0la")
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
color = Color(0.0352941, 0.0196078, 0.12549, 0.705882)
|
||||
|
||||
[node name="Choice" type="MarginContainer" parent="."]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
|
||||
[node name="VSplitContainer" type="VBoxContainer" parent="Choice"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
alignment = 1
|
||||
|
||||
[node name="Label" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "You reached the quota !"
|
||||
label_settings = SubResource("LabelSettings_4f1tl")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
text = "Choose a reward"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="GridContainer" type="GridContainer" parent="Choice/VSplitContainer"]
|
||||
layout_mode = 2
|
||||
theme = ExtResource("2_c278i")
|
||||
columns = 2
|
||||
|
||||
[node name="Reward1" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward1Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
process_mode = 3
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward1Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward1"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="Reward2" type="VBoxContainer" parent="Choice/VSplitContainer/GridContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="Reward2Button" type="Button" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
text = "Compost"
|
||||
icon = ExtResource("4_qmlcw")
|
||||
|
||||
[node name="Reward2Desc" type="Label" parent="Choice/VSplitContainer/GridContainer/Reward2"]
|
||||
unique_name_in_owner = true
|
||||
layout_mode = 2
|
||||
text = "The Compost can do so mush things.... But it's a little gross !"
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_7fpy7")
|
||||
}
|
||||
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward1/Reward1Button" to="." method="_on_reward_1_button_pressed"]
|
||||
[connection signal="pressed" from="Choice/VSplitContainer/GridContainer/Reward2/Reward2Button" to="." method="_on_reward_2_button_pressed"]
|
||||
@ -1,39 +0,0 @@
|
||||
extends Control
|
||||
|
||||
var planet: Planet
|
||||
var item1: Item
|
||||
var item2: Item
|
||||
|
||||
func show_rewards():
|
||||
get_tree().paused = true
|
||||
%AnimationPlayer.play("show")
|
||||
get_tree().paused = true
|
||||
|
||||
func hide_rewards():
|
||||
get_tree().paused = false
|
||||
%AnimationPlayer.play_backwards("show")
|
||||
get_tree().paused = false
|
||||
|
||||
func _on_planet_quota_reward_asked(_planet:Planet, _item1:Item, _item2:Item):
|
||||
planet = _planet
|
||||
item1 = _item1
|
||||
item2 = _item2
|
||||
|
||||
%Reward1Button.text = item1.name
|
||||
%Reward1Button.icon = item1.icon
|
||||
%Reward1Desc.text = item1.description
|
||||
|
||||
%Reward2Button.text = item2.name
|
||||
%Reward2Button.icon = item2.icon
|
||||
%Reward2Desc.text = item2.description
|
||||
show_rewards()
|
||||
|
||||
func _on_reward_1_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item1)
|
||||
hide_rewards()
|
||||
|
||||
func _on_reward_2_button_pressed():
|
||||
if planet:
|
||||
planet.choose_quota_reward(item2)
|
||||
hide_rewards()
|
||||
@ -1,7 +1,7 @@
|
||||
extends Control
|
||||
class_name GameGui
|
||||
|
||||
signal pause_asked
|
||||
@export var quota_reward : QuotaReward
|
||||
|
||||
func _ready():
|
||||
GameInfo.game_data.current_planet_data.updated.connect(_on_planet_updated)
|
||||
@ -9,12 +9,14 @@ func _ready():
|
||||
GameInfo.game_data.player_data.updated.connect(_on_player_updated)
|
||||
GameInfo.game_data.player_data.inventory.updated.connect(_on_inventory_updated)
|
||||
|
||||
if not GameInfo.game_data.current_planet_data.is_quota_announced:
|
||||
announce_quota(GameInfo.game_data.current_planet_data)
|
||||
GameInfo.game_data.current_planet_data.is_quota_announced = true
|
||||
planet_update(GameInfo.game_data.current_planet_data)
|
||||
player_update(GameInfo.game_data.player_data)
|
||||
inventory_update(GameInfo.game_data.player_data.inventory)
|
||||
|
||||
if not GameInfo.game_data.current_planet_data.is_quota_announced:
|
||||
await quota_reward.reward_chosen
|
||||
announce_quota(GameInfo.game_data.current_planet_data)
|
||||
GameInfo.game_data.current_planet_data.is_quota_announced = true
|
||||
|
||||
|
||||
func _on_player_updated(player_data : PlayerData):
|
||||
@ -73,8 +75,9 @@ func update_no_energy_left_info(energy):
|
||||
|
||||
|
||||
func _on_planet_new_quota_started(planet_data : PlanetData):
|
||||
announce_quota(planet_data)
|
||||
planet_update(planet_data)
|
||||
await quota_reward.reward_chosen
|
||||
announce_quota(planet_data)
|
||||
planet_data.is_quota_announced = true
|
||||
|
||||
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
extends Node
|
||||
|
||||
signal inspected_changed(info : Inspector.Info)
|
||||
|
||||
const DEFAULT_ACTION_COLOR = Color.WHITE
|
||||
const ENERGY_ACTION_COLOR = Color("ffff2b")
|
||||
const NO_ENERGY_ACTION_COLOR = Color.RED
|
||||
@ -9,12 +7,13 @@ const ZONE_OPACITY = 0.4
|
||||
const ZONE_ACTIVATED_COLOR = Color.TURQUOISE
|
||||
const ZONE_DEACTIVATED_COLOR = Color.REBECCA_PURPLE
|
||||
|
||||
const CARD_VISUALISATION_TIME = 1.0
|
||||
const CARD_VISUALISATION_TIME = 0.5
|
||||
|
||||
@export var default_cursor : Texture2D
|
||||
|
||||
var current_inspect : Node = null
|
||||
var inspected : Node = null
|
||||
var last_inspected : Node = null
|
||||
var inspected_card_info : CardInfo = null
|
||||
var time_last_inspected : float = 0.
|
||||
var player : Player # renseigné par Player
|
||||
var can_interact : bool = false
|
||||
@ -38,7 +37,7 @@ func _input(_event):
|
||||
|
||||
if Input.is_action_just_pressed("action"):
|
||||
if can_interact:
|
||||
var interactable = inspected as Interactable
|
||||
var interactable = current_inspect as Interactable
|
||||
player.try_interact(interactable)
|
||||
elif can_use_item:
|
||||
player.try_use_item(
|
||||
@ -47,14 +46,15 @@ func _input(_event):
|
||||
)
|
||||
|
||||
func _process(delta):
|
||||
time_last_inspected += delta
|
||||
if current_inspect != inspected:
|
||||
time_last_inspected += delta
|
||||
%Inspector.position = get_viewport().get_mouse_position()
|
||||
|
||||
if player:
|
||||
can_interact = (
|
||||
inspected
|
||||
and inspected is Interactable
|
||||
and player.can_interact(inspected)
|
||||
current_inspect
|
||||
and current_inspect is Interactable
|
||||
and player.can_interact(current_inspect)
|
||||
)
|
||||
|
||||
current_selected_item = player.data.inventory.get_item()
|
||||
@ -84,39 +84,42 @@ func _process(delta):
|
||||
update_inspector()
|
||||
|
||||
func inspect(node : Node):
|
||||
if inspected and inspected != node and inspected.has_method("inspect"):
|
||||
inspected.inspect(false)
|
||||
if current_inspect and current_inspect != node and current_inspect.has_method("inspect"):
|
||||
current_inspect.inspect(false)
|
||||
current_inspect = node
|
||||
inspected = node
|
||||
last_inspected = node
|
||||
if inspected is InspectableEntity:
|
||||
inspected_card_info = inspected.card_info()
|
||||
time_last_inspected = 0
|
||||
if inspected.has_method("inspect"):
|
||||
inspected.inspect(true)
|
||||
if current_inspect.has_method("inspect"):
|
||||
current_inspect.inspect(true)
|
||||
update_inspector()
|
||||
|
||||
func update_card():
|
||||
if not last_inspected or time_last_inspected > CARD_VISUALISATION_TIME:
|
||||
if not inspected or time_last_inspected > CARD_VISUALISATION_TIME:
|
||||
%CardVisualiser.hide()
|
||||
|
||||
elif last_inspected != null and last_inspected is InspectableEntity:
|
||||
%CardVisualiser.card_info = last_inspected.card_info()
|
||||
elif inspected != null and inspected is InspectableEntity:
|
||||
|
||||
if inspected_card_info != %CardVisualiser.card_info:
|
||||
%CardVisualiser.card_info = inspected_card_info
|
||||
%CardVisualiser.show()
|
||||
|
||||
var camera = get_viewport().get_camera_2d()
|
||||
var screen_size = get_viewport().get_visible_rect().size
|
||||
%CardPosition.position = last_inspected.global_position - camera.global_position + screen_size / 2
|
||||
%CardPosition.position = inspected.global_position - camera.global_position + screen_size / 2
|
||||
|
||||
if %CardVisualiser.is_mouse_over():
|
||||
time_last_inspected = 0.
|
||||
|
||||
|
||||
func update_inspector():
|
||||
|
||||
if player:
|
||||
if can_interact and inspected and inspected is Interactable:
|
||||
if can_interact and current_inspect and current_inspect is Interactable:
|
||||
%Action.visible = true
|
||||
%ActionText.text = inspected.interact_text()
|
||||
%Action.modulate = DEFAULT_ACTION_COLOR if inspected.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
|
||||
%ActionEnergyImage.visible = inspected.interaction_cost(player) != 0
|
||||
%ActionText.text = current_inspect.interact_text()
|
||||
%Action.modulate = DEFAULT_ACTION_COLOR if current_inspect.interaction_cost(player) == 0 else ENERGY_ACTION_COLOR
|
||||
%ActionEnergyImage.visible = current_inspect.interaction_cost(player) != 0
|
||||
elif current_selected_item and current_selected_item.use_text() != "":
|
||||
%Action.visible = true
|
||||
%ActionText.text = current_selected_item.use_text() + (" (no energy left)" if not have_energy_to_use_item else "")
|
||||
@ -134,6 +137,6 @@ func update_inspector():
|
||||
func stop_inspect(node : Node):
|
||||
if node.has_method("inspect"):
|
||||
node.inspect(false)
|
||||
if inspected == node:
|
||||
inspected = null
|
||||
if current_inspect == node:
|
||||
current_inspect = null
|
||||
update_inspector()
|
||||
|
||||
@ -17,6 +17,10 @@ run/main_scene="uid://c5bruelvqbm1k"
|
||||
config/features=PackedStringArray("4.5", "Forward Plus")
|
||||
config/icon="uid://df0y0s666ui4h"
|
||||
|
||||
[audio]
|
||||
|
||||
buses/default_bus_layout=""
|
||||
|
||||
[autoload]
|
||||
|
||||
Pointer="*res://gui/pointer/pointer.tscn"
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://12nak7amd1uq" path="res://gui/game/game_gui.tscn" id="1_yy1uy"]
|
||||
[ext_resource type="PackedScene" uid="uid://v41hfc7haaye" path="res://gui/game/win/win.tscn" id="3_6guxm"]
|
||||
[ext_resource type="PackedScene" uid="uid://doxm7uab8i3tq" path="res://gui/game/reward_choice/reward_choice.tscn" id="4_fbkgs"]
|
||||
[ext_resource type="PackedScene" uid="uid://doxm7uab8i3tq" path="res://gui/game/quota_reward/quota_reward.tscn" id="4_fbkgs"]
|
||||
[ext_resource type="PackedScene" uid="uid://bgvbgeq46wee2" path="res://entities/player/player.tscn" id="4_g33f4"]
|
||||
[ext_resource type="PackedScene" uid="uid://dt6mptqg80dew" path="res://gui/game/tutorial/tutorial.tscn" id="5_orelw"]
|
||||
[ext_resource type="PackedScene" uid="uid://tsi5j1uxppa4" path="res://stages/terrain/planet/planet.tscn" id="8_t31p7"]
|
||||
@ -12,13 +12,15 @@
|
||||
|
||||
[node name="PlanetRun" type="Node2D"]
|
||||
|
||||
[node name="Reward" parent="." instance=ExtResource("4_fbkgs")]
|
||||
layer = 2
|
||||
|
||||
[node name="CanvasLayer" type="CanvasLayer" parent="."]
|
||||
|
||||
[node name="RootGui" parent="CanvasLayer" instance=ExtResource("1_yy1uy")]
|
||||
[node name="RootGui" parent="CanvasLayer" node_paths=PackedStringArray("quota_reward") instance=ExtResource("1_yy1uy")]
|
||||
quota_reward = NodePath("../../Reward")
|
||||
metadata/_edit_use_anchors_ = true
|
||||
|
||||
[node name="RewardChoice" parent="CanvasLayer" instance=ExtResource("4_fbkgs")]
|
||||
|
||||
[node name="Win" parent="CanvasLayer" instance=ExtResource("3_6guxm")]
|
||||
visible = false
|
||||
|
||||
@ -38,8 +40,9 @@ position = Vector2(33, -139)
|
||||
[node name="TruckRecharge" parent="Entities" instance=ExtResource("10_cnjsq")]
|
||||
position = Vector2(-36, -154)
|
||||
|
||||
[node name="Planet" parent="." node_paths=PackedStringArray("import_entities_from_node") instance=ExtResource("8_t31p7")]
|
||||
[node name="Planet" parent="." node_paths=PackedStringArray("quota_reward", "import_entities_from_node") instance=ExtResource("8_t31p7")]
|
||||
loot_item_number = Array[int]([1])
|
||||
quota_reward = NodePath("../Reward")
|
||||
import_entities_from_node = NodePath("../Entities")
|
||||
|
||||
[node name="Camera" parent="." node_paths=PackedStringArray("following") instance=ExtResource("16_m18ms")]
|
||||
@ -49,4 +52,3 @@ following = NodePath("../Entities/Player")
|
||||
[connection signal="day_limit_exceed" from="Planet" to="CanvasLayer/Win" method="_on_planet_day_limit_exceed"]
|
||||
[connection signal="pass_day_ended" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_ended"]
|
||||
[connection signal="pass_day_started" from="Planet" to="CanvasLayer/RootGui" method="_on_planet_pass_day_started"]
|
||||
[connection signal="quota_reward_asked" from="Planet" to="CanvasLayer/RewardChoice" method="_on_planet_quota_reward_asked"]
|
||||
|
||||
@ -108,12 +108,8 @@ func generate_walls():
|
||||
|
||||
func generate_loot(number : int = LOOT_NUMBER.pick_random()):
|
||||
for i in range(number):
|
||||
var loot = UndergroundLoot.new()
|
||||
for j in range(LOOT_ITEM_NUMBER.pick_random()):
|
||||
loot.loot.append(
|
||||
Seed.new(GameInfo.game_data.unlocked_plant_types.pick_random())
|
||||
)
|
||||
|
||||
var loot : UndergroundLoot = (UndergroundLootData.SCENE.instantiate() as UndergroundLoot)
|
||||
loot.item_number = LOOT_ITEM_NUMBER.pick_random()
|
||||
|
||||
var max_placement_try = 10
|
||||
var valid_coord = false
|
||||
|
||||
@ -17,6 +17,7 @@ var size = PlanetData.DEFAULT_GARDEN_SIZE
|
||||
func _init(_planet_data : PlanetData, _initial_plants : Array[Plant] = []):
|
||||
planet_data = _planet_data
|
||||
plants = _initial_plants
|
||||
update_garden_score()
|
||||
|
||||
func _ready():
|
||||
contamination_sprite = generate_contamination_terrain_sprite()
|
||||
|
||||
@ -5,7 +5,6 @@ signal day_limit_exceed(planet : Planet)
|
||||
signal pass_day_started(planet : Planet)
|
||||
signal pass_day_proceeded(planet : Planet)
|
||||
signal pass_day_ended(planet : Planet)
|
||||
signal quota_reward_asked(planet : Planet, item1 : Item, item2 : Item)
|
||||
|
||||
const PASS_DAY_ANIMATION_TIME : float = 1.5
|
||||
const DEFAULT_DAY_LIMIT : int = 7
|
||||
@ -14,7 +13,8 @@ const PLANET_TEXTURE_SCALE : float = 5.0
|
||||
@export_group("Loot")
|
||||
@export var first_loot_number : int = 3
|
||||
@export var loot_item_number : Array[int] = [1,2]
|
||||
|
||||
@export var quota_reward : QuotaReward
|
||||
|
||||
var data : PlanetData
|
||||
|
||||
var contamination_texture : ImageTexture
|
||||
@ -37,6 +37,9 @@ func _ready():
|
||||
garden = Garden.new(data, plants)
|
||||
add_child(garden)
|
||||
|
||||
if len(GameInfo.game_data.unlocked_plant_types) == 0:
|
||||
quota_reward.trigger_reward()
|
||||
|
||||
generate_first_entities()
|
||||
|
||||
Music.enter_planet()
|
||||
@ -146,11 +149,8 @@ func pass_day():
|
||||
|
||||
func generate_loot(number : int):
|
||||
for i in range(number):
|
||||
var loot = UndergroundLoot.new()
|
||||
for j in range(loot_item_number.pick_random()):
|
||||
loot.loot.append(
|
||||
Seed.new(GameInfo.game_data.unlocked_plant_types.pick_random())
|
||||
)
|
||||
var loot : UndergroundLoot = (UndergroundLootData.SCENE.instantiate() as UndergroundLoot)
|
||||
loot.item_number = loot_item_number.pick_random()
|
||||
|
||||
var loot_random_range = UndergroundLoot.LOOTED_ITEM_RANDOM_RANGE
|
||||
|
||||
@ -164,21 +164,10 @@ func generate_loot(number : int):
|
||||
|
||||
func reach_quota():
|
||||
data.quota += 1
|
||||
quota_reward.trigger_reward()
|
||||
await quota_reward.reward_chosen
|
||||
if data.garden_score >= data.get_quota_score():
|
||||
reach_quota()
|
||||
data.quota_days = data.get_quota_duration()
|
||||
|
||||
func ask_quota_reward():
|
||||
quota_reward_asked.emit(
|
||||
self,
|
||||
generate_quota_reward(),
|
||||
generate_quota_reward()
|
||||
)
|
||||
|
||||
func generate_quota_reward() -> Item:
|
||||
var random_level = randi_range(
|
||||
max(data.quota - 1, 1),
|
||||
min(data.quota, Machine.MAX_MACHINE_LEVEL),
|
||||
)
|
||||
var random_machine_type = GameInfo.game_data.unlocked_machines.pick_random()
|
||||
return Blueprint.new(random_machine_type, random_level)
|
||||
|
||||
#endregion
|
||||
|
||||
@ -88,7 +88,7 @@ func generate_objective_rewards(level = 0) -> Array[ObjectiveReward]:
|
||||
#endregion
|
||||
|
||||
#region ------------------ Quotas ------------------
|
||||
func get_quota_score(q = quota) -> int:
|
||||
func get_quota_score(q : int = quota) -> int:
|
||||
var first_quotas = [
|
||||
4,
|
||||
10,
|
||||
|
||||
@ -39,7 +39,7 @@ func draw_random_zone(
|
||||
ImageTools.draw_circle(
|
||||
noise_image,
|
||||
noise_image_center,
|
||||
80/UNIT_PER_PIXEL,
|
||||
int(round(80./float(UNIT_PER_PIXEL))),
|
||||
Color.WHITE,
|
||||
)
|
||||
|
||||
|
||||
@ -9,6 +9,9 @@ const PLANET_RUN_PATH = "res://stages/planet_run/planet_run.tscn"
|
||||
|
||||
func _on_exit_interacted(_p : Player):
|
||||
data.entities_saved_data = save_entities()
|
||||
data.rewards = []
|
||||
for c in composts:
|
||||
data.rewards.append(c.reward)
|
||||
get_tree().change_scene_to_file(PLANET_RUN_PATH)
|
||||
|
||||
func _ready():
|
||||
|
||||
Loading…
Reference in New Issue
Block a user