Added timer

This commit is contained in:
Martin 2022-12-13 18:21:04 +01:00
parent 6ad522a79d
commit bef7505584
3 changed files with 217 additions and 94 deletions

View File

@ -27,11 +27,11 @@
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 133 "__id__": 136
}, },
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 134 "__id__": 137
}, },
"_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f" "_id": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f"
}, },
@ -235,17 +235,17 @@
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{
"__id__": 129
},
{
"__id__": 130
},
{
"__id__": 131
},
{ {
"__id__": 132 "__id__": 132
},
{
"__id__": 133
},
{
"__id__": 134
},
{
"__id__": 135
} }
], ],
"_prefab": null, "_prefab": null,
@ -2385,10 +2385,7 @@
"__id__": 79 "__id__": 79
}, },
{ {
"__id__": 102 "__id__": 105
},
{
"__id__": 116
}, },
{ {
"__id__": 119 "__id__": 119
@ -2398,12 +2395,15 @@
}, },
{ {
"__id__": 125 "__id__": 125
},
{
"__id__": 128
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 128 "__id__": 131
} }
], ],
"_prefab": null, "_prefab": null,
@ -2447,13 +2447,13 @@
"__id__": 80 "__id__": 80
}, },
{ {
"__id__": 92 "__id__": 95
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 101 "__id__": 104
} }
], ],
"_prefab": null, "_prefab": null,
@ -2495,15 +2495,18 @@
"_children": [ "_children": [
{ {
"__id__": 81 "__id__": 81
},
{
"__id__": 90
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 90 "__id__": 93
}, },
{ {
"__id__": 91 "__id__": 94
} }
], ],
"_prefab": null, "_prefab": null,
@ -2837,6 +2840,114 @@
"_reverse": false, "_reverse": false,
"_id": "5a1CWtS5hFdK4pcdIQ6qWC" "_id": "5a1CWtS5hFdK4pcdIQ6qWC"
}, },
{
"__type__": "cc.Node",
"_name": "TimeAliveText",
"_objFlags": 0,
"_parent": {
"__id__": 80
},
"_children": [],
"_active": true,
"_components": [
{
"__id__": 91
},
{
"__id__": 92
}
],
"_prefab": null,
"_lpos": {
"__type__": "cc.Vec3",
"x": 320,
"y": -80,
"z": 1000
},
"_lrot": {
"__type__": "cc.Quat",
"x": 0,
"y": 0,
"z": 0,
"w": 1
},
"_lscale": {
"__type__": "cc.Vec3",
"x": 1,
"y": 1,
"z": 1
},
"_layer": 1073741824,
"_euler": {
"__type__": "cc.Vec3",
"x": 0,
"y": 0,
"z": 0
},
"_id": "c4XsoErxpCwoh0Ud7l6xNv"
},
{
"__type__": "cc.UITransform",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_enabled": true,
"__prefab": null,
"_contentSize": {
"__type__": "cc.Size",
"width": 55.36,
"height": 50
},
"_anchorPoint": {
"__type__": "cc.Vec2",
"x": 0.5,
"y": 0.5
},
"_id": "d5/jjF9kZDLZd60qqMOTI6"
},
{
"__type__": "cc.Label",
"_name": "",
"_objFlags": 0,
"node": {
"__id__": 90
},
"_enabled": true,
"__prefab": null,
"_customMaterial": null,
"_srcBlendFactor": 2,
"_dstBlendFactor": 4,
"_color": {
"__type__": "cc.Color",
"r": 255,
"g": 255,
"b": 255,
"a": 255
},
"_string": "30",
"_horizontalAlign": 1,
"_verticalAlign": 1,
"_actualFontSize": 50,
"_fontSize": 50,
"_fontFamily": "Arial",
"_lineHeight": 50,
"_overflow": 0,
"_enableWrapText": true,
"_font": {
"__uuid__": "c96b42a9-d20d-4c59-8e99-8ed749a715c8",
"__expectedType__": "cc.BitmapFont"
},
"_isSystemFontUsed": false,
"_spacingX": 0,
"_isItalic": false,
"_isBold": false,
"_isUnderline": false,
"_underlineHeight": 2,
"_cacheMode": 1,
"_id": "b8o2CHyMhO9KAlJh/3XhyY"
},
{ {
"__type__": "cc.UITransform", "__type__": "cc.UITransform",
"_name": "", "_name": "",
@ -2896,13 +3007,13 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 93 "__id__": 96
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 100 "__id__": 103
} }
], ],
"_prefab": null, "_prefab": null,
@ -2939,23 +3050,23 @@
"_name": "VirtualJoystic", "_name": "VirtualJoystic",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 92 "__id__": 95
}, },
"_children": [ "_children": [
{ {
"__id__": 94 "__id__": 97
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 97 "__id__": 100
}, },
{ {
"__id__": 98 "__id__": 101
}, },
{ {
"__id__": 99 "__id__": 102
} }
], ],
"_prefab": null, "_prefab": null,
@ -2992,16 +3103,16 @@
"_name": "Knob", "_name": "Knob",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 93 "__id__": 96
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 95 "__id__": 98
}, },
{ {
"__id__": 96 "__id__": 99
} }
], ],
"_prefab": null, "_prefab": null,
@ -3038,7 +3149,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 94 "__id__": 97
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3059,7 +3170,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 94 "__id__": 97
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3097,7 +3208,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 93 "__id__": 96
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3118,7 +3229,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 93 "__id__": 96
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3156,13 +3267,13 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 93 "__id__": 96
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"maxDistance": 50, "maxDistance": 50,
"knob": { "knob": {
"__id__": 94 "__id__": 97
}, },
"_id": "50ceZG62tGlYXvZWEvSDKl" "_id": "50ceZG62tGlYXvZWEvSDKl"
}, },
@ -3171,7 +3282,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 92 "__id__": 95
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3199,6 +3310,9 @@
"xpBar": { "xpBar": {
"__id__": 89 "__id__": 89
}, },
"timeAliveText": {
"__id__": 92
},
"_id": "bau/7eItRFrKKoAZZb/uYL" "_id": "bau/7eItRFrKKoAZZb/uYL"
}, },
{ {
@ -3210,16 +3324,16 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 103 "__id__": 106
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 114 "__id__": 117
}, },
{ {
"__id__": 115 "__id__": 118
} }
], ],
"_prefab": null, "_prefab": null,
@ -3255,17 +3369,17 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 102 "__id__": 105
}, },
"_prefab": { "_prefab": {
"__id__": 104 "__id__": 107
}, },
"__editorExtras__": {} "__editorExtras__": {}
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 103 "__id__": 106
}, },
"asset": { "asset": {
"__uuid__": "663674aa-da1c-44b0-8049-49db9b020973", "__uuid__": "663674aa-da1c-44b0-8049-49db9b020973",
@ -3273,11 +3387,11 @@
}, },
"fileId": "32U/bJCUBDlaQxxGFNXZTu", "fileId": "32U/bJCUBDlaQxxGFNXZTu",
"instance": { "instance": {
"__id__": 105 "__id__": 108
}, },
"targetOverrides": [ "targetOverrides": [
{ {
"__id__": 112 "__id__": 115
} }
] ]
}, },
@ -3287,20 +3401,20 @@
"mountedChildren": [], "mountedChildren": [],
"mountedComponents": [], "mountedComponents": [],
"propertyOverrides": [ "propertyOverrides": [
{
"__id__": 106
},
{
"__id__": 108
},
{ {
"__id__": 109 "__id__": 109
}, },
{ {
"__id__": 110 "__id__": 111
}, },
{ {
"__id__": 111 "__id__": 112
},
{
"__id__": 113
},
{
"__id__": 114
} }
], ],
"removedComponents": [] "removedComponents": []
@ -3308,7 +3422,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 107 "__id__": 110
}, },
"propertyPath": [ "propertyPath": [
"_name" "_name"
@ -3324,7 +3438,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 107 "__id__": 110
}, },
"propertyPath": [ "propertyPath": [
"_lpos" "_lpos"
@ -3339,7 +3453,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 107 "__id__": 110
}, },
"propertyPath": [ "propertyPath": [
"_lrot" "_lrot"
@ -3355,7 +3469,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 107 "__id__": 110
}, },
"propertyPath": [ "propertyPath": [
"_euler" "_euler"
@ -3370,7 +3484,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 107 "__id__": 110
}, },
"propertyPath": [ "propertyPath": [
"_active" "_active"
@ -3387,7 +3501,7 @@
], ],
"target": null, "target": null,
"targetInfo": { "targetInfo": {
"__id__": 113 "__id__": 116
} }
}, },
{ {
@ -3401,7 +3515,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 102 "__id__": 105
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3422,7 +3536,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 102 "__id__": 105
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3445,10 +3559,10 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 117 "__id__": 120
}, },
{ {
"__id__": 118 "__id__": 121
} }
], ],
"_prefab": null, "_prefab": null,
@ -3485,7 +3599,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 116 "__id__": 119
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3506,7 +3620,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 116 "__id__": 119
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3550,10 +3664,10 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 120 "__id__": 123
}, },
{ {
"__id__": 121 "__id__": 124
} }
], ],
"_prefab": null, "_prefab": null,
@ -3590,7 +3704,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 119 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3611,7 +3725,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 119 "__id__": 122
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3655,10 +3769,10 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 123 "__id__": 126
}, },
{ {
"__id__": 124 "__id__": 127
} }
], ],
"_prefab": null, "_prefab": null,
@ -3695,7 +3809,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 122 "__id__": 125
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3716,7 +3830,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 122 "__id__": 125
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3760,10 +3874,10 @@
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 126 "__id__": 129
}, },
{ {
"__id__": 127 "__id__": 130
} }
], ],
"_prefab": null, "_prefab": null,
@ -3800,7 +3914,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 128
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3821,7 +3935,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 125 "__id__": 128
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -3928,7 +4042,7 @@
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"_cameraComponent": { "_cameraComponent": {
"__id__": 128 "__id__": 131
}, },
"_alignCanvasWithScreen": true, "_alignCanvasWithScreen": true,
"_id": "12O/ljcVlEqLmVm3U2gEOQ" "_id": "12O/ljcVlEqLmVm3U2gEOQ"
@ -3972,7 +4086,7 @@
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"virtualJoystic": { "virtualJoystic": {
"__id__": 99 "__id__": 102
}, },
"player": { "player": {
"__id__": 70 "__id__": 70
@ -3990,16 +4104,16 @@
"__id__": 77 "__id__": 77
}, },
"camera": { "camera": {
"__id__": 128 "__id__": 131
}, },
"gameUI": { "gameUI": {
"__id__": 101 "__id__": 104
}, },
"background": { "background": {
"__id__": 15 "__id__": 15
}, },
"modalWindowManager": { "modalWindowManager": {
"__id__": 115 "__id__": 118
}, },
"settingsAsset": { "settingsAsset": {
"__uuid__": "737b7646-f050-47db-8f02-a204ad5f768b", "__uuid__": "737b7646-f050-47db-8f02-a204ad5f768b",
@ -4019,26 +4133,26 @@
"__id__": 2 "__id__": 2
}, },
{ {
"__id__": 103 "__id__": 106
} }
] ]
}, },
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 135
},
"shadows": {
"__id__": 136
},
"_skybox": {
"__id__": 137
},
"fog": {
"__id__": 138 "__id__": 138
}, },
"octree": { "shadows": {
"__id__": 139 "__id__": 139
},
"_skybox": {
"__id__": 140
},
"fog": {
"__id__": 141
},
"octree": {
"__id__": 142
} }
}, },
{ {

View File

@ -48,6 +48,7 @@ export class Game extends Component {
private gamePauser: Pauser = new Pauser(); private gamePauser: Pauser = new Pauser();
private static instance: Game; private static instance: Game;
private timeAlive = 0;
public static get Instance(): Game { public static get Instance(): Game {
return this.instance; return this.instance;
@ -136,6 +137,9 @@ export class Game extends Component {
this.diagonalProjectileLauncher.gameTick(deltaTime); this.diagonalProjectileLauncher.gameTick(deltaTime);
this.background.gameTick(); this.background.gameTick();
this.timeAlive += deltaTime;
this.gameUI.updateTimeAlive(this.timeAlive);
this.camera.node.worldPosition = this.player.node.worldPosition; this.camera.node.worldPosition = this.player.node.worldPosition;
} }

View File

@ -1,4 +1,4 @@
import { Component, ProgressBar, _decorator } from "cc"; import { Component, Label, ProgressBar, _decorator } from "cc";
import { Player } from "../Unit/Player/Player"; import { Player } from "../Unit/Player/Player";
import { UnitLevel } from "../Unit/UnitLevel"; import { UnitLevel } from "../Unit/UnitLevel";
@ -7,6 +7,7 @@ const { ccclass, property } = _decorator;
@ccclass("GameUI") @ccclass("GameUI")
export class GameUI extends Component { export class GameUI extends Component {
@property(ProgressBar) private xpBar: ProgressBar; @property(ProgressBar) private xpBar: ProgressBar;
@property(Label) private timeAliveText: Label;
private playerLevel: UnitLevel; private playerLevel: UnitLevel;
@ -20,4 +21,8 @@ export class GameUI extends Component {
private updateProgressBar(): void { private updateProgressBar(): void {
this.xpBar.progress = this.playerLevel.XP / this.playerLevel.RequiredXP; this.xpBar.progress = this.playerLevel.XP / this.playerLevel.RequiredXP;
} }
public updateTimeAlive(timeAlive: number): void {
this.timeAliveText.string = `${Math.floor(timeAlive)}`;
}
} }