资源刷新 以及 出售

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-20 03:47:00 +08:00
parent cb64a6c25f
commit 98b7a52b45
41 changed files with 1483 additions and 263 deletions

View File

@@ -0,0 +1,43 @@
import { Label } from 'cc';
import { _decorator, Component, Node } from 'cc';
import ResourceData, { ResourceEvent, ResourceType } from '../../../data/ResourceData';
import { Enum } from 'cc';
import { app } from '../../../App';
const { ccclass, property } = _decorator;
@ccclass('PlayerResourceShow')
export class PlayerResourceShow extends Component {
//显示的资源
@property({type:Enum(ResourceType)})
type:ResourceType = ResourceType.Gold;
//显示文本
@property(Label)
show:Label;
protected onLoad(): void {
//更新
this.onUpdateView();
//监听
app.event.on(ResourceEvent.UPDATE,this.onUpdateView,this);
}
protected onDestroy(): void {
app.event.off(ResourceEvent.UPDATE,this.onUpdateView,this);
}
//刷新
onUpdateView(){
//更新资源数量
this.show.string = `${ResourceData.getIns().getValue(this.type)}`;
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "dd6ffde0-3461-40cc-a793-9463cad639f1",
"files": [],
"subMetas": {},
"userData": {}
}