Commit 87904b64 authored by zjz1994's avatar zjz1994

樱花暂存

parent 29f71450
......@@ -326,7 +326,10 @@ export default class MainBase extends eui.UILayer {
RES.getResAsync("ele43fn_png");
RES.getResAsync("ele44fn_png");
RES.getResAsync("ele45fn_png");
RES.getResAsync("ele46_png");
RES.getResAsync("ele46_sz_png");
for (var i = 1; i <= 27; i++) {
RES.getResAsync("bonusFra" + i + "_png")
}
......
This diff is collapsed.
......@@ -123,6 +123,7 @@ import doWormHoleAI from './doWormHoleAI';
import { Grass } from '../something/class/Grass';
import Food from '../something/class/Food';
import foodAni from '../something/anis/foodAni';
import shuzhi from '../something/class/shuzhi';
const aniClass = {
"BoomAni": BoomAni,
......@@ -441,6 +442,9 @@ export default class MainScene extends Scene {
}> = [];
inaniFood:boolean = false;
//樱花
//当前关卡的所有樱花
cherryData:Array<Array<number>> = [];
constructor(){
super();
window['gm'] = this.gm;
......@@ -581,6 +585,7 @@ export default class MainScene extends Scene {
if(!this.chapterTxt.parent){
this['chaptergro'].addChild(this.chapterTxt);
}
console.log("移除地图元素");
}
async start(data) {
super.start();
......@@ -618,6 +623,11 @@ export default class MainScene extends Scene {
//初始化回收口,如果是棒棒糖关卡,那么在地图底部增加棒棒糖洞,用到map
this.initRecycle();
this.initConnectedLats();
//初始化樱花
this.initCherry();
console.log("樱花数据",this.cherryData);
//初始化元素
this.initElement();
//重置基础元素类型及特效
......@@ -1340,7 +1350,63 @@ export default class MainScene extends Scene {
this.connectState = 1;
}//否则默认的2
}
//初始化樱花
initCherry(){
var cherydata = this.chapterData.map.cherrydata;
if(cherydata){
this.cherryData = JSON.parse(JSON.stringify(cherydata));
}else{
this.cherryData = new Array();
}
for(var i=0;i<this.cherryData.length;i++){
var icherydata = this.cherryData[i];
for(var j=0;j<icherydata.length;j++){
let idx = icherydata[j];
let p = Tool.getPositionByIndex(idx);
//添加树枝
if(j>0){
let lastidx = icherydata[j-1];
let lastp = Tool.getPositionByIndex(lastidx);
let chanum = Math.abs(idx-lastidx);
let szp;
let roatype:string;
if(chanum==9){
szp = [p[0],(lastp[1]-p[1])/2+p[1]];
roatype = "vir";
}else if(chanum==1){
szp = [(lastp[0]-p[0])/2+p[0],p[1]];
roatype = "hor";
}else{
console.error("检查樱花分布",idx,lastidx,i,j);
}
if(szp){
console.log("树枝位置",szp[0],szp[1]);
let onesz = new shuzhi();
onesz.name = "sz_"+idx+"_"+lastidx;
onesz.x = szp[0];
onesz.y = szp[1];
onesz.setroa(roatype);
this.mapupContainer.addChild(onesz);
}
}
//添加元素
let ele:Element = Pool.takeOut(RecoverName.ELEMENT);
if(!ele){
ele = new Element(ElementType.cherry);
}else{
ele.reset(ElementType.cherry);
}
console.log("樱花位置",p[0],p[1]);
ele.x = p[0];
ele.y = p[1];
this.elementContainer.addChild(ele);
this.lattices[idx].element = ele;
}
}
}
//初始化地图元素
initElement() {
this.cannonums = 0;
......@@ -1353,6 +1419,12 @@ export default class MainScene extends Scene {
//如果对应格子为空,直接跳过,
if(!this.lattices[i]) continue;
var p = Tool.getPositionByIndex(i);
//初始元素忽略樱花
var ischery = this.checkisCherry(i);
if(ischery){
continue;
}
switch(elements[i]) {
//如果为0记录空格
case ElementConfigType.EMPTY:
......@@ -3096,6 +3168,7 @@ export default class MainScene extends Scene {
}
}
}
//樱花绽放,放在fallAllPormise里
//没有可消除元素,执行掉落,
// setTimeout(() => {
......@@ -5693,6 +5766,7 @@ export default class MainScene extends Scene {
this.checkFireworksNebEle(latttice, ele);
this.checkFishNebEle(latttice);
this.checkPongoNebEle(latttice,ele);
this.checkCherryNebEle(latttice);
//如果附近有石头
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.ROCK
......@@ -5724,6 +5798,8 @@ export default class MainScene extends Scene {
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.FESTIVALELE_SMALL && (!lat.block || !lat.block.isLock());
});
//樱花元素
}
/**
......@@ -7339,4 +7415,117 @@ export default class MainScene extends Scene {
return [cutx,cuty];
}
//新元素樱花
//判断当前位置是否樱花
checkisCherry(idx:number){
for(var i=0;i<this.cherryData.length;i++){
var icherydata = this.cherryData[i];
if(icherydata.indexOf(idx)!=-1){
return true;
}
}
return false;
}
//相邻消除激活樱花
checkCherryNebEle(lat0:Lattice){
if(!lat0){
return;
}
var indexs = this.getNextIndexs(lat0);
for(let i=0;i<indexs.length;i++){
let index = indexs[i];
let lat = this.lattices[index];
if(lat&&lat.element){
let ele = lat.element;
if(ele.type==ElementType.cherry&&ele.activeStatus==0){
this.activeCherry(index);
}
}
}
}
//特效激活樱花
solveCherryEle(cherryArr:Array<number>){
}
//激活樱花
activeCherry(idx:number){
console.log("1消除樱花----------------------",idx);
var lat = this.lattices[idx];
var ele = this.lattices[idx].element;
let pro1 = ele.activeCherry();
this.fallAllPormise.push(pro1);
var nearidxs:Array<{
forback:string,
idx:number
}> = this.getNearCherry(idx);
//消除自身时,把连接自身的棍消除
this.removeCherryGun(idx,nearidxs);
console.log("2消除樱花----------------------",JSON.stringify(nearidxs));
// var pro2 = new Promise(res=>{
// setTimeout(() => {
// res();
// }, 200);
// })
// this.fallAllPormise.push(pro2);
for(let i=0;i<nearidxs.length;i++){
let nidx = nearidxs[i].idx;
let nlat = this.lattices[nidx];
let nele = nlat.element;
if(nele&&nele.type==ElementType.cherry&&nele.activeStatus==0){
this.activeCherry(nidx);
}
}
}
//获取相邻樱花
getNearCherry(idx:number){
var nearidxs = new Array();
for(var i=0;i<this.cherryData.length;i++){
var icherydata = this.cherryData[i];
for(var j=0;j<icherydata.length;j++){
var latidx = icherydata[j];
if(latidx==idx){
if(j>0){
nearidxs.push(
{
forback:"for",
idx:icherydata[j-1]
}
);
}
if(j<icherydata.length-1){
nearidxs.push({
forback:"back",
idx:icherydata[j+1]
});
}
break;
}
}
}
return nearidxs;
}
//消除樱花棍
removeCherryGun(idx:number,nearidxs:Array<{forback:string,idx:number}>){
for(var i=0;i<nearidxs.length;i++){
var ineardata = nearidxs[i];
var iforback = ineardata.forback;
var iidx = ineardata.idx;
var iguname = "";
if(iforback=="for"){
iguname = "sz_"+idx+"_"+iidx;
}else if(iforback=="back"){
iguname = "sz_"+iidx+"_"+idx;
}
var isz = this.mapupContainer.getChildByName(iguname);
isz&&this.mapupContainer.removeChild(isz);
}
}
}
\ No newline at end of file
......@@ -305,7 +305,9 @@ export class Tool {
// lat.element.type == ElementType.FESTIVALELE_SMALL
lat.element.type == ElementType.CANNO ||
lat.element.type == ElementType.CANNO_BLOCK ||
lat.element.type == ElementType.Pongo
lat.element.type == ElementType.Pongo||
lat.element.type == ElementType.cherry
) {
return false
}
......@@ -370,7 +372,8 @@ export class Tool {
lat.element.type == ElementType.FIREWORKS_SHOOTER ||
lat.element.type == ElementType.CANNO ||
lat.element.type == ElementType.CANNO_BLOCK ||
lat.element.type == ElementType.Pongo
lat.element.type == ElementType.Pongo ||
lat.element.type == ElementType.cherry
) {
return false
}
......@@ -472,7 +475,9 @@ export class Tool {
ele.type == ElementType.FESTIVALELE_SMALL ||
ele.type == ElementType.CANNO ||
ele.type == ElementType.CANNO_BLOCK ||
ele.type == ElementType.Pongo
ele.type == ElementType.Pongo||
ele.type == ElementType.cherry
) {
return false;
}
......@@ -501,7 +506,8 @@ export class Tool {
ele.hasState(StateType.HAIRBALLBROWN) ||
ele.type == ElementType.CANNO ||
ele.type == ElementType.CANNO_BLOCK ||
ele.type == ElementType.Pongo
ele.type == ElementType.Pongo||
ele.type == ElementType.cherry
) {
return false;
}
......
......@@ -2,14 +2,14 @@ import { ChapterData } from "../interface/ChapterData";
//801-825
export const Chapters32: ChapterData[] = [
//751
//801
{ baseElementTypes: [ 0, 1, 2, 3 ],
bubbleProbability: 0, stepCount: 26,
passTarget: { type: 1, elements: [ { type: 9, count: 71 }, { type: 0, count: 102 } ] }, starScores: [ 15000, 20000, 25000 ],
map: {
lattices: [
3, 3, 0, 3, 3, 3, 0, 3, 3,
3, 3, 0, 3, 3, 3, 0, 3, 3,
1, 1, 0, 3, 3, 3, 0, 3, 3,
1, 1, 0, 3, 3, 3, 0, 3, 3,
3, 3, 0, 3, 3, 3, 0, 3, 3,
3, 3, 0, 3, 3, 3, 0, 3, 3,
3, 3, 61, 3, 3, 3, 61, 3, 3,
......@@ -41,7 +41,7 @@ export const Chapters32: ChapterData[] = [
recycles: [],
cherrydata:[
[0,1,10,9],
],
generateLats: [
{ index: 0, type: null }, { index: 1, type: null },
......
......@@ -89,7 +89,7 @@ chapters.forEach((chapter,index) => {
*/
export function getChapterData(index: number): ChapterData {
//没有数据就返回第一关数据
// return chapters[751];
return chapters[801];
return chapters[index] || chapters[1];
}
......
......@@ -1313,4 +1313,21 @@ export class Element extends eui.Component {
onElimiate(){}
get isActive() { return false }
canElimite:boolean;
//激活樱花
activeStatus:number = 0;//0未激活,1绽放中,2,结束
activeCherry(){
this.activeStatus = 1;
return new Promise(res=>{
egret.Tween.get(this.showImage)
.to({
alpha:0
},300)
.call(function(){
this.activeStatus = 2;
res();
},null);
})
}
}
\ No newline at end of file
export default class shuzhi extends egret.Bitmap{
constructor(){
super();
var texture:egret.Texture = RES.getRes("ele46_sz_png");
if(!texture){
console.error("检查树枝纹理");
return;
};
this.texture = texture;
this.anchorOffsetX = texture.textureWidth/2;
this.anchorOffsetY = texture.textureHeight/2;
this.touchEnabled = false;
}
//树枝旋转,hor横向树枝,vir竖向树枝
setroa(type:string){
var roa:number = 0;
if(type=="hor"){
roa = 0;
}else if(type=="vir"){
roa = 90;
}
this.rotation = roa;
console.log("树枝啦啦啦啦",this);
}
}
\ 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