automarge
This commit is contained in:
commit
7e0c17b5f7
10
Characters/Player/PillCameras.gd
Normal file
10
Characters/Player/PillCameras.gd
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
|
||||||
|
onready var screen_texture = get_node("ScreenTexture") as ColorRect
|
||||||
|
|
||||||
|
|
||||||
|
func _process(delta: float) -> void:
|
||||||
|
# The factor is 0 when the level is between 0% and 25%; 1 when the level is between 75% and 100%; lerp inbetween
|
||||||
|
var factor = clamp((Pills.get_level() / Pills.get_max() * 1.5 - 0.25), 0.0, 1.0)
|
||||||
|
screen_texture.material.set_shader_param("mask_factor", factor)
|
9
Characters/Player/PillTaker.gd
Normal file
9
Characters/Player/PillTaker.gd
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
extends Spatial
|
||||||
|
|
||||||
|
|
||||||
|
# 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()])
|
@ -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
|
||||||
@ -53,6 +54,7 @@ func _ready():
|
|||||||
func _physics_process(delta):
|
func _physics_process(delta):
|
||||||
process_input()
|
process_input()
|
||||||
process_movement(delta)
|
process_movement(delta)
|
||||||
|
process_collision_layers()
|
||||||
|
|
||||||
func _process(_delta):
|
func _process(_delta):
|
||||||
check_interact()
|
check_interact()
|
||||||
@ -82,13 +84,6 @@ func process_input():
|
|||||||
|
|
||||||
# sprinting
|
# sprinting
|
||||||
_is_sprinting = Input.is_action_pressed("move_sprint")
|
_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):
|
func process_movement(delta):
|
||||||
@ -108,6 +103,17 @@ func process_animations():
|
|||||||
_animation.playback_speed = _vel.length() / MOVE_SPEED
|
_animation.playback_speed = _vel.length() / MOVE_SPEED
|
||||||
|
|
||||||
|
|
||||||
|
func process_collision_layers():
|
||||||
|
var new_layer: int = 6
|
||||||
|
|
||||||
|
if Pills.get_level() >= Pills.LEVELS.VERY_LOW:
|
||||||
|
# If the masked view is almost invisible, collision with masked objects is disabled
|
||||||
|
new_layer -= 1 # See collision layer names in editor
|
||||||
|
|
||||||
|
collision_layer = new_layer
|
||||||
|
collision_mask = new_layer
|
||||||
|
|
||||||
|
|
||||||
func check_interact():
|
func check_interact():
|
||||||
if _lookCast.is_colliding():
|
if _lookCast.is_colliding():
|
||||||
var collider = _lookCast.get_collider()
|
var collider = _lookCast.get_collider()
|
||||||
|
@ -1,18 +1,43 @@
|
|||||||
[gd_scene load_steps=8 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://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="Animation" id=2]
|
[sub_resource type="ViewportTexture" id=2]
|
||||||
resource_name = "Walk"
|
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]
|
||||||
|
resource_name = "PillTaking"
|
||||||
|
tracks/0/type = "transform"
|
||||||
|
tracks/0/path = NodePath("PillTaker/Pill")
|
||||||
|
tracks/0/interp = 1
|
||||||
|
tracks/0/loop_wrap = true
|
||||||
|
tracks/0/imported = false
|
||||||
|
tracks/0/enabled = true
|
||||||
|
tracks/0/keys = PoolRealArray( )
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=6]
|
||||||
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
|
||||||
@ -41,52 +66,102 @@ 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=8]
|
||||||
|
|
||||||
[node name="Player" type="KinematicBody" groups=[
|
[node name="Player" type="KinematicBody" groups=[
|
||||||
"Player",
|
"Player",
|
||||||
]]
|
]]
|
||||||
collision_layer = 5
|
collision_layer = 7
|
||||||
collision_mask = 5
|
collision_mask = 7
|
||||||
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-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
|
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
|
||||||
|
shadow_atlas_size = 4
|
||||||
|
|
||||||
|
[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
|
||||||
|
fov = 80.0
|
||||||
|
far = 2000.0
|
||||||
|
|
||||||
|
[node name="MaskedView" type="Viewport" parent="Body/PillCameras"]
|
||||||
|
size = Vector2( 1024, 600 )
|
||||||
|
render_target_update_mode = 3
|
||||||
|
shadow_atlas_size = 4
|
||||||
|
|
||||||
|
[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
|
||||||
|
fov = 80.0
|
||||||
|
far = 2000.0
|
||||||
|
|
||||||
|
[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/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="."]
|
||||||
|
script = ExtResource( 7 )
|
||||||
|
|
||||||
|
[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( 8 )
|
||||||
|
material/0 = null
|
||||||
|
|
||||||
[editable path="HUD"]
|
[editable path="HUD"]
|
||||||
|
@ -11,7 +11,7 @@ func _ready():
|
|||||||
_pillLevel = get_node("TextureProgress")
|
_pillLevel = get_node("TextureProgress")
|
||||||
|
|
||||||
# TODO: may use global values in Inspector?
|
# TODO: may use global values in Inspector?
|
||||||
_pillLevel.max_value = Pills._max
|
_pillLevel.max_value = Pills.get_max()
|
||||||
|
|
||||||
|
|
||||||
func add_item (name):
|
func add_item (name):
|
||||||
|
@ -7,9 +7,24 @@ 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
|
||||||
|
func get_max() -> float:
|
||||||
|
return _max
|
||||||
|
|
||||||
|
|
||||||
# Returns the exact current level as a floating point number between min and max
|
# Returns the exact current level as a floating point number between min and max
|
||||||
func get_level():
|
func get_level() -> float:
|
||||||
return _level
|
return _level
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=3 format=2]
|
[gd_scene load_steps=4 format=2]
|
||||||
|
|
||||||
[sub_resource type="CubeMesh" id=1]
|
[sub_resource type="CubeMesh" id=1]
|
||||||
size = Vector3( 26, 12, 14 )
|
size = Vector3( 26, 12, 14 )
|
||||||
@ -6,9 +6,17 @@ size = Vector3( 26, 12, 14 )
|
|||||||
[sub_resource type="SpatialMaterial" id=2]
|
[sub_resource type="SpatialMaterial" id=2]
|
||||||
albedo_color = Color( 1, 0.917647, 0.537255, 1 )
|
albedo_color = Color( 1, 0.917647, 0.537255, 1 )
|
||||||
|
|
||||||
|
[sub_resource type="ConcavePolygonShape" id=3]
|
||||||
|
data = PoolVector3Array( -13, 6, 7, 13, 6, 7, -13, -6, 7, 13, 6, 7, 13, -6, 7, -13, -6, 7, 13, 6, -7, -13, 6, -7, 13, -6, -7, -13, 6, -7, -13, -6, -7, 13, -6, -7, 13, 6, 7, 13, 6, -7, 13, -6, 7, 13, 6, -7, 13, -6, -7, 13, -6, 7, -13, 6, -7, -13, 6, 7, -13, -6, -7, -13, 6, 7, -13, -6, 7, -13, -6, -7, 13, 6, 7, -13, 6, 7, 13, 6, -7, -13, 6, 7, -13, 6, -7, 13, 6, -7, -13, -6, 7, 13, -6, 7, -13, -6, -7, 13, -6, 7, 13, -6, -7, -13, -6, -7 )
|
||||||
|
|
||||||
[node name="BuildingBlock" type="Spatial"]
|
[node name="BuildingBlock" type="Spatial"]
|
||||||
|
|
||||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0 )
|
||||||
mesh = SubResource( 1 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = SubResource( 2 )
|
material/0 = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="StaticBody" type="StaticBody" parent="MeshInstance"]
|
||||||
|
|
||||||
|
[node name="CollisionShape" type="CollisionShape" parent="MeshInstance/StaticBody"]
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[gd_scene load_steps=2 format=2]
|
[gd_scene load_steps=2 format=2]
|
||||||
|
|
||||||
[sub_resource type="CylinderMesh" id=4]
|
[sub_resource type="CylinderMesh" id=1]
|
||||||
top_radius = 20.0
|
top_radius = 20.0
|
||||||
bottom_radius = 35.0
|
bottom_radius = 35.0
|
||||||
height = 100.0
|
height = 100.0
|
||||||
@ -10,15 +10,15 @@ transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -185, 0, -191 )
|
|||||||
|
|
||||||
[node name="MeshInstance" type="MeshInstance" parent="."]
|
[node name="MeshInstance" type="MeshInstance" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 50, 0 )
|
||||||
mesh = SubResource( 4 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
[node name="MeshInstance2" type="MeshInstance" parent="."]
|
[node name="MeshInstance2" type="MeshInstance" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 30, 50, 60 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 30, 50, 60 )
|
||||||
mesh = SubResource( 4 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
|
||||||
[node name="MeshInstance3" type="MeshInstance" parent="."]
|
[node name="MeshInstance3" type="MeshInstance" parent="."]
|
||||||
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 30, 50, -60 )
|
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 30, 50, -60 )
|
||||||
mesh = SubResource( 4 )
|
mesh = SubResource( 1 )
|
||||||
material/0 = null
|
material/0 = null
|
||||||
|
File diff suppressed because one or more lines are too long
11
Shaders/PillScreenRenderer.shader
Normal file
11
Shaders/PillScreenRenderer.shader
Normal 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);
|
||||||
|
}
|
@ -63,7 +63,7 @@ _global_script_class_icons={
|
|||||||
[application]
|
[application]
|
||||||
|
|
||||||
config/name="retrace"
|
config/name="retrace"
|
||||||
run/main_scene="res://Level/PathTestWorld.tscn"
|
run/main_scene="res://Level/World.tscn"
|
||||||
config/icon="res://icon.png"
|
config/icon="res://icon.png"
|
||||||
|
|
||||||
[autoload]
|
[autoload]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user