moved "taking pill" to own script

This commit is contained in:
SyntaX 2019-11-21 11:25:59 +01:00
parent 233573ad44
commit 41e2d5b096
3 changed files with 32 additions and 9 deletions

View File

@ -0,0 +1,16 @@
extends Node
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
# Taking a pill
if Input.is_action_just_pressed("take_pill"):
Pills.take_pill()
Logger.info("Player took a pill; new level: %s" % [Pills.get_round_level()])

View File

@ -82,13 +82,6 @@ func process_input():
# sprinting
_is_sprinting = Input.is_action_pressed("move_sprint")
# Taking a pill
# TODO: Should be moved to a different component which only handles pills - this script should only do movement
# Only here for testing purposes!
if Input.is_action_just_pressed("take_pill"):
Pills.take_pill()
Logger.info("Player took a pill; new level: %s" % [Pills.get_round_level()])
func process_movement(delta):

View File

@ -1,9 +1,10 @@
[gd_scene load_steps=8 format=2]
[gd_scene load_steps=10 format=2]
[ext_resource path="res://Characters/Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Characters/Player/Footsteps.gd" type="Script" id=2]
[ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=3]
[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=4]
[ext_resource path="res://Characters/Player/PillTaker.gd" type="Script" id=5]
[sub_resource type="CylinderShape" id=1]
@ -45,6 +46,8 @@ tracks/1/keys = {
audio_stream = ExtResource( 3 )
random_pitch = 1.3
[sub_resource type="CapsuleMesh" id=4]
[node name="Player" type="KinematicBody" groups=[
"Player",
]]
@ -63,7 +66,7 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0625, 1.85, 0 )
current = true
[node name="LookingAt" type="RayCast" parent="Body/Camera"]
transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0 )
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, 0 )
enabled = true
cast_to = Vector3( 0, 0, 2 )
@ -89,4 +92,15 @@ pitch_scale = 1.5
[node name="HUD" parent="." instance=ExtResource( 4 )]
[node name="PillTaker" type="Node" parent="."]
script = ExtResource( 5 )
[node name="Pill" type="Spatial" parent="PillTaker"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1 )
[node name="MeshInstance" type="MeshInstance" parent="PillTaker/Pill"]
transform = Transform( 0.1, 0, 0, 0, -4.37114e-009, -0.1, 0, 0.1, -4.37114e-009, 0, 0, 0 )
mesh = SubResource( 4 )
material/0 = null
[editable path="HUD"]