added basic collectible

This commit is contained in:
SyntaX 2019-11-23 14:49:20 +01:00
parent 497521127a
commit 108c5bd67c
6 changed files with 44 additions and 8 deletions

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=10 format=2] [gd_scene load_steps=11 format=2]
[ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=1] [ext_resource path="res://Level/Objects/Wall.tscn" type="PackedScene" id=1]
[ext_resource path="res://Level/Objects/LongBuilding.tscn" type="PackedScene" id=2] [ext_resource path="res://Level/Objects/LongBuilding.tscn" type="PackedScene" id=2]
[ext_resource path="res://Level/Objects/SmallBuilding.tscn" type="PackedScene" id=3] [ext_resource path="res://Level/Objects/SmallBuilding.tscn" type="PackedScene" id=3]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=4] [ext_resource path="res://Level/Objects/Crystal.tscn" type="PackedScene" id=4]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=5]
[sub_resource type="PlaneMesh" id=1] [sub_resource type="PlaneMesh" id=1]
size = Vector2( 500, 500 ) size = Vector2( 500, 500 )
@ -153,6 +154,15 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 15, 0, 74 )
[node name="SmallBuilding" parent="Navigation/NavigationMeshInstance" instance=ExtResource( 3 )] [node name="SmallBuilding" parent="Navigation/NavigationMeshInstance" instance=ExtResource( 3 )]
[node name="Crystal" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 2, -15 )
[node name="Crystal2" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 2, -32.1406 )
[node name="Crystal3" parent="." instance=ExtResource( 4 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, -20.2151, 2, -32.1406 )
[node name="WorldEnvironment" type="WorldEnvironment" parent="."] [node name="WorldEnvironment" type="WorldEnvironment" parent="."]
environment = SubResource( 5 ) environment = SubResource( 5 )
@ -160,9 +170,5 @@ environment = SubResource( 5 )
transform = Transform( 0.965926, 0.212012, -0.148453, 0, 0.573576, 0.819152, 0.258819, -0.79124, 0.554032, 0, 0, 0 ) transform = Transform( 0.965926, 0.212012, -0.148453, 0, 0.573576, 0.819152, 0.258819, -0.79124, 0.554032, 0, 0, 0 )
shadow_enabled = true shadow_enabled = true
[node name="Player" parent="." instance=ExtResource( 4 )] [node name="Player" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
body_nodepath = NodePath("Body")
animation_nodepath = NodePath("WalkAnimationPlayer")
ui_nodepath = NodePath("HUD")
camera_nodepath = NodePath("Camera")

View File

@ -0,0 +1,8 @@
extends Spatial
func _ready():
Collector.addCollectible(self)
#TODO: handle collisions

View File

@ -0,0 +1,20 @@
[gd_scene load_steps=4 format=2]
[ext_resource path="res://Level/Objects/Crystal.gd" type="Script" id=1]
[sub_resource type="CapsuleMesh" id=1]
[sub_resource type="CapsuleShape" id=2]
[node name="Crystal" type="Spatial"]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 2, 0 )
script = ExtResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="."]
mesh = SubResource( 1 )
material/0 = null
[node name="StaticBody" type="StaticBody" parent="."]
[node name="CollisionShape" type="CollisionShape" parent="StaticBody"]
shape = SubResource( 2 )

View File

@ -7,5 +7,5 @@ onready var steps = [
func play_footstep(): func play_footstep():
Logger.trace("Footstep") #Logger.trace("Footstep")
steps[0].play() steps[0].play()

View File

@ -75,6 +75,7 @@ func _process_input():
# jumping # jumping
if Input.is_action_just_pressed("move_jump") and is_on_floor(): if Input.is_action_just_pressed("move_jump") and is_on_floor():
Logger.info("current collection count: " + String(Collector.getCount()))
_vel.y = JUMP_SPEED _vel.y = JUMP_SPEED
# sprinting # sprinting

View File

@ -4,6 +4,7 @@ var _collectibles: Array
func addCollectible (coll): func addCollectible (coll):
Logger.info("appending new collectible: " + String(coll.get_instance_id()))
_collectibles.append(coll) _collectibles.append(coll)