Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
666Savior committed Apr 26, 2021
2 parents 1c7f8eb + fa89faf commit 6e698c2
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 5 deletions.
20 changes: 20 additions & 0 deletions environment/props/ResearchTable.gd
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
extends Area2D

onready var panel: Panel = $CanvasLayer/ResearchPanel
onready var done_button: Button = $CanvasLayer/ResearchPanel/DoneButton

var character: Node2D = null

func _ready() -> void:
connect("body_entered", self, "on_body_entered")
connect("body_exited", self, "on_body_exited")
panel.hide()
done_button.connect("pressed", self, "done_interacting")

func on_body_entered(body):
if body.has_method("entered_interactive_range"):
Expand Down Expand Up @@ -34,3 +37,20 @@ func done_interacting():
return
character.set_process_input(true)
character.set_physics_process(true)

func update_inventory_view():
if !character || !is_instance_valid(character):
character = null
return
var inventory_buttons = $CanvasLayer/ResearchPanel/InventoryButtons.get_children()
var button_idx = 0
for item_type in character.inventory:
if button_idx >= inventory_buttons.size():
break
if character.inventory[item_type] <= 0:
continue
inventory_buttons[button_idx].icon = Item.ICONS[item_type]
button_idx += 1
while button_idx < inventory_buttons.size():
inventory_buttons[button_idx].icon = Item.ICONS[Item.ItemType.NONE]
button_idx += 1
7 changes: 4 additions & 3 deletions environment/props/TableWide2.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]

[ext_resource path="res://environment/props/table.png" type="Texture" id=1]
[ext_resource path="res://environment/props/ResearchTable.gd" type="Script" id=2]
[ext_resource path="res://game/ui-theme/ui_theme.tres" type="Theme" id=3]
[ext_resource path="res://game/menu/InventoryButton.tscn" type="PackedScene" id=4]
[ext_resource path="res://game/ui-theme/panel_style_transparent.tres" type="StyleBox" id=5]

[sub_resource type="CircleShape2D" id=1]
radius = 40.0
Expand Down Expand Up @@ -31,7 +32,6 @@ shape = SubResource( 2 )
layer = 2

[node name="ResearchPanel" type="Panel" parent="CanvasLayer"]
visible = false
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
Expand All @@ -43,6 +43,7 @@ margin_bottom = 200.0
grow_horizontal = 2
grow_vertical = 2
theme = ExtResource( 3 )
custom_styles/panel = ExtResource( 5 )
__meta__ = {
"_edit_use_anchors_": false
}
Expand Down Expand Up @@ -143,7 +144,7 @@ __meta__ = {
"_edit_use_anchors_": false
}

[node name="ConfirmButton2" type="Button" parent="CanvasLayer/ResearchPanel"]
[node name="DoneButton" type="Button" parent="CanvasLayer/ResearchPanel"]
margin_left = 200.0
margin_top = 350.0
margin_right = 360.0
Expand Down
1 change: 1 addition & 0 deletions game/Game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func on_start_game() -> void:
spawn_player()

func back_to_menu() -> void:
character = null
level_container.remove_child(level)
level.queue_free()
level = null
Expand Down
3 changes: 2 additions & 1 deletion game/Game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,15 @@ layer = 99
material = ExtResource( 8 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
__meta__ = {
"_edit_use_anchors_": false
}

[node name="UI" type="Control" parent="UILayer"]
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 1
mouse_filter = 2
theme = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
Expand Down
2 changes: 1 addition & 1 deletion game/ui-theme/panel_style_transparent.tres
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_resource type="StyleBoxFlat" format=2]

[resource]
bg_color = Color( 0, 0, 0, 0.6 )
bg_color = Color( 0, 0, 0, 0 )
3 changes: 3 additions & 0 deletions item/None.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[gd_resource type="AtlasTexture" format=2]

[resource]
14 changes: 14 additions & 0 deletions level/Item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,20 @@ enum ItemType {
BOTTLE_GREEN,
}

const ICONS: Dictionary = {
NONE = preload("res://item/None.tres"),
ORB_RED = preload("res://item/OrbRed.tres"),
ORB_BLUE = preload("res://item/OrbBlue.tres"),
ORB_YELLOW = preload("res://item/OrbYellow.tres"),
ORB_GREEN = preload("res://item/OrbGreen.tres"),
LEAVES = preload("res://item/Leaves.tres"),
TWIG = preload("res://item/Twig.tres"),
BOTTLE_RED = preload("res://item/BottleRed.tres"),
BOTTLE_BLUE = preload("res://item/BottleBlue.tres"),
BOTTLE_YELLOW = preload("res://item/BottleYellow.tres"),
BOTTLE_GREEN = preload("res://item/BottleGreen.tres"),
}

static func type_str(item_type):
for entry in ItemType:
if item_type == ItemType.get(entry):
Expand Down

0 comments on commit 6e698c2

Please sign in to comment.