ajout du camion #87
* changements des objectifs, donnent juste des graines, sprite moins gros et objectifs plus nombreux * changement de la probabilité de mutation * refactor du code terrain et planet
This commit is contained in:
@@ -14,16 +14,14 @@ const DEFAULT_DAY_LIMIT : int = 7
|
||||
const PLANET_TEXTURE_SCALE : float = 5.0
|
||||
const OBJECTIVE_MAX_LEVEL : int = 10
|
||||
const OBJECTIVE_MIN_ANGLE_DIFF = PI/2
|
||||
const OBJECTIVE_FIRST_DISTANCE = 200
|
||||
const OBJECTIVE_BETWEEN_DISTANCE = 50
|
||||
|
||||
@export_group("Loot")
|
||||
@export var first_loot_number : int = 3
|
||||
@export var loot_number : Array[int] = [0,1,2]
|
||||
@export var loot_item_number : Array[int] = [1,2]
|
||||
|
||||
@export_group("Objectives")
|
||||
@export var objective_first_distance : int = 200
|
||||
@export var objective_between_distance : int = 200
|
||||
|
||||
@export_group("Textures")
|
||||
@export var background_texture : Texture2D
|
||||
@export var contamination_material : ShaderMaterial
|
||||
@@ -34,6 +32,14 @@ var decontamination_surface : float
|
||||
var garden_score : int
|
||||
|
||||
@onready var objective_scene : PackedScene = preload("res://entities/objectives/objective.tscn")
|
||||
var terrain_size = Vector2.ONE * 1000 :
|
||||
set(v):
|
||||
terrain_size = v
|
||||
if border_limit:
|
||||
border_limit.queue_free()
|
||||
border_limit = create_border_limit()
|
||||
|
||||
@onready var border_limit : StaticBody2D = create_border_limit()
|
||||
|
||||
var planet_data : PlanetData
|
||||
|
||||
@@ -43,7 +49,6 @@ var day_limit = DEFAULT_DAY_LIMIT
|
||||
var days_on_last_quota : int = 0
|
||||
var last_quota : float = 0
|
||||
var next_quota : float
|
||||
var player : Player
|
||||
|
||||
func _ready():
|
||||
planet_data = GameInfo.game_data.current_planet_data if GameInfo.game_data.current_planet_data else PlanetData.new()
|
||||
@@ -103,18 +108,6 @@ func instantiate_machine(m_type : MachineType, level, machine_position : Vector2
|
||||
|
||||
machine.global_position = machine_position
|
||||
|
||||
func add_entity(e : Node2D, container : Node2D = entity_container):
|
||||
if e.get_parent():
|
||||
e.get_parent().remove_child(e)
|
||||
|
||||
if "planet" in e:
|
||||
e.planet = self
|
||||
|
||||
if e is Player:
|
||||
player = e
|
||||
|
||||
container.add_child(e)
|
||||
|
||||
func generate_polygon_sprite(order : int = 0) -> Polygon2D:
|
||||
var sprite = Polygon2D.new()
|
||||
var size = terrain_size
|
||||
@@ -156,6 +149,29 @@ func generate_contamination_terrain_sprite() -> Polygon2D:
|
||||
|
||||
return sprite
|
||||
|
||||
func create_border_limit() -> StaticBody2D:
|
||||
var static_body = StaticBody2D.new()
|
||||
var static_body_collision = CollisionPolygon2D.new()
|
||||
|
||||
add_child(static_body)
|
||||
static_body.add_child(static_body_collision)
|
||||
|
||||
var size = terrain_size
|
||||
static_body_collision.polygon = PackedVector2Array([
|
||||
Vector2(0,0),
|
||||
Vector2(0, size.y),
|
||||
Vector2(size.x, size.y),
|
||||
Vector2(size.x, 0),
|
||||
Vector2(0,0),
|
||||
Vector2(-BORDER_WIDTH, -BORDER_WIDTH),
|
||||
Vector2(size.x + BORDER_WIDTH, -BORDER_WIDTH),
|
||||
Vector2(size.x + BORDER_WIDTH, size.y + BORDER_WIDTH),
|
||||
Vector2(- BORDER_WIDTH, size.y + BORDER_WIDTH),
|
||||
Vector2(-BORDER_WIDTH, -BORDER_WIDTH)
|
||||
])
|
||||
|
||||
return static_body
|
||||
|
||||
#endregion
|
||||
|
||||
#region ------------------ Usage ------------------
|
||||
@@ -221,7 +237,7 @@ func pass_day():
|
||||
|
||||
func generate_loot(number : int = loot_number.pick_random()):
|
||||
for i in range(number):
|
||||
var loot = UndergroundLoot.new(self)
|
||||
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())
|
||||
@@ -249,7 +265,7 @@ func generate_objectives():
|
||||
last_objective_angle = objective_angle
|
||||
|
||||
generate_objective(
|
||||
objective_first_distance + objective_between_distance * i,
|
||||
OBJECTIVE_FIRST_DISTANCE + OBJECTIVE_BETWEEN_DISTANCE * i,
|
||||
objective_angle,
|
||||
objective_reward,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user