Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added project/assets_external/flaticon/gear_freepik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions project/assets_external/flaticon/gear_freepik.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bqtm20wrivj0q"
path="res://.godot/imported/gear_freepik.png-ebef99de1234ec6a69e97bad06ea2f3a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets_external/flaticon/gear_freepik.png"
dest_files=["res://.godot/imported/gear_freepik.png-ebef99de1234ec6a69e97bad06ea2f3a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 40 additions & 0 deletions project/assets_external/flaticon/recycle_roundicons.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://bm3lffivg4yul"
path="res://.godot/imported/recycle_roundicons.png-867b539f2ec7696e1c30abc9f7e2876a.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets_external/flaticon/recycle_roundicons.png"
dest_files=["res://.godot/imported/recycle_roundicons.png-867b539f2ec7696e1c30abc9f7e2876a.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
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/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
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
30 changes: 22 additions & 8 deletions project/autoloads/player_inventory.gd
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,15 @@ var equipped_torso: Upgrade
var equipped_legs: Upgrade
var equipped_arm: Upgrade
var equipped_weapon: Weapon
var skyscraper_gears: int
var maze_gears: int


func _ready() -> void:
Signals.item_picked_up.connect(add_item.bind(1))
for item_scenes in item_library.values():
for item_scene in item_scenes:
flattened_item_library.append(load(item_scene))
print(flattened_item_library)

func generate_new_android_inventory() -> void:
equipped_head = load(item_library["heads"].pick_random()).duplicate()
Expand All @@ -59,7 +60,6 @@ func add_item(item: Item, count: int) -> void:
inventory[item] += count
else:
inventory[item] = count
prints("The player picked up the item with name:", item.name, "the player now has:", inventory)
Signals.inventory_updated.emit()


Expand All @@ -78,23 +78,38 @@ func can_drop_item(pos: Vector2, item: Item):
for slot in inventory_slots:
if slot.get_global_rect().has_point(pos):
return false
var weapon_slot = get_tree().get_nodes_in_group("weapon_slot")[0]
var recycle_slot = get_tree().get_first_node_in_group("recycle_slot")
if recycle_slot.get_global_rect().has_point(pos):
return true
var weapon_slot = get_tree().get_first_node_in_group("weapon_slot")
if item is Weapon and weapon_slot.get_global_rect().has_point(pos):
return true
if item is Upgrade:
var slot
match item.type:
Upgrade.Type.LEGS:
slot = get_tree().get_nodes_in_group("legs_slot")[0]
slot = get_tree().get_first_node_in_group("legs_slot")
Upgrade.Type.ARMS:
slot = get_tree().get_nodes_in_group("arm_slot")[0]
slot = get_tree().get_first_node_in_group("arm_slot")
Upgrade.Type.HEAD:
slot = get_tree().get_nodes_in_group("head_slot")[0]
slot = get_tree().get_first_node_in_group("head_slot")
Upgrade.Type.TORSO:
slot = get_tree().get_nodes_in_group("torso_slot")[0]
slot = get_tree().get_first_node_in_group("torso_slot")
return slot.get_global_rect().has_point(pos)
return false

func drop_item(pos: Vector2, dropped_item: Item, original_item: Item):
var recycle_slot = get_tree().get_first_node_in_group("recycle_slot")
if recycle_slot.get_global_rect().has_point(pos):
if SceneManager.player_in_hub():
skyscraper_gears += dropped_item.recycle_value
else:
maze_gears += dropped_item.recycle_value
else:
equip_item(dropped_item)
remove_item(original_item, 1)
Signals.inventory_updated.emit()

func equip_item(item: Item) -> void:
if item is Weapon:
equipped_weapon = item
Expand All @@ -110,7 +125,6 @@ func equip_item(item: Item) -> void:
equipped_torso = item
Weapon.Type:
equipped_weapon = item
Signals.inventory_updated.emit()



14 changes: 5 additions & 9 deletions project/autoloads/scene_manager.gd
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
extends Node

## --- public vars ---
var current_scene: Node = null
var current_scene: PackedScene = null

## --- export vars ---
@export var main_menu_scene: PackedScene
Expand All @@ -23,19 +23,15 @@ func _process(_delta: float) -> void:

## Changes the room
func change_room(scene: PackedScene) -> void:
# Remove current room
#if current_scene and is_instance_valid(current_scene):
#current_scene.queue_free()
#
## Load new room
#current_scene = scene.instantiate()
#add_child(current_scene)

current_scene = scene
get_tree().change_scene_to_packed.call_deferred(scene)

# Send signal
Signals.scene_change.emit()

func player_in_hub() -> bool:
return current_scene == hub_scene

## Loads game scene
func load_game_scene():
change_room(game_scene)
Expand Down
1 change: 1 addition & 0 deletions project/data/items/android_arm.tres
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script = ExtResource("2_4rvc7")
type = 1
name = "Android Arm"
flavor = "Fresh from the press!"
recycle_value = 5
icon = SubResource("AtlasTexture_g8oi5")
icon_variants = 10
icon_variants_x = 10
Expand Down
1 change: 1 addition & 0 deletions project/data/items/android_head.tres
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script = ExtResource("1_ck3dl")
type = 3
name = "Android Head"
flavor = "Central processing"
recycle_value = 5
icon = SubResource("AtlasTexture_muex4")
icon_variants = 4
icon_variants_x = 4
Expand Down
1 change: 1 addition & 0 deletions project/data/items/android_leg.tres
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ region = Rect2(0, 0, 15, 12)
script = ExtResource("2_7j0qn")
name = "Android Legs"
flavor = "Fabricator Quality"
recycle_value = 5
icon = SubResource("AtlasTexture_p281a")
icon_variants = 7
icon_variants_x = 1
Expand Down
1 change: 1 addition & 0 deletions project/data/items/android_torso.tres
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script = ExtResource("1_gxak5")
type = 2
name = "Android Torso"
flavor = "Factory Grade"
recycle_value = 5
icon = SubResource("AtlasTexture_5td40")
icon_variants = 10
icon_variants_x = 10
Expand Down
1 change: 1 addition & 0 deletions project/data/items/blunderbuss.tres
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ script = ExtResource("1_i0wum")
type = 1
name = "Blunderbuss"
flavor = "Goes boom boom"
recycle_value = 5
icon = SubResource("AtlasTexture_om2kc")
icon_variants = 3
icon_variants_x = 1
Expand Down
1 change: 1 addition & 0 deletions project/data/items/katana.tres
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ region = Rect2(0, 0, 48, 14)
script = ExtResource("2_kixpy")
name = "Katana"
flavor = "Quck slice!"
recycle_value = 5
icon = SubResource("AtlasTexture_om2kc")
icon_variants = 3
icon_variants_x = 1
Expand Down
1 change: 1 addition & 0 deletions project/data/items/polearm.tres
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ region = Rect2(0, 0, 48, 14)
script = ExtResource("2_wyvwt")
name = "Polearm"
flavor = "Stay away from me!"
recycle_value = 5
icon = SubResource("AtlasTexture_om2kc")
icon_variants = 3
icon_variants_x = 1
Expand Down
7 changes: 5 additions & 2 deletions project/modules/hud/weapon_hotbar.gd
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ func _ready() -> void:
# Populate the hotbar with all items in same order
func populate_hotbar() -> void:
var inventory = PlayerInventory.inventory.keys()
for idx in min(len(inventory), len(weapons_hotbar_list.get_children())):
weapons_hotbar_list.get_child(idx).item = inventory[idx]
for idx in len(weapons_hotbar_list.get_children()):
if idx < len(inventory):
weapons_hotbar_list.get_child(idx).item = inventory[idx]
else:
weapons_hotbar_list.get_child(idx).item = null
select_item(0)

# Hightlight the currentlty selected item by showing a frame around it
Expand Down
16 changes: 12 additions & 4 deletions project/modules/hud/weapon_slot.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,22 @@ extends Control

@onready var WeaponSlotScene = preload("res://modules/hud/weapon_slot.tscn")

@export var slot_texture: Texture2D

var item: Item:
set(new_item):
item = new_item
if is_node_ready():
$SlotImage.texture = item.get_2d_texture()
if item:
$SlotImage.texture = item.get_2d_texture()
else:
$SlotImage.texture = null

func _ready() -> void:
if item:
$SlotImage.texture = item.get_2d_texture()
if slot_texture:
$SlotImage.texture = slot_texture

func _get_drag_data(_pos):
if not PlayerInventory.can_drag_item(item):
Expand All @@ -29,6 +36,7 @@ func _can_drop_data(pos, data):
var global_pos = pos + global_position
return PlayerInventory.can_drop_item(global_pos, data["item"])

func _drop_data(_pos, data):
PlayerInventory.equip_item(data["item"])
PlayerInventory.remove_item(data["source_item"], 1)
func _drop_data(pos, data):
var global_pos = pos + global_position
PlayerInventory.drop_item(
global_pos, data["item"], data["source_item"])
1 change: 1 addition & 0 deletions project/modules/hud/weapon_slot.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
expand_mode = 2
1 change: 1 addition & 0 deletions project/modules/items/item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ extends Resource

@export var name: String
@export var flavor: String
@export var recycle_value: int

@export var icon: AtlasTexture
@export var icon_variants: int
Expand Down
22 changes: 0 additions & 22 deletions project/modules/player/player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -45,34 +45,12 @@ var target_enemy: Node2D
func _ready() -> void:
bullet_timer.wait_time= shoot_rate
_post_ready.call_deferred()
_update_player_textures()
Signals.inventory_updated.connect(_update_player_textures)

func _post_ready():
# ensure the HUD is fully loaded before setting the initial values
Signals.change_ammo_count_value.emit(ammo, max_ammo)
Signals.change_health_value.emit(health, max_health)

func _update_player_textures():
$Model/Leg.texture = null
if PlayerInventory.equipped_legs:
$Model/Leg.texture = PlayerInventory.equipped_legs.get_2d_texture()

$Model/Torso.texture = null
if PlayerInventory.equipped_torso:
$Model/Torso.texture = PlayerInventory.equipped_torso.get_2d_texture()

$Model/Shoulder/Arm.texture = null
if PlayerInventory.equipped_arm:
$Model/Shoulder/Arm.texture = PlayerInventory.equipped_arm.get_2d_texture()

$Model/Shoulder/Arm/Weapon/Sprite2D.texture = null
if PlayerInventory.equipped_weapon:
$Model/Shoulder/Arm/Weapon/Sprite2D.texture = PlayerInventory.equipped_weapon.get_2d_texture()

$Model/Head.texture = null
if PlayerInventory.equipped_head:
$Model/Head.texture = PlayerInventory.equipped_head.get_2d_texture()

func _process(_delta: float) -> void:
var looking_right := global_position.x < get_global_mouse_position().x
Expand Down
5 changes: 4 additions & 1 deletion project/modules/player/player_doll.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ func _input(event: InputEvent) -> void:
else:
show()


func _update_icons() -> void:
if PlayerInventory.equipped_arm:
$Arm.item = PlayerInventory.equipped_arm
Expand All @@ -31,3 +30,7 @@ func _update_icons() -> void:
$Legs.item = PlayerInventory.equipped_legs
if PlayerInventory.equipped_torso:
$Torso.item = PlayerInventory.equipped_torso
if SceneManager.player_in_hub():
$GearsDisplay/Label.text = str(PlayerInventory.skyscraper_gears)
else:
$GearsDisplay/Label.text = str(PlayerInventory.maze_gears)
Loading