Переходы между днями.
This commit is contained in:
parent
7663a741e4
commit
71502b0653
7 changed files with 128 additions and 6 deletions
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://c1abgp6quvo3o"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://c1abgp6quvo3o"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_a6v5r"]
|
||||
[ext_resource type="Script" path="res://scripts/Day.cs" id="1_cko08"]
|
||||
[ext_resource type="PackedScene" uid="uid://coogmsw6rsdun" path="res://prefabs/Door.tscn" id="2_qedp5"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_t4e54"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://dsgqo48qikwsn" path="res://resources/sprites/npcs/cock.tres" id="4_ephn1"]
|
||||
|
@ -50,6 +51,8 @@ stream_count = 1
|
|||
stream_0 = ExtResource("9_43nb0")
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource("1_cko08")
|
||||
NextScene = "Day2"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_a6v5r")
|
||||
|
@ -251,3 +254,11 @@ Speed = 100.0
|
|||
stream = SubResource("AudioStreamPlaylist_7838k")
|
||||
autoplay = true
|
||||
bus = &"Music"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
z_index = 11
|
||||
offset_left = 894.0
|
||||
offset_top = 115.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 355.0
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://bpnc0noa6do5m"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://bpnc0noa6do5m"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Day.cs" id="1_6vltc"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_j1x6m"]
|
||||
[ext_resource type="PackedScene" uid="uid://coogmsw6rsdun" path="res://prefabs/Door.tscn" id="2_mm217"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_w8l5u"]
|
||||
|
@ -50,6 +51,8 @@ stream_count = 1
|
|||
stream_0 = ExtResource("10_x821k")
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource("1_6vltc")
|
||||
NextScene = "Day3"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_j1x6m")
|
||||
|
@ -250,3 +253,11 @@ Speed = 100.0
|
|||
stream = SubResource("AudioStreamPlaylist_7838k")
|
||||
autoplay = true
|
||||
bus = &"Music"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
z_index = 11
|
||||
offset_left = 894.0
|
||||
offset_top = 115.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 355.0
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://dydhxm41f4kqu"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://dydhxm41f4kqu"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Day.cs" id="1_6ouk8"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_m7xoy"]
|
||||
[ext_resource type="PackedScene" uid="uid://coogmsw6rsdun" path="res://prefabs/Door.tscn" id="2_72qyp"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_s2s8w"]
|
||||
|
@ -50,6 +51,8 @@ stream_count = 1
|
|||
stream_0 = ExtResource("10_ouee8")
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource("1_6ouk8")
|
||||
NextScene = "Day4"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_m7xoy")
|
||||
|
@ -250,3 +253,11 @@ Speed = 100.0
|
|||
stream = SubResource("AudioStreamPlaylist_7838k")
|
||||
autoplay = true
|
||||
bus = &"Music"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
z_index = 11
|
||||
offset_left = 894.0
|
||||
offset_top = 115.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 355.0
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://cxvsyen213g1o"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://cxvsyen213g1o"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Day.cs" id="1_gb313"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_ngvqc"]
|
||||
[ext_resource type="PackedScene" uid="uid://coogmsw6rsdun" path="res://prefabs/Door.tscn" id="2_kyojn"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_vhb2r"]
|
||||
|
@ -50,6 +51,8 @@ stream_count = 1
|
|||
stream_0 = ExtResource("10_vlywc")
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource("1_gb313")
|
||||
NextScene = "Day5"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_ngvqc")
|
||||
|
@ -250,3 +253,11 @@ Speed = 100.0
|
|||
stream = SubResource("AudioStreamPlaylist_7838k")
|
||||
autoplay = true
|
||||
bus = &"Music"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
z_index = 11
|
||||
offset_left = 894.0
|
||||
offset_top = 115.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 355.0
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
[gd_scene load_steps=23 format=3 uid="uid://10ew1xa1pxm2"]
|
||||
[gd_scene load_steps=24 format=3 uid="uid://10ew1xa1pxm2"]
|
||||
|
||||
[ext_resource type="Script" path="res://scripts/Day.cs" id="1_ii8yu"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5baxx5o21qy1" path="res://resources/sprites/Sub/Sub.png" id="1_p4jcj"]
|
||||
[ext_resource type="PackedScene" uid="uid://coogmsw6rsdun" path="res://prefabs/Door.tscn" id="2_o6uwl"]
|
||||
[ext_resource type="PackedScene" uid="uid://c5ndo6b0unkst" path="res://prefabs/NPC.tscn" id="3_4c2bg"]
|
||||
|
@ -50,6 +51,8 @@ stream_count = 1
|
|||
stream_0 = ExtResource("10_bwdem")
|
||||
|
||||
[node name="Test" type="Node2D"]
|
||||
script = ExtResource("1_ii8yu")
|
||||
NextScene = "Menu"
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_p4jcj")
|
||||
|
@ -245,3 +248,11 @@ Speed = 100.0
|
|||
stream = SubResource("AudioStreamPlaylist_7838k")
|
||||
autoplay = true
|
||||
bus = &"Music"
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
z_index = 11
|
||||
offset_left = 894.0
|
||||
offset_top = 115.0
|
||||
offset_right = 1214.0
|
||||
offset_bottom = 355.0
|
||||
color = Color(0, 0, 0, 0)
|
||||
|
|
67
scripts/Day.cs
Normal file
67
scripts/Day.cs
Normal file
|
@ -0,0 +1,67 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Day : Node2D
|
||||
{
|
||||
[Export] public string NextScene;
|
||||
|
||||
private enum State
|
||||
{
|
||||
Default,
|
||||
TransitionIn,
|
||||
TransitionOut
|
||||
}
|
||||
|
||||
private State _state = State.TransitionIn;
|
||||
|
||||
private Player _player;
|
||||
private ColorRect _colorRect;
|
||||
private AudioStreamPlayer _music;
|
||||
|
||||
private double _transitionTimeout = 0;
|
||||
|
||||
// Called when the node enters the scene tree for the first time.
|
||||
public override void _Ready()
|
||||
{
|
||||
_player = (Player)FindChild("Player");
|
||||
_colorRect = (ColorRect)FindChild("ColorRect");
|
||||
_music = (AudioStreamPlayer)FindChild("Music");
|
||||
_colorRect.Color = new Color(0, 0, 0, 1f);
|
||||
_music.VolumeDb = -40;
|
||||
_player.CurrentState = Player.State.Wait;
|
||||
}
|
||||
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (_state == State.TransitionIn)
|
||||
{
|
||||
if (_transitionTimeout <= 2)
|
||||
{
|
||||
_transitionTimeout += delta;
|
||||
_music.VolumeDb = Mathf.Lerp(-40, 0, (float)_transitionTimeout/2);
|
||||
_colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(1, 0, (float)_transitionTimeout/2));
|
||||
}
|
||||
else
|
||||
{
|
||||
_state = State.Default;
|
||||
_player.CurrentState = Player.State.Normal;
|
||||
_transitionTimeout = 0;
|
||||
}
|
||||
}
|
||||
if (_state == State.TransitionOut)
|
||||
{
|
||||
_player.CurrentState = Player.State.Wait;
|
||||
if (_transitionTimeout <= 2)
|
||||
{
|
||||
_transitionTimeout += delta;
|
||||
_music.VolumeDb = Mathf.Lerp(0, -40, (float)_transitionTimeout/2);
|
||||
_colorRect.Color = new Color(0, 0, 0, Mathf.Lerp(0, 1, (float)_transitionTimeout/2));
|
||||
}
|
||||
else
|
||||
{
|
||||
GetNode<SceneManager>("/root/SceneManager").SwitchScene("Day1");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ public partial class Player : CharacterBody2D
|
|||
public State CurrentState
|
||||
{
|
||||
get => _state;
|
||||
private set
|
||||
set
|
||||
{
|
||||
_sprite.Play("default");
|
||||
switch (value)
|
||||
|
|
Loading…
Add table
Reference in a new issue