Commit 1a1c751b authored by wjf's avatar wjf

l

parent 276189de
......@@ -45,11 +45,11 @@ export default class Container extends DisplayObject {
}
/**
* 添加child
* 添加child,返回的就是child
* @param {DisplayObject} child
* @return {DisplayObject}
*/
addChild(child: DisplayObject): DisplayObject {
addChild<T extends DisplayObject>(child: T): T {
//默认添加在最顶层
this.addChildAt(child, this.children.length);
return child;
......@@ -61,7 +61,7 @@ export default class Container extends DisplayObject {
* @param {number} index - The index to place the child in
* @return {DisplayObject} The child that was added.
*/
addChildAt(child: DisplayObject, index: number): DisplayObject {
addChildAt<T extends DisplayObject>(child: T, index: number): T {
if (!child) return;
let s = this;
......
......@@ -62,7 +62,7 @@ export class EventDispatcher extends HashObject {
}
/**
* 给对象添加一个侦听
* 给对象添加一个侦听,返回自身
* @method addEventListener
* @public
* @since 1.0.0
......@@ -73,7 +73,7 @@ export class EventDispatcher extends HashObject {
* @example
* this.addEventListener(Event.ADD_TO_STAGE,function(e){trace(this);},this);
*/
public addEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public addEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
if (!type) {
throw new Error("添加侦听的type值为undefined");
}
......@@ -106,17 +106,17 @@ export class EventDispatcher extends HashObject {
if (type.indexOf("onMouse") == 0) {
s._changeMouseCount(type, true);
}
return s
}
/**
* 监听一次
* 监听一次,返回自身
* @param type
* @param listener
* @param context
* @param useCapture
*/
public once(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public once(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
if (!type) {
throw new Error("添加侦听的type值为undefined");
}
......@@ -136,6 +136,7 @@ export class EventDispatcher extends HashObject {
if (type.indexOf("onMouse") == 0) {
s._changeMouseCount(type, true);
}
return s
}
/**
......@@ -246,7 +247,7 @@ export class EventDispatcher extends HashObject {
}
/**
* 移除对应类型的侦听
* 移除对应类型的侦听,返回自身
* @method removeEventListener
* @public
* @since 1.0.0
......@@ -255,7 +256,7 @@ export class EventDispatcher extends HashObject {
* @param context listener和context都相等的才移除,默认自身
* @param {boolean} useCapture true 捕获阶段 false 冒泡阶段 默认 true
*/
public removeEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): void {
public removeEventListener(type: string, listener: Function, context?: any, useCapture: boolean = true): this {
let s = this;
let listeners: EE[] = s.eventTypes[type];
if (!useCapture) {
......@@ -279,15 +280,16 @@ export class EventDispatcher extends HashObject {
// }
}
}
return s
}
/**
* 移除对象中所有的侦听
* 移除对象中所有的侦听,返回自身
* @method removeAllEventListener
* @public
* @since 1.0.0
*/
public removeAllEventListener() {
public removeAllEventListener(): this {
let s = this;
for (let type in s.eventTypes) {
if (type.indexOf("onMouse") == 0) {
......@@ -305,6 +307,7 @@ export class EventDispatcher extends HashObject {
}
s.eventTypes1 = {};
s.eventTypes = {};
return s;
}
destroy(): void {
......
......@@ -31,7 +31,7 @@ export default class PanelCtrl {
this._parent = parent;
let bg = new Graphics();
bg.beginFill(0, 1);
bg.drawRect(0, 0, layers.stageWidth, layers.stageHeight);
bg.drawRect(0, layers.stageOffsetY - parent.y, layers.stageWidth, layers.stageHeight);
bg.endFill();
bg.visible = false;
this._parent.addChild(bg);
......
......@@ -33,13 +33,15 @@ class Layers extends Container {
this.addChild(this[arr[i]]);
}
//弹框要居中适配,加个
this.popupLayer.y = 0;
//初始化场景层级
SceneCtrl.instance.init(this.sceneLayer)
//初始化弹框层级
PanelCtrl.instance.init(this.popupLayer)
//弹框要居中适配,加个
this.popupLayer.y = 0;
}
......
{
"groups": [
{
"keys": "comCloseBtn.png,toastBg.png,waitingBg.png,waitingRot.png",
"keys": "comCloseBtn.png,light.png,toastBg.png,waitingBg.png,waitingRot.png",
"name": "common"
},
{
"keys": "fanhuishouye.png,gameOverPanelBg.png,quzhuanjifen.png,scoreLevel1.png,scoreLevel2.png,scoreLevel3.png,zailaiyiju.png",
"name": "gameOverPanel"
},
{
"keys": "bombBtn.png,ele1024.png,ele128.png,ele16.png,ele2.png,ele2048.png,ele256.png,ele32.png,ele4.png,ele512.png,ele64.png,ele8.png,exchangeBtn.png,filterBtn.png,playBg.png",
"name": "playScene"
},
{
"keys": "getPropBtn.png,propOutPanelBg.png",
"name": "propOutPanel"
},
{
"keys": "fangqi.png,huoqudaoju.png,propPanelBg.png",
"name": "propPanel"
},
{
"keys": "jixuchuangguan.png,quitPanelBg.png,tuichubenguan.png",
"name": "quitPanel"
},
{
"keys": "snake.png,startBtn.png",
"name": "startScene"
},
{
"keys": "jiaohuan.png,kaixinshouxia.png,libao.png,lvwang.png,t0.png,t1.png,t2.png,t3.png,t4.png,t5.png,t6.png,t7.png,t8.png,t9.png,taskCompletePanelBg.png,tx.png,zhadan.png",
"name": "taskCompletePanel"
},
{
"keys": "lingqujiangli.png,quguanzhu.png,qushoucang.png,quxiadan.png,quyaoqing.png,taskPanelBg.png,yiguanzhu.png,yilingqu.png",
"name": "taskPanel"
},
{
"keys": "jixuyouxi.png,n0.png,n1.png,n2.png,n3.png,n4.png,n5.png,n6.png,n7.png,n8.png,n9.png,unlock128.png,unlockMsg.png,unlockPanelBg.png",
"name": "unlockPanel"
}
]
}
\ No newline at end of file
resource/taskPanel/taskPanelBg.png

724 KB | W: | H:

resource/taskPanel/taskPanelBg.png

741 KB | W: | H:

resource/taskPanel/taskPanelBg.png
resource/taskPanel/taskPanelBg.png
resource/taskPanel/taskPanelBg.png
resource/taskPanel/taskPanelBg.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -62,12 +62,13 @@ export class Main {
//隐藏加载中
if (document.getElementById("__loading__")) document.getElementById("__loading__").style.display = "none";
//打开开始场景
changeScene(PlayScene); return;
// changeScene(StartScene); return;
//获取数据,,必成功
showWaiting();
sendTbNet(TbNetName.getAppData, {}, (s, res) => {
Tool.globalData = res.data;
changeScene(PlayScene);
// changeScene(PlayScene);
changeScene(StartScene);
})
......
......@@ -3,17 +3,12 @@ import { showToast } from "../module/ctrls";
//接口枚举,包括需要调用淘宝的api,用是否含有兑吧区分,或者单独区分
export enum TbNetName {
/**
* 登录
* activityId,nickName,avatar,shareId可选
*/
login = "login",
/**
* 获取接力信息
* activityId,shareId,不传获取自己的助力信息,传的话获取shareId的助力信息
* 查询积分
* activityId
*/
getRelayInfo = "getRelayInfo",
getCredits = "getCredits",
/**
* 开始接口
* activityId,nickName
......@@ -21,53 +16,20 @@ export enum TbNetName {
startGame = "startGame",
/**
* 提交分数接口
* activityId,distance
*/
submitDistance = "submitDistance",
/**
* 验证分享助力,助力者的提交
* activityId,shareId(分享者的),nickName,avatar,distance
*/
doShareComplete = "doShareComplete",
/**
* 领奖接口,里面会校验是否是会员,直接传接口里返回的prizeInfo
* activityId,ename,prizeId,prizeLevel,type,credits
* activityId,grade,score,type(0:解锁 1:提交), playId
*/
collectionPrize = "collectionPrize",
submit = "submit",
/**
* 选择奖励
* image,activityId,ename,name,prizeId,type,credits(不必须,到时确认)
* 额外加个nickName
*/
choosePrize = "choosePrize",
/**
* 获取可选择的奖品列表
* activityId
*/
getPrizeList = "getPrizeList",
/**
* 获取可领取的奖品信息,只会有一个,
* activityId
*/
getCollectionPrize = "getCollectionPrize",
/**
* 获取自己的分享Id
* activityId
* 查询道具数量
* actitvityId
*/
getShareId = "getShareId",
getTools = "getTools",
/**
* 获取游戏规则
* 获取任务列表
* activityId
*/
getGameInfo = "getGameInfo",
getTaskList = "getTaskList",
/**
* 检查是否是会员
* activityId
*/
checkIsMember = "checkIsMember",
//前端自己调用小程序的方法
......@@ -91,13 +53,11 @@ export enum TbNetName {
* delta,页面数,不传默认1
*/
navigateBack = "mine.navigateBack",
/**
* 显示分享面板
* openId
*/
invite = "mine.showSharePanel",
/**
* 单纯接收来自小程序的信息,事件自行绑定
*/
......@@ -118,7 +78,7 @@ if (!window["develop"]) {
//接收数据
my.onMessage = function (e: dataIn) {
//记录数据
console.log("返回数据",e.netName, e.data)
console.log("返回数据", e.netName, e.data)
data[e.netName] = e.data;
//触发事件,会考虑单独发过来的事件
GDispatcher.dispatchEvent(e.netName, e.data)
......@@ -158,7 +118,7 @@ export function sendTbNet(netName: TbNetName, parameter: any, callback: Function
}, 500)
return
}
console.log("发送数据",netName,parameter)
console.log("发送数据", netName, parameter)
//向小程序发信息
my.postMessage({
netName: netName,
......@@ -224,208 +184,84 @@ const mockData = {
"nickName": "开发环境",
"avatar": "//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png",
// "shareId": "115564",
"type": "kid"//adult
"type": "kid",//adult
"joinNeedsCredits": 20,
}
},
//登录
"login": {
"getCredits": {
"code": 0,
"data": {
"endTime": "1586503134000",
"isNewGuy": true,//是否新人
"memberUrl": "//store.taobao.com/shop/view_shop.htm?user_number_id=2207623078795&extraInfo=%7B%22source%22%3A%22isvapp%22%2C%22activityId%22%3A%225e82d9db347ad421de487df7%22%2C%22entrance%22%3A%22duiba%22%7D",
"isMember": false,
"openId": "aaaaaa",
"shareUserInfo": { //如果参数带了shareId就会传
"avatar": "//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png",
"nickName": "aaa"
}
"credits": 20,
},
"success": true,
"errorMessage": "ok"
"message": "ok"
},
//获取接力信息
"getRelayInfo": {
"code": 10000,
//开始游戏
"startGame": {
"code": 0,
"data": {
"image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
"list": [//为空表示没跑,第一项就是自己的
{
"distance": 300,
"nickName": "cat",
"avatar": "//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png",
},
{
"distance": 400,
"nickName": "cat",
"avatar": "//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png",
},
{
"distance": 200,
"nickName": "cat",
"avatar": "//yun.duiba.com.cn/developer/img/activityTool/slotMachine/virtual.png",
},
]
"maxScore": 2048,
"bombCount": 3,
"exchangeCount": 0,
"netCount": 0,
"unlockGrade": 256,
"id": "asdasd456"
},
"success": true,
"message": "成功"
},
//开始游戏,失败也继续
"startGame": {
"code": 10000,
"success": true,
"message": "成功"
"message": "ok"
},
//提交分数
"submitDistance": {
"code": 10000,
"success": true,
"message": "成功"
},
//助力者提交分数
"doShareComplete": {
"code": 10000,
"submit": {
"success": true,
"message": "成功"
"data": {
"creditsTimesToday": 2,
"credits": 300,
"score": 24567,
"grade": 1024,
"playDuration": 4567
}
},
//领奖
"collectionPrize": {
//获取道具数量
"getTools": {
"code": 0,
"data": {
"bombCount": 3,
"exchangeCount": 0,
"netCount": 0
},
"success": true,
"errorMessage": "ok"
"message": "ok"
},
//选择奖励
"choosePrize": {
"code": 0,
//获取任务列表
"getTaskList": {
"success": true,
"errorMessage": "ok"
},
//获取可选择的奖品列表
"getPrizeList": {
"code": 10000,
"data": {
"list": [
{
"image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
"activityId": "5e82d9db347ad421de487df7",
"ename": "98e8af5681924b06beb09ca42215ef0c",
"createTime": 1585633755684,
"openId": "AAHg4uxWAKY3lWPqUtHiTOuF",
"deleteStatus": 1,
"name": "权益类型",
"updateTime": 1585633755684,
"_id": "5e82d9dbac0ac97ac0d45c61",
"type": 2,
"restStock": 0,//<=0 库存不足
// "noCount":true 没有选择次数
"taskName": "doFollowShop",
"isComplete": true,
"taskDrawStatus": 0
},
{
"image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
"activityId": "5e82d9db347ad421de487df7",
"credits": 20,
"createTime": 1585633755684,
"openId": "AAHg4uxWAKY3lWPqUtHiTOuF",
"deleteStatus": 1,
"name": "积分类型",
"totalStock": 100,
"updateTime": 1585633755684,
"_id": "5e82d9dbac0ac97ac0d45c62",
"type": 3,
// "noCount":true
"taskName": "doInvite",
"isComplete": false,
"taskDrawStatus": 0
},
// {
// "image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
// "activityId": "5e82d9db347ad421de487df7",
// "createTime": 1585633755684,
// "openId": "AAHg4uxWAKY3lWPqUtHiTOuF",
// "deleteStatus": 1,
// "name": "实物类型",
// "totalStock": 100,
// "updateTime": 1585633755684,
// "_id": "5e82d9dbac0ac97ac0d45c63",
// "type": 4
// },
// {
// "image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
// "activityId": "5e82d9db347ad421de487df7",
// "createTime": 1585633755684,
// "openId": "AAHg4uxWAKY3lWPqUtHiTOuF",
// "deleteStatus": 1,
// "name": "实物类型",
// "totalStock": 100,
// "updateTime": 1585633755684,
// "_id": "5e82d9dbac0ac97ac0d45c63",
// "type": 4
// },
// {
// "image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
// "activityId": "5e82d9db347ad421de487df7",
// "createTime": 1585633755684,
// "openId": "AAHg4uxWAKY3lWPqUtHiTOuF",
// "deleteStatus": 1,
// "name": "实物类型",
// "totalStock": 100,
// "updateTime": 1585633755684,
// "_id": "5e82d9dbac0ac97ac0d45c63",
// "type": 4
// }
{
"taskName": "doCollect",
"isComplete": false,
"collectCount": 3,
"taskDrawStatus": 0
},
{
"taskName": "doOrder",
"isComplete": false,
"taskDrawStatus": 0
}
]
},
"success": true,
"message": "成功"
},
//获取可领取的奖品,就一个,看状态是否完成
"getCollectionPrize": {
"code": 10000,
"data": {
"prizeInfo": {
"image": "//yun.duiba.com.cn/aurora/assets/3c0cc7a660dc9f41af113eaa09ef3f512cd0669a.png",
"getMsg": "",
"distance": 100,
"openId": "AAHw4uxWAKY3lWHqUtPxyu4F",
"getStatus": 1,//6是重新领取状态
"type": 2,
"prizeId": "5e82d9dbac0ac97ac0d45c61",
"activityId": "5e82d9db347ad421de487df7",
"ename": "98e8af5681924b06beb09ca42215ef0c",
"prizeLevel": 1,
"name": "权益类型",
"_id": "5e82e283d86ed65836a807a7",
"isComplete": false
}
},
"success": true,
"message": "成功"
},
//获取自己的分享Id
"getShareId": {
"code": 0,
"data": {
"shareId": "AAFdOf3jAJ9vbnS7X6h0Kros"
},
"success": true,
"errorMessage": "ok"
},
//获取游戏规则
"getGameInfo": {
"code": 0,
"data": {
"rule": "aaaaaaaa\n阿斯达克风景区而离开期间为人情味人品全家人迫切居然跑去居然跑去让聘请外籍热切盼望进入强迫微软进去哦陪我认为金融排气昂克赛拉的骄傲快乐圣诞节爱丽丝的卡拉生当届阿里方污染破七万人哦强我弱\n阿三大苏打去微软亲热我去无人区热情而日期而且我人权为荣去微软去微软去微软去微软\nasd qw去问问请问我去饿请问齐威王恶趣味恶趣味恶趣味请问请问"
},
"success": true,
"errorMessage": "ok"
},
//获取游戏规则
"checkIsMember": {
"code": 0,
"data": {
"memberUrl": "//store.taobao.com/shop/view_shop.htm?user_number_id=2207623078795&extraInfo=%7B%22source%22%3A%22isvapp%22%2C%22activityId%22%3A%225e82d9db347ad421de487df7%22%2C%22entrance%22%3A%22duiba%22%7D",
"isMember": false,
},
"success": true,
"errorMessage": "ok"
},
}
}
}
/**
......
import { Sprite } from "../engine/2d/display";
import { RES } from "../module/RES";
import { GTool } from "../module/tools/GTool";
import { TEXT_ALIGN } from "../engine/2d/const";
import { TextField } from "../engine/2d/text";
import { Graphics } from "../engine/2d/graphics";
/**
* 定制,记录一些全局量和方法
......@@ -48,40 +51,69 @@ export class Tool {
sprite.y = y;
return sprite
}
/**
* 最大距离
*/
public static maxDistance: number = 1000;
//当前奖品的Icon图片,现在链接测试,注意需要更新
public static curPrizeIcon: string //= "//yun.duiba.com.cn/images/201607/73htz55ih9.jpg"
public static memberUrl: string;
public static endTime: number;
public static addText(
txt: string,
size: number,
color: string = "#000000",
align: TEXT_ALIGN = TEXT_ALIGN.CENTER,
textWidth: number = 0,
x: number = 0,
y: number = 0
) {
var text = new TextField();
text.fillColor = color;
text.size = size;
text.textWidth = textWidth;
text.textAlign = align;
text.x = x;
text.y = y;
text.text = txt;
return text
}
/**
* 已经过期
*/
public static hasExpired: boolean
/**
* 自己的分享shareId
* 左上角原点
* @param width
* @param height
* @param color
* @param alpha
* @param radius
* @param x
* @param y
*/
public static openId: string
public static addRect(
width: number,
height: number,
color: number = 0xff0000,
alpha: number = 1,
radius: number = 0,
x: number = 0,
y: number = 0,
) {
var g = new Graphics();
g.beginFill(color);
g.alpha = alpha;
if (!radius) {
g.drawRect(0, 0, width, height)
} else {
g.drawRoundedRect(0, 0, width, height, radius)
}
g.endFill();
g.position.set(x, y);
return g
}
//进页面需要从小程序获得的数据
public static globalData: {
joinNeedsCredits: number,
activityId: string,
nickName: string,
avatar: string,
shareId?: string,//分享者的
theme:string,//adult kid
theme: string,//adult kid
};
/**
* 分享者的信息
*/
public static shareUserInfo: {
"avatar": string,
"nickName": string
}
}
\ No newline at end of file
import { Sprite } from "../../engine/2d/display";
import { RES } from "../../module/RES";
import { Event } from "../../engine/2d/events";
/**
* 旋转光
*/
export class Light extends Sprite {
constructor() {
super();
this.texture = RES.getRes("light.png");
this.anchorTexture.set(0.5, 0.5);
this.addEventListener(Event.ENTER_FRAME, () => {
this.rotation += 1;
}, this)
}
}
\ No newline at end of file
import { sendTbNet, TbNetName } from "./TaoBaoNet";
import { Tool } from "./Tools";
import { GDispatcher } from "../engine/2d/events";
/**
*
* @param callback
* @param score
* @param grade
* @param isFinal 是否最终提交,默认是的
*/
export function submit(callback: (s: boolean, res?: any) => void, score: number, grade: number, id: string, isFinal: boolean = true) {
sendTbNet(
TbNetName.submit,
{
activityId: Tool.globalData.activityId,
grade: grade,
score: score,
type: isFinal ? 1 : 0,
playId: id
},
(s, res) => {
callback(s, res)
}
)
}
/**
* 获取道具数量
* 自动派发事件
* 暂时可能不需要加回调,需要时再说
*/
export function getTools() {
sendTbNet(
TbNetName.getTools,
{ actitvityId: Tool.globalData.activityId },
(s, res) => {
//如果成功就更新道具数量
if (s) GDispatcher.dispatchEvent("updateProp", res.data.bombCount, res.data.exchangeCount, res.data.netCount)
},
true
)
}
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { Light } from '../common/Light';
import { TextField } from '../../engine/2d/text';
import { TEXT_ALIGN } from '../../engine/2d/const';
import { sendTbNet, TbNetName } from '../TaoBaoNet';
import { showWaiting, hideWaiting, getCurrentScene } from '../../module/ctrls';
import { PlayScene } from '../scenes/playScene/PlayScene';
import { GDispatcher } from '../../engine/2d/events';
import Tween from '../../engine/tween/Tween';
import { Ease } from '../../engine/tween/Ease';
const levelDes = {
2: "33",
4: "11",
8: "11",
16: "22",
32: "22",
64: "22",
128: "22",
256: "22",
512: "22",
1024: "22",
2048: "22",
}
/**
* 游戏结束
*/
export class GameOverPanel extends Panel {
get groupNames() { return ["gameOverPanel"] }
closeBtn: Button;
returnBtn: Button;
againBtn: Button;
goEarnBtn: Button;
data: {
score: number;
playDuration: number;
grade: number;
credits?: number//获取的积分
creditsTimesToday?: number
}
initUi() {
//加光
this.addChild(new Light()).position.set(375, 735);
//背景
this.addChild(Tool.addSprite("gameOverPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(612, 460);
this.addChild(this.closeBtn);
//分数
var scoreTxt = new TextField();
scoreTxt.fillColor = "#fada30";
scoreTxt.bold = true;
scoreTxt.size = 72;
scoreTxt.textWidth = 550;
scoreTxt.textAlign = TEXT_ALIGN.CENTER;
scoreTxt.x = 90;
scoreTxt.y = 660;
scoreTxt.text = this.data.score + "";
this.addChild(scoreTxt)
//获得积分文案,根据数据判断
if (this.data.credits) {
this.addChild(Tool.addText(
"获得" + this.data.credits + "积分(今日" + this.data.creditsTimesToday + "/3)",
24,
"#ddccfe",
TEXT_ALIGN.CENTER,
350,
200,
731
))
}
//印章
var t: string;
if (this.data.score >= 2000) {
t = "scoreLevel3"
} else if (this.data.score >= 1000) {
t = "scoreLevel2"
} else if (this.data.score >= 300) {
t = "scoreLevel1"
}
if (t) {
var yin = Sprite.from(t + ".png");
yin.alpha = 0;
yin.position.set(200, 600)
yin.scale.set(2, 2);
this.addChild(yin);
Tween.get(yin).to({ x: 40, y: 497, alpha: 1, scaleX: 1, scaleY: 1 }, 500, Ease.quadIn)
}
//时间
var timeTxt = new TextField();
timeTxt.fillColor = "#ebde69";
timeTxt.size = 28;
timeTxt.textWidth = 270;
timeTxt.textAlign = TEXT_ALIGN.CENTER;
timeTxt.x = 117;
timeTxt.y = 855;
timeTxt.text = date_format(this.data.playDuration);
this.addChild(timeTxt)
//最高解锁
var levelTxt = new TextField();
levelTxt.fillColor = "#ebde69";
levelTxt.size = 28;
levelTxt.textWidth = 118;
levelTxt.textAlign = TEXT_ALIGN.CENTER;
levelTxt.x = 450;
levelTxt.y = 855;
levelTxt.text = this.data.grade + "";
this.addChild(levelTxt)
//最高解锁形容词
var desTxt = new TextField();
desTxt.fillColor = "#b093ea";
desTxt.size = 18;
desTxt.textWidth = 118;
desTxt.textAlign = TEXT_ALIGN.CENTER;
desTxt.x = 450;
desTxt.y = 887;
desTxt.text = "(" + levelDes[this.data.grade] + ")";
this.addChild(desTxt);
//返回首页按钮
this.returnBtn = this.addChild(new Button(RES.getRes("fanhuishouye.png"))) as Button;
this.returnBtn.position.set(117, 959);
//再来一次按钮
this.againBtn = this.addChild(new Button(RES.getRes("zailaiyiju.png"))) as Button;
this.againBtn.position.set(383, 959);
this.againBtn.visible = false;
//去赚积分按钮
this.goEarnBtn = this.addChild(new Button(RES.getRes("quzhuanjifen.png"))) as Button;
this.goEarnBtn.position.set(383, 959);
this.goEarnBtn.visible = false;
//积分/次文案
var needCreditsTxt = this.addChild(Tool.addText(
"(" + Tool.globalData.joinNeedsCredits + "积分/次)",
24,
"#b093ea",
TEXT_ALIGN.CENTER,
233,
383,
1044
))
needCreditsTxt.visible = false;
//先获取积分,然后判断
sendTbNet(TbNetName.getCredits, { activityId: Tool.globalData.activityId }, (s, res) => {
//积分足够
if (s && res.data.credits && res.data.credits >= Tool.globalData.joinNeedsCredits) {
needCreditsTxt.visible = true;
this.againBtn.visible = true;
} else {
this.goEarnBtn.visible = true;
}
})
}
start() {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.returnBtn, this.onClick_closeBtn, this)
this.onClick(this.againBtn, this.onClick_againBtn, this)
this.onClick(this.goEarnBtn, this.onClick_goEarnBtn, this)
}
onClick_closeBtn() {
// this.hidePanel();
//回到首页
sendTbNet(TbNetName.navigateBack, { delta: 1 }, () => { })
}
onClick_againBtn() {
//发接口,重玩游戏 TODO
showWaiting();
sendTbNet(
TbNetName.startGame,
{ activityId: Tool.globalData.activityId, nickName: Tool.globalData.nickName },
(s, res: { data: { maxScore: number, unlockGrade: number, bombCount: number, exchangeCount: number, netCount: number } }) => {
hideWaiting();
this.hidePanel();
if (s) {
var data = res.data
var playScene: PlayScene = getCurrentScene();
// playScene.resetGame(res.unlockGrade)//代加参数,方法
//修改道具数量
GDispatcher.dispatchEvent("updateProp", data.bombCount, data.exchangeCount, data.netCount)
}
}
)
}
onClick_goEarnBtn() {
//链接待填
sendTbNet(TbNetName.navigateToOutside, { url: "" }, () => { })
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this);
this.removeClick(this.returnBtn, this.onClick_closeBtn, this);
this.removeClick(this.againBtn, this.onClick_againBtn, this);
this.removeClick(this.goEarnBtn, this.onClick_goEarnBtn, this);
}
}
//转换时分秒
//时分秒换算
function date_format(micro_second) {
// 总秒数
var second = Math.floor(micro_second / 1000);
// 天数
var day = Math.floor(second / 3600 / 24);
// 小时
var hr = Math.floor(second / 3600 % 24);
// 分钟
var min = Math.floor(second / 60 % 60);
// 秒
var sec = Math.floor(second % 60);
// return day + "天" + hr + "小时" + min + "分钟" + sec + "秒";
// return (hr + day * 24) + "小时" + min + "分" + sec + "秒";
var str = sec + "秒";
if (min) str = min + "分" + str;
if (hr + day * 24) str = (hr + day * 24) + "小时" + str;
return str
};
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { showPanel } from '../../module/ctrls';
import { TaskPanel } from './TaskPanel';
export class PropOutPanel extends Panel {
get groupNames() { return ["propOutPanel"] }
closeBtn: Button;
getPropBtn: Button;
initUi() {
//背景
this.addChild(Tool.addSprite("propOutPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(627, 471);
this.addChild(this.closeBtn);
//获取道具按钮,弹出任务弹框
this.getPropBtn = new Button(RES.getRes("getPropBtn.png"));
this.getPropBtn.position.set(209, 749);
this.addChild(this.getPropBtn);
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.getPropBtn, this.onClick_getPropBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
onClick_getPropBtn() {
this.hidePanel();
showPanel(TaskPanel)
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
this.removeClick(this.getPropBtn, this.onClick_getPropBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { showPanel, showToast, getCurrentScene, showWaiting, hideWaiting } from '../../module/ctrls';
import { TaskPanel } from './TaskPanel';
import { GDispatcher } from '../../engine/2d/events';
import { TextField } from '../../engine/2d/text';
import { PlayScene } from '../scenes/playScene/PlayScene';
import { sendTbNet, TbNetName } from '../TaoBaoNet';
import { GameOverPanel } from './GameOverPanel';
import { submit } from '../commonNet';
/**
* 道具弹框,还没好
*/
export class PropPanel extends Panel {
get groupNames() { return ["propPanel"] }
closeBtn: Button;
quitBtn: Button;
getPropBtn: Button;
//炸弹
private bombCountTxt: TextField;
private _bombCount: number;
private bombArea: Graphics;
get bombCount() {
return this._bombCount;
}
set bombCount(value) {
this._bombCount = value;
this.bombCountTxt.text = value > 99 ? "99" : value + ""
}
//交换
private exchangeCountTxt: TextField;
private _exchangeCount: number;
private exchangeArea: Graphics;
get exchangeCount() {
return this._exchangeCount;
}
set exchangeCount(value) {
this._exchangeCount = value;
this.exchangeCountTxt.text = value > 99 ? "99" : value + ""
}
//滤网
private netCountTxt: TextField;
private _netCount: number;
private netArea: Graphics;
get netCount() {
return this._netCount;
}
set netCount(value) {
this._netCount = value;
this.netCountTxt.text = value > 99 ? "99" : value + ""
}
data: {
bombCount: number,
exchangeCount: number,
netCount: number,
grade: number,
score: number,
id: string;
}
initUi() {
//背景
this.addChild(Tool.addSprite("propPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(613, 460);
this.addChild(this.closeBtn);
//放弃按钮
this.quitBtn = this.addChild(new Button(RES.getRes("fangqi.png")));
this.quitBtn.position.set(116, 926);
//获取道具按钮
this.getPropBtn = this.addChild(new Button(RES.getRes("huoqudaoju.png")))
this.getPropBtn.position.set(383, 926);
//文案
this.bombCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 194, 728))
this.exchangeCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 377, 728))
this.netCountTxt = this.addChild(Tool.addText("", 28, "#ffffff", undefined, 70, 556, 728))
//点击区域
this.bombArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 117, 717))
this.exchangeArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 296, 717))
this.netArea = this.addChild(Tool.addRect(126, 142, undefined, 0, 0, 476, 717))
}
start() {
super.start();
//需要添加事件,如果道具数量更新了,需要执行
GDispatcher.addEvent("updateProp", this.updateProp, this);
this.bombCount = this.data.bombCount;
this.exchangeCount = this.data.exchangeCount;
this.netCount = this.data.netCount;
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
this.onClick(this.quitBtn, this.onClick_closeBtn, this)
this.onClick(this.getPropBtn, this.onClick_getPropBtn, this)
this.onClick(this.bombArea, this.onClick_prop, this);
this.onClick(this.exchangeArea, this.onClick_prop, this);
this.onClick(this.netArea, this.onClick_prop, this);
}
onClick_closeBtn() {
// this.hidePanel();//提交完成再关闭,弹其他弹窗
//提交游戏
showWaiting();
submit((s, res) => {
hideWaiting();
if (s) {
this.hidePanel();
//显示结束弹框
showPanel(GameOverPanel, res.data)
}
}, this.data.score, this.data.grade, this.data.id)
}
onClick_getPropBtn() {
showPanel(TaskPanel)
}
updateProp(bombCount: number, exchangeCount: number, netCount: number) {
this.bombCount = bombCount;
this.exchangeCount = exchangeCount;
this.netCount = netCount;
}
onClick_prop(e: MouseEvent) {
let count: number, type: string;
if (e.target == this.bombArea) {
count = this.bombCount;
type = "onClick_bombBtn"
}
else if (e.target == this.exchangeArea) {
count = this.exchangeCount;
type = "onClick_exchangeBtn"
}
else if (e.target == this.netArea) {
count = this.netCount;
type = "onClick_filterBtn"
}
if (!count) {
showToast("暂无此道具,快去赚取道具吧")
return
}
this.hidePanel();
//执行道具的方法
getCurrentScene()[type]();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
this.removeClick(this.quitBtn, this.onClick_closeBtn, this)
this.removeClick(this.getPropBtn, this.onClick_getPropBtn, this)
this.removeClick(this.bombArea, this.onClick_prop, this);
this.removeClick(this.exchangeArea, this.onClick_prop, this);
this.removeClick(this.netArea, this.onClick_prop, this);
GDispatcher.removeEvent("updateProp", this.updateProp, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { submit } from '../commonNet';
import { showWaiting, hideWaiting, showPanel } from '../../module/ctrls';
import { GameOverPanel } from './GameOverPanel';
/**
* 弹框复制用
*/
export class QuitPanel extends Panel {
get groupNames() { return ["quitPanel"] }
closeBtn: Button;
data: {
grade: number,
score: number,
id: string//订单id
}
initUi() {
//背景
this.addChild(Tool.addSprite("quitPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(630, 467);
this.addChild(this.closeBtn);
//继续闯关
this.addChild(new Button(RES.getRes("jixuchuangguan.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set(398, 750)
//退出本关,提交后,出结束弹框,
this.addChild(new Button(RES.getRes("tuichubenguan.png")))
.once(MouseEvent.CLICK, () => {
showWaiting();
//提交
submit((s, res) => {
hideWaiting();
if (!s) return
this.hidePanel();
//显示结束弹框
showPanel(GameOverPanel, res.data)
}, this.data.score, this.data.grade, this.data.id)
}, this)
.position.set(134, 750)
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
/**
* 任务完成,点击领取弹框,还没好
*/
export class TaskCompletePanel extends Panel {
get groupNames() { return ["taskCompletePanel"] }
closeBtn: Button;
initUi() {
//背景
this.addChild(Tool.addSprite("taskCompletePanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(630, 468);
this.addChild(this.closeBtn);
//开心收下
this.addChild(new Button(RES.getRes("kaixinshouxia.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set(212, 846)
//领奖内容,注意发接口刷新道具数量,更新场景道具数量
}
data: {
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { layers } from '../../module/views/layers';
import Tween from '../../engine/tween/Tween';
/**
* 任务弹框,还没好
*/
export class TaskPanel extends Panel {
get groupNames() { return ["taskPanel"] }
closeBtn: Button;
initUi() {
//底部适配,原先都是居中的,
this.y = (layers.stageHeight - 1624) / 2
//背景
this.addChild(Tool.addSprite("taskPanelBg.png")).position.set(0, 1624 - 1075);
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(681, 870);
this.addChild(this.closeBtn);
//四个按钮
}
//动画重写,从下往上
showAni() {
var oriY = this.y;
this.y += this.getLocalBounds().height;
Tween.get(this)
.to({ y: oriY }, 500)
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
\ No newline at end of file
import { Rectangle } from '../../engine/2d/math/Rectangle';
import { Tool } from "../Tools";
import { Button } from "../../engine/2d/ui/Button";
import { MouseEvent } from "../../engine/2d/events/MouseEvent";
import { Panel } from "../../module/views/Panel";
import { RES } from "../../module/RES";
import { Sprite, Container } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
import { Light } from '../common/Light';
import { BitmapText } from '../../engine/2d/text';
import { TEXT_ALIGN } from '../../engine/2d/const';
const foodData: {
[key: number]: { name: string, des: string }
} = {
8: { name: "啊是大", des: "自学成才" },
16: { name: "", des: "" },
32: { name: "", des: "" },
64: { name: "", des: "" },
128: { name: "良品铺子猪肉脯", des: "靖江特产独立小包装肉干网红休闲零食小吃" },
256: { name: "", des: "" },
512: { name: "", des: "" },
1024: { name: "", des: "" },
2048: { name: "", des: "" },
}
/**
* 解锁弹框
*/
export class UnlockPanel extends Panel {
get groupNames() { return ["unlockPanel"] }
closeBtn: Button;
data: {
grade: number
}
initUi() {
//加光
this.addChild(new Light()).position.set(375, 735);
//背景
this.addChild(Tool.addSprite("unlockPanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(614, 460);
this.addChild(this.closeBtn);
//继续游戏
this.addChild(new Button(RES.getRes("jixuyouxi.png")))
.once(MouseEvent.CLICK, this.onClick_closeBtn, this)
.position.set((750 - 341) / 2, 978)
//标题文案
this.addChild(new Title(this.data.grade))
//奖品图片 246;
this.addChild(new Sprite(RES.getRes("unlock" + this.data.grade + ".png")))
.position.set((750 - 246) / 2, 622)
//名字
this.addChild(Tool.addText(
foodData[this.data.grade].name,
28,
"#ffffff",
undefined,
560,
(750 - 560) / 2,
890
))
//描述
this.addChild(Tool.addText(
foodData[this.data.grade].des,
22,
"#dac5fc",
undefined,
560,
(750 - 560) / 2,
931
))
}
start(data) {
super.start();
}
initEvents() {
this.onClick(this.closeBtn, this.onClick_closeBtn, this)
}
onClick_closeBtn() {
this.hidePanel();
}
removeEvents() {
this.removeClick(this.closeBtn, this.onClick_closeBtn, this)
}
}
class Title extends Container {
grade: number
constructor(grade: number) {
super();
var msg = new Sprite(RES.getRes("unlockMsg.png"))
this.addChild(msg);
var textures = {}
for (var i = 0; i < 10; i++)textures[i] = RES.getRes("n" + i + ".png");
var num = new BitmapText(textures);
num.textAlign = TEXT_ALIGN.LEFT;
num.text = grade + "";
this.addChild(num);
var w = msg.width + num.width;
msg.position.set((750 - w) / 2, 548);
num.position.set(msg.x + msg.width, 548 + 4)
}
}
\ No newline at end of file
......@@ -9,29 +9,28 @@ import { Sprite } from "../../engine/2d/display";
import { Graphics } from '../../engine/2d/graphics';
/**
* 奖品擦肩而过的弹框
* 弹框复制用
*/
export class PanelBase extends Panel {
get groupNames() { return ["common", "rulePanel"] }
bg
get groupNames() { return ["rulePanel"] }
closeBtn: Button;
/**
* 关闭之后的回调
*/
closeFun;
initUi() {
//背景
this.bg = this.addChild(Tool.addSprite("rulePanelBg.png", (750 - 600) / 2, 200));
this.addChild(Tool.addSprite("rulePanelBg.png"));
//关闭按钮
this.closeBtn = new Button(RES.getRes("comCloseBtn.png"));
this.closeBtn.position.set(650, 380);
this.addChild(this.closeBtn);
}
data:{
}
start(data) {
super.start();
}
initEvents() {
......@@ -39,7 +38,7 @@ export class PanelBase extends Panel {
}
onClick_closeBtn() {
this.hidePanel()
this.hidePanel();
}
removeEvents() {
......
......@@ -25,20 +25,46 @@ import { AdjustmentFilter } from "../../engine/2d/filter/adjustment/AdjustmentFi
import { AdvancedBloomFilter } from "../../engine/2d/filter/advanced-bloom/AdvancedBloomFilter";
import { Scene } from "../../module/views/Scene";
import { RES } from "../../module/RES";
import { changeScene } from "../../module/ctrls";
import { changeScene, showPanel } from "../../module/ctrls";
import { layers } from "../../module/views/layers";
import { NineSlicePlane } from '../../engine/2d/mesh';
import { Rope } from '../../engine/2d/mesh/Rope';
import { GameOverPanel } from '../panels/GameOverPanel';
import { PropOutPanel } from '../panels/PropOutPanel';
import { TaskPanel } from '../panels/TaskPanel';
import { PropPanel } from '../panels/PropPanel';
import { QuitPanel } from '../panels/QuitPanel';
import { UnlockPanel } from '../panels/UnlockPanel';
import { TaskCompletePanel } from '../panels/TaskCompletePanel';
export class StartScene extends Scene {
get groupNames(): string[] { return ["startScene"] }
start() {
super.start();
// this.scaleX=0.5
// showPanel(PrizePanel)
showPanel(TaskPanel)
// showPanel(TaskCompletePanel)
// showPanel(UnlockPanel,{grade:128})
// showPanel(PropPanel, {
// bombCount: 22,
// exchangeCount: 22,
// netCount: 33,
// score: 22,
// grade: 1024,
// id:"223"
// })
// showPanel(QuitPanel, {
// score: 22,
// grade: 1024,
// id:"223"
// })
// showPanel(GameOverPanel, {
// score: 4444,
// playDuration: 956456,
// grade: 1024,
// credits: 20,
// creditsTimesToday: 1
// })
// setTimeout(() => {
// // console.log(this.stage)
// // this.stage.globalToLocal(new Point(10, 1))
......@@ -59,7 +85,7 @@ export class StartScene extends Scene {
// this.testDisplaceFilter()
// this.testEditableText()
// this.testNine();
this.testRope()
// this.testRope()
}
//初始化ui
initUi() {
......
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