Compare commits
2 Commits
8e8ec8e759
...
a0d3ded185
| Author | SHA1 | Date | |
|---|---|---|---|
| a0d3ded185 | |||
| 2f6b085dec |
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://src/actors/players/playerE/PlayerE.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://src/levels/TestBox.tscn" type="PackedScene" id=2]
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
[ext_resource path="res://src/classes/camera_guide.gd" type="Script" id=5]
|
||||
[ext_resource path="res://src/Camera2D.gd" type="Script" id=6]
|
||||
[ext_resource path="res://src/Main.gd" type="Script" id=7]
|
||||
[ext_resource path="res://assets/items/mushroom_icon.png" type="Texture" id=8]
|
||||
|
||||
[sub_resource type="Shader" id=2]
|
||||
code = "shader_type canvas_item;
|
||||
|
|
@ -68,3 +69,7 @@ position = Vector2( 160, 90 )
|
|||
current = true
|
||||
script = ExtResource( 6 )
|
||||
tracking_node_path = NodePath("../CameraGuide")
|
||||
|
||||
[node name="MushroomIcon" type="Sprite" parent="ViewportContainer/Viewport"]
|
||||
position = Vector2( 60, 160 )
|
||||
texture = ExtResource( 8 )
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ extends Node
|
|||
var player_position: Vector2
|
||||
var player_health: int
|
||||
var player_stamina: int
|
||||
var player_inventory: InventoryManager
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ func _ready():
|
|||
add_child(item_sprite)
|
||||
item_sprite.play()
|
||||
|
||||
|
||||
func trigger_interaction():
|
||||
queue_free()
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
#func _process(delta):
|
||||
|
|
|
|||
|
|
@ -6,13 +6,21 @@ export var player_number: int = 1
|
|||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
onready var player_inventory :InventoryManager = InventoryManager.new()
|
||||
|
||||
#var mushroom :Item = preload("res://assets/items/doodad.tres")
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
PlayerInfo.player_health = $Health_Component.health
|
||||
PlayerInfo.player_inventory = player_inventory
|
||||
# Set initial player position in world.
|
||||
global_position = LevelInfo.player_start_position
|
||||
|
||||
# player_inventory.add_to_inventory(mushroom)
|
||||
# player_inventory.select_primary(mushroom)
|
||||
|
||||
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
|
|
@ -46,4 +54,8 @@ func touch_the_thing(the_thing: Interactable) -> bool:
|
|||
transform.x.x = movement_component.LEFT
|
||||
movement_state_machine.change_to_known_state('enter_right')
|
||||
the_thing.trigger_interaction()
|
||||
if the_thing is ItemPickup:
|
||||
player_inventory.add_to_inventory(the_thing.item)
|
||||
player_inventory.select_primary(the_thing.item)
|
||||
the_thing.trigger_interaction()
|
||||
return true
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
class_name InventoryManager
|
||||
extends Resource
|
||||
## Currently doing this in a weird way where the inventory items are the
|
||||
## dictionary keys. This would make world inventory items ownable
|
||||
## by the resourse itself. At least that's what I think. We'll see.
|
||||
## I'm interested in an approach where the game world items aren't
|
||||
## duplicated.
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
|
|
@ -16,6 +21,14 @@ var _items :Dictionary
|
|||
func _ready():
|
||||
pass # Replace with function body.
|
||||
|
||||
func select_primary(_item :Item) -> void:
|
||||
if _items.has(_item):
|
||||
primary_selection = _item
|
||||
|
||||
func select_secondary(_item :Item) -> void:
|
||||
if _items.has(_item):
|
||||
secondary_selection = _item
|
||||
|
||||
func add_to_inventory(_item :Item) -> int:
|
||||
if _items.has(_item):
|
||||
_items[_item] += 1
|
||||
|
|
|
|||
|
|
@ -14,7 +14,11 @@ onready var DialogContainerText = $PanelContainer/HSplitContainer/Label
|
|||
|
||||
onready var DialogIndicator = $PanelContainer/Polygon2D
|
||||
|
||||
onready var HUD = $HealthBar
|
||||
onready var health_bar = $HealthBar
|
||||
|
||||
## Cool I can bring this in with a ctrl drag
|
||||
onready var selected_inventory_items = $"%SelectedInventoryItems"
|
||||
|
||||
|
||||
var current_pane
|
||||
|
||||
|
|
@ -39,11 +43,11 @@ func _process(delta):
|
|||
print("UI Switch detected")
|
||||
current_pane = UiManager.current_pane
|
||||
DialogContainer.visible = false
|
||||
HUD.visible = false
|
||||
health_bar.visible = false
|
||||
match current_pane:
|
||||
UiManager.UI_PANES.HUD:
|
||||
print("Enable HUD")
|
||||
HUD.visible = true
|
||||
health_bar.visible = true
|
||||
UiManager.UI_PANES.DIALOG:
|
||||
print("Enable Dialog")
|
||||
DialogContainerPortrait.texture = UiManager.dialog_portrait
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=8 format=2]
|
||||
[gd_scene load_steps=9 format=2]
|
||||
|
||||
[ext_resource path="res://icon.png" type="Texture" id=1]
|
||||
[ext_resource path="res://assets/Fonts/QuinqueFive.tres" type="DynamicFont" id=2]
|
||||
|
|
@ -7,6 +7,7 @@
|
|||
[ext_resource path="res://src/ui/HealthBar.gd" type="Script" id=5]
|
||||
[ext_resource path="res://assets/UI/Healthbar-Indicator.png" type="Texture" id=6]
|
||||
[ext_resource path="res://assets/UI/Staminabar-Indicator.png" type="Texture" id=7]
|
||||
[ext_resource path="res://src/ui/SelectedInventoryItems.gd" type="Script" id=8]
|
||||
|
||||
[node name="HUD" type="CanvasLayer"]
|
||||
pause_mode = 2
|
||||
|
|
@ -96,3 +97,22 @@ margin_bottom = 40.0
|
|||
margin_left = 13.0
|
||||
margin_right = 40.0
|
||||
margin_bottom = 40.0
|
||||
|
||||
[node name="SelectedInventoryItems" type="HBoxContainer" parent="."]
|
||||
unique_name_in_owner = true
|
||||
anchor_top = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 2.0
|
||||
margin_top = -18.0
|
||||
margin_right = 48.0
|
||||
margin_bottom = -2.0
|
||||
rect_clip_content = true
|
||||
script = ExtResource( 8 )
|
||||
|
||||
[node name="PrimaryItem" type="TextureRect" parent="SelectedInventoryItems"]
|
||||
margin_bottom = 16.0
|
||||
|
||||
[node name="SecondaryItem" type="TextureRect" parent="SelectedInventoryItems"]
|
||||
margin_left = 4.0
|
||||
margin_right = 4.0
|
||||
margin_bottom = 16.0
|
||||
|
|
|
|||
19
src/ui/SelectedInventoryItems.gd
Normal file
19
src/ui/SelectedInventoryItems.gd
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
extends HBoxContainer
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
onready var primary_item = $PrimaryItem
|
||||
onready var secondary_item = $SecondaryItem
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
pass
|
||||
#secondary_item.texture = PlayerInfo.player_inventory.secondary_selection.inventory_icon
|
||||
|
||||
func _process(delta):
|
||||
if (PlayerInfo.player_inventory.primary_selection):
|
||||
primary_item.texture = PlayerInfo.player_inventory.primary_selection.inventory_icon
|
||||
|
||||
Loading…
Reference in New Issue
Block a user