mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2024-12-25 11:18:54 +00:00
AppRoot loading
This commit is contained in:
parent
6961e48c15
commit
d32340471b
@ -27,11 +27,11 @@
|
||||
"_active": true,
|
||||
"_components": [],
|
||||
"_prefab": {
|
||||
"__id__": 104
|
||||
"__id__": 107
|
||||
},
|
||||
"autoReleaseAssets": false,
|
||||
"_globals": {
|
||||
"__id__": 109
|
||||
"__id__": 112
|
||||
},
|
||||
"_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f"
|
||||
},
|
||||
@ -245,21 +245,24 @@
|
||||
},
|
||||
{
|
||||
"__id__": 62
|
||||
},
|
||||
{
|
||||
"__id__": 100
|
||||
}
|
||||
],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 100
|
||||
},
|
||||
{
|
||||
"__id__": 101
|
||||
},
|
||||
{
|
||||
"__id__": 102
|
||||
},
|
||||
{
|
||||
"__id__": 103
|
||||
},
|
||||
{
|
||||
"__id__": 104
|
||||
},
|
||||
{
|
||||
"__id__": 105
|
||||
},
|
||||
{
|
||||
"__id__": 106
|
||||
}
|
||||
],
|
||||
"_prefab": null,
|
||||
@ -2823,6 +2826,111 @@
|
||||
},
|
||||
"_id": "bau/7eItRFrKKoAZZb/uYL"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Node",
|
||||
"_name": "BlackScreen",
|
||||
"_objFlags": 0,
|
||||
"_parent": {
|
||||
"__id__": 12
|
||||
},
|
||||
"_children": [],
|
||||
"_active": true,
|
||||
"_components": [
|
||||
{
|
||||
"__id__": 101
|
||||
},
|
||||
{
|
||||
"__id__": 102
|
||||
}
|
||||
],
|
||||
"_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": 33554432,
|
||||
"_euler": {
|
||||
"__type__": "cc.Vec3",
|
||||
"x": 0,
|
||||
"y": 0,
|
||||
"z": 0
|
||||
},
|
||||
"_id": "f1qlIT/nRNuIKxwJCYVTPM"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 100
|
||||
},
|
||||
"_enabled": true,
|
||||
"__prefab": null,
|
||||
"_contentSize": {
|
||||
"__type__": "cc.Size",
|
||||
"width": 1000,
|
||||
"height": 1000
|
||||
},
|
||||
"_anchorPoint": {
|
||||
"__type__": "cc.Vec2",
|
||||
"x": 0.5,
|
||||
"y": 0.5
|
||||
},
|
||||
"_id": "fdOZJb68xNc5vijRoOMRnI"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.Sprite",
|
||||
"_name": "",
|
||||
"_objFlags": 0,
|
||||
"node": {
|
||||
"__id__": 100
|
||||
},
|
||||
"_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": null,
|
||||
"_id": "a8XQuQ3opI3Ks9qtPgAfJk"
|
||||
},
|
||||
{
|
||||
"__type__": "cc.UITransform",
|
||||
"_name": "",
|
||||
@ -2924,12 +3032,15 @@
|
||||
"__id__": 99
|
||||
},
|
||||
"gameCanvas": {
|
||||
"__id__": 101
|
||||
"__id__": 104
|
||||
},
|
||||
"background": {
|
||||
"__id__": 23
|
||||
},
|
||||
"gameAudioAdapter": null,
|
||||
"blackScreen": {
|
||||
"__id__": 100
|
||||
},
|
||||
"_id": "3a9z1bqlFCGL4/WyDwU4L5"
|
||||
},
|
||||
{
|
||||
@ -2937,10 +3048,10 @@
|
||||
"fileId": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f",
|
||||
"targetOverrides": [
|
||||
{
|
||||
"__id__": 105
|
||||
"__id__": 108
|
||||
},
|
||||
{
|
||||
"__id__": 107
|
||||
"__id__": 110
|
||||
}
|
||||
],
|
||||
"nestedPrefabInstanceRoots": [
|
||||
@ -2958,7 +3069,7 @@
|
||||
{
|
||||
"__type__": "cc.TargetOverrideInfo",
|
||||
"source": {
|
||||
"__id__": 103
|
||||
"__id__": 106
|
||||
},
|
||||
"sourceInfo": null,
|
||||
"propertyPath": [
|
||||
@ -2968,7 +3079,7 @@
|
||||
"__id__": 34
|
||||
},
|
||||
"targetInfo": {
|
||||
"__id__": 106
|
||||
"__id__": 109
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -2980,7 +3091,7 @@
|
||||
{
|
||||
"__type__": "cc.TargetOverrideInfo",
|
||||
"source": {
|
||||
"__id__": 103
|
||||
"__id__": 106
|
||||
},
|
||||
"sourceInfo": null,
|
||||
"propertyPath": [
|
||||
@ -2990,7 +3101,7 @@
|
||||
"__id__": 13
|
||||
},
|
||||
"targetInfo": {
|
||||
"__id__": 108
|
||||
"__id__": 111
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -3002,19 +3113,19 @@
|
||||
{
|
||||
"__type__": "cc.SceneGlobals",
|
||||
"ambient": {
|
||||
"__id__": 110
|
||||
},
|
||||
"shadows": {
|
||||
"__id__": 111
|
||||
},
|
||||
"_skybox": {
|
||||
"__id__": 112
|
||||
},
|
||||
"fog": {
|
||||
"__id__": 113
|
||||
},
|
||||
"octree": {
|
||||
"shadows": {
|
||||
"__id__": 114
|
||||
},
|
||||
"_skybox": {
|
||||
"__id__": 115
|
||||
},
|
||||
"fog": {
|
||||
"__id__": 116
|
||||
},
|
||||
"octree": {
|
||||
"__id__": 117
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -60,6 +60,8 @@ export class PlayerCollisionSystem {
|
||||
}
|
||||
|
||||
private resolveContact(otherCollider: Collider2D): void {
|
||||
if (!this.player.Health.IsAlive) return;
|
||||
|
||||
if (this.groupToResolver.has(otherCollider.group)) {
|
||||
this.groupToResolver.get(otherCollider.group)(otherCollider);
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { Canvas, Component, KeyCode, Vec2, _decorator } from "cc";
|
||||
import { Canvas, Component, KeyCode, Vec2, _decorator, Node } from "cc";
|
||||
import { AppRoot } from "../AppRoot/AppRoot";
|
||||
import { requireAppRootAsync } from "../AppRoot/AppRootUtils";
|
||||
import { delay } from "../Services/Utils/AsyncUtils";
|
||||
@ -50,6 +50,7 @@ export class Game extends Component {
|
||||
@property(Canvas) private gameCanvas: Canvas;
|
||||
@property(Background) private background: Background;
|
||||
@property(GameAudioAdapter) private gameAudioAdapter: GameAudioAdapter;
|
||||
@property(Node) private blackScreen: Node;
|
||||
|
||||
private playerCollisionSystem: PlayerCollisionSystem;
|
||||
private haloProjectileLauncher: HaloProjectileLauncher;
|
||||
@ -70,11 +71,8 @@ export class Game extends Component {
|
||||
return this.instance;
|
||||
}
|
||||
|
||||
public async start(): Promise<void> {
|
||||
public start(): void {
|
||||
this.gamePauser.pause();
|
||||
this.node.active = false; // make sure that nothing is rendered until the app root is ready
|
||||
await requireAppRootAsync();
|
||||
this.node.active = true;
|
||||
Game.instance = this;
|
||||
}
|
||||
|
||||
@ -84,6 +82,7 @@ export class Game extends Component {
|
||||
translationData: TranslationData,
|
||||
testValues?: TestValues
|
||||
): Promise<GameResult> {
|
||||
await requireAppRootAsync();
|
||||
this.gameCanvas.cameraComponent = AppRoot.Instance.MainCamera;
|
||||
|
||||
this.gameResult = new GameResult();
|
||||
@ -174,15 +173,18 @@ export class Game extends Component {
|
||||
this.haloProjectileLauncher
|
||||
);
|
||||
this.gamePauser.resume();
|
||||
this.blackScreen.active = false;
|
||||
AppRoot.Instance.ScreenFader.playClose();
|
||||
|
||||
while (!this.gameResult.hasExitManually && this.player.Health.IsAlive) await delay(100);
|
||||
if (!this.gameResult.hasExitManually) {
|
||||
await delay(1000);
|
||||
}
|
||||
this.gamePauser.pause();
|
||||
Game.instance = null;
|
||||
this.gameResult.score = this.timeAlive;
|
||||
|
||||
if (!this.gameResult.hasExitManually) {
|
||||
await delay(2000);
|
||||
}
|
||||
|
||||
return this.gameResult;
|
||||
}
|
||||
|
||||
|
@ -73,6 +73,8 @@ export class Player extends Component {
|
||||
}
|
||||
|
||||
private move(deltaTime: number): void {
|
||||
if (!this.health.IsAlive) return;
|
||||
|
||||
const movement: Vec2 = this.input.getAxis();
|
||||
if (!movement.equals(Vec2.ZERO)) {
|
||||
movement.x *= deltaTime * this.speed;
|
||||
@ -111,6 +113,10 @@ export class Player extends Component {
|
||||
|
||||
await delay(100);
|
||||
this.sprite.color = Color.WHITE;
|
||||
|
||||
if (!this.health.IsAlive) {
|
||||
this.animation.play("Die");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user