Screen fader

This commit is contained in:
Martin 2022-12-31 13:32:40 +01:00
parent 50c44b7d64
commit 756e9db049
10 changed files with 494 additions and 91 deletions

View File

@ -11,7 +11,7 @@
"speed": 1,
"wrapMode": 1,
"enableTrsBlending": false,
"_duration": 0.3333333333333333,
"_duration": 1,
"_hash": 500763545,
"_tracks": [
{
@ -68,7 +68,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -113,7 +113,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -158,7 +158,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -203,7 +203,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{

View File

@ -11,7 +11,7 @@
"speed": 1,
"wrapMode": 1,
"enableTrsBlending": false,
"_duration": 0.3333333333333333,
"_duration": 1,
"_hash": 500763545,
"_tracks": [
{
@ -68,7 +68,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -80,10 +80,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
},
{
"__type__": "cc.RealKeyframeValue",
@ -94,10 +91,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
}
],
"preExtrapolation": 1,
@ -113,7 +107,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -125,10 +119,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
},
{
"__type__": "cc.RealKeyframeValue",
@ -139,10 +130,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
}
],
"preExtrapolation": 1,
@ -158,7 +146,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -170,10 +158,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
},
{
"__type__": "cc.RealKeyframeValue",
@ -184,10 +169,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
}
],
"preExtrapolation": 1,
@ -203,7 +185,7 @@
"__type__": "cc.RealCurve",
"_times": [
0,
0.3333333333333333
1
],
"_values": [
{
@ -215,10 +197,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
},
{
"__type__": "cc.RealKeyframeValue",
@ -229,10 +208,7 @@
"rightTangentWeight": 1,
"leftTangent": 0,
"leftTangentWeight": 1,
"easingMethod": 0,
"__editorExtras__": {
"tangentMode": 0
}
"easingMethod": 0
}
],
"preExtrapolation": 1,

View File

@ -0,0 +1,200 @@
[
{
"__type__": "cc.Prefab",
"_name": "ScreenFader",
"_objFlags": 0,
"_native": "",
"data": {
"__id__": 1
},
"optimizationPolicy": 0,
"persistent": false,
"asyncLoadAssets": false
},
{
"__type__": "cc.Node",
"_name": "ScreenFader",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": null,
"_children": [],
"_active": false,
"_components": [
{
"__id__": 2
},
{
"__id__": 4
},
{
"__id__": 6
},
{
"__id__": 8
}
],
"_prefab": {
"__id__": 10
},
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 8388608,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": ""
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 3
},
"_contentSize": {
"__type__": "cc.Size",
"width": 640,
"height": 960
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "6enxQ1KzBEvqOWCGMWj4kp"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 5
},
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0a917d5c-2810-46e1-8332-63f00395d63a@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": {
"__uuid__": "c4872559-07b2-44e5-9613-5f22506b1989",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "ecD8Nkb9dPaJ9N91FsykR9"
},
{
"__type__": "f9bdcLpmMdIgqWNOgetdMv1",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 7
},
"animation": {
"__id__": 8
},
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "83zvKO0AFLuLrQVHfpw7yG"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 1
},
"_enabled": true,
"__prefab": {
"__id__": 9
},
"playOnLoad": false,
"_clips": [
{
"__uuid__": "62a2bbe7-81e3-4f5d-85a7-e6ed018e783a",
"__expectedType__": "cc.AnimationClip"
},
{
"__uuid__": "03c7a83d-bc15-48b9-b343-7c930ab88d2c",
"__expectedType__": "cc.AnimationClip"
}
],
"_defaultClip": null,
"_id": ""
},
{
"__type__": "cc.CompPrefabInfo",
"fileId": "b0C4L0T+pGSYu09o8CU1xS"
},
{
"__type__": "cc.PrefabInfo",
"root": {
"__id__": 1
},
"asset": {
"__id__": 0
},
"fileId": "94InV0g5lPEL9T8UP6gS83"
}
]

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.40",
"importer": "prefab",
"imported": true,
"uuid": "7d9555ec-6f1b-492e-96e2-574becb17c9d",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "ScreenFader"
}
}

View File

@ -27,11 +27,11 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 119
"__id__": 124
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 124
"__id__": 129
},
"_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f"
},
@ -245,28 +245,31 @@
},
{
"__id__": 60
},
{
"__id__": 115
}
],
"_active": true,
"_components": [
{
"__id__": 115
"__id__": 120
},
{
"__id__": 116
"__id__": 121
},
{
"__id__": 117
"__id__": 122
},
{
"__id__": 118
"__id__": 123
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 319.99999999999994,
"y": 480.00000000000006,
"y": 479.99999999999994,
"z": 0
},
"_lrot": {
@ -1636,7 +1639,7 @@
"_lpos": {
"__type__": "cc.Vec3",
"x": -320,
"y": 480.0000000000001,
"y": 480,
"z": -1000
},
"_lrot": {
@ -3388,7 +3391,7 @@
"_priority": 1073741824,
"_fov": 45,
"_fovAxis": 0,
"_orthoHeight": 480.00000000000006,
"_orthoHeight": 480,
"_near": 0,
"_far": 2000,
"_color": {
@ -3418,6 +3421,158 @@
"_trackingType": 0,
"_id": "63WIch3o5BEYRlXzTT0oWc"
},
{
"__type__": "cc.Node",
"_name": "ScreenFader",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 12
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 116
},
{
"__id__": 117
},
{
"__id__": 118
},
{
"__id__": 119
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 8388608,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "216gAM+7NOIJYva3wm2GR4"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 115
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 640,
"height": 960
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "52N4jnMHlOvoV/K03D6Uja"
},
{
"__type__": "cc.Sprite",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 115
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 0,
"g": 0,
"b": 0,
"a": 255
},
"_spriteFrame": {
"__uuid__": "0a917d5c-2810-46e1-8332-63f00395d63a@f9941",
"__expectedType__": "cc.SpriteFrame"
},
"_type": 0,
"_fillType": 0,
"_sizeMode": 0,
"_fillCenter": {
"__type__": "cc.Vec2",
"x": 0,
"y": 0
},
"_fillStart": 0,
"_fillRange": 0,
"_isTrimmedMode": true,
"_useGrayscale": false,
"_atlas": {
"__uuid__": "c4872559-07b2-44e5-9613-5f22506b1989",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": "779DLAb3ZAL5JKWJfxp7F3"
},
{
"__type__": "f9bdcLpmMdIgqWNOgetdMv1",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 115
},
"_enabled": true,
"__prefab": null,
"animation": {
"__id__": 119
},
"_id": "27V5fDDRZFBoMDbhP1iFO6"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 115
},
"_enabled": true,
"__prefab": null,
"playOnLoad": false,
"_clips": [
{
"__uuid__": "62a2bbe7-81e3-4f5d-85a7-e6ed018e783a",
"__expectedType__": "cc.AnimationClip"
},
{
"__uuid__": "03c7a83d-bc15-48b9-b343-7c930ab88d2c",
"__expectedType__": "cc.AnimationClip"
}
],
"_defaultClip": null,
"_id": "a2TKXTESlJfLW4cwYpnrNl"
},
{
"__type__": "cc.UITransform",
"_name": "",
@ -3467,8 +3622,8 @@
"_target": null,
"_left": -5.684341886080802e-14,
"_right": 0,
"_top": 1.1368683772161603e-13,
"_bottom": 5.684341886080802e-14,
"_top": 0,
"_bottom": -5.684341886080802e-14,
"_horizontalCenter": 0,
"_verticalCenter": 0,
"_isAbsLeft": true,
@ -3530,6 +3685,9 @@
"__id__": 101
},
"gameAudioAdapter": null,
"screenFader": {
"__id__": 118
},
"_id": "3a9z1bqlFCGL4/WyDwU4L5"
},
{
@ -3537,10 +3695,10 @@
"fileId": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f",
"targetOverrides": [
{
"__id__": 120
"__id__": 125
},
{
"__id__": 122
"__id__": 127
}
],
"nestedPrefabInstanceRoots": [
@ -3558,7 +3716,7 @@
{
"__type__": "cc.TargetOverrideInfo",
"source": {
"__id__": 118
"__id__": 123
},
"sourceInfo": null,
"propertyPath": [
@ -3568,7 +3726,7 @@
"__id__": 34
},
"targetInfo": {
"__id__": 121
"__id__": 126
}
},
{
@ -3580,7 +3738,7 @@
{
"__type__": "cc.TargetOverrideInfo",
"source": {
"__id__": 118
"__id__": 123
},
"sourceInfo": null,
"propertyPath": [
@ -3590,7 +3748,7 @@
"__id__": 13
},
"targetInfo": {
"__id__": 123
"__id__": 128
}
},
{
@ -3602,19 +3760,19 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 125
"__id__": 130
},
"shadows": {
"__id__": 126
"__id__": 131
},
"_skybox": {
"__id__": 127
"__id__": 132
},
"fog": {
"__id__": 128
"__id__": 133
},
"octree": {
"__id__": 129
"__id__": 134
}
},
{

View File

@ -24,11 +24,11 @@
"_active": true,
"_components": [],
"_prefab": {
"__id__": 81
"__id__": 83
},
"autoReleaseAssets": false,
"_globals": {
"__id__": 82
"__id__": 84
},
"_id": "1a3bccb5-bbb7-4058-846c-ed41b52415b0"
},
@ -190,12 +190,6 @@
],
"_active": true,
"_components": [
{
"__id__": 76
},
{
"__id__": 77
},
{
"__id__": 78
},
@ -204,6 +198,12 @@
},
{
"__id__": 80
},
{
"__id__": 81
},
{
"__id__": 82
}
],
"_prefab": null,
@ -2417,17 +2417,24 @@
"__type__": "cc.Node",
"_name": "ScreenFader",
"_objFlags": 0,
"__editorExtras__": {},
"_parent": {
"__id__": 10
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 74
},
{
"__id__": 75
},
{
"__id__": 76
},
{
"__id__": 77
}
],
"_prefab": null,
@ -2457,7 +2464,7 @@
"y": 0,
"z": 0
},
"_id": "94InV0g5lPEL9T8UP6gS83"
"_id": "71qF2ggGpMcLF94AUlql0u"
},
{
"__type__": "cc.UITransform",
@ -2478,7 +2485,7 @@
"x": 0.5,
"y": 0.5
},
"_id": "8eB/xQWtlBM6LZmo5nize7"
"_id": "7bzTWH09FA4oZ0VugCpmQ3"
},
{
"__type__": "cc.Sprite",
@ -2519,7 +2526,44 @@
"__uuid__": "c4872559-07b2-44e5-9613-5f22506b1989",
"__expectedType__": "cc.SpriteAtlas"
},
"_id": "cfe3CQC7dFSIe0kaPgVHQa"
"_id": "cdmu4EBtJM6rWXHQdGNEN0"
},
{
"__type__": "f9bdcLpmMdIgqWNOgetdMv1",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 73
},
"_enabled": true,
"__prefab": null,
"animation": {
"__id__": 77
},
"_id": "0bBTtYUmtAGoBYF+/lNGeL"
},
{
"__type__": "cc.Animation",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 73
},
"_enabled": true,
"__prefab": null,
"playOnLoad": false,
"_clips": [
{
"__uuid__": "62a2bbe7-81e3-4f5d-85a7-e6ed018e783a",
"__expectedType__": "cc.AnimationClip"
},
{
"__uuid__": "03c7a83d-bc15-48b9-b343-7c930ab88d2c",
"__expectedType__": "cc.AnimationClip"
}
],
"_defaultClip": null,
"_id": "6cOISS7ZBL7ZILXit/Dlrm"
},
{
"__type__": "cc.UITransform",
@ -2607,6 +2651,9 @@
"modalWindowManager": {
"__id__": 72
},
"screenFader": {
"__id__": 76
},
"_id": "4cQFnvx1xB65sFsTPGRrB7"
},
{
@ -2643,19 +2690,19 @@
{
"__type__": "cc.SceneGlobals",
"ambient": {
"__id__": 83
},
"shadows": {
"__id__": 84
},
"_skybox": {
"__id__": 85
},
"fog": {
"shadows": {
"__id__": 86
},
"octree": {
"_skybox": {
"__id__": 87
},
"fog": {
"__id__": 88
},
"octree": {
"__id__": 89
}
},
{

View File

@ -1,6 +1,7 @@
import { Camera, Component, KeyCode, Prefab, Vec2, _decorator } from "cc";
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
import { delay } from "../Services/Utils/AsyncUtils";
import { OpenCloseAnimator } from "../Utils/OpenCloseAnimator";
import { GameAudioAdapter } from "./Audio/GameAudioAdapter";
import { Background } from "./Background/Background";
import { MagnetCollisionSystem } from "./Collision/MagnetCollisionSystem";
@ -50,6 +51,7 @@ export class Game extends Component {
@property(Background) private background: Background;
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
@property(GameAudioAdapter) private gameAudioAdapter: GameAudioAdapter;
@property(OpenCloseAnimator) private screenFader: OpenCloseAnimator;
private playerCollisionSystem: PlayerCollisionSystem;
private haloProjectileLauncher: HaloProjectileLauncher;
@ -73,6 +75,9 @@ export class Game extends Component {
public start(): void {
Game.instance = this;
this.gamePauser.pause();
this.screenFader.init();
this.screenFader.node.active = true;
}
public async playGame(
@ -169,6 +174,7 @@ export class Game extends Component {
this.haloProjectileLauncher
);
this.gamePauser.resume();
this.screenFader.playClose();
while (!this.gameResult.hasExitManually && this.player.Health.IsAlive) await delay(100);
if (!this.gameResult.hasExitManually) {

View File

@ -42,8 +42,6 @@ export class ProjectileLauncher extends Component implements IProjectileLauncher
this.projectilePierces = projectilePierces;
this.projectilePool = new ObjectPool<Projectile>(this.projectilePrefab, this.node, 6, "Projectile");
console.log("DAMAGE " + JSON.stringify((<Projectile>this.projectilePrefab.data).Damage));
}
public gameTick(deltaTime: number): void {

View File

@ -1,6 +1,7 @@
import { Component, _decorator } from "cc";
import { ModalWindowManager } from "../Services/ModalWindowSystem/ModalWindowManager";
import { UIButton } from "../Services/UI/Button/UIButton";
import { OpenCloseAnimator } from "../Utils/OpenCloseAnimator";
import { GameRunner } from "./GameRunner";
import { MenuModalLauncher } from "./ModalWindows/MenuModalLauncher";
@ -12,6 +13,7 @@ export class Menu extends Component {
@property(UIButton) private upgradeBtn: UIButton;
@property(UIButton) private audioSettingsBtn: UIButton;
@property(ModalWindowManager) private modalWindowManager: ModalWindowManager;
@property(OpenCloseAnimator) private screenFader: OpenCloseAnimator;
private menuModalLauncher: MenuModalLauncher;
@ -21,9 +23,13 @@ export class Menu extends Component {
this.audioSettingsBtn.InteractedEvent.on(this.openAudioSettingsWindow, this);
this.menuModalLauncher = new MenuModalLauncher(this.modalWindowManager);
this.screenFader.init();
this.screenFader.node.active = false;
}
private startGame(): void {
this.screenFader.playOpen();
GameRunner.Instance.playGame();
}

View File

@ -12,8 +12,7 @@ export class OpenCloseAnimator extends Component {
private openDuration = 0;
private closeDuration = 0;
public start(): void {
this.node.active = false;
public init(): void {
this.openDuration = this.animation.getState(this.openStateName).duration;
this.closeDuration = this.animation.getState(this.closeStateName).duration;
}
@ -21,13 +20,13 @@ export class OpenCloseAnimator extends Component {
public async playOpen(): Promise<void> {
this.node.active = true;
this.animation.play(this.openStateName);
await delay(this.openDuration);
await delay(this.openDuration * 1000);
}
public async playClose(): Promise<void> {
this.node.active = true;
this.animation.play(this.openStateName);
await delay(this.closeDuration);
this.animation.play(this.closeStateName);
await delay(this.closeDuration * 1000);
this.node.active = false;
}
}