Tractor beam
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
[gd_scene load_steps=8 format=3 uid="uid://bcj812ox8xv2t"]
|
||||
[gd_scene format=3 uid="uid://bcj812ox8xv2t"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://reliyx2pg7kf" path="res://entities/interactables/item_object/script/item_object_sprite.gd" id="1_wing4"]
|
||||
[ext_resource type="Texture2D" uid="uid://bo3o2qf3i20ke" path="res://common/icons/scuba-diving-tank.svg" id="2_ng3e4"]
|
||||
[ext_resource type="Texture2D" uid="uid://c1eiu5ag7lcp8" path="res://entities/interactables/item_object/assets/sprites/shadow.svg" id="2_ng201"]
|
||||
[ext_resource type="Texture2D" uid="uid://dompaj451gklw" path="res://entities/player/assets/sprites/movement_particles.png" id="4_ng3e4"]
|
||||
|
||||
[sub_resource type="Animation" id="Animation_wing4"]
|
||||
length = 0.001
|
||||
@@ -95,22 +96,46 @@ _data = {
|
||||
&"pickup": SubResource("Animation_ng3e4")
|
||||
}
|
||||
|
||||
[node name="ItemObjectSprite" type="Node2D"]
|
||||
[sub_resource type="Curve" id="Curve_b6vos"]
|
||||
_data = [Vector2(0, 0.29213488), 0.0, 0.0, 0, 0, Vector2(0.3, 1), 0.0, 0.0, 0, 0, Vector2(0.63809526, 0.46067423), 0.0, 0.0, 0, 0, Vector2(0.9904762, 0.3820225), 0.0, 0.0, 0, 0]
|
||||
point_count = 4
|
||||
|
||||
[sub_resource type="Gradient" id="Gradient_14kbc"]
|
||||
offsets = PackedFloat32Array(0, 0.77729255, 1)
|
||||
colors = PackedColorArray(0.5803922, 0.7058824, 0.8862745, 1, 0.5785, 0.70829165, 0.89, 1, 0.5785, 0.70829165, 0.89, 0)
|
||||
|
||||
[node name="ItemObjectSprite" type="Node2D" unique_id=69332129]
|
||||
script = ExtResource("1_wing4")
|
||||
|
||||
[node name="Icon" type="Sprite2D" parent="."]
|
||||
[node name="Icon" type="Sprite2D" parent="." unique_id=2070904988]
|
||||
texture = ExtResource("2_ng3e4")
|
||||
|
||||
[node name="Shadow" type="Sprite2D" parent="."]
|
||||
[node name="Shadow" type="Sprite2D" parent="." unique_id=1621814025]
|
||||
modulate = Color(1, 1, 1, 0.227451)
|
||||
z_index = -1
|
||||
position = Vector2(0, 23)
|
||||
scale = Vector2(0.875, 0.875)
|
||||
texture = ExtResource("2_ng201")
|
||||
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1385834581]
|
||||
unique_name_in_owner = true
|
||||
libraries = {
|
||||
&"": SubResource("AnimationLibrary_ng3e4")
|
||||
}
|
||||
autoplay = "default"
|
||||
libraries/ = SubResource("AnimationLibrary_ng3e4")
|
||||
autoplay = &"default"
|
||||
|
||||
[node name="TractorBeam" type="CPUParticles2D" parent="." unique_id=382704689]
|
||||
z_index = -1
|
||||
position = Vector2(83, 0)
|
||||
scale = Vector2(0.7, 0.7)
|
||||
emitting = false
|
||||
amount = 5
|
||||
texture = ExtResource("4_ng3e4")
|
||||
lifetime = 1.25
|
||||
local_coords = true
|
||||
particle_flag_align_y = true
|
||||
direction = Vector2(-1, 0)
|
||||
spread = 0.0
|
||||
gravity = Vector2(0, 0)
|
||||
initial_velocity_min = 100.0
|
||||
initial_velocity_max = 100.0
|
||||
scale_amount_curve = SubResource("Curve_b6vos")
|
||||
color_ramp = SubResource("Gradient_14kbc")
|
||||
|
||||
@@ -2,6 +2,7 @@ extends Node2D
|
||||
class_name ItemObjectSprite
|
||||
|
||||
@onready var icon_sprite = $Icon
|
||||
@onready var tractor_beam: CPUParticles2D = $TractorBeam
|
||||
|
||||
const PARTICLES_SCENE : PackedScene = preload("res://common/vfx/particles/effect_particles.tscn")
|
||||
|
||||
|
||||
@@ -17,7 +17,10 @@ func _init(size : int = 1):
|
||||
seeds_size = size
|
||||
|
||||
func current_is_tool() -> bool:
|
||||
return current_item_ind < len(tools)
|
||||
return ind_is_tool(current_item_ind)
|
||||
|
||||
func ind_is_tool(ind:int)->bool:
|
||||
return ind < len(tools)
|
||||
|
||||
func set_current_item(new_ind: int):
|
||||
if new_ind < 0:
|
||||
@@ -75,7 +78,7 @@ func update_seeds_size(size = seeds_size):
|
||||
|
||||
func add_item_at(item: Item, item_ind: int) -> bool:
|
||||
if item.type == Item.ItemType.CONSUMABLE_ITEM:
|
||||
return add_seed_at(item, item_ind - tools.size())
|
||||
return add_seed_at(item, item_ind - len(tools))
|
||||
else:
|
||||
return false
|
||||
|
||||
@@ -89,7 +92,7 @@ func add_seed_at(s: Item, seed_ind: int) -> bool:
|
||||
return true
|
||||
|
||||
func get_all_items_size() -> int:
|
||||
return tools.size() + seeds.size()
|
||||
return len(tools) + len(seeds)
|
||||
|
||||
func get_all_items() -> Array[Item]:
|
||||
return tools + seeds
|
||||
|
||||
@@ -48,6 +48,9 @@ func is_action_need_press_time() -> bool:
|
||||
func get_action_press_time() -> float:
|
||||
return DEFAULT_PRESS_TIME
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
return false
|
||||
|
||||
func get_usage_object_affected(_i : Area2D) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
49
entities/player/inventory/scripts/items/tractor_beam.gd
Normal file
49
entities/player/inventory/scripts/items/tractor_beam.gd
Normal file
@@ -0,0 +1,49 @@
|
||||
extends Item
|
||||
class_name TractorBeam
|
||||
|
||||
const USE_INTERVAL = 0.15
|
||||
|
||||
func get_item_name() -> String:
|
||||
return tr("TRACTOR_BEAM")
|
||||
|
||||
func get_description() -> String:
|
||||
return tr("TRACTOR_BEAM_DESC_TEXT")
|
||||
|
||||
func get_icon() -> Texture2D:
|
||||
# return preload("res://common/icons/tractor_beam.svg")
|
||||
return preload("res://common/icons/alert-triangle.svg")
|
||||
|
||||
func get_item_type() -> ItemType:
|
||||
return Item.ItemType.TOOL_ITEM
|
||||
|
||||
func get_energy_used() -> int:
|
||||
return 0
|
||||
|
||||
func get_usage_zone_radius() -> int:
|
||||
return 1
|
||||
|
||||
func is_usage_need_proximity() -> bool:
|
||||
return false
|
||||
|
||||
func get_action_is_hold() -> bool:
|
||||
return true
|
||||
|
||||
func use_text() -> String:
|
||||
return tr("MOVE")
|
||||
|
||||
func can_use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
return Pointer.inspected != null
|
||||
|
||||
func use(_player: Player, _zone: Player.ActionZone) -> bool:
|
||||
if Pointer.dragging_inspected:
|
||||
Pointer.stop_dragging()
|
||||
if !Pointer.dragging_inspected:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
else:
|
||||
Pointer.start_dragging()
|
||||
if Pointer.dragging_inspected:
|
||||
return true
|
||||
else:
|
||||
return false
|
||||
@@ -0,0 +1 @@
|
||||
uid://drs03fydfofxx
|
||||
@@ -55,13 +55,14 @@ func appear(with_falling_animation = true):
|
||||
%AnimationPlayer.play("float")
|
||||
|
||||
func _input(_event) -> void:
|
||||
if Input.is_action_pressed("change_item_left"):
|
||||
data.inventory.change_current_item(1)
|
||||
if Input.is_action_pressed("change_item_right"):
|
||||
data.inventory.change_current_item(-1)
|
||||
for i in range(1, 10):
|
||||
if Input.is_action_pressed("item_" + str(i)):
|
||||
data.inventory.set_current_item(i - 1)
|
||||
if not Pointer.dragging_inspected:
|
||||
if Input.is_action_pressed("change_item_left"):
|
||||
data.inventory.change_current_item(1)
|
||||
if Input.is_action_pressed("change_item_right"):
|
||||
data.inventory.change_current_item(-1)
|
||||
for i in range(1, 10):
|
||||
if Input.is_action_pressed("item_" + str(i)):
|
||||
data.inventory.set_current_item(i - 1)
|
||||
|
||||
# Méthode déclenchée par la classe region
|
||||
func _start_pass_day():
|
||||
|
||||
Reference in New Issue
Block a user