mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 16:46:00 +00:00
Screen fader
This commit is contained in:
@@ -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) {
|
||||
|
@@ -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 {
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user