refonte de l'inspecteur #61
This commit is contained in:
@@ -22,13 +22,26 @@ func _ready():
|
||||
if item and object_sprite:
|
||||
object_sprite.apply_texture_to_sprite(item.icon, ITEM_SPRITE_SIZE)
|
||||
|
||||
func pointer_text():
|
||||
var name_suffix = ""
|
||||
|
||||
func inspected_text():
|
||||
return item.name + (" Seed" if item is Seed else "")
|
||||
if item is Seed:
|
||||
name_suffix = "Seed"
|
||||
if item is Package:
|
||||
name_suffix = "Package"
|
||||
|
||||
return item.name + (" " + name_suffix if name_suffix else "")
|
||||
|
||||
func interact_text():
|
||||
return "Take"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
item.description,
|
||||
item.icon
|
||||
)
|
||||
|
||||
func interact(player : Player) -> bool:
|
||||
var swapped_item = player.inventory.get_item()
|
||||
|
||||
|
||||
@@ -7,12 +7,18 @@ var fill_value : float = 0.
|
||||
func _process(_delta):
|
||||
%ProgressBar.value = lerp(%ProgressBar.value, fill_value * 100, 0.5)
|
||||
|
||||
func inspected_text():
|
||||
func pointer_text():
|
||||
return "Compost"
|
||||
|
||||
func interact_text():
|
||||
return "Put a seed ("+str(roundi((1-fill_value)/value_per_seed))+" left)"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"The compost allow you to upgrade your max energy when putting in it a certain amount of seeds."
|
||||
)
|
||||
|
||||
func can_interact(p : Player) -> bool:
|
||||
return p.inventory.get_item() and p.inventory.get_item() is Seed
|
||||
|
||||
|
||||
@@ -10,4 +10,13 @@ func interact(_p: Player) -> bool:
|
||||
return true
|
||||
|
||||
func interact_text():
|
||||
return "Recharge"
|
||||
return "Recharge"
|
||||
|
||||
func pointer_text():
|
||||
return "Recharge Station"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
"You can recharge your robot here. When recharging, time will pass and plants may grow."
|
||||
)
|
||||
@@ -22,6 +22,3 @@ func generate_collision(area_width : float) -> CollisionShape2D:
|
||||
add_child(collision)
|
||||
|
||||
return collision
|
||||
|
||||
func interact_text():
|
||||
return ""
|
||||
|
||||
@@ -23,11 +23,18 @@ func _init(_plant_type = null, _planet = null):
|
||||
plant_type = _plant_type
|
||||
planet = _planet
|
||||
|
||||
func inspected_text():
|
||||
func pointer_text():
|
||||
var state_text = "Growing"
|
||||
if state == State.MATURE: state_text = "Mature"
|
||||
return state_text + " " + plant_type.name
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text(),
|
||||
plant_type.description,
|
||||
get_state_texture(State.MATURE)
|
||||
)
|
||||
|
||||
func generate_sprite() -> PlantSprite:
|
||||
var spriteObject : PlantSprite = SPRITE_SCENE.instantiate()
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
[gd_scene load_steps=24 format=3 uid="uid://bgvbgeq46wee2"]
|
||||
[gd_scene load_steps=26 format=3 uid="uid://bgvbgeq46wee2"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://das7twcy5153p" path="res://entities/player/scripts/player.gd" id="1_abrql"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7ff87jniga5m" path="res://entities/player/assets/sprites/robot.png" id="1_symyc"]
|
||||
@@ -23,6 +23,15 @@ radius = 27.0
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_abrql"]
|
||||
radius = 40.0
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_yqrof"]
|
||||
colors = PackedColorArray(0.145098, 0.423529, 0.635294, 1, 0.12549, 0.294118, 0.545098, 1)
|
||||
|
||||
[sub_resource type="GradientTexture2D" id="GradientTexture2D_3wlsy"]
|
||||
gradient = SubResource("Gradient_yqrof")
|
||||
fill = 1
|
||||
fill_from = Vector2(0.5, 0.380342)
|
||||
fill_to = Vector2(1, 0.0726496)
|
||||
|
||||
[sub_resource type="AudioStreamRandomizer" id="AudioStreamRandomizer_wq0jh"]
|
||||
random_pitch = 1.5
|
||||
streams_count = 3
|
||||
@@ -59,17 +68,6 @@ stream_0/stream = ExtResource("15_gx6sm")
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
script = ExtResource("1_abrql")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
position = Vector2(2, -46)
|
||||
scale = Vector2(0.08, 0.08)
|
||||
texture = ExtResource("1_symyc")
|
||||
|
||||
[node name="ItemSprite" type="Sprite2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
position = Vector2(0, 5)
|
||||
texture = ExtResource("3_yqrof")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(-2, -18)
|
||||
shape = SubResource("CircleShape2D_sglur")
|
||||
@@ -80,6 +78,26 @@ position = Vector2(0, -12)
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="InteractArea2D"]
|
||||
shape = SubResource("CircleShape2D_abrql")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
position = Vector2(0, -46)
|
||||
scale = Vector2(0.08, 0.08)
|
||||
texture = ExtResource("1_symyc")
|
||||
|
||||
[node name="HideEyes" type="Sprite2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
position = Vector2(8.125, -26.195)
|
||||
scale = Vector2(0.347656, 0.253906)
|
||||
texture = SubResource("GradientTexture2D_3wlsy")
|
||||
|
||||
[node name="ItemSprite" type="Sprite2D" parent="."]
|
||||
unique_name_in_owner = true
|
||||
visible = false
|
||||
modulate = Color(0.164706, 0.898039, 0.984314, 1)
|
||||
position = Vector2(8.25, -27.32)
|
||||
scale = Vector2(0.403333, 0.403333)
|
||||
texture = ExtResource("3_yqrof")
|
||||
|
||||
[node name="Audio" type="Node2D" parent="."]
|
||||
|
||||
[node name="AudioStreamPlayer_dig" type="AudioStreamPlayer" parent="Audio"]
|
||||
|
||||
@@ -2,7 +2,7 @@ extends CharacterBody2D
|
||||
class_name Player
|
||||
|
||||
const MAX_REACH = 100
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 40.
|
||||
const HOLDING_ITEM_SPRITE_SIZE = 20.
|
||||
|
||||
signal player_updated(player: Player)
|
||||
signal upgraded
|
||||
@@ -75,6 +75,7 @@ func _on_inventory_updated(_inventory: Inventory):
|
||||
1./(item_texture.get_width()/HOLDING_ITEM_SPRITE_SIZE),
|
||||
1./(item_texture.get_height()/HOLDING_ITEM_SPRITE_SIZE)
|
||||
)
|
||||
%HideEyes.visible = inventory.get_item() != null
|
||||
%ItemSprite.visible = inventory.get_item() != null
|
||||
emit_signal("player_updated", self)
|
||||
|
||||
@@ -90,9 +91,14 @@ func calculate_direction():
|
||||
|
||||
velocity = input_direction * speed
|
||||
if input_direction.x:
|
||||
$Sprite.flip_h = (input_direction.x < 0)
|
||||
flip_character(input_direction.x > 0)
|
||||
|
||||
|
||||
func flip_character(face_right = true):
|
||||
$Sprite.flip_h = not face_right
|
||||
%ItemSprite.position.x = abs(%ItemSprite.position.x) * (1 if face_right else -1)
|
||||
%HideEyes.position.x = abs(%ItemSprite.position.x) * (1 if face_right else -1)
|
||||
|
||||
func can_interact(interactable : Interactable):
|
||||
return interactable.can_interact(self)
|
||||
|
||||
|
||||
@@ -22,5 +22,10 @@ func _on_mouse_entered():
|
||||
func _on_mouse_excited():
|
||||
Pointer.stop_inspect_entity(self)
|
||||
|
||||
func inspected_text():
|
||||
return ""
|
||||
func pointer_text():
|
||||
return ""
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
pointer_text()
|
||||
)
|
||||
|
||||
@@ -15,9 +15,15 @@ var planet : Planet # mis à jour par la classe Planet
|
||||
func _init(_planet = null):
|
||||
planet = _planet
|
||||
|
||||
func inspected_text():
|
||||
func pointer_text():
|
||||
return "Buried Loot"
|
||||
|
||||
func inspector_info() -> Inspector.Info:
|
||||
return Inspector.Info.new(
|
||||
"Buried Loot",
|
||||
"Can contain some seeds from the past... Dig it with a shovel."
|
||||
)
|
||||
|
||||
func generate_sprite() -> Node2D:
|
||||
var object = SPRITE_SCENE.instantiate()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user