added fadeOut effect if get in touch with a meldewesen

only triggers for under 50 % Pill level, otherwise there will be an conversation
This commit is contained in:
incredibleLeitman 2019-12-14 15:32:29 +01:00
parent 07cbb545c0
commit 0d37f1076d
14 changed files with 267 additions and 51 deletions

View File

@ -1,7 +1,12 @@
extends Spatial
onready var screen_texture = get_node("ScreenTexture") as ColorRect
var screen_texture: ColorRect
func _ready():
screen_texture = get_node("ScreenTextureView") as ColorRect
assert(null != screen_texture)
func _process(delta: float) -> void:

View File

@ -1,6 +1,11 @@
extends Spatial
var _animation: AnimationPlayer
var _animationWalk: AnimationPlayer
func _ready():
_animationWalk = get_parent().get_node("PillAnimationPlayer") as AnimationPlayer
assert(null != _animationWalk)
# Called every frame. 'delta' is the elapsed time since the previous frame.
@ -9,9 +14,4 @@ func _process(delta):
if Input.is_action_just_pressed("take_pill"):
Pills.take_pill()
Logger.info("Player took a pill; new level: %s" % [Pills.get_round_level()])
_animation.play("PillTaking")
func _ready():
_animation = get_parent().get_node("PillAnimationPlayer") as AnimationPlayer
assert(null != _animation)
_animationWalk.play("PillTaking")

View File

@ -3,7 +3,8 @@ extends KinematicBody
# export variables
export(NodePath) var body_nodepath
export(NodePath) var lookingAt_nodepath
export(NodePath) var animation_nodepath
export(NodePath) var animationWalk_nodepath
export(NodePath) var animationFadeOut_nodepath
export(NodePath) var ui_interact_nodepath
export(NodePath) var camera_nodepath
export(int) var keycard_lvl
@ -23,7 +24,8 @@ const INTERACT_DISTANCE = 4
var _body: Spatial
var _camera: Camera
var _lookCast: RayCast
var _animation: AnimationPlayer
var _animationWalk: AnimationPlayer
var _animationFadeOut: AnimationPlayer
var _dir = Vector3();
var _vel = Vector3();
var _is_sprinting : bool;
@ -40,8 +42,11 @@ func _ready():
_camera = get_node(camera_nodepath)
assert(null != _camera)
_animation = get_node(animation_nodepath) as AnimationPlayer
assert(null != _animation)
_animationWalk = get_node(animationWalk_nodepath) as AnimationPlayer
assert(null != _animationWalk)
_animationFadeOut = get_node(animationFadeOut_nodepath) as AnimationPlayer
assert(null != _animationFadeOut)
# Setup mouse look
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
@ -105,7 +110,7 @@ func process_movement(delta):
func process_animations():
_animation.playback_speed = _vel.length() / MOVE_SPEED
_animationWalk.playback_speed = _vel.length() / MOVE_SPEED
func process_collision_layers():
@ -122,18 +127,18 @@ func process_collision_layers():
func check_interact():
if _lookCast.is_colliding():
var collider = _lookCast.get_collider()
if collider.is_in_group("Touchables"):
if null != collider and collider.is_in_group("Touchables"):
#show interact tooltip
get_node(ui_interact_nodepath).show()
#enable outline of seen object
collider.get_node(collider.outline_path).show()
if _prev_look != null and is_instance_valid(_prev_look):
if _prev_look != collider:
_prev_look.get_node(_prev_look.outline_path).hide()
_prev_look = collider
#do interaction
if Input.is_action_just_pressed("interact"):
collider.do_interact(self)
@ -157,12 +162,35 @@ func _input(event):
if event is InputEventMouseMotion:
_camera.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
self.rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1))
# Prevent player from doing a purzelbaum
_camera.rotation_degrees.x = clamp(_camera.rotation_degrees.x, -70, 70)
func _on_interact_entered (area: Area):
if area.is_in_group("Enemy"):
Logger.info("ermagerd they touched :-o !")
#TODO: fade to black and restart scene
#_animation.
Logger.info("ermahgerd they touched :-o !")
if Pills.get_level() < Pills.get_max() * 0.5:
_reset_scene() # TODO: call per event -> also rais if Meldewesen is looking at player and pill level reaches treshold!
else:
get_node("AudioStreamPlayer3D").play()
# TODO: check why this does not work as intended:
#var player = AudioStreamPlayer3D.new()
#var audio_file = "res://Resources/Audio/dino-eat.wav"
#player.stream = load("res://Resources/Audio/dino-eat.wav")
#add_child(player)
#Logger.info("should play sound again?")
#player.play()
#remove_child(player)
#player. queue_free()
func _reset_scene ():
# fade to black and restart scene
_animationFadeOut.play("FadeOut")
yield(_animationFadeOut, "animation_finished")
# reset values
_animationFadeOut.seek(0, true)
get_tree().reload_current_scene()
Pills._set_level(Pills.get_max())

View File

@ -1,14 +1,17 @@
[gd_scene load_steps=18 format=2]
[gd_scene load_steps=23 format=2]
[ext_resource path="res://Characters/Player/Player.gd" type="Script" id=1]
[ext_resource path="res://Characters/Player/PillCameras.gd" type="Script" id=2]
[ext_resource path="res://Shaders/PillScreenRenderer.shader" type="Shader" id=3]
[ext_resource path="res://Resources/Audio/dino-eat.wav" type="AudioStream" id=4]
[ext_resource path="res://Characters/Player/Footsteps.gd" type="Script" id=5]
[ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=6]
[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=7]
[ext_resource path="res://Characters/Player/PillTaker.gd" type="Script" id=8]
[ext_resource path="res://Level/Interactables/Pills/Pills.tscn" type="PackedScene" id=9]
[ext_resource path="res://Shaders/FadeOut.shader" type="Shader" id=4]
[ext_resource path="res://Shaders/Masks/from_center.png" type="Texture" id=5]
[ext_resource path="res://Resources/Audio/dino-eat.wav" type="AudioStream" id=6]
[ext_resource path="res://Resources/Audio/Stop you violated the law.wav" type="AudioStream" id=7]
[ext_resource path="res://Characters/Player/Footsteps.gd" type="Script" id=8]
[ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=9]
[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=10]
[ext_resource path="res://Characters/Player/PillTaker.gd" type="Script" id=11]
[ext_resource path="res://Level/Interactables/Pills/Pills.tscn" type="PackedScene" id=12]
[sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("Body/PillCameras/MaskedView")
@ -23,9 +26,16 @@ shader_param/mask_factor = 0.5
shader_param/true_view = SubResource( 2 )
shader_param/masked_view = SubResource( 1 )
[sub_resource type="CylinderShape" id=4]
[sub_resource type="ShaderMaterial" id=4]
shader = ExtResource( 4 )
shader_param/cutoff = 1.0
shader_param/smooth_size = 0.135
shader_param/color = null
shader_param/mask = ExtResource( 5 )
[sub_resource type="Animation" id=5]
[sub_resource type="CylinderShape" id=5]
[sub_resource type="Animation" id=6]
length = 0.8
loop = true
tracks/0/type = "value"
@ -58,8 +68,7 @@ tracks/1/keys = {
} ]
}
[sub_resource type="Animation" id=6]
resource_name = "PillTaking"
[sub_resource type="Animation" id=7]
tracks/0/type = "value"
tracks/0/path = NodePath("PillTaker/Pills:visible")
tracks/0/interp = 1
@ -106,7 +115,7 @@ tracks/3/keys = {
"clips": [ {
"end_offset": 0.0,
"start_offset": 0.0,
"stream": ExtResource( 4 )
"stream": ExtResource( 6 )
} ],
"times": PoolRealArray( 0 )
}
@ -125,11 +134,27 @@ tracks/4/keys = {
} ]
}
[sub_resource type="AudioStreamRandomPitch" id=7]
audio_stream = ExtResource( 6 )
[sub_resource type="Animation" id=8]
resource_name = "FadeOut"
length = 2.0
tracks/0/type = "value"
tracks/0/path = NodePath(".:material:shader_param/cutoff")
tracks/0/interp = 2
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.8, 1.3, 2 ),
"transitions": PoolRealArray( 1, 1, 1, 1 ),
"update": 0,
"values": [ 1.0, 0.5, 0.7, 0.0 ]
}
[sub_resource type="AudioStreamRandomPitch" id=10]
audio_stream = ExtResource( 9 )
random_pitch = 1.3
[sub_resource type="CylinderShape" id=8]
[sub_resource type="CylinderShape" id=11]
[node name="Player" type="KinematicBody" groups=[
"Player",
@ -139,14 +164,15 @@ collision_mask = 5
script = ExtResource( 1 )
body_nodepath = NodePath("Body")
lookingAt_nodepath = NodePath("Body/PillCameras/LookingAt")
animation_nodepath = NodePath("WalkAnimationPlayer")
animationWalk_nodepath = NodePath("WalkAnimationPlayer")
animationFadeOut_nodepath = NodePath("FadeOutAnimationPlayer")
ui_interact_nodepath = NodePath("HUD/PressInteract")
camera_nodepath = NodePath("Body/PillCameras")
[node name="Body" type="Spatial" parent="."]
[node name="PillCameras" type="Spatial" parent="Body"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00764713, 1.80765, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0461721, 1.84617, 0 )
script = ExtResource( 2 )
[node name="LookingAt" type="RayCast" parent="Body/PillCameras"]
@ -163,7 +189,7 @@ render_target_update_mode = 3
audio_listener_enable_3d = true
[node name="TrueCamera" type="Camera" parent="Body/PillCameras/TrueView"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00764713, 1.80765, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0461721, 1.84617, 0 )
cull_mask = 2
current = true
@ -173,15 +199,23 @@ render_target_update_mode = 3
audio_listener_enable_3d = true
[node name="MaskedCamera" type="Camera" parent="Body/PillCameras/MaskedView"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.00764713, 1.80765, 0 )
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -0.0461721, 1.84617, 0 )
cull_mask = 1
current = true
[node name="ScreenTexture" type="ColorRect" parent="Body/PillCameras"]
[node name="ScreenTextureView" type="ColorRect" parent="Body/PillCameras"]
material = SubResource( 3 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
color = Color( 0, 0, 0, 1 )
[node name="ScreenTextureFadeOut" type="ColorRect" parent="Body/PillCameras"]
material = SubResource( 4 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
color = Color( 0, 0, 0, 1 )
[node name="TrueCameraRemoteTransform" type="RemoteTransform" parent="Body/PillCameras"]
remote_path = NodePath("../TrueView/TrueCamera")
@ -191,37 +225,47 @@ remote_path = NodePath("../MaskedView/MaskedCamera")
[node name="Collider" type="CollisionShape" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
shape = SubResource( 4 )
shape = SubResource( 5 )
[node name="WalkAnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Walk"
anims/Walk = SubResource( 5 )
anims/Walk = SubResource( 6 )
[node name="PillAnimationPlayer" type="AnimationPlayer" parent="."]
playback_speed = 2.0
anims/PillTaking = SubResource( 6 )
anims/PillTaking = SubResource( 7 )
[node name="FadeOutAnimationPlayer" type="AnimationPlayer" parent="."]
root_node = NodePath("../Body/PillCameras/ScreenTextureFadeOut")
playback_speed = 2.0
anims/FadeOut = SubResource( 8 )
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."]
stream = ExtResource( 7 )
[node name="Eating" type="Spatial" parent="."]
editor/display_folded = true
[node name="Chrum" type="AudioStreamPlayer3D" parent="Eating"]
stream = ExtResource( 4 )
stream = ExtResource( 6 )
[node name="Footsteps" type="Spatial" parent="."]
script = ExtResource( 5 )
script = ExtResource( 8 )
[node name="Footstep1" type="AudioStreamPlayer3D" parent="Footsteps"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 )
stream = SubResource( 7 )
stream = SubResource( 10 )
unit_db = -25.0
pitch_scale = 1.5
[node name="HUD" parent="." instance=ExtResource( 7 )]
[node name="HUD" parent="." instance=ExtResource( 10 )]
editor/display_folded = true
[node name="PillTaker" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0 )
script = ExtResource( 8 )
script = ExtResource( 11 )
[node name="Pills" parent="PillTaker" instance=ExtResource( 9 )]
[node name="Pills" parent="PillTaker" instance=ExtResource( 12 )]
transform = Transform( 0.1, 0, 0, 0, -4.37114e-009, 0.1, 0, -0.1, -4.37114e-009, 0, 0.7, 0 )
visible = false
@ -229,6 +273,6 @@ visible = false
[node name="CollisionShape" type="CollisionShape" parent="InteractArea"]
transform = Transform( 1.2, 0, 0, 0, 1, 0, 0, 0, 1.2, 0, 1, 0 )
shape = SubResource( 8 )
shape = SubResource( 11 )
[editable path="HUD"]

View File

@ -41,6 +41,7 @@ transform = Transform( 0.766044, -0.582564, 0.271654, 0, 0.422618, 0.906308, -0.
light_energy = 0.19
[node name="NavigationMeshInstance" type="NavigationMeshInstance" parent="."]
editor/display_folded = true
navmesh = SubResource( 1 )
[node name="MeshInstance" type="MeshInstance" parent="NavigationMeshInstance"]

Binary file not shown.

View File

@ -0,0 +1,21 @@
[remap]
importer="wav"
type="AudioStreamSample"
path="res://.import/Stop you violated the law.wav-aebf25561443a5ca8a476a44d4b5dae7.sample"
[deps]
source_file="res://Resources/Audio/Stop you violated the law.wav"
dest_files=[ "res://.import/Stop you violated the law.wav-aebf25561443a5ca8a476a44d4b5dae7.sample" ]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=true
edit/normalize=true
edit/loop=false
compress/mode=0

15
Shaders/FadeOut.shader Normal file
View File

@ -0,0 +1,15 @@
shader_type canvas_item;
render_mode unshaded;
uniform float cutoff : hint_range(0.0, 1.0);
uniform float smooth_size : hint_range(0.0, 1.0);
uniform sampler2D mask : hint_albedo;
uniform vec4 color : hint_color;
void fragment()
{
float value = texture(mask, UV).r;
float alpha = smoothstep(cutoff, cutoff + smooth_size, value * (1.0 - smooth_size) + smooth_size);
COLOR = vec4(color.rgb, alpha);
}

BIN
Shaders/Masks/curtain.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/curtain.png-d93cae6a707b8a1a6281d16724fae7c8.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Shaders/Masks/curtain.png"
dest_files=[ "res://.import/curtain.png-d93cae6a707b8a1a6281d16724fae7c8.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/from_center.png-490774fdc3f15852dbf553f3f034cb2e.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Shaders/Masks/from_center.png"
dest_files=[ "res://.import/from_center.png-490774fdc3f15852dbf553f3f034cb2e.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

BIN
Shaders/Masks/shards.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/shards.png-f42359025c77c5dbd63d7482d49930fb.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Shaders/Masks/shards.png"
dest_files=[ "res://.import/shards.png-f42359025c77c5dbd63d7482d49930fb.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0