import { _decorator, Button, Component, log, Node } from 'cc'; import { FillSpriteEffect } from './FillSpriteEffect'; import { ChangeWorldColor } from './ChangeWorldColor' import { PopupEffect } from './PopupEffect' const { ccclass, property } = _decorator; @ccclass('TaskManager') export class TaskManager extends Component { //关闭弹窗 @property(Button) public closeBtn: Button = null; //领取饲料按钮 @property public getFeedBtn: Button = null; //点击互动能手按钮 public getInteractBtn: Node = null; //点赞达人 public getLikeBtn: Node = null; @property(FillSpriteEffect) public fillEffects: FillSpriteEffect[] = []; @property(ChangeWorldColor) public changeWorldColor: ChangeWorldColor[] = []; @property(PopupEffect) public popupEffects: PopupEffect private lineNum: number = 0; //是否领取 private isGetFeed: boolean = false; protected onLoad(): void { //this.lineNum=this.fillEffects.length; // this.popupEffects = this.node.getComponent(PopupEffect); this.getFeedBtn = this.node.getChildByName('领取').getComponent(Button); } start() { //领取饲料按钮点击事件 this.getFeedBtn.node.on('click', this.getFeed, this); //关闭按钮点击事件 this.closeBtn.node.on('click', this.closePopup, this); } update(deltaTime: number) { } //关闭弹窗 public closePopup() { log('关闭弹窗'); this.popupEffects.hidePopup() } //领取饲料 public getFeed() { //TODO 判断是否有饲料可以领取 //TODO 向服务器发送领取饲料请求 //模拟 if (!this.isGetFeed) { this.isGetFeed = true; if (this.lineNum < this.fillEffects.length) { this.fillEffects[this.lineNum].triggerFillEffect(); this.changeWorldColor[this.lineNum].isClaimed = true; this.changeWorldColor[this.lineNum].triggerUpdate(); this.lineNum++; } } } //初始化设置 public init() { //服务器获取今天是否已经领取 if (this.isGetFeed) { //已经领取过 设置为灰色 } else { this.isGetFeed = false; } } }