2024-10-12 18:51:50 +08:00
|
|
|
import { _decorator, Button, Component, log, Node } from 'cc';
|
2024-10-11 18:09:54 +08:00
|
|
|
import { FillSpriteEffect } from './FillSpriteEffect';
|
|
|
|
import { ChangeWorldColor } from './ChangeWorldColor'
|
2024-10-12 18:51:50 +08:00
|
|
|
import { PopupEffect } from './PopupEffect'
|
2024-10-11 18:09:54 +08:00
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
|
|
@ccclass('TaskManager')
|
|
|
|
export class TaskManager extends Component {
|
|
|
|
|
|
|
|
|
2024-10-12 18:51:50 +08:00
|
|
|
//关闭弹窗
|
|
|
|
@property(Button)
|
|
|
|
public closeBtn: Button = null;
|
|
|
|
|
2024-10-11 18:09:54 +08:00
|
|
|
//领取饲料按钮
|
|
|
|
@property
|
|
|
|
public getFeedBtn: Button = null;
|
|
|
|
//点击互动能手按钮
|
|
|
|
public getInteractBtn: Node = null;
|
|
|
|
//点赞达人
|
|
|
|
public getLikeBtn: Node = null;
|
|
|
|
@property(FillSpriteEffect)
|
|
|
|
public fillEffects: FillSpriteEffect[] = [];
|
|
|
|
@property(ChangeWorldColor)
|
|
|
|
public changeWorldColor: ChangeWorldColor[] = [];
|
2024-10-12 18:51:50 +08:00
|
|
|
@property(PopupEffect)
|
|
|
|
public popupEffects: PopupEffect
|
|
|
|
|
2024-10-11 18:09:54 +08:00
|
|
|
private lineNum: number = 0;
|
|
|
|
|
|
|
|
//是否领取
|
|
|
|
private isGetFeed: boolean = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected onLoad(): void {
|
|
|
|
//this.lineNum=this.fillEffects.length;
|
2024-10-12 18:51:50 +08:00
|
|
|
// this.popupEffects = this.node.getComponent(PopupEffect);
|
2024-10-11 18:09:54 +08:00
|
|
|
this.getFeedBtn = this.node.getChildByName('领取').getComponent(Button);
|
|
|
|
}
|
|
|
|
|
|
|
|
start() {
|
|
|
|
//领取饲料按钮点击事件
|
|
|
|
this.getFeedBtn.node.on('click', this.getFeed, this);
|
2024-10-12 18:51:50 +08:00
|
|
|
//关闭按钮点击事件
|
|
|
|
this.closeBtn.node.on('click', this.closePopup, this);
|
2024-10-11 18:09:54 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
update(deltaTime: number) {
|
|
|
|
|
|
|
|
}
|
2024-10-12 18:51:50 +08:00
|
|
|
|
|
|
|
//关闭弹窗
|
|
|
|
public closePopup() {
|
|
|
|
log('关闭弹窗');
|
|
|
|
this.popupEffects.hidePopup()
|
|
|
|
}
|
|
|
|
|
2024-10-11 18:09:54 +08:00
|
|
|
//领取饲料
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|