import { _decorator, Button, Component, Node } from 'cc'; import { CircularProgressBar } from './CircularProgressBar'; import { PopupEffect } from './PopupEffect' const { ccclass, property } = _decorator; @ccclass('MainManager') export class MainManager extends Component { //任务按钮 @property(Button) public taskBtn: Button = null; //领取饲料 @property(Button) public getFoodBtn: Button = null; //消息按钮 @property(Button) public messageBtn: Button = null; //加饲料 @property(Button) public addFood: Button = null; //领鸡蛋 @property(Button) public getEgg: Button = null; @property(PopupEffect) public popupEffects: PopupEffect @property(CircularProgressBar) public circularProgressBar: CircularProgressBar private feedGrams: number = 20 @property(Node) public popupUI: Node = null; @property(Node) public feedObj: Node = null; start() { // this.taskBtn.node.on('click', this.onTaskBtnClick, this); this.getFoodBtn.node.on('click', this.onGetFoodBtnClick, this); this.messageBtn.node.on('click', this.onMessageBtnClick, this); this.addFood.node.on('click', this.onAddFoodClick, this); this.getEgg.node.on('click', this.onGetEggClick, this); } //任务按钮点击 onTaskBtnClick() { //跳转到其他界面 console.log('任务按钮点击'); } //领取饲料按钮点击 onGetFoodBtnClick() { //弹出界面 this.popupEffects.showPopup(); //跳转到其他界面 console.log('领取饲料按钮点击'); } //消息按钮点击 onMessageBtnClick() { //跳转到其他界面 console.log('消息按钮点击'); } //加饲料按钮点击 onAddFoodClick() { //跳转到其他界面 //TODO 向服务器获取数据 饲料充足则向碗里加饲料 //处理数据 if (this.feedGrams <= 10) { //显示弹窗 this.popupUI.active = true; } else { this.feedObj.active = true; this.circularProgressBar.updateProgressBar(); console.log('加饲料按钮点击'); } } //领鸡蛋按钮点击 onGetEggClick() { //跳转到其他界面 //TODO 向服务器获取数据 鸡蛋充足则领取鸡蛋 console.log('领鸡蛋按钮点击'); } update(deltaTime: number) { } }