inventory kind of works, working on attachments still
This commit is contained in:
parent
a6f5419893
commit
349c63ccd7
|
@ -1,14 +0,0 @@
|
||||||
extends Control
|
|
||||||
|
|
||||||
var inventory : Array[Array]
|
|
||||||
|
|
||||||
func _ready():
|
|
||||||
inventory = [[0,0],[0,0]]
|
|
||||||
update_tiles()
|
|
||||||
|
|
||||||
func update_tiles():
|
|
||||||
%InventoryTiles.clear()
|
|
||||||
for y in range(len(inventory)):
|
|
||||||
for x in range(len(inventory[0])):
|
|
||||||
if inventory[y][x] != null:
|
|
||||||
%InventoryTiles.set_cell(Vector2i(x,y),0,Vector2i(0,0))
|
|
20
item.gd
20
item.gd
|
@ -1,20 +0,0 @@
|
||||||
extends Node2D
|
|
||||||
|
|
||||||
class_name Item
|
|
||||||
|
|
||||||
var shape : Array[Array]
|
|
||||||
var inventory_position : Vector2i
|
|
||||||
|
|
||||||
var draggable = true
|
|
||||||
|
|
||||||
var dragging = false
|
|
||||||
|
|
||||||
var mouse_offset : Vector2
|
|
||||||
|
|
||||||
func _process(delta: float) -> void:
|
|
||||||
if dragging:
|
|
||||||
global_position = get_global_mouse_position() + mouse_offset
|
|
||||||
|
|
||||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
|
||||||
var mouse_difference = get_global_mouse_position() - position
|
|
||||||
if mouse_difference.x > 0 and mouse_difference.y > 0 and mouse_difference.x:
|
|
33
items/attachment_points/connector.gd
Normal file
33
items/attachment_points/connector.gd
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
class_name Connector
|
||||||
|
|
||||||
|
enum types {power}
|
||||||
|
|
||||||
|
@export var type : types
|
||||||
|
|
||||||
|
@onready var inventory : Inventory = get_tree().get_first_node_in_group("inventory")
|
||||||
|
|
||||||
|
var color_dictionary = {types.power : Color(0,0,1)}
|
||||||
|
|
||||||
|
func get_connected() -> Item:
|
||||||
|
var inventory_position = inventory.global_to_inventory(global_position)
|
||||||
|
var direction
|
||||||
|
if global_rotation_degrees < 0: global_rotation_degrees += 360
|
||||||
|
if 315 <= global_rotation_degrees or global_rotation_degrees < 45:
|
||||||
|
direction = Vector2i(1,0)
|
||||||
|
elif 45 <= global_rotation_degrees and global_rotation_degrees < 135:
|
||||||
|
direction = Vector2i(0,1)
|
||||||
|
elif 135 <= global_rotation_degrees and global_rotation_degrees < 225:
|
||||||
|
direction = Vector2i(-1,0)
|
||||||
|
elif 225 <= global_rotation_degrees and global_rotation_degrees < 315:
|
||||||
|
direction = Vector2i(0,-1)
|
||||||
|
var item = inventory.inventory[inventory_position.y+direction.y][inventory_position.x+direction.x]
|
||||||
|
|
||||||
|
if item is Item:
|
||||||
|
return item
|
||||||
|
else:
|
||||||
|
return null
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
%Sprite.modulate = color_dictionary[type]
|
1
items/attachment_points/connector.gd.uid
Normal file
1
items/attachment_points/connector.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://beun604o128e6
|
BIN
items/attachment_points/connector.png
Normal file
BIN
items/attachment_points/connector.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 149 B |
34
items/attachment_points/connector.png.import
Normal file
34
items/attachment_points/connector.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://eo0hucjrygr8"
|
||||||
|
path="res://.godot/imported/connector.png-84c229cfebf4e4926836f7f85cbef59c.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://items/attachment_points/connector.png"
|
||||||
|
dest_files=["res://.godot/imported/connector.png-84c229cfebf4e4926836f7f85cbef59c.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
BIN
items/attachment_points/connector.png.pxo
Normal file
BIN
items/attachment_points/connector.png.pxo
Normal file
Binary file not shown.
11
items/attachment_points/connector.tscn
Normal file
11
items/attachment_points/connector.tscn
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
[gd_scene load_steps=3 format=3 uid="uid://cgs87ygrksyge"]
|
||||||
|
|
||||||
|
[ext_resource type="Texture2D" uid="uid://eo0hucjrygr8" path="res://items/attachment_points/connector.png" id="1_drqex"]
|
||||||
|
[ext_resource type="Script" uid="uid://beun604o128e6" path="res://items/attachment_points/connector.gd" id="1_h4kde"]
|
||||||
|
|
||||||
|
[node name="Connector" type="Node2D"]
|
||||||
|
script = ExtResource("1_h4kde")
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
texture = ExtResource("1_drqex")
|
70
items/item.gd
Normal file
70
items/item.gd
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
class_name Item
|
||||||
|
|
||||||
|
var shape
|
||||||
|
var inventory_position : Vector2i
|
||||||
|
|
||||||
|
var draggable = true
|
||||||
|
|
||||||
|
var dragging = false
|
||||||
|
|
||||||
|
@export var connectors : Array[Connector]
|
||||||
|
|
||||||
|
var mouse_offset : Vector2
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("select") and Globals.selected_item == null:
|
||||||
|
var mouse_difference : Vector2 = get_global_mouse_position() - global_position + Vector2(len(shape[0])*Globals.tilesize/2,len(shape)*Globals.tilesize/2)
|
||||||
|
if mouse_difference.x > 0 and mouse_difference.y > 0 and mouse_difference.y < Globals.tilesize*len(shape) and mouse_difference.x < Globals.tilesize*len(shape[0]):
|
||||||
|
var shape_position : Vector2i = Vector2i(mouse_difference/Globals.tilesize)
|
||||||
|
if shape[shape_position.y][shape_position.x]:
|
||||||
|
dragging = true
|
||||||
|
Globals.selected_item = self
|
||||||
|
mouse_offset = -get_global_mouse_position() + global_position
|
||||||
|
if Input.is_action_just_released("select"):
|
||||||
|
dragging = false
|
||||||
|
Globals.set_deferred("selected_item", null)
|
||||||
|
|
||||||
|
if dragging:
|
||||||
|
global_position = get_global_mouse_position() + mouse_offset
|
||||||
|
|
||||||
|
if Input.is_action_just_pressed("rotate_c"):
|
||||||
|
rotate_shape()
|
||||||
|
if Input.is_action_just_pressed("rotate_cc"):
|
||||||
|
rotate_shape(true)
|
||||||
|
item_process(delta)
|
||||||
|
|
||||||
|
func item_process(delta : float) -> void:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func get_head_position() -> Vector2:
|
||||||
|
var return_position = global_position
|
||||||
|
return_position -= Vector2(len(shape[0])-0.5,len(shape)-0.5) * Globals.tilesize / 2
|
||||||
|
|
||||||
|
return return_position
|
||||||
|
|
||||||
|
func rotate_shape(counter_clockwise : bool = false):
|
||||||
|
var new_arr = []
|
||||||
|
if !counter_clockwise:
|
||||||
|
for i in range(len(shape[0])):
|
||||||
|
var row = []
|
||||||
|
for j in range(len(shape)):
|
||||||
|
row.append(shape[len(shape) - j - 1][i])
|
||||||
|
new_arr.append(row)
|
||||||
|
rotation_degrees += 90
|
||||||
|
mouse_offset = Vector2(-mouse_offset.y,mouse_offset.x)
|
||||||
|
else:
|
||||||
|
for i in range(len(shape[0])):
|
||||||
|
var row = []
|
||||||
|
for j in range(len(shape)):
|
||||||
|
row.append(shape[j][len(shape[0])-i-1])
|
||||||
|
new_arr.append(row)
|
||||||
|
rotation_degrees -= 90
|
||||||
|
mouse_offset = Vector2(mouse_offset.y,-mouse_offset.x)
|
||||||
|
global_position = get_global_mouse_position() + mouse_offset
|
||||||
|
shape = new_arr
|
||||||
|
|
||||||
|
func move_away():
|
||||||
|
pass
|
11
items/plasma_gun/plasma_gun.gd
Normal file
11
items/plasma_gun/plasma_gun.gd
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
extends Item
|
||||||
|
|
||||||
|
func item_process(delta):
|
||||||
|
if Input.is_action_just_pressed("shoot"):
|
||||||
|
var connected = %Connector.get_connected()
|
||||||
|
if connected != null:
|
||||||
|
if "power" in connected:
|
||||||
|
connected.power -= 10
|
||||||
|
|
||||||
|
func _init():
|
||||||
|
shape = [[true,true]]
|
1
items/plasma_gun/plasma_gun.gd.uid
Normal file
1
items/plasma_gun/plasma_gun.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://coxkxxcmcpsiy
|
BIN
items/plasma_gun/plasma_gun.png
Normal file
BIN
items/plasma_gun/plasma_gun.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 409 B |
34
items/plasma_gun/plasma_gun.png.import
Normal file
34
items/plasma_gun/plasma_gun.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dord0w07p70xg"
|
||||||
|
path="res://.godot/imported/plasma_gun.png-67a7237f136c7c713d0741563cbd9a88.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://items/plasma_gun/plasma_gun.png"
|
||||||
|
dest_files=["res://.godot/imported/plasma_gun.png-67a7237f136c7c713d0741563cbd9a88.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
27
items/plasma_gun/plasma_gun.tscn
Normal file
27
items/plasma_gun/plasma_gun.tscn
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://c3rg18hsyy1ds"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://coxkxxcmcpsiy" path="res://items/plasma_gun/plasma_gun.gd" id="1_ihkyt"]
|
||||||
|
[ext_resource type="Texture2D" uid="uid://dord0w07p70xg" path="res://items/plasma_gun/plasma_gun.png" id="2_ihkyt"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cgs87ygrksyge" path="res://items/attachment_points/connector.tscn" id="3_7ayw8"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bpura8ysoupso" path="res://ui/menu/tooltip.tscn" id="4_i35d6"]
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a8w1a"]
|
||||||
|
size = Vector2(32, 16)
|
||||||
|
|
||||||
|
[node name="PlasmaGun" type="Node2D"]
|
||||||
|
script = ExtResource("1_ihkyt")
|
||||||
|
|
||||||
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
|
position = Vector2(8, 0)
|
||||||
|
texture = ExtResource("2_ihkyt")
|
||||||
|
|
||||||
|
[node name="Connector" parent="." instance=ExtResource("3_7ayw8")]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
position = Vector2(-8, 8)
|
||||||
|
|
||||||
|
[node name="Tooltip" parent="." instance=ExtResource("4_i35d6")]
|
||||||
|
title = "Plasma Gun"
|
||||||
|
text = "Fires plasma bolts periodically"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tooltip"]
|
||||||
|
shape = SubResource("RectangleShape2D_a8w1a")
|
|
@ -1,4 +1,11 @@
|
||||||
extends Item
|
extends Item
|
||||||
|
|
||||||
|
var power
|
||||||
|
@export var total_power = 100
|
||||||
|
|
||||||
|
func item_process(delta):
|
||||||
|
%PowerBar.value = (float(power)/total_power)*100
|
||||||
|
|
||||||
func _init():
|
func _init():
|
||||||
|
power = total_power
|
||||||
shape = [[true,true]]
|
shape = [[true,true]]
|
||||||
|
|
|
@ -1,12 +1,47 @@
|
||||||
[gd_scene load_steps=3 format=3 uid="uid://bhwd344v0r8lf"]
|
[gd_scene load_steps=9 format=3 uid="uid://bhwd344v0r8lf"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://bh4vv4745n16i" path="res://items/power_capsule/power_capsule.gd" id="1_4uwqi"]
|
[ext_resource type="Script" uid="uid://bh4vv4745n16i" path="res://items/power_capsule/power_capsule.gd" id="1_4uwqi"]
|
||||||
[ext_resource type="Texture2D" uid="uid://du35v4wya2pfm" path="res://items/power_capsule/power-capsule.png" id="2_8reo3"]
|
[ext_resource type="Texture2D" uid="uid://du35v4wya2pfm" path="res://items/power_capsule/power-capsule.png" id="2_8reo3"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cgs87ygrksyge" path="res://items/attachment_points/connector.tscn" id="3_ro74n"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bpura8ysoupso" path="res://ui/menu/tooltip.tscn" id="4_5lsfi"]
|
||||||
|
|
||||||
[node name="PowerCapsule" type="Node2D" node_paths=PackedStringArray("selection_shape")]
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_5lsfi"]
|
||||||
|
bg_color = Color(0.55, 0.55, 0.55, 1)
|
||||||
|
|
||||||
|
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_ro74n"]
|
||||||
|
bg_color = Color(3.94672e-06, 0.604938, 0.778654, 1)
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_5lsfi"]
|
||||||
|
ProgressBar/styles/background = SubResource("StyleBoxFlat_5lsfi")
|
||||||
|
ProgressBar/styles/fill = SubResource("StyleBoxFlat_ro74n")
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_a8w1a"]
|
||||||
|
size = Vector2(32, 16)
|
||||||
|
|
||||||
|
[node name="PowerCapsule" type="Node2D"]
|
||||||
script = ExtResource("1_4uwqi")
|
script = ExtResource("1_4uwqi")
|
||||||
selection_shape = NodePath("")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||||
position = Vector2(16, 8)
|
|
||||||
texture = ExtResource("2_8reo3")
|
texture = ExtResource("2_8reo3")
|
||||||
|
|
||||||
|
[node name="Connector" parent="." instance=ExtResource("3_ro74n")]
|
||||||
|
position = Vector2(-16, 0)
|
||||||
|
rotation = 3.14159
|
||||||
|
|
||||||
|
[node name="PowerBar" type="ProgressBar" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
offset_left = -10.0
|
||||||
|
offset_top = -2.0
|
||||||
|
offset_right = 8.0
|
||||||
|
offset_bottom = 2.0
|
||||||
|
mouse_filter = 2
|
||||||
|
theme = SubResource("Theme_5lsfi")
|
||||||
|
value = 100.0
|
||||||
|
show_percentage = false
|
||||||
|
|
||||||
|
[node name="Tooltip" parent="." instance=ExtResource("4_5lsfi")]
|
||||||
|
title = "Power Capsule"
|
||||||
|
text = "Used to transfer energy to other components"
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Tooltip"]
|
||||||
|
shape = SubResource("RectangleShape2D_a8w1a")
|
||||||
|
|
BIN
misc/Zeroes One.otf
Normal file
BIN
misc/Zeroes One.otf
Normal file
Binary file not shown.
35
misc/Zeroes One.otf.import
Normal file
35
misc/Zeroes One.otf.import
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://6pxk8w000i2m"
|
||||||
|
path="res://.godot/imported/Zeroes One.otf-f985ce592f7ea7d127358cf8b820dca7.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://misc/Zeroes One.otf"
|
||||||
|
dest_files=["res://.godot/imported/Zeroes One.otf-f985ce592f7ea7d127358cf8b820dca7.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
5
misc/globals.gd
Normal file
5
misc/globals.gd
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
extends Node
|
||||||
|
|
||||||
|
var tilesize : int = 16
|
||||||
|
|
||||||
|
var selected_item
|
1
misc/globals.gd.uid
Normal file
1
misc/globals.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://bqwiglbdjlag1
|
BIN
misc/regular.otf
Normal file
BIN
misc/regular.otf
Normal file
Binary file not shown.
35
misc/regular.otf.import
Normal file
35
misc/regular.otf.import
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="font_data_dynamic"
|
||||||
|
type="FontFile"
|
||||||
|
uid="uid://dck6uat43f8rp"
|
||||||
|
path="res://.godot/imported/regular.otf-1d0943e52fcf5ef9659207272da6a0dc.fontdata"
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://misc/regular.otf"
|
||||||
|
dest_files=["res://.godot/imported/regular.otf-1d0943e52fcf5ef9659207272da6a0dc.fontdata"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
Rendering=null
|
||||||
|
antialiasing=1
|
||||||
|
generate_mipmaps=false
|
||||||
|
disable_embedded_bitmaps=true
|
||||||
|
multichannel_signed_distance_field=false
|
||||||
|
msdf_pixel_range=8
|
||||||
|
msdf_size=48
|
||||||
|
allow_system_fallback=true
|
||||||
|
force_autohinter=false
|
||||||
|
hinting=1
|
||||||
|
subpixel_positioning=4
|
||||||
|
keep_rounding_remainders=true
|
||||||
|
oversampling=0.0
|
||||||
|
Fallbacks=null
|
||||||
|
fallbacks=[]
|
||||||
|
Compress=null
|
||||||
|
compress=true
|
||||||
|
preload=[]
|
||||||
|
language_support={}
|
||||||
|
script_support={}
|
||||||
|
opentype_features={}
|
|
@ -11,9 +11,14 @@ config_version=5
|
||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="Knockoff"
|
config/name="Knockoff"
|
||||||
|
run/main_scene="uid://civmfx6p744nl"
|
||||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||||
config/icon="res://icon.svg"
|
config/icon="res://icon.svg"
|
||||||
|
|
||||||
|
[autoload]
|
||||||
|
|
||||||
|
Globals="*res://misc/globals.gd"
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=213
|
window/size/viewport_width=213
|
||||||
|
@ -22,6 +27,56 @@ window/stretch/mode="canvas_items"
|
||||||
window/stretch/aspect="expand"
|
window/stretch/aspect="expand"
|
||||||
window/per_pixel_transparency/allowed=true
|
window/per_pixel_transparency/allowed=true
|
||||||
|
|
||||||
|
[global_group]
|
||||||
|
|
||||||
|
inventory=""
|
||||||
|
|
||||||
|
[input]
|
||||||
|
|
||||||
|
select={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(334, 7),"global_position":Vector2(343, 55),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
rotate_cc={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":81,"key_label":0,"unicode":113,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
rotate_c={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":82,"key_label":0,"unicode":114,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":69,"key_label":0,"unicode":101,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
zoom_in={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":8,"position":Vector2(371, 16),"global_position":Vector2(380, 64),"factor":1.0,"button_index":4,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
zoom_out={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":16,"position":Vector2(393, 25),"global_position":Vector2(402, 73),"factor":1.0,"button_index":5,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
drag_camera={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":4,"position":Vector2(339, 16),"global_position":Vector2(348, 64),"factor":1.0,"button_index":3,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(292, 15),"global_position":Vector2(301, 63),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
tooltip_view={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
shoot={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":32,"key_label":0,"unicode":32,"location":0,"echo":false,"script":null)
|
||||||
|
, Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(395, 18),"global_position":Vector2(404, 66),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[rendering]
|
[rendering]
|
||||||
|
|
||||||
textures/canvas_textures/default_texture_filter=0
|
textures/canvas_textures/default_texture_filter=0
|
||||||
|
|
Before Width: | Height: | Size: 119 B After Width: | Height: | Size: 119 B |
|
@ -3,15 +3,15 @@
|
||||||
importer="texture"
|
importer="texture"
|
||||||
type="CompressedTexture2D"
|
type="CompressedTexture2D"
|
||||||
uid="uid://de6072727efes"
|
uid="uid://de6072727efes"
|
||||||
path="res://.godot/imported/inventory-tile.png-d0903f412222a61cfaf624828d419428.ctex"
|
path="res://.godot/imported/inventory-tile.png-31401f647b7d1b924e7a9f9c376f8e76.ctex"
|
||||||
metadata={
|
metadata={
|
||||||
"vram_texture": false
|
"vram_texture": false
|
||||||
}
|
}
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
|
|
||||||
source_file="res://inventory/inventory-tile.png"
|
source_file="res://ui/inventory/inventory-tile.png"
|
||||||
dest_files=["res://.godot/imported/inventory-tile.png-d0903f412222a61cfaf624828d419428.ctex"]
|
dest_files=["res://.godot/imported/inventory-tile.png-31401f647b7d1b924e7a9f9c376f8e76.ctex"]
|
||||||
|
|
||||||
[params]
|
[params]
|
||||||
|
|
59
ui/inventory/inventory.gd
Normal file
59
ui/inventory/inventory.gd
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
class_name Inventory
|
||||||
|
|
||||||
|
var inventory : Array[Array]
|
||||||
|
|
||||||
|
func _ready():
|
||||||
|
for i in range(5):
|
||||||
|
inventory.append([])
|
||||||
|
for j in range(5):
|
||||||
|
inventory[i].append(true)
|
||||||
|
update_tiles()
|
||||||
|
|
||||||
|
func _process(delta) -> void:
|
||||||
|
if Input.is_action_just_released("select"):
|
||||||
|
if Globals.selected_item is Item:
|
||||||
|
remove_item(Globals.selected_item)
|
||||||
|
var item_head_position = global_to_inventory(Globals.selected_item.get_head_position())
|
||||||
|
insert_item(Globals.selected_item, item_head_position)
|
||||||
|
|
||||||
|
func remove_item(item : Item):
|
||||||
|
for y in range(len(inventory)):
|
||||||
|
for x in range(len(inventory[0])):
|
||||||
|
if inventory[y][x] is not Item: continue
|
||||||
|
if inventory[y][x] == item:
|
||||||
|
inventory[y][x] = true
|
||||||
|
|
||||||
|
func insert_item(item : Item, at : Vector2i):
|
||||||
|
var fits = true
|
||||||
|
|
||||||
|
if len(item.shape) + at.y > len(inventory) or len(item.shape[0]) + at.x > len(inventory[0]) or at.x < 0 or at.y < 0: fits = false
|
||||||
|
|
||||||
|
if fits:
|
||||||
|
for y in range(len(item.shape)):
|
||||||
|
for x in range(len(item.shape[0])):
|
||||||
|
if (inventory[y+at.y][x+at.x] is not bool or inventory[y+at.y][x+at.x] == false) and item.shape[y][x]: fits = false
|
||||||
|
|
||||||
|
if not fits:
|
||||||
|
item.move_away()
|
||||||
|
return
|
||||||
|
|
||||||
|
item.position = Vector2(at.x + float(len(item.shape[0]))/2, at.y + float(len(item.shape))/2) * Globals.tilesize
|
||||||
|
|
||||||
|
for y in range(len(item.shape)):
|
||||||
|
for x in range(len(item.shape[0])):
|
||||||
|
if item.shape[y][x]:
|
||||||
|
inventory[y+at.y][x+at.x] = item
|
||||||
|
|
||||||
|
func global_to_inventory(location : Vector2) -> Vector2:
|
||||||
|
location -= global_position
|
||||||
|
var new_location : Vector2i = Vector2i(location/Globals.tilesize)
|
||||||
|
return new_location
|
||||||
|
|
||||||
|
func update_tiles():
|
||||||
|
%InventoryTiles.clear()
|
||||||
|
for y in range(len(inventory)):
|
||||||
|
for x in range(len(inventory[0])):
|
||||||
|
if inventory[y][x]:
|
||||||
|
%InventoryTiles.set_cell(Vector2i(x,y),0,Vector2i(0,0))
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://cquc6kpasvo7r"]
|
[gd_scene load_steps=5 format=3 uid="uid://cquc6kpasvo7r"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://cvwx472s1l0wh" path="res://inventory/inventory.gd" id="1_s83yu"]
|
[ext_resource type="Script" uid="uid://cvwx472s1l0wh" path="res://ui/inventory/inventory.gd" id="1_s83yu"]
|
||||||
[ext_resource type="Texture2D" uid="uid://de6072727efes" path="res://inventory/inventory-tile.png" id="2_qse2j"]
|
[ext_resource type="Texture2D" uid="uid://de6072727efes" path="res://ui/inventory/inventory-tile.png" id="2_qse2j"]
|
||||||
|
|
||||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_f8i2h"]
|
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_f8i2h"]
|
||||||
texture = ExtResource("2_qse2j")
|
texture = ExtResource("2_qse2j")
|
||||||
|
@ -10,18 +10,10 @@ texture = ExtResource("2_qse2j")
|
||||||
[sub_resource type="TileSet" id="TileSet_70ao8"]
|
[sub_resource type="TileSet" id="TileSet_70ao8"]
|
||||||
sources/0 = SubResource("TileSetAtlasSource_f8i2h")
|
sources/0 = SubResource("TileSetAtlasSource_f8i2h")
|
||||||
|
|
||||||
[node name="Inventory" type="Control"]
|
[node name="Inventory" type="Node2D" groups=["inventory"]]
|
||||||
layout_mode = 3
|
z_index = -1
|
||||||
anchors_preset = 8
|
|
||||||
anchor_left = 0.5
|
|
||||||
anchor_top = 0.5
|
|
||||||
anchor_right = 0.5
|
|
||||||
anchor_bottom = 0.5
|
|
||||||
grow_horizontal = 2
|
|
||||||
grow_vertical = 2
|
|
||||||
script = ExtResource("1_s83yu")
|
script = ExtResource("1_s83yu")
|
||||||
|
|
||||||
[node name="InventoryTiles" type="TileMapLayer" parent="."]
|
[node name="InventoryTiles" type="TileMapLayer" parent="."]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
scale = Vector2(0.5, 0.5)
|
|
||||||
tile_set = SubResource("TileSet_70ao8")
|
tile_set = SubResource("TileSet_70ao8")
|
29
ui/menu/camera.gd
Normal file
29
ui/menu/camera.gd
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
extends Camera2D
|
||||||
|
|
||||||
|
var dragging = false
|
||||||
|
@export var max_zoom = 2
|
||||||
|
@export var min_zoom = 0.1
|
||||||
|
|
||||||
|
func _input(event: InputEvent) -> void:
|
||||||
|
if event.is_action("drag_camera"):
|
||||||
|
if event.is_released():
|
||||||
|
dragging = false
|
||||||
|
else:
|
||||||
|
dragging = true
|
||||||
|
elif event.is_action("zoom_out"):
|
||||||
|
zoom *= 0.9
|
||||||
|
|
||||||
|
if zoom.x < min_zoom:
|
||||||
|
zoom = Vector2(min_zoom,min_zoom)
|
||||||
|
elif event.is_action("zoom_in"):
|
||||||
|
zoom *= 1.1
|
||||||
|
|
||||||
|
if zoom.x > max_zoom:
|
||||||
|
zoom = Vector2(max_zoom,max_zoom)
|
||||||
|
elif event is InputEventMouse:
|
||||||
|
|
||||||
|
if event is InputEventMouseMotion:
|
||||||
|
|
||||||
|
if dragging:
|
||||||
|
position -= event.relative / zoom.x
|
||||||
|
|
1
ui/menu/camera.gd.uid
Normal file
1
ui/menu/camera.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://bww7u4imhpuxf
|
22
ui/menu/menu.tscn
Normal file
22
ui/menu/menu.tscn
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
[gd_scene load_steps=5 format=3 uid="uid://cpnlcq1dosgu5"]
|
||||||
|
|
||||||
|
[ext_resource type="PackedScene" uid="uid://cquc6kpasvo7r" path="res://ui/inventory/inventory.tscn" id="1_v6ljw"]
|
||||||
|
[ext_resource type="Script" uid="uid://bww7u4imhpuxf" path="res://ui/menu/camera.gd" id="1_w0ybq"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bhwd344v0r8lf" path="res://items/power_capsule/power_capsule.tscn" id="2_77h3e"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://c3rg18hsyy1ds" path="res://items/plasma_gun/plasma_gun.tscn" id="4_trkij"]
|
||||||
|
|
||||||
|
[node name="Menu" type="Node2D"]
|
||||||
|
|
||||||
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
|
script = ExtResource("1_w0ybq")
|
||||||
|
|
||||||
|
[node name="PowerCapsule" parent="." instance=ExtResource("2_77h3e")]
|
||||||
|
position = Vector2(91, 41)
|
||||||
|
|
||||||
|
[node name="PowerCapsule2" parent="." instance=ExtResource("2_77h3e")]
|
||||||
|
position = Vector2(77, -7)
|
||||||
|
|
||||||
|
[node name="Inventory" parent="." instance=ExtResource("1_v6ljw")]
|
||||||
|
|
||||||
|
[node name="PlasmaGun" parent="." instance=ExtResource("4_trkij")]
|
||||||
|
position = Vector2(-31, 5)
|
26
ui/menu/tooltip.gd
Normal file
26
ui/menu/tooltip.gd
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
extends Area2D
|
||||||
|
|
||||||
|
var mouse_inside = false
|
||||||
|
|
||||||
|
@export var title : String
|
||||||
|
@export var text : String
|
||||||
|
|
||||||
|
func _ready() -> void:
|
||||||
|
%Title.text = "[u]" + title + "[/u]"
|
||||||
|
%Body.text = text
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
global_rotation = 0
|
||||||
|
if mouse_inside and Input.is_action_pressed("tooltip_view"):
|
||||||
|
%PanelContainer.show()
|
||||||
|
else:
|
||||||
|
%PanelContainer.hide()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func _on_mouse_entered() -> void:
|
||||||
|
mouse_inside = true
|
||||||
|
|
||||||
|
|
||||||
|
func _on_mouse_exited() -> void:
|
||||||
|
mouse_inside = false
|
1
ui/menu/tooltip.gd.uid
Normal file
1
ui/menu/tooltip.gd.uid
Normal file
|
@ -0,0 +1 @@
|
||||||
|
uid://dqo52q1ptmuv2
|
47
ui/menu/tooltip.tscn
Normal file
47
ui/menu/tooltip.tscn
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
[gd_scene load_steps=6 format=3 uid="uid://bpura8ysoupso"]
|
||||||
|
|
||||||
|
[ext_resource type="Script" uid="uid://dqo52q1ptmuv2" path="res://ui/menu/tooltip.gd" id="1_5nn81"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://6pxk8w000i2m" path="res://misc/Zeroes One.otf" id="1_bm30g"]
|
||||||
|
[ext_resource type="FontFile" uid="uid://dck6uat43f8rp" path="res://misc/regular.otf" id="2_h5m05"]
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_h5m05"]
|
||||||
|
default_font = ExtResource("1_bm30g")
|
||||||
|
default_font_size = 8
|
||||||
|
|
||||||
|
[sub_resource type="Theme" id="Theme_bm30g"]
|
||||||
|
default_font = ExtResource("2_h5m05")
|
||||||
|
default_font_size = 4
|
||||||
|
|
||||||
|
[node name="Tooltip" type="Area2D"]
|
||||||
|
script = ExtResource("1_5nn81")
|
||||||
|
|
||||||
|
[node name="PanelContainer" type="PanelContainer" parent="."]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
offset_right = 69.0
|
||||||
|
offset_bottom = 28.0
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="VBoxContainer" type="VBoxContainer" parent="PanelContainer"]
|
||||||
|
layout_mode = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
|
||||||
|
[node name="Title" type="RichTextLabel" parent="PanelContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
layout_mode = 2
|
||||||
|
mouse_filter = 2
|
||||||
|
theme = SubResource("Theme_h5m05")
|
||||||
|
bbcode_enabled = true
|
||||||
|
text = "[u]Lorem Ipsum[/u]"
|
||||||
|
fit_content = true
|
||||||
|
autowrap_mode = 0
|
||||||
|
|
||||||
|
[node name="Body" type="Label" parent="PanelContainer/VBoxContainer"]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
custom_minimum_size = Vector2(50, 0)
|
||||||
|
layout_mode = 2
|
||||||
|
theme = SubResource("Theme_bm30g")
|
||||||
|
text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna "
|
||||||
|
autowrap_mode = 2
|
||||||
|
|
||||||
|
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||||
|
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
3
world/world.tscn
Normal file
3
world/world.tscn
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
[gd_scene format=3 uid="uid://civmfx6p744nl"]
|
||||||
|
|
||||||
|
[node name="World" type="Node2D"]
|
Loading…
Reference in a new issue