# Conflicts:
#	Characters/Player/Player.tscn
This commit is contained in:
SyntaX 2019-11-21 12:37:50 +01:00
commit 0d8c940170
5 changed files with 100 additions and 26 deletions

View File

@ -0,0 +1,8 @@
extends Spatial
onready var screen_texture = get_node("ScreenTexture") as ColorRect
func _process(delta: float) -> void:
screen_texture.material.set_shader_param("mask_factor", Pills.get_level() / Pills.get_max())

View File

@ -5,6 +5,7 @@ export(NodePath) var body_nodepath
export(NodePath) var lookingAt_nodepath export(NodePath) var lookingAt_nodepath
export(NodePath) var animation_nodepath export(NodePath) var animation_nodepath
export(NodePath) var ui_interact_nodepath export(NodePath) var ui_interact_nodepath
export(NodePath) var camera_nodepath
export(int) var keycard_lvl export(int) var keycard_lvl
export(Array) var key_chain export(Array) var key_chain
@ -36,7 +37,7 @@ func _ready():
_body = get_node(body_nodepath) as Spatial # = $Body _body = get_node(body_nodepath) as Spatial # = $Body
assert(null != _body) assert(null != _body)
_camera = $Body/Camera _camera = get_node(camera_nodepath)
assert(null != _camera) assert(null != _camera)
_animation = get_node(animation_nodepath) as AnimationPlayer _animation = get_node(animation_nodepath) as AnimationPlayer

View File

@ -1,12 +1,27 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=16 format=2]
[ext_resource path="res://Characters/Player/Player.gd" type="Script" id=1] [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://Characters/Player/PillCameras.gd" type="Script" id=2]
[ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=3] [ext_resource path="res://Shaders/PillScreenRenderer.shader" type="Shader" id=3]
[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=4] [ext_resource path="res://Characters/Player/Footsteps.gd" type="Script" id=4]
[ext_resource path="res://Characters/Player/PillTaker.gd" type="Script" id=5] [ext_resource path="res://Resources/Audio/Step.wav" type="AudioStream" id=5]
[ext_resource path="res://Characters/Player/UI/UI.tscn" type="PackedScene" id=6]
[ext_resource path="res://Characters/Player/PillTaker.gd" type="Script" id=7]
[sub_resource type="CylinderShape" id=1] [sub_resource type="ViewportTexture" id=1]
viewport_path = NodePath("Body/PillCameras/MaskedView")
[sub_resource type="ViewportTexture" id=2]
viewport_path = NodePath("Body/PillCameras/TrueView")
[sub_resource type="ShaderMaterial" id=3]
resource_local_to_scene = true
shader = ExtResource( 3 )
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="Animation" id=5] [sub_resource type="Animation" id=5]
resource_name = "PillTaking" resource_name = "PillTaking"
@ -18,12 +33,11 @@ tracks/0/imported = false
tracks/0/enabled = true tracks/0/enabled = true
tracks/0/keys = PoolRealArray( ) tracks/0/keys = PoolRealArray( )
[sub_resource type="Animation" id=2] [sub_resource type="Animation" id=6]
resource_name = "Walk"
length = 0.8 length = 0.8
loop = true loop = true
tracks/0/type = "value" tracks/0/type = "value"
tracks/0/path = NodePath("Body/Camera:translation") tracks/0/path = NodePath("Body/PillCameras:translation")
tracks/0/interp = 2 tracks/0/interp = 2
tracks/0/loop_wrap = true tracks/0/loop_wrap = true
tracks/0/imported = false tracks/0/imported = false
@ -52,11 +66,11 @@ tracks/1/keys = {
} ] } ]
} }
[sub_resource type="AudioStreamRandomPitch" id=3] [sub_resource type="AudioStreamRandomPitch" id=7]
audio_stream = ExtResource( 3 ) audio_stream = ExtResource( 5 )
random_pitch = 1.3 random_pitch = 1.3
[sub_resource type="CapsuleMesh" id=4] [sub_resource type="CapsuleMesh" id=8]
[node name="Player" type="KinematicBody" groups=[ [node name="Player" type="KinematicBody" groups=[
"Player", "Player",
@ -65,53 +79,83 @@ collision_layer = 5
collision_mask = 5 collision_mask = 5
script = ExtResource( 1 ) script = ExtResource( 1 )
body_nodepath = NodePath("Body") body_nodepath = NodePath("Body")
lookingAt_nodepath = NodePath("Body/Camera/LookingAt") lookingAt_nodepath = NodePath("Body/PillCameras/LookingAt")
animation_nodepath = NodePath("AnimationPlayer") animation_nodepath = NodePath("AnimationPlayer")
ui_interact_nodepath = NodePath("HUD/PressInteract") ui_interact_nodepath = NodePath("HUD/PressInteract")
camera_nodepath = NodePath("Body/PillCameras")
[node name="Body" type="Spatial" parent="."] [node name="Body" type="Spatial" parent="."]
[node name="Camera" type="Camera" parent="Body"] [node name="PillCameras" type="Spatial" parent="Body"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0625, 1.85, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0625, 1.85, 0 )
current = true script = ExtResource( 2 )
[node name="LookingAt" type="RayCast" parent="Body/Camera"] [node name="LookingAt" type="RayCast" parent="Body/PillCameras"]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 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 enabled = true
cast_to = Vector3( 0, 0, 2 ) cast_to = Vector3( 0, 0, 2 )
[node name="Listener" type="Listener" parent="Body/Camera"] [node name="Listener" type="Listener" parent="Body/PillCameras"]
current = true current = true
[node name="TrueView" type="Viewport" parent="Body/PillCameras"]
size = Vector2( 1024, 600 )
render_target_update_mode = 3
[node name="TrueCamera" type="Camera" parent="Body/PillCameras/TrueView"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0625, 1.85, 0 )
cull_mask = 2
current = true
[node name="MaskedView" type="Viewport" parent="Body/PillCameras"]
size = Vector2( 1024, 600 )
render_target_update_mode = 3
[node name="MaskedCamera" type="Camera" parent="Body/PillCameras/MaskedView"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0625, 1.85, 0 )
cull_mask = 1
current = true
[node name="ScreenTexture" type="ColorRect" parent="Body/PillCameras"]
material = SubResource( 3 )
anchor_right = 1.0
anchor_bottom = 1.0
mouse_filter = 2
[node name="TrueCameraRemoteTransform" type="RemoteTransform" parent="Body/PillCameras"]
remote_path = NodePath("../TrueView/TrueCamera")
[node name="MaskedCameraRemoteTransform" type="RemoteTransform" parent="Body/PillCameras"]
remote_path = NodePath("../MaskedView/MaskedCamera")
[node name="Collider" type="CollisionShape" parent="."] [node name="Collider" type="CollisionShape" parent="."]
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 )
shape = SubResource( 1 ) shape = SubResource( 4 )
[node name="AnimationPlayer" type="AnimationPlayer" parent="."] [node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Walk"
anims/PillTaking = SubResource( 5 ) anims/PillTaking = SubResource( 5 )
anims/Walk = SubResource( 2 ) anims/Walk = SubResource( 6 )
[node name="Footsteps" type="Spatial" parent="."] [node name="Footsteps" type="Spatial" parent="."]
script = ExtResource( 2 ) script = ExtResource( 4 )
[node name="Footstep1" type="AudioStreamPlayer3D" parent="Footsteps"] [node name="Footstep1" type="AudioStreamPlayer3D" parent="Footsteps"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1 )
stream = SubResource( 3 ) stream = SubResource( 7 )
unit_db = -25.0 unit_db = -25.0
pitch_scale = 1.5 pitch_scale = 1.5
[node name="HUD" parent="." instance=ExtResource( 4 )] [node name="HUD" parent="." instance=ExtResource( 6 )]
[node name="PillTaker" type="Spatial" parent="."] [node name="PillTaker" type="Spatial" parent="."]
script = ExtResource( 5 ) script = ExtResource( 7 )
[node name="Pill" type="Spatial" parent="PillTaker"] [node name="Pill" type="Spatial" parent="PillTaker"]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -1 )
[node name="MeshInstance" type="MeshInstance" parent="PillTaker/Pill"] [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 ) transform = Transform( 0.1, 0, 0, 0, -4.37114e-009, -0.1, 0, 0.1, -4.37114e-009, 0, 0, 0 )
mesh = SubResource( 4 ) mesh = SubResource( 8 )
material/0 = null material/0 = null
[editable path="HUD"] [editable path="HUD"]

View File

@ -7,6 +7,16 @@ var _max: float = 6.0
var _decrease_per_second: float = 0.2 var _decrease_per_second: float = 0.2
var _pill_add_amount: float = 2.0 var _pill_add_amount: float = 2.0
enum LEVELS {
SOBRE = 0,
VERY_LOW = 1,
LOW = 2,
MEDIUM = 3,
HIGH = 4,
VERY_HIGH = 5,
FULL = 6
}
# Returns the max level # Returns the max level
func get_max() -> float: func get_max() -> float:

View File

@ -0,0 +1,11 @@
shader_type canvas_item;
uniform sampler2D true_view;
uniform sampler2D masked_view;
uniform float mask_factor;
void fragment() {
// Add the masked view and the true view depending on the factor
COLOR = (1.0f - mask_factor) * texture(true_view, SCREEN_UV) + mask_factor * texture(masked_view, SCREEN_UV);
}