mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
资源刷新 以及 出售
This commit is contained in:
9
JisolGameCocos/assets/script/ui/Consts/Resource.meta
Normal file
9
JisolGameCocos/assets/script/ui/Consts/Resource.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "1.2.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "a2e6e211-4b26-493c-85ba-38c5a9f2c614",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
@@ -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)}`;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "dd6ffde0-3461-40cc-a793-9463cad639f1",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user