Commit 7f560292 authored by wjf's avatar wjf

l

parent 26f7fb99
......@@ -6,21 +6,34 @@ import { DataManager } from "../libs/tw/manager/DataManager";
*/
export default (callback?) => {
NetManager.ins.hc_redBombAward((success) => {
callback(success);
if (success) {
const data = DataManager.ins.getData('hc_redBombAward').data;
if (data && data.option && data.option.categoryType != 1) {
callback(1);
}
else {
callback(0);
}
} else {
callback(0);
if (data) changeTimesData(data.remainAwardTimes || 0);
// if (data && data.option && data.option.categoryType != 1) {
// callback(1);
// }
// else {
// callback(0);
// }
}
NetManager.ins.hc_redBombBaseInfo(()=>{});
// else {
// callback(0);
// }
// NetManager.ins.hc_redBombBaseInfo(() => { });
});
}
export const getRedBombTimes = ()=>{
return DataManager.ins.getData('hc_redBombBaseInfo');
//如果接口没成功就返回0
export const getRedBombTimes = () => {
if (DataManager.ins.getData('hc_redBombBaseInfo') &&
DataManager.ins.getData('hc_redBombBaseInfo').data) {
return DataManager.ins.getData('hc_redBombBaseInfo').data;
}
return 0;
}
function changeTimesData(timess: number) {
DataManager.ins.getData('hc_redBombBaseInfo').data = timess;
}
\ No newline at end of file
......@@ -64,7 +64,8 @@ import { PropBtnCon } from '../something/uis/PropBtnCon';
import { ChapterNum } from '../something/uis/ChapterNum';
import { CurScoreNum } from '../something/uis/CurScoreNum';
import { FestivalTarget } from '../something/uis/FestivalTarget';
import getRedBombAward from '../getRedBombAward';
import getRedBombAward, { getRedBombTimes } from '../getRedBombAward';
import { FesRedBombShowAni } from '../something/anisCall/FesRedBombShowAni';
const aniClass = {
"BoomAni": BoomAni,
......@@ -81,7 +82,6 @@ const aniClass = {
"EggBrokenAni": EggBrokenAni,
"HairballGreyDisAni": HairballGreyDisAni,
// "HairballBlackDisAni": HairballBlackDisAni,
// "FestivalEleSmallDisAni": FestivalEleSmallDisAni,
}
export const baseScore = 20;
/**
......@@ -103,13 +103,17 @@ export const effectBaseTimes = {
EE: 25,
MM: 50
}
//加载器
let svgaParser;
//三个toast和bonusTime
const movieClips: any = {}
//红包炸弹弹框名字
const redBombPanelName = "aaaaa";
//所有可能被添加节日红包的关卡及索引,默认索引值都是40;如果没有就不放
const fesChapterData: number[] = [1]
//节日大红包格子索引
const festivalIndex: number = 40
export default class MainScene extends Scene {
get skinKey() { return 'Main2' }
......@@ -163,6 +167,8 @@ export default class MainScene extends Scene {
elementTargets: ElementTargets;
//节日元素目标
festivalTarget: FestivalTarget;
//节日小元素需要个数
festivalTargetNum: number = 6;
//所有元素的消耗数量,需要传给后端
hasEliminatedElements: number[];
//得分的动画,首先特效组合的单独算分,然后把所有符合的放入,在波及的特效触发时不算分
......@@ -239,20 +245,9 @@ export default class MainScene extends Scene {
this.chapterData = getChapterData(this.chapter);
//初始化目标信息
this.initTarget();
//添加节日元素,条件可能会变
if (111) {
//添加节日红包目标
this.festivalTarget = new FestivalTarget();
this.festivalTarget.x = 580;
this.festivalTarget.y = 115;
this.addChildAt(this.festivalTarget, 1);
//动效,修改最中间元素为红包
}
//初始化索引信息,包括10*10的,
Tool.init(Tool.getColOddEven(this.chapterData.map.lattices), !!(this.passElements && this.passElements[ElementType.LOLLIPOP]));
this.initUi();
this.initSvgas();
//先禁掉事件
this.enableMouseEvt(false);
//三个曝光埋点
......@@ -260,7 +255,8 @@ export default class MainScene extends Scene {
NetManager.ins.showLog(getlogItem(10))
NetManager.ins.showLog(getlogItem(13))
//初始话地图格子数据
this.initLattices();
//初始化回收口,如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞,用到map
this.initRecycle();
//初始化元素
......@@ -271,6 +267,8 @@ export default class MainScene extends Scene {
this.addChild(this["settingAll"])
//AiControl初始化,
AiControl.ins.init(this.lattices);
//先判断是否添加节日元素,如果加节日元素,就按initFestivalEle里的来
if (!this.initFestivalEle()) {
//检查一次三消
if (this.threeMatch()) {
this.eliminate();
......@@ -288,16 +286,21 @@ export default class MainScene extends Scene {
}
}
}
//最后加载svga,为了判断是否要加大红包的动效
this.initSvgas();
}
/**
* 加载所有用到的svga
*/
initSvgas() {
var resPath = getResPath()
var parser = new window["SVGA"].Parser();
var svgas = ["amazing", "great", "wonderful", "bonusTime"]
var resPath = getResPath();
if (!svgaParser) svgaParser = new window["SVGA"].Parser();
var svgas = ["amazing", "great", "wonderful", "bonusTime"];
//如果有节日的加
if (this.festivalTarget) svgas.push("redBombLight");
for (let i = 0; i < svgas.length; i++) {
if (movieClips[svgas[i]]) continue;
parser.load(resPath + 'resource/assets/svgas/' + svgas[i] + ".svga", (videoItem) => {
svgaParser.load(resPath + 'resource/assets/svgas/' + svgas[i] + ".svga", (videoItem) => {
var mv = new window["SVGA"].EgretMovieClip(videoItem);
mv.lockStep = true;
if (svgas[i] != "bonusTime") {
......@@ -348,8 +351,6 @@ export default class MainScene extends Scene {
var bg = drawBg(path, this.chapterData.map.lattices)
this.addChild(bg);
this.map = bg;
//初始话地图格子数据,主要因为有冰块,要添加进map,还有要判断是否需要大遮罩,所以位置在这里
this.initLattices();
//容器
this.elementContainer = new egret.DisplayObjectContainer();
this.addChild(this.elementContainer);
......@@ -696,6 +697,56 @@ export default class MainScene extends Scene {
// }
// }
}
//初始化节日元素
initFestivalEle(): boolean {
//添加节日元素,条件可能会变
if (getRedBombTimes() &&
fesChapterData.indexOf(this.chapter >> 0) > -1 &&
// Math.random() > 0.5 &&
this.lattices[festivalIndex] && //格子必须有
(Tool.judgeSetFesEle(this.lattices[festivalIndex]) || !this.lattices[festivalIndex].element) //没有元素也行
) {
var p = Tool.getPositionByIndex(festivalIndex);
//添加节日红包目标
this.festivalTarget = new FestivalTarget(this.festivalTargetNum);
this.festivalTarget.x = 580;
this.festivalTarget.y = 115;
this.addChildAt(this.festivalTarget, 1);
if (this.lattices[festivalIndex].element) {
this.lattices[festivalIndex].element.reset(ElementType.FESTIVALELE_BIG)
} else {
let ele: Element = Tool.getElement(ElementType.FESTIVALELE_BIG)
ele.x = p[0];
ele.y = p[1];
this.elementContainer.addChild(ele);
this.lattices[festivalIndex].element = ele;
}
//动画,然后恢复this.enableMouseEvt(true);
let ani: FesRedBombShowAni = Pool.takeOut(RecoverName.FESREDBOMBSHOW_ANI)
if (!ani) ani = new FesRedBombShowAni();
this.addChild(ani);
this.lattices[festivalIndex].element.visible = false;
ani.play(p, () => {
this.lattices[festivalIndex].element.visible = true;
//检查三消
if (this.threeMatch()) {
this.eliminate();
} else {
//先检测死图
this.warningCop = Tool.dieMapCheck(this.lattices);
if (!this.warningCop) {
//替换顺序
this.upsetElement();
}
else {
this.enableMouseEvt(true);
}
}
})
return true
}
return false
}
/**
* 更新三个道具
......@@ -1041,22 +1092,18 @@ export default class MainScene extends Scene {
}
//交换元素动画
private exchangeElementAni(s: Element, o: Element, callback?) {
var self = this;
// self.enableTouch = false;
this.enableMouseEvt(false);
egret.Tween.get(s)
.to({ x: o.x, y: o.y }, 166)
.call(() => {
if (callback) {
callback.bind(self)(s, o);
callback.bind(this)(s, o);
} else {
// self.enableTouch = true;
self.enableMouseEvt(true);
this.enableMouseEvt(true);
}
})
egret.Tween.get(o)
.to({ x: s.x, y: s.y }, 166)
}
//数据交换
private exchangeData(a: Element, b: Element) {
......@@ -2474,15 +2521,7 @@ export default class MainScene extends Scene {
* @param index
*/
recoverEle(index: number) {
let ele = this.lattices[index].element;
//添加进emptys
this.emptys.push(index)
//从容器移除
this.elementContainer.removeChild(ele);
//回收元素
Pool.recover(RecoverName.ELEMENT, ele);
//置空格子的element,
this.lattices[index].element = null;
let ele = this.removeOperation(index);
//棒棒糖消除不产生任何其他效果
if (ele.type != ElementType.LOLLIPOP) this.checkNebAll(this.lattices[index]);
//计算元素消除个数
......@@ -2692,6 +2731,14 @@ export default class MainScene extends Scene {
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.hasState(StateType.HAIRBALLBLACK)
});
//如果附近有节日大红包
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.FESTIVALELE_BIG;
});
//如果附近有节日小红包
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.FESTIVALELE_SMALL;
});
}
/**
* 石头的移除,包括动效
......@@ -2715,17 +2762,19 @@ export default class MainScene extends Scene {
//移除小红包,包括动效,还有个数累计等等。发接口,等等
removeFestivalEleSmall(index: number) {
this.removeOperation(index);
//播放动效
this.playAni(RecoverName.FESTIVALELESMALLDIS_ANI, Tool.getPositionByIndex(index))
let ele = this.removeOperation(index);
//查看次数,原先不为0,
if (this.festivalTarget.count) {
if (this.festivalTargetNum) {
this.festivalTargetNum--;
var p = this.festivalTarget.localToGlobal(40 * 0.8, 40 * 0.8)
this.addChild(FlyTargetAni(ElementType.FESTIVALELE_SMALL, [ele.x, ele.y], [p.x, p.y], () => {
this.festivalTarget.count--;
//完成了,发接口,,
if (this.festivalTarget.count == 0) {
getRedBombAward(() => {
this.redBombPanelMark = true;
})
}))
//完成了,发接口,到时需要修改,对于接口没成功的不设置
if (!this.festivalTargetNum) {
NetManager.ins.hc_redBombAward((success) => {
if (success) this.redBombPanelMark = true;
});
}
}
}
......
......@@ -369,6 +369,24 @@ export class Tool {
return false;
}
/**
* 可放置节日元素
* 必须是基础元素,且不带毛球状态
* 毛球可能成为通关目标,不放
*
* @param lat
*/
public static judgeSetFesEle(lat: Lattice) {
if (Tool.judgeBaseEle(lat) && //基础元素
!lat.element.hasState(StateType.HAIRBALLGREY) && //不带毛球,下同
!lat.element.hasState(StateType.HAIRBALLBLACK) &&
!lat.element.hasState(StateType.HAIRBALLBROWN)
) {
return true;
}
return false;
}
/**
* 判断元素是否可被手势选中和交换
......
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
export class FesRedBombShowAni extends egret.DisplayObjectContainer {
constructor() {
super()
var textureDown: egret.Texture = RES.getRes("fesRedBombSta1_png")
var down = new egret.Bitmap(textureDown);
down.x = -textureDown.textureWidth / 2;
down.y = -textureDown.textureHeight / 2;
this.addChild(down);
var textureUp: egret.Texture = RES.getRes("xingxingbi_png");
var up = new egret.Bitmap(textureUp);
up.x = -textureUp.textureWidth / 2; //-89
up.y = -100;
this.addChild(up);
}
play(position: number[], callback: Function) {
this.scaleX = this.scaleY = 0.29;
this.x = position[0];
this.y = position[1];
egret.Tween.get(this)
.wait(200)
.to({ scaleX: 1, scaleY: 1 }, 500, egret.Ease.backOut)
.wait(500)
.to({ scaleX: 0.29, scaleY: 0.29 }, 500, egret.Ease.backInOut)
.call(() => {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.FESREDBOMBSHOW_ANI, this);
callback()
})
//波纹动效再说,现在来不及
}
}
\ No newline at end of file
......@@ -10,8 +10,7 @@ const images = {
* 节日元素
*
*/
export class FestivalEle extends eui.Component {
private showImage: eui.Image;
export class FestivalEle extends egret.DisplayObjectContainer {
/**
* 是否要分裂了
*/
......@@ -25,52 +24,224 @@ export class FestivalEle extends eui.Component {
}
set statusNum(value: number) {
if (value >= 0) {
//播放原来的动画
let child = this.$children[this._statusNum];
child["play"](() => {
//切换
this.toggleStatus(value);
})
this._statusNum = value;
//播放动画,然后循环动画
// if (this.showImage.source != images[this._statusNum]) {
// this.changeSource(images[this._statusNum]);
// }
} else {
//不用动画
this._statusNum = 0;
this.isActive = true;
}
}
constructor(n: number = 2) {
super()
this.showImage = new eui.Image();
this.addChild(this.showImage)
this.changeSource(images[n]);
super();
var status3 = new Status3();
this.addChild(status3);
var status2 = new Status2();
this.addChild(status2);
var status1 = new Status1();
this.addChild(status1);
this.toggleStatus(n);
this.isActive = false;
this._statusNum = n;
}
changeSource(source: string) {
var texture: egret.Texture = RES.getRes(source);
this.showImage.texture = texture
this.showImage.anchorOffsetX = texture.textureWidth / 2;
this.showImage.anchorOffsetY = texture.textureHeight / 2 + 20;
this.showImage.y = 20
}
shakeAni() {
this.showImage.rotation = 0;
egret.Tween.get(this.showImage)
.to({ rotation: 10 }, 80)
.to({ rotation: -8 }, 160)
.to({ rotation: 5 }, 160)
.to({ rotation: 0 }, 50)
}
reset(n: number = 2) {
this.changeSource(images[n]);
this.toggleStatus(n);
this.isActive = false;
this._statusNum = n;
}
toggleStatus(index: number) {
for (var i = 0; i < this.$children.length; i++) {
var child = this.$children[i];
if (i == index) {
child.visible = true;
//重置状态
child["reset"]();
} else {
child.visible = false;
}
}
}
}
//第一种状态
class Status1 extends egret.DisplayObjectContainer {
upImage: egret.Bitmap;
constructor() {
super();
var textureDown: egret.Texture = RES.getRes("fesRedBombSta1_png")
var down = new egret.Bitmap(textureDown);
down.x = -textureDown.textureWidth / 2;
down.y = -textureDown.textureHeight / 2;
this.addChild(down);
var textureUp: egret.Texture = RES.getRes("xingxingbi_png");
var up = new egret.Bitmap(textureUp);
up.anchorOffsetX = textureUp.textureWidth / 2;
up.anchorOffsetY = textureUp.textureHeight / 2;
up.y = textureUp.textureHeight / 2 - 100;
this.addChild(up);
this.upImage = up;
this.scaleX = this.scaleY = 0.29;
}
reset() {
this.upImage.scaleX = this.upImage.scaleY = 1;
}
play(callback: Function) {
egret.Tween.get(this.upImage)
.to({ scaleX: 1.8, scaleY: 1.8 }, 240)
.call(() => {
callback();
})
}
}
const status2Cfg = [
{
"name": "fesRedCap",
"x": -7,
"y": -6,
"width": 251,
"height": 104
},
{
"name": "fesRedSmallLight",
"x": -7,
"y": -14,
"width": 249,
"height": 159
},
{
"name": "fesRedUp",
"x": -2,
"y": 52,
"width": 237,
"height": 185
},
{
"name": "fesRedDown",
"x": -2,
"y": 0,
"width": 237,
"height": 237
}
]
//第二种状态
class Status2 extends egret.DisplayObjectContainer {
light: egret.Bitmap;
fesRedCap: egret.Bitmap
constructor() {
super();
this.scaleX = this.scaleY = 0.29
for (var i = status2Cfg.length - 1; i >= 0; i--) {
var bitmap = new egret.Bitmap(RES.getRes(status2Cfg[i].name + "_png"));
bitmap.x = status2Cfg[i].x - 237 / 2;
bitmap.y = status2Cfg[i].y - 237 / 2;
this.addChild(bitmap);
if (status2Cfg[i].name == "fesRedSmallLight") {
this.light = bitmap
} else if (status2Cfg[i].name == "fesRedCap") {
this.fesRedCap = bitmap;
}
}
}
reset() {
this.fesRedCap.scaleY = 1;
this.light.alpha = 1;
egret.Tween.get(this.light, { loop: true })
.to({ alpha: 0 }, 450)
.to({ alpha: 1 }, 450)
}
play(callback: Function) {
this.light.alpha = 0;
egret.Tween.removeTweens(this.light);
this.fesRedCap.scaleY = 1;
egret.Tween.get(this.fesRedCap)
.to({ scaleY: 0.1 }, 180)
.call(() => {
callback();
})
}
}
const status3Cfg = [
{
"name": "fesRedUp",
"x": 0,
"y": 817 - 765,
"width": 237,
"height": 185
},
{
"name": "tinyRedMid",
"x": 770 - 684,
"y": 825 - 765,
"width": 74,
"height": 90
},
{
"name": "tinyRedLeft",
"x": 706 - 684,
"y": 770 - 765,
"width": 116,
"height": 132
},
{
"name": "tinyRedRight",
"x": 807 - 684,
"y": 779 - 765,
"width": 89,
"height": 106
},
{
"name": "fesRedDown",
"x": 0,
"y": 0,
"width": 237,
"height": 237
}
]
class Status3 extends egret.DisplayObjectContainer {
midRed: egret.Bitmap;
leftRed: egret.Bitmap;
rightRed: egret.Bitmap;
constructor() {
super();
this.scaleX = this.scaleY = 0.29
for (var i = status3Cfg.length - 1; i >= 0; i--) {
var config = status3Cfg[i];
var bitmap = new egret.Bitmap(RES.getRes(config.name + "_png"));
bitmap.x = config.x - 237 / 2;
bitmap.y = config.y - 237 / 2;
this.addChild(bitmap);
if (config.name == "tinyRedMid") {
this.midRed = bitmap;
} else if (config.name == "tinyRedLeft") {
this.leftRed = bitmap;
} else if (config.name == "tinyRedRight") {
this.rightRed = bitmap;
}
}
}
reset() {
// class
\ No newline at end of file
}
play(callback: Function) {
}
}
\ No newline at end of file
......@@ -22,6 +22,7 @@ export enum RecoverName {
BUBBLE_ANI = "BubbleAni",
HAIRBALLBROWNDIVIDE_ANI = "HairballBrownDivideAni",
HAIRBALLJUMP_ANI = "HairballJumpAni", //三种毛球是一样的动画
FESREDBOMBSHOW_ANI = "FesRedBombShowAni",
......@@ -52,7 +53,6 @@ export enum RecoverName {
EGGBROKEN_ANI = "EggBrokenAni",
HAIRBALLGREYDIS_ANI = "HairballGreyDisAni",
HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni",
FESTIVALELESMALLDIS_ANI = "FestivalEleSmallDisAni",
//方形遮罩
RECT_MASK = "RectMask",
......
......@@ -30,7 +30,7 @@ export class FestivalTarget extends egret.DisplayObjectContainer {
this._count = value;
this.countNum.num = value;
}
constructor() {
constructor(count: number = 6) {
super()
var texture: egret.Texture = RES.getRes("festivalTargetBg_png");
var showImage = new egret.Bitmap(texture);
......@@ -46,6 +46,6 @@ export class FestivalTarget extends egret.DisplayObjectContainer {
this.countNum.y = 60;
this.addChild(this.countNum);
this.count = 6;
this.count = count;
}
}
\ 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