Commit 327c7643 authored by zhangjinzhou's avatar zhangjinzhou

气球,盲盒,星星宝箱暂存

parent 3c97d3bd
export enum CouponJoinScene{
BlindBox=0,//盲盒
//星级宝箱
StarBox1,
StarBox2,
StarBox3,
//通关
Checkpoint,
Buoy,
}
export interface CouponJoinOptions{
scene:CouponJoinScene,//场景
beforeUse:Function,//跳转前
afterClose:Function,//关闭
}
export interface ShowTurnCircleOptions{
afterClose:Function,//关闭转盘
}
export default class Utils {
constructor() {
......@@ -125,4 +143,23 @@ export default class Utils {
rect2.y = obj2.y;
return rect1.intersects(rect2);
}
//奖品相关弹窗
static couponJoin(scene:CouponJoinScene,beforeUse=()=>{},afterClose=()=>{}):void{
let options:CouponJoinOptions = {
scene:scene,
beforeUse:beforeUse,
afterClose:afterClose
}
console.error("奖品弹窗点击===》",scene);
beforeUse&&beforeUse();
afterClose&&afterClose();
}
//展示大转盘
static showTurnCircle(afterClose=()=>{}):void{
let options:ShowTurnCircleOptions = {
afterClose,
}
afterClose&&afterClose();
}
}
\ No newline at end of file
......@@ -67,6 +67,8 @@ import getRedBombAward, { getRedBombTimes } from '../getRedBombAward';
import { FesRedBombShowAni } from '../something/anisCall/FesRedBombShowAni';
import { RectsWaveAni } from '../something/anisCall/RectsWaveAni';
import { Door } from '../something/class/Door';
import Utils, { CouponJoinScene } from '../Utils';
import { Candy } from '../../../../../../../node_modules/@spark/guideact/types/something/class/Candy';
const aniClass = {
"BoomAni": BoomAni,
......@@ -248,7 +250,9 @@ export default class MainScene extends Scene {
failStep: false
}
//气球宝箱
balloonsp:eui.Image;
balloonsp: eui.Image;
//盲盒
alertBlindBox = false;
start(data: { chapter: number, boom: number, hammer: number, step: number, videoProp: number[] }) {
// 请求游戏内banner 由于卡顿问题,暂时去掉
......@@ -279,6 +283,9 @@ export default class MainScene extends Scene {
if (b1ele != 1) {
canadd = false;
}
if(canadd&&!this.chapterData.map.lattices[b1]){
canadd = false;
}
if (canadd) {
for (let showidx of chaptershowidxs) {
if (showidx.indexOf(b1) != -1) {
......@@ -287,30 +294,32 @@ export default class MainScene extends Scene {
}
}
}
if(canadd){
for(let biridx of chapterbirthidx){
if(biridx.index==b1){
if (canadd) {
for (let biridx of chapterbirthidx) {
if (biridx.index == b1) {
canadd = false;
break;
}
}
}
if(canadd){
for(let cntidx of chapterconnectidx){
if(cntidx.indexOf(b1)!=-1){
if (canadd) {
for (let cntidx of chapterconnectidx) {
if (cntidx.indexOf(b1) != -1) {
canadd = false;
break;
}
}
}
if(canadd){
if (canadd) {
brandidxs.push(b1);
}
}
if(brandidxs.length){
let randidx = brandidxs[Math.floor(Math.random()*brandidxs.length)];
if (brandidxs.length) {
let randidx = brandidxs[Math.floor(Math.random() * brandidxs.length)];
this.chapterData.map.elements[randidx] = 21;
console.error("设置盲盒idx===》",randidx);
console.error("本关存在盲盒,位置:",randidx);
}else{
console.error("本关没有盲盒",this.chapter);
}
}
//初始化目标信息
......@@ -382,23 +391,24 @@ export default class MainScene extends Scene {
let topboty = 224;
let gametopy = 224;
let lattices = this.chapterData.map.lattices;
for(var m=0;m<lattices.length;m++){
if(lattices[m]){
for (var m = 0; m < lattices.length; m++) {
if (lattices[m]) {
gametopy = Tool.getPositionByIndex(m)[1]
break;
}
}
if(gametopy<224){
if (gametopy < 224) {
gametopy = 224;
}
this.balloonsp.y = (gametopy-topboty)/2+topboty-balloonhei/2;
this.balloonsp.y = (gametopy - topboty) / 2 + topboty - balloonhei / 2;
let movetime = 5000;
egret.Tween.get(this.balloonsp,{loop:true}).to({
x:750-balloonwid
},movetime)
egret.Tween.get(this.balloonsp, { loop: true }).to({
x: 750 - balloonwid
}, movetime)
.to({
x:0
},movetime)
x: 0
}, movetime)
this.balloonsp.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickBallon, this);
}
/**
* 加载所有用到的svga
......@@ -455,7 +465,7 @@ export default class MainScene extends Scene {
this.addChild(curScoreNum);
//分数进度条,托管
this.scoreProgress = new ScoreProgress(this.starProgress, curScoreNum, this.chapterData.starScores);
this.scoreProgress = new ScoreProgress(this.starProgress, curScoreNum, this.chapterData.starScores, this.addStarDia.bind(this));
//分数置0
this.score = 0;
//地图生成
......@@ -2009,6 +2019,11 @@ export default class MainScene extends Scene {
this.eliminate()
return
}
if (this.alertBlindBox) {
this.solveDiaPush("blind");
this.alertBlindBox = false;
}
AiControl.ins.doorMotion(this, () => {
//鸡蛋的ai操作,存在判断三消,毛球的ai,也一样,所以放前面,存在三消时都直接执行eliminate了。不执行后续的回调
AiControl.ins.eggMotion(this, () => {
......@@ -2085,7 +2100,8 @@ export default class MainScene extends Scene {
setTimeout(() => { this.steps += 5; }, 333)
}
})
PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { });
this.solveDiaPush("fail",panelsDatas);
// PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { });
// PanelCtrl.instance.show("failed", { level: this.chapter });
return
}
......@@ -2119,7 +2135,8 @@ export default class MainScene extends Scene {
setTimeout(() => {
// playSound(SoundType.fail);
var panelsDatas = this.returnPanels("failed", { level: this.chapter })
PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { });
this.solveDiaPush("fail",panelsDatas);
// PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { });
// PanelCtrl.instance.show("failed", { level: this.chapter });
}, 1000)
} else {
......@@ -2415,6 +2432,7 @@ export default class MainScene extends Scene {
this.removeBlind(index);
//算个数
this.goElementTarget(ele.type, [ele.x, ele.y]);
this.alertBlindBox = true;
}
//果冻
else if (ele.type == ElementType.JELLY) {
......@@ -2820,7 +2838,8 @@ export default class MainScene extends Scene {
// PanelCtrl.instance.show(ModuleTypes.NO_PRIZE_PANEL, { level: this.chapter });
}
//弹出所有的
PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { })
this.solveDiaPush("success",panelsDatas);
// PanelCtrl.instance.showPanels(panelsDatas[0], panelsDatas[1], () => { })
} else {
if (!data) {
......@@ -3104,4 +3123,98 @@ export default class MainScene extends Scene {
this.quitBtn.touchEnabled = b;
this.enableTouch = b;
}
//气球点击
clickBallon() {
egret.Tween.removeTweens(this.balloonsp);
this.solveDiaPush("ballon");
this.removeChild(this.balloonsp);
}
//星星宝箱点击
addStarDia(staridx) {
this.solveDiaPush(("star"+staridx));
}
//气球奖励开启
openBallonDia(){
Utils.couponJoin(CouponJoinScene.Buoy,()=>{
},()=>{
this.isInDom = false;
this.showOneDia();
});
}
//盲盒弹窗
openBlindBox() {
Utils.couponJoin(CouponJoinScene.BlindBox,()=>{
},()=>{
this.isInDom = false;
this.showOneDia();
});
}
//星星宝箱开启
openStarDia(staridx){
Utils.couponJoin(CouponJoinScene["StarBox" + staridx],()=>{
},()=>{
this.isInDom = false;
this.showOneDia();
});
}
diarr = [];
//当前状态是否处于展示dom弹窗
isInDom = false;
/**
*
* @param type 序列弹窗的类型,success,过关弹窗,fail,失败弹窗,ballon气球弹窗,blind盲盒弹窗,star星级弹窗
*/
solveDiaPush(type: string,data={}) {
let needadd = true;
for(let item of this.diarr){
if(item.type==type){
needadd = false;
break;
}
}
if(needadd){
this.diarr.push({
type,
data,
});
this.showOneDia();
}
}
showOneDia() {
if (this.diarr.length&&!this.isInDom) {
let onedia = this.diarr.shift();
const {type,data} = onedia;
switch (type) {
case "success":
PanelCtrl.instance.showPanels(data[0], data[1], () => { })
break;
case "fail":
PanelCtrl.instance.showPanels(data[0],data[1],()=>{
});
break;
case "ballon":
this.openBallonDia();
break;
case "blind":
this.openBlindBox();
break;
case "star1":
this.openStarDia(1);
break;
case "star2":
this.openStarDia(2);
break;
case "star3":
this.openStarDia(3);
break;
default:
console.error("为定义的弹窗类型==》", onedia);
break;
}
}
}
}
\ No newline at end of file
......@@ -327,7 +327,17 @@ export const Chapters10: ChapterData[] = [
bubbleProbability: 0,
stepCount: 25,
passTarget: { type: 1, elements: [{ type: 0, count: 30 }, { type: 1, count: 36 }] },
starScores: [5000, 11000, 19000], map: { lattices: [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0], connectedLats: [[31, 67], [45, 63], [46, 64], [47, 65], [51, 69], [52, 70], [53, 71]], elements: [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], baseElements: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], recycles: [], generateLats: [{ index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 8, type: null }] }
starScores: [5000, 11000, 19000], map: {
lattices: [1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 0], connectedLats: [[31, 67], [45, 63], [46, 64], [47, 65], [51, 69], [52, 70], [53, 71]], elements:
[
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], baseElements: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], recycles: [], generateLats: [{ index: 0, type: null }, { index: 1, type: null }, { index: 2, type: null }, { index: 3, type: null }, { index: 5, type: null }, { index: 6, type: null }, { index: 7, type: null }, { index: 8, type: null }]
}
},
//191
{
......
......@@ -175,8 +175,6 @@ export class Element extends eui.Component {
var texture: egret.Texture;
if(this.type==ElementType.BLIND_BOX){
texture = await loadImageByUrl("//yun.duiba.com.cn/aurora/assets/730048e95b89906c3a8076b88910ab272bc47d6f.jpeg");
console.error("盲盒网络图片显示===》",texture);
}else{
texture = RES.getRes(source);
}
......
import { loadImageByUrl } from "../../../libs/new_wx/loadSpriteSheet";
import Utils, { CouponJoinScene } from "../../Utils";
import { CurScoreNum } from "./CurScoreNum";
/**
......@@ -85,6 +87,7 @@ export class ScoreProgress {
mask.graphics.endFill();
}
/**
......@@ -93,7 +96,8 @@ export class ScoreProgress {
* @param scoreTxt 托管
* @param starScores
*/
constructor(starProgress: eui.Image, scoreTxt: CurScoreNum, starScores: number[]) {
constructor(starProgress: eui.Image, scoreTxt: CurScoreNum, starScores: number[],openStarDia) {
this.openStarDia = openStarDia;
this.starProgress = starProgress;
this.scoreTxt = scoreTxt;
this.starScores = starScores;
......@@ -120,5 +124,121 @@ export class ScoreProgress {
this.star3.x = 573;
this.star3.y = 76;
p.addChild(this.star3);
let starboxwid = 50;
let starboxhei = 50;
let starboxy = 25;
let starbox1x = 423;
let starbox2x = 498;
let starbox3x = 573;
this.starbox1 = new eui.Image();
this.starbox1.width = starboxwid;
this.starbox1.height = starboxhei;
p.addChild(this.starbox1);
this.starbox1.x = starbox1x;//-starboxwid/2;
this.starbox1.y = starboxy;
this.starbox2 = new eui.Image();
this.starbox2.width = starboxwid;
this.starbox2.height = starboxhei;
p.addChild(this.starbox2);
this.starbox2.x = starbox2x;//-starboxwid/2;
this.starbox2.y = starboxy;
this.starbox3 = new eui.Image();
this.starbox3.width = starboxwid;
this.starbox3.height = starboxhei;
p.addChild(this.starbox3);
this.starbox3.x = starbox3x;//-starboxwid/2;
this.starbox3.y = starboxy;
this.updateStarBox([2, 1, 0]);
this.starbox1.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickStar1,this);
this.starbox2.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickStar2,this);
this.starbox3.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickStar3,this);
}
//新增星星宝箱
starboxdata = [0, 0, 0];//0未开启,1待开启,2已开启
starbox1: eui.Image;
starbox2: eui.Image;
starbox3: eui.Image;
box1wid = 50;
box1hei = 50;
box2wid = 70;
box2hei = 70;
sbox1x = 423;
sbox2x = 498;
sbox3x = 573;
starwid = 46;
sboxy = 50;
updateStarBox(data) {
this.starboxdata = data;
this.setboxtex(0);
this.setboxtex(1);
this.setboxtex(2);
}
s1havetween = false;
s2havetween = false;
s3havetween = false;
openStarDia = null;
async setboxtex(idx) {
let sp: eui.Image = this["starbox" + (idx + 1)];
let data = this.starboxdata[idx];
let spx = this["sbox" + (idx + 1) + "x"];
let texurl = data == 2 ? "//yun.duiba.com.cn/aurora/assets/8312db117356184c07b0d67153ec67ba3ed16f9f.png" : "//yun.duiba.com.cn/aurora/assets/f565872fe14ec885c7a9935bc0cfc40515b81898.png";
sp.texture = await loadImageByUrl(texurl);
sp.width = data == 2 ? this.box2wid : this.box1wid;
sp.height = data == 2 ? this.box2hei : this.box1hei;
sp.anchorOffsetX = sp.width / 2;
sp.anchorOffsetY = sp.height / 2;
sp.x = spx + this.starwid / 2;// - sp.width / 2;
sp.y = this.sboxy;// - sp.height / 2;
if (data == 1) {
if (!this["s" + (idx + 1) + "havetween"]) {
this["s" + (idx + 1) + "havetween"] = true;
egret.Tween.get(sp, { loop: true }).to({
rotation: 30
}, 300)
.to({
rotation: -30
}, 600)
.to({
rotation: 0,
}, 300);
}
} else {
egret.Tween.removeTweens(sp);
}
}
//星星宝箱点击
clickStar1(){
if(this.starboxdata[0]==1){
this.openStarDia&&this.openStarDia(1);
}
}
clickStar2(){
if(this.starboxdata[1]==1){
this.openStarDia&&this.openStarDia(2);
}
}
clickStar3(){
if(this.starboxdata[2]==1){
this.openStarDia&&this.openStarDia(3);
}
}
}
\ No newline at end of file
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