Commit 15fc1da5 authored by haiyoucuv's avatar haiyoucuv

1

parent db2ddbe4
{
"record_icon.png": {
"x": 657,
"y": 2,
"w": 138,
"h": 192,
"ox": 0,
"oy": 0,
"sw": 138,
"sh": 192,
"ro": true
},
"record_item_bg.png": {
"x": 2,
"y": 2,
"w": 653,
"h": 176,
"ox": 0,
"oy": 0,
"sw": 653,
"sh": 176,
"ro": false
}
}
\ No newline at end of file
{
"comm_bg.png": {
"x": 2,
"y": 2,
"w": 750,
"h": 1070,
"ox": 0,
"oy": 0,
"sw": 750,
"sh": 1070,
"ro": false
}
}
\ No newline at end of file
{
"shop_icon.png": {
"x": 2,
"y": 2,
"w": 135,
"h": 185,
"ox": 0,
"oy": 0,
"sw": 135,
"sh": 185,
"ro": false
}
}
\ No newline at end of file
{
"task_chat_icon.png": {
"x": 558,
"y": 184,
"w": 137,
"h": 137,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 137,
"ro": false
},
"task_collection_icon.png": {
"x": 419,
"y": 184,
"w": 137,
"h": 137,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 137,
"ro": false
},
"task_done.png": {
"x": 765,
"y": 176,
"w": 71,
"h": 24,
"ox": 29,
"oy": 21,
"sw": 129,
"sh": 66,
"ro": true
},
"task_friend_icon.png": {
"x": 280,
"y": 184,
"w": 137,
"h": 137,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 137,
"ro": false
},
"task_go.png": {
"x": 697,
"y": 176,
"w": 129,
"h": 66,
"ox": 0,
"oy": 0,
"sw": 129,
"sh": 66,
"ro": true
},
"task_icon.png": {
"x": 658,
"y": 2,
"w": 130,
"h": 172,
"ox": 0,
"oy": 0,
"sw": 130,
"sh": 172,
"ro": false
},
"task_item_bg.png": {
"x": 2,
"y": 2,
"w": 654,
"h": 180,
"ox": 0,
"oy": 0,
"sw": 654,
"sh": 180,
"ro": false
},
"task_shop_icon.png": {
"x": 141,
"y": 184,
"w": 137,
"h": 137,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 137,
"ro": false
},
"task_sign_icon.png": {
"x": 2,
"y": 184,
"w": 137,
"h": 137,
"ox": 0,
"oy": 0,
"sw": 137,
"sh": 137,
"ro": false
}
}
\ No newline at end of file
{
"wareHouse_icon.png": {
"x": 2,
"y": 2,
"w": 149,
"h": 178,
"ox": 0,
"oy": 0,
"sw": 149,
"sh": 178,
"ro": false
}
}
\ No newline at end of file
import { Panel } from "../../module/views/Panel";
import { Tool } from "../Tools";
import Sprite = FYGE.Sprite;
export default class ExRecordPanel extends Panel {
get groupNames() {
return ["exRecordPanel"];
}
closeBtn: Sprite;
initUi() {
this.addChild(Tool.getSprite("rule_bg.png"));
this.closeBtn = this.addChild(Tool.getSprite('closeBtn.png'));
this.closeBtn.position.set(600, 350);
}
start(data) {
super.start();
}
initEvents() {
this.closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
removeEvents() {
this.closeBtn.removeEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
}
import { Panel } from "../../module/views/Panel";
import { Tool } from "../Tools";
import Sprite = FYGE.Sprite;
export class ExahangePanel extends Panel {
get groupNames() {
return ["exchangePanel"];
}
closeBtn: Sprite;
initUi() {
this.addChild(Tool.getSprite("rule_bg.png"));
this.closeBtn = this.addChild(Tool.getSprite('closeBtn.png'));
this.closeBtn.position.set(600, 350);
}
start(data) {
super.start();
}
initEvents() {
this.closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
removeEvents() {
this.closeBtn.removeEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
}
import { Panel } from "../../module/views/Panel";
import { Tool } from "../Tools";
import Sprite = FYGE.Sprite;
import ScrollList = FYGE.ScrollList;
import { layers } from "../../module/views/layers";
import Container = FYGE.Container;
import IScrollListItem = FYGE.IScrollListItem;
import Tween = FYGE.Tween;
import TextField = FYGE.TextField;
import { RES } from "../../module/RES";
import MouseEvent = FYGE.MouseEvent;
export default class TaskPanel extends Panel {
get groupNames() {
return ["taskPanel"];
}
closeBtn: Sprite;
scroll: ScrollList;
initUi() {
this.addChild(Tool.getSprite("comm_bg.png"))
.position.set(0, 65);
let title = this.addChild(Tool.getSprite("task_icon.png"));
title.position.set((this.width - title.width) / 2, 0);
this.closeBtn = this.addChild(Tool.getSprite('closeBtn.png'));
this.closeBtn.position.set(670, -50);
this.scroll = this.addChild(new ScrollList(TaskItem, 654, 200, 654, 830));
this.scroll.position.set((this.width - this.scroll.width) / 2, 210);
this.scroll.updateData([
{
type: 'sign',
name: '每日签到',
tips: '每日签到可领水滴',
num: '60',
done: true,
},
{
type: 'chat',
name: '加入群聊',
tips: '加入本店铺群可领水滴',
num: '60',
done: false,
},
{
type: 'shop',
name: '关注/收藏店铺',
tips: '成为洽洽粉丝可领水滴',
num: '60',
done: true,
},
{
type: 'vip',
name: '成为会员',
tips: '成为会员可领水滴',
num: '60',
done: false,
},
{
type: 'friend',
name: '邀请好友',
tips: '邀请3位好友可得大量水滴',
num: '60',
done: true,
},
{
type: 'buy',
name: '购买指定商品',
tips: '今日完成下单即可领水滴',
num: '60',
done: false,
},
]);
}
public showAni() {
if (this.isShowing) return;
this.isShowing = true;
this.y = this.height;
const _y = layers.height - this.height + 30;
Tween.get(this)
.to({y: _y}, 500, FYGE.Ease.quartOut)
.call(() => {
this.isShowing = false;
});
}
start(data) {
super.start();
}
initEvents() {
this.closeBtn.addEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
removeEvents() {
this.closeBtn.removeEventListener(FYGE.MouseEvent.CLICK, this.hidePanel, this)
}
}
// enum TASK_TYPE {
//
// }
class TaskItem extends Container implements IScrollListItem {
public data: number;
public id: number;
private taskImg: Sprite;
private taskName: TextField;
private taskTips: TextField;
private prizeNum: TextField;
private btn: Sprite;
public initData(id: number, data: any): void {
// {
// type: 'buy',
// name: '购买指定商品',
// tips: '今日完成下单即可领水滴',
// num: '60',
// done: false,
// },
if (!data) return;
this.data = data;
this.taskImg.texture = RES.getRes(`task_${data.type}_icon.png`);
this.taskName.text = data.name;
this.taskTips.text = data.tips;
this.prizeNum.text = ${data.num}`;
this.prizeNum.position.set(this.taskName.x + this.taskName.textWidth + 50, 53);
this.btn.removeAllEventListener();
if (data.done) {
this.btn.texture = RES.getRes('task_done.png');
} else {
this.btn.texture = RES.getRes('task_go.png');
this.btn.addEventListener(MouseEvent.CLICK, () => {
console.log(this.data);
});
}
}
constructor() {
super();
this.addChild(Tool.getSprite('task_item_bg.png'));
this.taskImg = this.addChild(Tool.getSprite('task_sign_icon.png'));
this.taskImg.position.set(20, 20);
// 任务名字
this.taskName = this.addChild(new TextField());
this.taskName.size = 30;
this.taskName.fillColor = '#a65310';
this.taskName.text = '名字';
this.taskName.position.set(177, 53);
// 奖励数量
this.prizeNum = this.addChild(new TextField());
this.prizeNum.size = 30;
this.prizeNum.fillColor = '#ff6300';
this.prizeNum.text = '× 60';
this.prizeNum.position.set(this.taskName.x + this.taskName.textWidth + 10, 53);
// 任务提示
this.taskTips = this.addChild(new TextField());
this.taskTips.size = 30;
this.taskTips.fillColor = '#9a9a9a';
this.taskTips.text = '提示提示';
this.taskTips.position.set(177, 102);
// 按钮
this.btn = this.addChild(Tool.getSprite('task_go.png'));
this.btn.position.set(505, 57);
}
}
import Container = FYGE.Container;
import { Tool } from "../../Tools";
import Sprite = FYGE.Sprite;
import TextField = FYGE.TextField;
import Graphics = FYGE.Graphics;
import Tween = FYGE.Tween;
import Ease = FYGE.Ease;
import { s_PlantData } from "../../const/staticData";
export default class ProgressBar extends Container {
private fill: Sprite;
private nameLabel: TextField;
private timeLabel: TextField;
constructor() {
super();
this.addChild(Tool.getSprite('进度_bg.png'))
.position.set(80, 130);
// 进度
this.fill = this.addChild(Tool.getSprite('进度_fill.png'));
this.fill.position.set(136, 131);
// mask
const mask = this.addChild(new Graphics());
mask.drawRect(136, 131, 139, 29);
this.fill.mask = mask;
this.fill.x = -59;
// nameLabel
this.nameLabel = this.addChild(new TextField());
this.nameLabel.size = 16;
this.nameLabel.fillColor = '#333333';
this.nameLabel.text = '山核桃';
this.nameLabel.position.set(80 + (56 - this.nameLabel.textWidth) / 2, 139);
// timeLabel
this.timeLabel = this.addChild(new TextField());
this.timeLabel.size = 16;
this.timeLabel.fillColor = '#fffefe';
this.timeLabel.text = '0时0分后浇水';
this.timeLabel.position.set(136 + (136 - this.timeLabel.textWidth) / 2, 139);
this.visible = false;
}
private cutTime: number = 0;
private fullTime: number = 0;
private interval = null;
/**
* 更新data,会更新名字倒计时等
* @param data
*/
public setData(data) {
this.nameLabel.text = s_PlantData[data.type].name;
this.nameLabel.position.set(80 + (56 - this.nameLabel.textWidth) / 2, 139);
this.fullTime = data.fullTime;
this.cutTime = (data.timestamp - Date.now()) / 1000 + 3;
if (this.cutTime <= 3) {
this.cutTime = 3;
}
this.setTime();
this.interval && clearInterval(this.interval);
this.interval = setInterval(() => {
this.cutTime--;
this.setTime();
if (this.cutTime <= 0) {
console.warn("倒计时结束");
clearInterval(this.interval);
this.interval = null;
setTimeout(() => {
this.hidden();
}, 500);
this.dispatchEvent('endTime');
}
}, 1000);
}
private setTime() {
const hour = ~~(this.cutTime / 3600);
const min = ~~((this.cutTime - hour * 3600 + 59) / 60);
this.timeLabel.text = `${hour}${min}分后浇水`;
this.timeLabel.position.set(136 + (136 - this.timeLabel.textWidth) / 2, 139);
const progress = 1 - this.cutTime / this.fullTime;
this.fill.x = (195 - 59) * progress;
}
/**
* 显示
*/
public show() {
if (this.cutTime <= 0) {
return;
}
Tween.removeTweens(this);
const tw = this.visible
? Tween.get(this)
.set({alpha: 1, visible: true})
: Tween.get(this)
.set({alpha: 0, visible: true})
.to({alpha: 1}, 500, Ease.quadInOut);
tw.wait(3000)
.call(() => {
this.hidden();
});
}
/**
* 隐藏
*/
public hidden() {
if (!this.visible) {
return;
}
Tween.removeTweens(this);
Tween.get(this)
.to({alpha: 0}, 500, Ease.quadInOut)
.set({visible: false});
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment