new structure, spawner, rebind

This commit is contained in:
Martin
2022-11-08 19:45:57 +01:00
parent 5b098af31d
commit 279218b4c3
45 changed files with 1157 additions and 302 deletions

View File

@@ -0,0 +1,19 @@
import { Component, ProgressBar, _decorator } from "cc";
import { UnitHealth } from "../UnitHealth";
const { ccclass, property } = _decorator;
@ccclass("PlayerHealthUI")
export class PlayerHealthUI extends Component {
@property(ProgressBar) public healthBar: ProgressBar;
private health: UnitHealth;
public init(health: UnitHealth): void {
this.healthBar.progress = 1;
this.health = health;
this.health.HealthPointsChangeEvent.on(this.updateHealthBar, this);
}
private updateHealthBar(): void {
this.healthBar.progress = this.health.HealthPoints / this.health.MaxHealthPoints;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "84a1c057-2ef8-4ead-8903-5753f36ac735",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { Component, _decorator } from "cc";
import { UnitHealth } from "../UnitHealth";
import { PlayerHealthUI } from "./PlayerHealthUI";
const { ccclass, property } = _decorator;
@ccclass("PlayerUI")
export class PlayerUI extends Component {
@property(PlayerHealthUI) private healthUI: PlayerHealthUI;
public init(playerHealth: UnitHealth): void {
this.healthUI.init(playerHealth);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "634f676f-c335-42a2-85e8-f214e9ce5eb7",
"files": [],
"subMetas": {},
"userData": {}
}