Commit dcc7f8af authored by haiyoucuv's avatar haiyoucuv
parents efc9cfcc f35c4a9c
......@@ -22,12 +22,12 @@
"name": "60关奖品3",
"useStock": 1,
"rank": "",
"_id": "5f08084e0cb7338a0a377c8e",
"_id": "123",
"id": "",
"stock": 200
},
{
"image": "https://img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png",
"image": "https://source.unsplash.com/user/erondu/80x80",
"isBackUp": true,
"properiodto": 10000,
"level": 2,
......@@ -42,10 +42,10 @@
"deleteStatus": 1,
"name": "谢谢参与",
"useStock": 0,
"_id": "5f0c043852bbde91d1ca5682"
"_id": "456"
},
{
"image": "https://img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png",
"image": "https://source.unsplash.com/user/erondu/90x90",
"isBackUp": true,
"properiodto": 10000,
"level": 2,
......@@ -60,10 +60,46 @@
"deleteStatus": 1,
"name": "谢谢参与",
"useStock": 0,
"_id": "5f0c043852bbde91d1ca5682"
"_id": "789"
},
{
"image": "https://img.alicdn.com/imgextra/i2/2275046294/O1CN01c4rCs11wMhRrsjEep_!!2275046294-2-miniprogram.png",
"image": "https://source.unsplash.com/user/erondu/100x100",
"isBackUp": true,
"properiodto": 10000,
"level": 2,
"probability": "84",
"prizeType": 60,
"updateTime": 1594623032197,
"type": 5,
"properiodfrom": 1601,
"activityId": "5f08084ec3ad3494b9201c0e",
"lockStatus": 1,
"createTime": 1594623032197,
"deleteStatus": 1,
"name": "谢谢参与",
"useStock": 0,
"_id": "1213"
},
{
"image": "https://source.unsplash.com/user/erondu/110x110",
"isBackUp": true,
"properiodto": 10000,
"level": 2,
"probability": "84",
"prizeType": 60,
"updateTime": 1594623032197,
"type": 5,
"properiodfrom": 1601,
"activityId": "5f08084ec3ad3494b9201c0e",
"lockStatus": 1,
"createTime": 1594623032197,
"deleteStatus": 1,
"name": "谢谢参与",
"useStock": 0,
"_id": "9898"
},
{
"image": "https://source.unsplash.com/user/erondu/120x120",
"isBackUp": true,
"properiodto": 10000,
"level": 2,
......@@ -78,7 +114,7 @@
"deleteStatus": 1,
"name": "谢谢参与",
"useStock": 0,
"_id": "5f0c043852bbde91d1ca5682"
"_id": "9654"
}
],
"success": true,
......
{
"code": "000000",
"data": {
"image": "https://img.alicdn.com/imgextra/i1/2275046294/O1CN01TrcMYF1wMhRuCphHI_!!2275046294-2-miniprogram.png",
"level": 90,
"drawStatus": 1,
"openId": "AAHuCvE-ALiIWXYsJuTb5S4W",
"createDay": "2020/07/14",
"avatar": "sdfwerwerwer",
"type": 3,
"prizeId": "5f08084e0cb7338a0a377c8d",
"activityId": "5f08084ec3ad3494b9201c0e",
"ename": "",
"userNick": "wmmmmm",
"name": "90关奖品4",
"_id": "AAHuCvE-ALiIWXYsJuTb5S4W1594715684002"
},
"success": true,
"message": "成功"
}
\ No newline at end of file
......@@ -155,6 +155,11 @@ export class GTool {
return (0.5 - Math.random());
});
}
public static disturbArr(arr: any[]) {
return arr.sort(function () {
return (0.5 - Math.random());
});
}
/**
* 其实打乱数组取前几个就行
......
This diff is collapsed.
This diff is collapsed.
......@@ -19,4 +19,6 @@ RES修改成与FYGE独立的贴图缓存,否则FYGE多页面应该会有同名
多page上的canvas,destroy最好别执行removeAllTweens,
多page上的canvas,对于相同资源是否考虑,还有公用弹框,(还是不考虑吧,多page只在活动相互独立的情况下使用)
\ No newline at end of file
多page上的canvas,对于相同资源是否考虑,还有公用弹框(可以考虑用dom的component),
(多page最好只在活动相互独立的情况下使用)
\ No newline at end of file
This diff is collapsed.
var fs = require("fs");
//测试脚本,白鹭的图集格式转fyge的图集格式
var readPath = "./scripts/";
var writePath = "./psd/"
//取指令后的参数
let arg = process.argv.splice(2);
//json名字
var jsonName = arg[0];
var data = fs.readFileSync(readPath + jsonName + ".json");
//反序列化
data = JSON.parse(data);
let frames = data.frames;
var obj = {};
for (var key in frames) {
let f = frames[key];
obj[jsonName + key + ".png"] = {
"x": f.x,
"y": f.y,
"w": f.w,
"h": f.h,
"ox": f.offX,
"oy": f.offY,
"sw": f.sourceW,
"sh": f.sourceH,
"ro": false,
}
}
//写入
fs.writeFileSync(writePath + jsonName + ".json", JSON.stringify(obj, "", "\t"));
//例子json
// {"file":"coin.png","frames":{
// "8":{"x":0,"y":0,"w":109,"h":112,"offX":3,"offY":1,"sourceW":115,"sourceH":115},
// "4":{"x":67,"y":340,"w":65,"h":113,"offX":25,"offY":1,"sourceW":115,"sourceH":115},
// "5":{"x":222,"y":0,"w":24,"h":108,"offX":45,"offY":3,"sourceW":115,"sourceH":115},
// "7":{"x":0,"y":114,"w":94,"h":113,"offX":10,"offY":1,"sourceW":115,"sourceH":115},
// "6":{"x":0,"y":229,"w":65,"h":114,"offX":25,"offY":0,"sourceW":115,"sourceH":115},
// "2":{"x":111,"y":0,"w":109,"h":111,"offX":3,"offY":2,"sourceW":115,"sourceH":115},
// "3":{"x":96,"y":225,"w":94,"h":113,"offX":10,"offY":1,"sourceW":115,"sourceH":115},
// "1":{"x":111,"y":113,"w":109,"h":110,"offX":3,"offY":2,"sourceW":115,"sourceH":115}}}
\ No newline at end of file
This diff is collapsed.
......@@ -76,6 +76,11 @@ export enum TbNetName {
* activityId
*/
getTaskList = "babycare.getTaskList",
/**
* 抽奖
* activityId
*/
luckyDraw = "babycare.luckyDraw",
///////////////////前端调用接口都加个mine
......
......@@ -69,9 +69,9 @@ export class StartPanel extends Panel {
if (!success) return;
Tools.gameData.power = res.data.power;
changeScene(PlayScene, { chapter: this.data.level });
this.hidePanel();
}
);
this.hidePanel();
}
initEvents() {
......
......@@ -71,9 +71,9 @@ export class StartPanelPrize extends Panel {
if (!success) return;
Tools.gameData.power = res.data.power;
changeScene(PlayScene, {chapter: this.data.level});
this.hidePanel();
}
);
this.hidePanel();
}
initEvents() {
......
......@@ -12,6 +12,7 @@ import TextField = FYGE.TextField;
import { changeScene } from "../../module/ctrls";
import { MapScene } from "../scene/map/MapScene";
import MouseEvent = FYGE.MouseEvent;
import { LotteryScene } from "../scene/LotteryScene";
export class SuccessPrizePanel extends Panel {
get groupNames() {
......@@ -27,8 +28,8 @@ export class SuccessPrizePanel extends Panel {
this.isShowing = true;
this.anchor.set(375, 812);
Tween.get(this)
.set({scaleX: 0, scaleY: 0})
.to({scaleX: 1, scaleY: 1}, 400, Ease.backOut)
.set({ scaleX: 0, scaleY: 0 })
.to({ scaleX: 1, scaleY: 1 }, 400, Ease.backOut)
.call(() => {
this.isShowing = false;
});
......@@ -100,13 +101,13 @@ export class SuccessPrizePanel extends Panel {
}
private lightEffect() {
Tween.get(this.light1, {loop: true})
.set({anchorX: 219.5, anchorY: 219.5})
.to({rotation: 360}, 12000);
Tween.get(this.light1, { loop: true })
.set({ anchorX: 219.5, anchorY: 219.5 })
.to({ rotation: 360 }, 12000);
Tween.get(this.light2, {loop: true})
.set({anchorX: 219.5, anchorY: 219.5})
.to({rotation: -360}, 12000);
Tween.get(this.light2, { loop: true })
.set({ anchorX: 219.5, anchorY: 219.5 })
.to({ rotation: -360 }, 12000);
}
start(data) {
......@@ -117,7 +118,7 @@ export class SuccessPrizePanel extends Panel {
* 挑战满星
*/
private again() {
changeScene(MapScene, {level: this.data.level});
changeScene(MapScene, { level: this.data.level });
super.hidePanel();
}
......@@ -128,14 +129,16 @@ export class SuccessPrizePanel extends Panel {
if (this.data.level == 120) {
changeScene(MapScene);
} else {
changeScene(MapScene, {level: this.data.level + 1});
changeScene(MapScene, { level: this.data.level + 1 });
}
super.hidePanel();
}
public goPrize(){
/// TODO 去抽奖
public goPrize() {
// 去抽奖
changeScene(LotteryScene, { level: this.data.level })
super.hidePanel();
}
......
......@@ -245,7 +245,7 @@ class CusButton extends Button {
if (this.type == TaskType.browseGoods || this.type == TaskType.member) {
//都需要添加事件,回来时,派发事件刷任务接口
GDispatcher.once(G_EVENT.ON_SHOW, () => {
GDispatcher.dispatchEvent(G_EVENT.ON_SHOW)
GDispatcher.dispatchEvent(G_EVENT.UPDATE_TASK)
}, this)
}
}
......
......@@ -2,7 +2,7 @@ import { Scene } from "../../module/views/Scene";
import { Tools } from "../Tools";
import { ProgressBarS } from "../common/ProgressBarS";
import { RES } from "../../module/RES";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { sendTbNet, TbNetName, getTbData } from "../TaoBaoNet";
import { changeScene } from "../../module/ctrls";
import { MapScene } from "./map/MapScene";
import { layers } from "../../module/views/layers";
......@@ -106,10 +106,12 @@ export class LoadingScene extends Scene {
//获取首页数据
var getIndexSuccesss = await Tools.getIndex()
//失败不进入
if (!getIndexSuccesss) return;
this.dispatchEvent(FYGE.Event.PROGRESS, 0.3);
//赋值openId,取getIndex里的数据
Tools.globalData.openId = getTbData(TbNetName.getIndex).data.openId;
// 游戏基本信息
const baseInfo = await sendTbNet(TbNetName.getActivityBaseInfoById);
Tools.baseInfo = baseInfo.data;
......
......@@ -2,14 +2,20 @@ import { Scene } from "../../module/views/Scene";
import { RES } from "../../module/RES";
import { layers } from "../../module/views/layers";
import { Tools } from "../Tools";
import { showWaiting } from "../../module/ctrls";
import { showWaiting, wait, changeScene, hideWaiting, showPanel } from "../../module/ctrls";
import { sendTbNet, TbNetName } from "../TaoBaoNet";
import { GTool } from "../../module/tools/GTool";
import { MapScene } from "./map/MapScene";
import { PrizePanel } from "../panels/PrizePanel";
import { NoPrizePanel } from "../panels/NoPrizePanel";
/**
* 摇奖机弹框
*/
export class LotteryScene extends Scene {
get groupNames() { return ["lotteryScene"] }
lotScroll: LotteryScroll;
data: {
level: number,
}
......@@ -46,12 +52,16 @@ export class LotteryScene extends Scene {
FYGE.TEXT_ALIGN.CENTER,
488,
(750 - 488) / 2,
360
420
))
//抽奖按钮
this.addChild(new FYGE.Button(RES.getRes("lotteryBtn.png")))
.addEventListener(FYGE.MouseEvent.CLICK, this.lottery, this)
.position.set((750 - RES.getRes("lotteryBtn.png").width) / 2, 797);
//返回按钮,回到地图页
this.addChild(new FYGE.Button(RES.getRes("lotteryReturnBtn.png")))
.addEventListener(FYGE.MouseEvent.CLICK, () => { changeScene(MapScene) }, this)
.position.set(0, 300)
//刷新奖品列表和摇奖列表
this.updatePrizes();
}
......@@ -59,15 +69,31 @@ export class LotteryScene extends Scene {
showWaiting();
const { data: prizeList } = await sendTbNet(TbNetName.getPrizesByLevel, { level: this.data.level });
//滚动列表
console.log(prizeList)
// console.log(prizeList)
var scroll = this.addChild(new FYGE.ScrollList(PrizeItem, 122, 140, 345, 152, false))
scroll.position.set(195, 1013);
scroll.updateData(prizeList || [])
//摇奖部分
var p = [201, 620]
this.lotScroll = this.addChild(new LotteryScroll(prizeList))
this.lotScroll.position.set(p[0], p[1]);
}
lottery() {
showWaiting()
sendTbNet(TbNetName.luckyDraw)
.then((res) => {
hideWaiting();
//如果是失败
if (!res.success) return;
let id;
if (res.data && res.data._id) id = res.data._id;
this.enableMouseEvt(false);
this.lotScroll.lot(id, () => {
this.enableMouseEvt(true)
//弹框
showPanel(id ? PrizePanel : NoPrizePanel, id ? res.data : null)
})
})
}
}
interface PrizeInt {
......@@ -104,48 +130,169 @@ class PrizeItem extends FYGE.Container implements FYGE.IScrollListItem {
}
class LotteryItem extends FYGE.Container {
private showImage: FYGE.Sprite;
private cusPosition: number;
constructor(tex?: FYGE.Texture) {
id: string
constructor(data: PrizeInt) {
super();
this.id = data._id;
this.addChild(new FYGE.Sprite(RES.getRes("lotteryItemBg.png")));
this.showImage = this.addChild(new FYGE.Sprite(tex));
this.showImage = this.addChild(new FYGE.Sprite(FYGE.Texture.from(data.image)));
this.showImage.width = this.showImage.height = 88;
this.showImage.position.set((103 - 88) / 2, 6);
var mask = this.addChild(new FYGE.Shape())
mask.beginFill(0);
mask.drawRoundedRect((103 - 88) / 2, 6, 88, 88, 10);
mask.endFill();
this.showImage.mask = mask
}
changeShowImage(tex: FYGE.Texture) {
this.showImage.texture = tex;
reset(data: PrizeInt) {
this.showImage.texture = FYGE.Texture.from(data.image);
this.id = data._id;
}
}
const HEIGHT = 123;
/**
* 滚动条
* 功能可以滚动到指定的图
*/
class LotteryScroll extends FYGE.Container {
private currentIndex: number;
constructor(textures: FYGE.Texture[]) {
class LotteryScrollItem extends FYGE.Container {
/**
* 当前childre的中位索引
*/
get currentIndex(): number {
var a = 1 - this.cusP;
var l = this.children.length
return a < 0 ? a % l + l : a % l
};
private cusP: number
constructor(datas: PrizeInt[]) {
super();
textures.forEach((t, i) => {
this.addChild(new LotteryItem(t))
.position.set(0, i * 123)
datas.forEach((d) => {
this.addChild(new LotteryItem(d))
})
this.cusP = 0;
this.updatePosition();
//修改位置
this.addEventListener(FYGE.Event.ENTER_FRAME, () => {
this.children.forEach((c) => {
// if () { }
})
}, this)
this.addEventListener(FYGE.Event.ENTER_FRAME, this.updatePosition, this)
}
scrollTo(index: number, time: number, callback: () => void) {
scrollTo(id: string, callback: () => void) {
//找出目标图
let child, curIndex;
for (var i = 0; i < this.children.length; i++) {
if (this.children[i].id == id) {
child = this.children[i];
curIndex = i;
break
}
}
var delta = this.currentIndex - curIndex;
if (delta < 0) delta += this.children.length;
//目标图的位置必须是,多加几圈
var cusP = this.cusP + delta + 10 * this.children.length;
FYGE.Tween.get(this)
.to({ cusP }, 5000, FYGE.Ease.quadInOut)
.call(() => {
callback && callback();
})
}
reset() {
}
updatePosition() {
this.children.forEach((c) => {
// if () { }
this.children.forEach((c: LotteryItem, j) => {
c.y = ((this.cusP + j) % this.children.length) * HEIGHT - HEIGHT;
//超过一定距离,移到上面
if (c.y > HEIGHT * 1.5) {
c.y = c.y - this.children.length * HEIGHT
}
})
}
// 0 0- 10 21 1
// 1 00 11 2- 0
// 2 01 1- 20 2
// 3 0- 10 21 1
destroy() {
FYGE.Tween.removeTweens(this);
super.destroy()
}
}
/**
* 暂时固定3列,宽高
*/
class LotteryScroll extends FYGE.Container {
ids: string[]
scrollItems: LotteryScrollItem[];
constructor(datas: PrizeInt[]) {
super();
this.scrollItems = []
for (var i = 0; i < 3; i++) {
var s = this.addChild(new LotteryScrollItem(GTool.disturbArr(datas.slice())))
s.position.set(116 * i, 0);
this.scrollItems.push(s)
}
this.ids = [];
datas.forEach((d) => { this.ids.push(d._id) });
var h = -50
//遮罩
var mask = this.addChild(new FYGE.Shape())
mask.beginFill(0)
mask.drawRect(0, h + 3, 350, 195 - 5)
mask.endFill();
this.mask = mask;
//蒙层
this.addChild(new FYGE.Sprite(RES.getRes("shadowMask.png")))
.position.set(0, h)
}
lot(id?: string, callback?: () => void) {
if (id) {
//确保得是ids里的id。否则无效
if (this.ids.indexOf(id) == -1) {
console.error("中奖id不存在")
return;
}
let count = 0;
let countAll = this.scrollItems.length;
this.scrollItems.forEach((c: LotteryScrollItem, i) => {
wait(() => {
c.scrollTo(id, () => {
if (++count == countAll && callback) callback();
})
}, 400 * i)
})
} else {
//保证几个id不能一致
var ids = [
GTool.randomT(this.ids),
GTool.randomT(this.ids),
];
//如果都相同
// if(!ids.some(function (value, index) { return value !== ids[0];})){
// ids.push()
// }
//才两个,直接判断
ids[0] === ids[1] ? ids.push(
GTool.randomT((() => {
var arr = this.ids.slice();
arr.splice(this.ids.indexOf(ids[0]), 1)
return arr
})())
) : ids.push(GTool.randomT(this.ids));
console.log(ids)
let count = 0;
let countAll = this.scrollItems.length;
this.scrollItems.forEach((c: LotteryScrollItem, i) => {
wait(() => {
c.scrollTo(ids[i], () => {
if (++count == countAll && callback) callback();
})
}, 400 * i)
})
}
}
}
\ No newline at end of file
......@@ -50,7 +50,7 @@ export class MapScene extends Scene {
888, true, true
));
this.mapContainer = this.scrollPage.view.addChild(new Container());
this.uiLayer = this.addChild(new MapUI());
// this.uiLayer = this.addChild(new MapUI());//待测试,在下面updateMapCheck里再初始化
this.initMap();
this.updateMapCheck();
......@@ -79,13 +79,15 @@ export class MapScene extends Scene {
private updateMapCheck() {
if (this.data && this.data.from == 'loading') {
this.uiLayer = this.addChild(new MapUI());
this.initMapByData(Tools.gameData);
if (Tools.gameData.isFristLogin) {
this.initGuide();
}
} else {
Tools.getGameInfo().then((success) => {
if (success) {
if (success) {//不考虑失败的情况
this.uiLayer = this.addChild(new MapUI());
this.initMapByData(Tools.gameData);
}
});
......@@ -101,7 +103,7 @@ export class MapScene extends Scene {
g.beginFill(0, 0.6);
g.drawRect(0, 0, layers.stageWidth, layers.stageHeight);
g.endFill();
const guide_check = guide.addChild(new CheckBtn({check: 1}));
const guide_check = guide.addChild(new CheckBtn({ check: 1 }));
guide_check.enabled = true;
guide_check.type = CHECK_TYPE.CUR;
guide_check.position.set(MapScene.checkArr[1].x, layers.stageHeight - 162);
......@@ -128,15 +130,15 @@ export class MapScene extends Scene {
guide.alpha = 0;
Tween.get(guide)
.to({alpha: 1}, 600, Ease.quadInOut);
.to({ alpha: 1 }, 600, Ease.quadInOut);
Tween.get(guide_fox)
.wait(300)
.to({y: guide_check.y - 345, alpha: 1}, 300, Ease.quadInOut)
.to({ y: guide_check.y - 345, alpha: 1 }, 300, Ease.quadInOut)
.wait(100)
.call(() => {
Tween.get(guide_tip)
.to({scaleX: 1, scaleY: 1}, 300, Ease.quadInOut);
.to({ scaleX: 1, scaleY: 1 }, 300, Ease.quadInOut);
});
}
......
......@@ -6,12 +6,13 @@ import TEXT_ALIGN = FYGE.TEXT_ALIGN;
import { RES } from "../../../module/RES";
import { Tools } from "../../Tools";
import MouseEvent = FYGE.MouseEvent;
import { showPanel } from "../../../module/ctrls";
import { showPanel, changeScene, showToast } from "../../../module/ctrls";
import { RulePanel } from "../../panels/RulePanel";
import { BuyPowerPanel } from "../../panels/BuyPowerPanel";
import { TaskPanel } from "../../panels/TaskPanel";
import { sendTbNet, TbNetName } from "../../TaoBaoNet";
import Texture = FYGE.Texture;
import { LotteryScene } from "../LotteryScene";
export default class MapUI extends Container {
public energyBox: EnergyBox = null;
......@@ -61,7 +62,7 @@ export default class MapUI extends Container {
break;
case this.prizeBox:
/// TODO 奖励盒子
/// TODO 奖励盒子,有条件的吧,放在类里了prizeBox
console.log('奖励盒子');
break;
......@@ -247,11 +248,18 @@ class PrizeBox extends Button {
this.tip.text = '';
this.prizeImg.texture = Texture.fromUrl(Tools.baseInfo.levelPrize[`level_${upLevel}`]);
this.prizeImg.y -= 20;
this.addEventListener(FYGE.MouseEvent.CLICK, () => {
//有需要,到时再改
showToast(this.checkTip.text + "才可以抽奖哦")
}, this)
} else if (prizes.length == 1 && +prizes[0].level == 120) {
this.checkTip.text = `等待开奖`;
this.tip.text = `8月28日10点\n开启大奖`;
this.prizeImg.texture = Texture.fromUrl(Tools.baseInfo.levelPrize['level_120']);
this.addEventListener(FYGE.MouseEvent.CLICK, () => {
//有需要,到时再改
showToast(this.tip.text)
}, this)
} else {
let lowerLevel = 120;
prizes.forEach((value) => {
......@@ -263,11 +271,12 @@ class PrizeBox extends Button {
this.tip.text = `抽取${lowerLevel}关奖励`;
this.tip.y += 10;
this.prizeImg.texture = Texture.fromUrl(Tools.baseInfo.levelPrize[`level_${lowerLevel}`]);
this.addEventListener(FYGE.MouseEvent.CLICK, () => {
changeScene(LotteryScene, { level: lowerLevel })
}, this)
}
}
initEvent() {
}
}
......@@ -38,7 +38,7 @@ export class PropGuide extends FYGE.Container {
text.fillColor = "#ffffff";
text.size = 20;
text.x = (750 - 500) / 2;
text.y = offsetY - 92;
text.y = offsetY - 30;
text.textAlign = FYGE.TEXT_ALIGN.CENTER;
text.textWidth = 500;
this.addChild(text);
......@@ -75,7 +75,7 @@ export class PropGuide extends FYGE.Container {
this.bg.moveTo(stepPosition[0] + 50, stepPosition[1])
this.bg.drawCircle(stepPosition[0], stepPosition[1], 50, false)
this.bg.endFill();
this.msgTxt.text = "点击上方步数,可为闯关时增加额外5次步数";
this.msgTxt.text = "点击上方步数,可为闯关时增加额外5次步数";
// this.msgTxt.x = 320;
}
}
......
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