Game files
This commit is contained in:
28
Scripts/Logic/NightManager.gd
Normal file
28
Scripts/Logic/NightManager.gd
Normal file
@@ -0,0 +1,28 @@
|
||||
class_name NightManager
|
||||
extends Node
|
||||
|
||||
signal hour_changed(new_hour)
|
||||
signal night_completed
|
||||
|
||||
@export var seconds_per_hour := 10.0 # FNAF-ish
|
||||
@export var start_hour := 12
|
||||
@export var end_hour := 6
|
||||
|
||||
var current_hour := start_hour
|
||||
var hour_timer := 0.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
hour_timer += delta
|
||||
if hour_timer >= seconds_per_hour:
|
||||
hour_timer = 0.0
|
||||
_advance_hour()
|
||||
|
||||
func _advance_hour() -> void:
|
||||
if current_hour == 12:
|
||||
current_hour = 1
|
||||
else:
|
||||
current_hour += 1
|
||||
emit_signal("hour_changed", current_hour)
|
||||
|
||||
if current_hour >= end_hour:
|
||||
emit_signal("night_completed")
|
||||
1
Scripts/Logic/NightManager.gd.uid
Normal file
1
Scripts/Logic/NightManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://ttgieweerpay
|
||||
47
Scripts/Logic/cCameraManager.gd
Normal file
47
Scripts/Logic/cCameraManager.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
# CameraSystem.gd
|
||||
extends Node
|
||||
class_name CameraManager
|
||||
|
||||
@export var display: TextureRect
|
||||
var current_room: Room
|
||||
@export var rooms: Array[Room] = []
|
||||
|
||||
func select_room(room_id: Global.LocationID):
|
||||
for room in rooms:
|
||||
print(room, room.room_id)
|
||||
print("Comparing room id: ", room.room_id, " With: ", room_id)
|
||||
if room.room_id == room_id:
|
||||
current_room = room
|
||||
break
|
||||
|
||||
func force_room(index: int):
|
||||
if index >= 0 and index < rooms.size():
|
||||
current_room = rooms[index]
|
||||
else:
|
||||
print("force_room: invalid index ", index)
|
||||
|
||||
func _process(_delta):
|
||||
if current_room == null:
|
||||
current_room = rooms[0]
|
||||
if current_room:
|
||||
current_room._process(_delta)
|
||||
display.texture = current_room.getTexture()
|
||||
|
||||
|
||||
func _on_cam_pressed(id:int) -> void:
|
||||
print("Camera Change with: ", id)
|
||||
force_room(id)
|
||||
return
|
||||
var eRoom: Global.LocationID
|
||||
match id:
|
||||
0: eRoom = Global.LocationID.POWER_STATION
|
||||
1: eRoom = Global.LocationID.DINING_AREA
|
||||
2: eRoom = Global.LocationID.WEST_HALL
|
||||
3: eRoom = Global.LocationID.EAST_HALL
|
||||
4: eRoom = Global.LocationID.SUPPLY_CLOSET
|
||||
5: eRoom = Global.LocationID.BACKSTAGE
|
||||
6: eRoom = Global.LocationID.LIVING_AREA
|
||||
7: eRoom = Global.LocationID.OFFICE_LEFT_DOOR
|
||||
8: eRoom = Global.LocationID.OFFICE_RIGHT_DOOR
|
||||
9: eRoom = Global.LocationID.OFFICE
|
||||
select_room(eRoom)
|
||||
1
Scripts/Logic/cCameraManager.gd.uid
Normal file
1
Scripts/Logic/cCameraManager.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cxj3fa512gs6r
|
||||
47
Scripts/Logic/cPlayerCamera.gd
Normal file
47
Scripts/Logic/cPlayerCamera.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Camera2D
|
||||
|
||||
var screenWidth = ProjectSettings.get_setting("display/window/size/viewport_width")
|
||||
var screenHeight = ProjectSettings.get_setting("display/window/size/viewport_height")
|
||||
|
||||
@export var scrollArea : int
|
||||
@export var scrollSpeed : float
|
||||
@export var scrollDivisions : int
|
||||
@export var officeSprite : Sprite2D
|
||||
|
||||
var officeWidth : int
|
||||
var officeHeight : int
|
||||
var distance : float
|
||||
var divisionSize : float
|
||||
var speedMultiplier : float
|
||||
|
||||
func _ready() -> void:
|
||||
make_current()
|
||||
print("Camera Running")
|
||||
if scrollDivisions == 0:
|
||||
scrollDivisions = 1
|
||||
divisionSize = scrollArea / scrollDivisions
|
||||
if officeSprite:
|
||||
officeWidth = officeSprite.texture.get_width() * officeSprite.scale.x
|
||||
position.x = officeSprite.position.x + (officeWidth - screenWidth) / 2
|
||||
officeHeight = officeSprite.texture.get_height() * officeSprite.scale.y
|
||||
position.y = officeSprite.position.y + (officeHeight - screenHeight) / 2
|
||||
|
||||
func _process(delta : float) -> void:
|
||||
if get_local_mouse_position().x < scrollArea:
|
||||
distance = scrollArea - get_local_mouse_position().x
|
||||
getSpeedMultiplier()
|
||||
position.x -= (scrollSpeed * speedMultiplier) * delta
|
||||
if get_local_mouse_position().x > screenWidth - scrollArea:
|
||||
distance = get_local_mouse_position().x - (screenWidth - scrollArea)
|
||||
getSpeedMultiplier()
|
||||
position.x += (scrollSpeed * speedMultiplier) * delta
|
||||
|
||||
if officeSprite:
|
||||
if position.x < officeSprite.position.x:
|
||||
position.x = officeSprite.position.x
|
||||
if (position.x - officeSprite.position.x) + screenWidth > officeWidth:
|
||||
position.x = officeWidth - screenWidth + officeSprite.position.x
|
||||
|
||||
func getSpeedMultiplier() -> void:
|
||||
speedMultiplier = clamp(floor(distance / divisionSize) + 1, 1, scrollDivisions)
|
||||
speedMultiplier /= scrollDivisions
|
||||
1
Scripts/Logic/cPlayerCamera.gd.uid
Normal file
1
Scripts/Logic/cPlayerCamera.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c14ey58hfx7i8
|
||||
55
Scripts/Logic/cRoom.gd
Normal file
55
Scripts/Logic/cRoom.gd
Normal file
@@ -0,0 +1,55 @@
|
||||
extends Node
|
||||
class_name Room
|
||||
|
||||
#@export var visual: TextureRect
|
||||
|
||||
# One entry per valid combination
|
||||
# Key = sorted list of enemy IDs + their pose index
|
||||
#@export var render_map: Dictionary
|
||||
|
||||
@export var enemies: Array[cCharacter] # all AI that *could* appear here
|
||||
@export var room_id: Global.LocationID
|
||||
var last_key := ""
|
||||
var texture: Texture2D
|
||||
var render_map: Dictionary
|
||||
|
||||
#func _process(_delta):
|
||||
#var key := _build_render_key()
|
||||
#if key == last_key:
|
||||
#return
|
||||
#
|
||||
#last_key = key
|
||||
#
|
||||
#
|
||||
#if render_map.has(key):
|
||||
#visual.texture = render_map[key]
|
||||
#else:
|
||||
#visual.texture = null # or fallback
|
||||
|
||||
func _process(_delta):
|
||||
var key := _build_render_key()
|
||||
if key == null: texture = render_map[""]
|
||||
|
||||
if key == last_key:
|
||||
return
|
||||
#
|
||||
last_key = key
|
||||
#
|
||||
if render_map.has(key):
|
||||
texture = render_map[key]
|
||||
else:
|
||||
texture = render_map["default"]
|
||||
|
||||
func getTexture() -> Texture2D:
|
||||
return texture
|
||||
|
||||
func _build_render_key() -> String:
|
||||
var entries := []
|
||||
|
||||
for enemy in enemies:
|
||||
var presence : int = enemy.get_room_presence(room_id)
|
||||
if presence >= 0:
|
||||
entries.append("%s:%d" % [enemy.name, presence])
|
||||
|
||||
entries.sort()
|
||||
return "|".join(entries)
|
||||
1
Scripts/Logic/cRoom.gd.uid
Normal file
1
Scripts/Logic/cRoom.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://bh0j1ffo2peo0
|
||||
85
Scripts/Logic/video_distortion.gdshader
Normal file
85
Scripts/Logic/video_distortion.gdshader
Normal file
@@ -0,0 +1,85 @@
|
||||
shader_type canvas_item;
|
||||
|
||||
uniform sampler2D SCREEN_TEXTURE : hint_screen_texture, filter_linear_mipmap;
|
||||
uniform float amount : hint_range(0.0, 1.0) = 0.5;
|
||||
uniform float seed = 0.0;
|
||||
uniform float line_density : hint_range(0.0, 1.0) = 0.4;
|
||||
uniform float offset_mul : hint_range(0.0, 2.0) = 1.0;
|
||||
|
||||
uniform vec2 screen_offset = vec2(0.0);
|
||||
uniform vec2 screen_bend_amount = vec2(0.02, 0.02);
|
||||
|
||||
float hash1d(float p) {
|
||||
return fract(sin(127.1 * p) * 43758.5453123);
|
||||
}
|
||||
|
||||
void fragment() {
|
||||
/* ===============================
|
||||
Coordinate setup
|
||||
================================ */
|
||||
|
||||
vec2 uv = SCREEN_UV;
|
||||
uv += screen_offset;
|
||||
|
||||
// Screen bend (CRT-like)
|
||||
vec2 normal_uv = uv * 2.0 - 1.0;
|
||||
vec2 bend_add;
|
||||
bend_add.x = cos(1.5707963 * normal_uv.y) * normal_uv.x - normal_uv.x * 1.5;
|
||||
bend_add.y = cos(1.5707963 * normal_uv.x) * normal_uv.y - normal_uv.y * 1.5;
|
||||
uv += bend_add * screen_bend_amount;
|
||||
|
||||
vec4 base_color = texture(SCREEN_TEXTURE, uv);
|
||||
|
||||
vec2 virtual_coords = uv * 100.0;
|
||||
|
||||
/* ===============================
|
||||
Row-based randomization
|
||||
================================ */
|
||||
|
||||
float row_rand = hash1d(seed + floor(virtual_coords.y * 0.1));
|
||||
float y_mul = mix(0.05, 0.8, row_rand * row_rand);
|
||||
float rand_strength = hash1d(floor(virtual_coords.y * y_mul) + 100.0 + row_rand);
|
||||
|
||||
float final_amount = 0.0;
|
||||
float coord_add = 0.0;
|
||||
|
||||
if (rand_strength > (1.0 - line_density)) {
|
||||
float distort_amount = 0.15;
|
||||
|
||||
final_amount = amount * (
|
||||
0.5 +
|
||||
(hash1d(floor(virtual_coords.y * y_mul) + 1273.0 + floor(amount * 4.0)) * 2.0 - 1.0) * 0.5
|
||||
);
|
||||
|
||||
float ra = hash1d(floor(virtual_coords.y)) * 2.0 - 1.0;
|
||||
coord_add = ra * distort_amount * final_amount;
|
||||
coord_add += (hash1d(floor(virtual_coords.x * 0.25)) * 2.0 - 1.0) * distort_amount * 0.4;
|
||||
coord_add *= offset_mul;
|
||||
}
|
||||
|
||||
/* ===============================
|
||||
Intensity weighting
|
||||
================================ */
|
||||
|
||||
float intensity = dot(base_color.rgb, vec3(0.3, 0.58, 0.12));
|
||||
intensity = clamp(intensity, 0.0, 1.0);
|
||||
|
||||
float dual_intensity = abs(intensity * 2.0 - 1.0);
|
||||
dual_intensity *= dual_intensity;
|
||||
|
||||
/* ===============================
|
||||
Distortion sampling
|
||||
================================ */
|
||||
|
||||
vec4 samp1 = texture(SCREEN_TEXTURE, uv + vec2(coord_add * -0.65 * dual_intensity, 0.0));
|
||||
vec4 samp2 = texture(SCREEN_TEXTURE, uv + vec2(coord_add * 1.0 * dual_intensity, 0.0));
|
||||
vec4 distort_color = mix(samp1, samp2, 0.5);
|
||||
|
||||
/* ===============================
|
||||
Final output
|
||||
================================ */
|
||||
|
||||
float mix_amount = dual_intensity * final_amount;
|
||||
COLOR = mix(base_color, distort_color, mix_amount)
|
||||
+ vec4(vec3(intensity * final_amount * 0.05), 1.0);
|
||||
}
|
||||
1
Scripts/Logic/video_distortion.gdshader.uid
Normal file
1
Scripts/Logic/video_distortion.gdshader.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://dy4tffth3v12b
|
||||
Reference in New Issue
Block a user