72 lines
1.8 KiB
TypeScript
72 lines
1.8 KiB
TypeScript
|
import { _decorator, Button, Component, Node } from 'cc';
|
||
|
import { FillSpriteEffect } from './FillSpriteEffect';
|
||
|
import { ChangeWorldColor } from './ChangeWorldColor'
|
||
|
const { ccclass, property } = _decorator;
|
||
|
|
||
|
@ccclass('TaskManager')
|
||
|
export class TaskManager extends Component {
|
||
|
|
||
|
|
||
|
//领取饲料按钮
|
||
|
@property
|
||
|
public getFeedBtn: Button = null;
|
||
|
//点击互动能手按钮
|
||
|
public getInteractBtn: Node = null;
|
||
|
//点赞达人
|
||
|
public getLikeBtn: Node = null;
|
||
|
@property(FillSpriteEffect)
|
||
|
public fillEffects: FillSpriteEffect[] = [];
|
||
|
@property(ChangeWorldColor)
|
||
|
public changeWorldColor: ChangeWorldColor[] = [];
|
||
|
private lineNum: number = 0;
|
||
|
|
||
|
//是否领取
|
||
|
private isGetFeed: boolean = false;
|
||
|
|
||
|
|
||
|
|
||
|
protected onLoad(): void {
|
||
|
//this.lineNum=this.fillEffects.length;
|
||
|
this.getFeedBtn = this.node.getChildByName('领取').getComponent(Button);
|
||
|
}
|
||
|
|
||
|
start() {
|
||
|
//领取饲料按钮点击事件
|
||
|
this.getFeedBtn.node.on('click', this.getFeed, this);
|
||
|
}
|
||
|
|
||
|
update(deltaTime: number) {
|
||
|
|
||
|
}
|
||
|
//领取饲料
|
||
|
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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|