Commit 1b2b44f0 authored by wildfirecode's avatar wildfirecode

1

parents e9a6cbff 0d7b0f29
......@@ -59,8 +59,9 @@ import { EleMaskAni } from '../something/anis/EleMaskAni';
import { getChapterData } from '../something/chapters/getChapter';
import { GenerateLatData } from '../something/interface/GenerateLatData';
import { StateType } from '../something/enum/StateType';
import { HairballState } from '../something/states/HairballState';
import { HairballDisAni } from '../something/anis/HairballDisAni';
import { HairballBlackState } from '../something/states/HairballBlackState';
import { HairballGreyDisAni } from '../something/anis/HairballGreyDisAni';
import { HairballBrownState } from '../something/states/HairballBrownState';
const aniClass = {
"BoomAni": BoomAni,
......@@ -75,7 +76,7 @@ const aniClass = {
"StepAni": StepAni,
"JellyDisAni": JellyDisAni,
"EggBrokenAni": EggBrokenAni,
"HairballDisAni": HairballDisAni,
"HairballGreyDisAni": HairballGreyDisAni,
}
export const baseScore = 20;
/**
......@@ -150,7 +151,7 @@ export default class MainScene extends Scene {
hasPassed: boolean = false;
//是否结算时间
isCountingTime: boolean = false;
//通关的目标元素的计数,下标和元素类型索引一致
//通关的目标元素的计数,下标和元素类型ElementType枚举一致
passElements: number[];
elementTargets: ElementTargets;
//所有元素的消耗数量,需要传给后端
......@@ -224,8 +225,8 @@ export default class MainScene extends Scene {
this.chapterTxt.text = "第" + this.chapter + "关";
//关卡数据
this.chapterData = getChapterData(this.chapter)
//初始化索引信息,暂时不做判断列数的奇偶,如需,要修改的地方再考虑,还有道具使用的蒙层是否要改
Tool.init(/*Tool.getColOddEven(this.chapterData.map.lattices)*/);
//初始化索引信息,包括10*10的,
Tool.init(Tool.getColOddEven(this.chapterData.map.lattices));
this.initUi();
this.initSvgas();
//先禁掉事件
......@@ -464,8 +465,8 @@ export default class MainScene extends Scene {
}
this.map.addChild(ice);
this.lattices[i].ice = ice;
ice.x = p[0] - 80 / 2;
ice.y = p[1] - 81 / 2;
ice.x = p[0];
ice.y = p[1];
}
}
//设置生成口,
......@@ -1456,6 +1457,8 @@ export default class MainScene extends Scene {
/**
* 只关心交换后元素的可消除
* 或者冰淇淋的掉落
* 逻辑以后待加,
* 该方法只针对手动触发的消除,包括特效组合,手动三消的,可以另写方法,并重新修改鸡蛋,石头,果冻,毛球逻辑
*/
simpleMatch(s: Element, o: Element) {
//先判断两个都是特效
......@@ -1810,10 +1813,8 @@ export default class MainScene extends Scene {
lat.element.effectType = Math.random() > 0.5 ? EffectType.HORIZONTAL : EffectType.VERTICAL;
}
} else {
//普通元素的旋转消除,无特效,无锁
if (!lat.element.hasState(StateType.LOCK) &&
!lat.element.hasState(StateType.HAIRBALL) &&
lat.element.effectType == null) {
//普通元素的旋转消除,无特效,无锁,无毛球
if (Tool.judgeMagicRotate(lat.element)) {
rotateData.elementsIndex.push(i);
}
}
......@@ -1919,7 +1920,7 @@ export default class MainScene extends Scene {
}
/**
* 普通元素消除,先消除无特效的,有特效的存下,然后触发,找下一步消除的元素
* 加入石头,果冻,鸡蛋
* 加入石头,果冻,鸡蛋,各种状态
*/
commonEliminate(): number[] {
playSound(SoundType.eliminate)
......@@ -1934,28 +1935,32 @@ export default class MainScene extends Scene {
if (!ele) {
//以防万一还是判断一次
}
//下面带状态的要优先判断
//有枷锁的
else if (ele.hasState(StateType.LOCK)) {
//被禁锢的解开
ele.setState(StateType.LOCK, false);
}
//有毛球的
else if (ele.hasState(StateType.HAIRBALL)) {
var hairballState: HairballState = ele.getState(StateType.HAIRBALL);
//二级毛球的记录需要分裂isActive
if (hairballState.levelNum == 2) {
hairballState.isActive = true;
}
//一级的直接消失
else {
//播放毛球消失动画
this.playAni(RecoverName.HAIRBALLDIS_ANI, p)
//设为无毛球
ele.setState(StateType.HAIRBALL, false)
//算个数
this.goElementTarget(ele.getState(StateType.HAIRBALL));
}
//暂时笼子不算个数,算的话,改图片名称,列入ElementType的状态下
}
//有褐色毛球的,记录分裂激活
else if (ele.hasState(StateType.HAIRBALLBROWN)) {
var hairballBrownState: HairballBrownState = ele.getState(StateType.HAIRBALLBROWN);
hairballBrownState.isActive = true;
//算个数,不能在这里算,得在分裂时算
// this.goElementTarget(ElementType.HAIRBALLBROWN, [ele.x, ele.y]);
}
//有灰色毛球的,消失
else if (ele.hasState(StateType.HAIRBALLGREY)) {
//播放毛球消失动画
this.playAni(RecoverName.HAIRBALLGREYDIS_ANI, p)
//设为无毛球
ele.setState(StateType.HAIRBALLGREY, false)
//算个数
this.goElementTarget(ElementType.HAIRBALLGREY, [ele.x, ele.y]);
}
//有黑色毛球的,一次眩晕,两次消失
else if (ele.hasState(StateType.HAIRBALLGREY)) {
//逻辑待写,参照上面
}
//如果有特效,存下
else if (ele.effectType != null) {
......@@ -1970,26 +1975,27 @@ export default class MainScene extends Scene {
ele.setState(StateType.BUBBLE, false)
}
//但是算个数,
this.goElementTarget(ele);
this.goElementTarget(ele.type, [ele.x, ele.y]);
//附近依旧有影响
this.checkNebAll(this.lattices[index])
} else {
//单纯元素消失特效
if (ele.type <= 4) {
this.playAni(RecoverName.ELEDIS_ANI, p)
//这里面会去算个数
this.recoverEle(index)
}
//石头
else if (ele.type == ElementType.ROCK) {
this.removeRock(index);
//算个数
this.goElementTarget(ele);
this.goElementTarget(ele.type, [ele.x, ele.y]);
}
//果冻
else if (ele.type == ElementType.JELLY) {
this.removeJelly(index);
//算个数
this.goElementTarget(ele);
this.goElementTarget(ele.type, [ele.x, ele.y]);
}
//鸡蛋
else if (ele.type == ElementType.CHICKEN_EGG) {
......@@ -2044,13 +2050,11 @@ export default class MainScene extends Scene {
this.lattices[i].element.type == type) {
if (this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
this.eliminatedElements.push(i);
//无特效未枷锁
if (!this.lattices[i].element.hasState(StateType.LOCK) &&
!this.lattices[i].element.hasState(StateType.HAIRBALL) &&
this.lattices[i].element.effectType == null) {
//无特效未枷锁,无毛球的参与旋转
if (Tool.judgeMagicRotate(this.lattices[i].element)) {
rotateData.elementsIndex.push(i);
}
//
//加分
if (Tool.judgeHasScore(this.lattices[i].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["3"], Tool.getPositionByIndex(i))
}
......@@ -2070,7 +2074,7 @@ export default class MainScene extends Scene {
(Math.abs(this.lattices[i].row - lat.row) < 2 && Math.abs(this.lattices[i].column - lat.column) < 2)) {
if (this.eliminatedElements.indexOf(i) < 0 && effectIndexs.indexOf(i) < 0) {
this.eliminatedElements.push(i);
//
//加分
if (Tool.judgeHasScore(this.lattices[i].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["2"], Tool.getPositionByIndex(i))
}
......@@ -2089,7 +2093,7 @@ export default class MainScene extends Scene {
if (Tool.judgeEliminate(this.lattices[ein])) {
if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) {
this.eliminatedElements.push(ein);
//
//加分
if (Tool.judgeHasScore(this.lattices[ein].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["0"], Tool.getPositionByIndex(ein))
}
......@@ -2108,7 +2112,7 @@ export default class MainScene extends Scene {
if (Tool.judgeEliminate(this.lattices[ein])) {
if (this.eliminatedElements.indexOf(ein) < 0 && effectIndexs.indexOf(ein) < 0) {
this.eliminatedElements.push(ein);
//
//加分
if (Tool.judgeHasScore(this.lattices[ein].element)) {
this.pushScoreAni(baseScore * this.effectContinuityTimes * effectBaseTimes["1"], Tool.getPositionByIndex(ein))
}
......@@ -2270,11 +2274,7 @@ export default class MainScene extends Scene {
var anis = [];//两个,0下标是元素,1下标是索引
for (var i = 0; i < this.lattices.length; i++) {
var lat = this.lattices[i];
if (Tool.judgeBaseEle(lat) &&
!lat.element.hasState(StateType.LOCK) &&
!lat.element.hasState(StateType.HAIRBALL)) {
lats.push(lat)
}
if (Tool.judgeUpsetMove(lat)) lats.push(lat);
}
//不改变的
var latsCopy = lats.slice();
......@@ -2340,7 +2340,7 @@ export default class MainScene extends Scene {
//棒棒糖消除不产生任何其他效果
if (ele.type != ElementType.LOLLIPOP) this.checkNebAll(this.lattices[index]);
//计算元素消除个数
this.goElementTarget(ele);
this.goElementTarget(ele.type, [ele.x, ele.y]);
}
/**
......@@ -2460,13 +2460,12 @@ export default class MainScene extends Scene {
if (lat && lat.ice) {
var ice = lat.ice;
ice.countNum--;
let fun;
if (ice.countNum == 0) {
this.map.removeChild(ice);
//回收
Pool.recover(RecoverName.ICE, ice);
lat.ice = null;
this.goElementTarget(ice);
this.goElementTarget(ElementType.ICE, [ice.x, ice.y]);
} else {
ice.alpha = 0.6;
}
......@@ -2477,22 +2476,13 @@ export default class MainScene extends Scene {
}
goElementTarget(ele: Element | Ice | HairballState) {
goElementTarget(type: ElementType, fromP: number[]) {
if (!this.passElements) return
var type: number;
if (ele instanceof Ice) {
type = ElementType.ICE;
}
else if (ele instanceof HairballState) {
type = ElementType.HAIRBALL;
} else {
type = ele.type;
}
if (this.passElements[type] != undefined) {
if (this.passElements[type] != 0) {
this.passElements[type]--;
var p = this.elementTargets.targets[type].localToGlobal(40 * 0.8, 40 * 0.8)
FlyTargetAni(ele, [p.x, p.y], this)
FlyTargetAni(type, fromP, [p.x, p.y], this);
}
//数量增加
this.hasEliminatedElements[type]++;
......@@ -2537,9 +2527,13 @@ export default class MainScene extends Scene {
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.type == ElementType.CHICKEN_EGG
});
//如果附近有毛球
//如果附近有灰色毛球
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.hasState(StateType.HAIRBALLGREY)
});
//如果附近有黑色毛球
this.checkNebEle(latttice, (lat) => {
return lat && lat.element && lat.element.hasState(StateType.HAIRBALL)
return lat && lat.element && lat.element.hasState(StateType.HAIRBALLBLACK)
});
}
/**
......
......@@ -176,7 +176,7 @@ export class PropGuideInt extends egret.DisplayObjectContainer {
if (Tool.judgeEliminate(lat) && (lat.row == rc[0] || lat.column == rc[1])) {
if (this.thisObj.eliminatedElements.indexOf(i) == -1) {
this.thisObj.eliminatedElements.push(i);
if (!lat.element.hasState(StateType.LOCK) && !lat.element.hasState(StateType.HAIRBALL)) {
if (Tool.judgeHasScore(lat.element)) {
//算直线+直线LL
this.thisObj.pushScoreAni(baseScore * 1 * effectBaseTimes.LL, Tool.getPositionByIndex(i))
}
......
......@@ -23,6 +23,7 @@ import Utils from "../Utils";
import { GDispatcher } from "../../libs/tc/util/GDispatcher";
import Loading from "../../libs/new_wx/components/Loading";
import ScratchIcon from "./icon/ScratchIcon";
import TurntableIcon from "./icon/TurntableIcon";
import { loadTurntableSvga } from "../panels/TurntablePanel/Turntable";
let doHelpFlag = false;
......@@ -38,6 +39,8 @@ export default class MapScene extends Scene {
static starHash: any = {};
_data;
private icons = {};
sendInvite() {
const code = Utils.getRequestByKey('shareCode');
if (!code) return;
......@@ -73,6 +76,8 @@ export default class MapScene extends Scene {
async start(data?) {
super.start();
this.addIcon(); // 添加Icon
this.sendInvite();
PanelCtrl.instance.show('back');
......@@ -92,8 +97,6 @@ export default class MapScene extends Scene {
stopGamebg();
let scratchBtn = new ScratchIcon("scratch", this["scratchGroup"], this["scratchBtn"], this["scratchTipsBg"], this["scratchTips"]);
NetManager.ins.getSignInfo(() => {
const panels = [];
const date = new Date();
......@@ -249,6 +252,14 @@ export default class MapScene extends Scene {
}
// 添加图标
private addIcon(){
this.icons = {
"scratchIcon": new ScratchIcon("scratchIcon", this["scratchGroup"], this["scratchBtn"], this["scratchTipsBg"], this["scratchTips"]),
"turntableIcon": new TurntableIcon("turntableIcon", this["turnTableGroup"], this["turnTableBtn"], this["turnTableTipsBg"], this["turnTableTips"])
};
}
updateMyInfo() {
this['avatar'].visible = false;
this['nameTxt'].text = '';
......@@ -300,7 +311,7 @@ export default class MapScene extends Scene {
if (this['pic'])
egret.Tween.removeTweens(this['pic']);
if (this.inviteTimer) {
if(this.inviteTimer) {
this.inviteTimer.stop();
this.inviteTimer.removeEventListener(egret.TimerEvent.TIMER, this.inviteCutTimer, this);
}
......@@ -640,27 +651,8 @@ export default class MapScene extends Scene {
}, window['signActivityId'])
}
////////////////////////////////////////////////// 刮刮卡 //////////////////////////////////////////////////
onTap_scratchBtn() {
NetManager.ins.getInviteInfo((success, res) => {
if (!success) {
return;
}
PanelCtrl.instance.show('scratch', res.data);
});
}
////////////////////////////////////////////////// 大转盘 //////////////////////////////////////////////////
onTap_turnTableBtn() {
loadTurntableSvga((mv) => {
PanelCtrl.instance.show('turnTable', {mv:mv})
})
}
protected initEvents() {
// this['goldBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_goldBtn, this)
this['turnTableBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_turnTableBtn, this)
// this['scratchBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_scratchBtn, this)
this['inviteBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_inviteBtn, this)
this['friendBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_friendBtn, this)
this['adBtn'].addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTap_adBtn, this)
......
/**
* 地图页图标基类
* 2019.10.24
* 2019.10.25
*/
export default class IconBase{
private iconGroup:eui.Group;
......@@ -14,12 +14,16 @@ export default class IconBase{
}
constructor(name:string, group:eui.Group, btn:eui.Button, tipsBg:eui.Image, tipsLabel:eui.Label){
constructor(name:string, group:eui.Group, btn:eui.Button, tipsBg?:eui.Image, tipsLabel?:eui.Label){
this.iconGroup = group;
this.iconBtn = btn;
this.iconTipsBg = tipsBg;
this.iconTips = tipsLabel;
this._name = name;
this.start();
}
protected start(){
this.initEvents();
}
......@@ -28,7 +32,7 @@ export default class IconBase{
}
protected onTouchBtn(e:egret.TouchEvent){
console.log("基类");
}
protected removeEvents(){
......
import IconBase from "./IconBase";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
export default class ScratchIcon extends IconBase {
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg: eui.Image, tipsLabel: eui.Label) {
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
super(name, group, btn, tipsBg, tipsLabel);
}
protected start() {
super.start();
}
protected initEvents() {
super.initEvents();
}
protected onTouchBtn(e: egret.TouchEvent) {
super.onTouchBtn(e);
console.log("子类");
NetManager.ins.getInviteInfo((success, res) => {
if(!success) {
return;
}
PanelCtrl.instance.show('scratch', res.data);
});
}
protected removeEvents() {
......
import IconBase from "./IconBase";
import { NetManager } from "../../../libs/tw/manager/NetManager";
import PanelCtrl from "../../../libs/new_wx/ctrls/panelCtrl";
import { loadTurntableSvga } from "../../panels/TurntablePanel/Turntable";
export default class TurntableIcon extends IconBase {
constructor(name: string, group: eui.Group, btn: eui.Button, tipsBg?: eui.Image, tipsLabel?: eui.Label) {
super(name, group, btn, tipsBg, tipsLabel);
}
protected start() {
super.start();
}
protected initEvents() {
super.initEvents();
}
protected onTouchBtn(e: egret.TouchEvent) {
super.onTouchBtn(e);
loadTurntableSvga((mv) => {
PanelCtrl.instance.show('turnTable', {mv:mv})
})
}
protected removeEvents() {
super.removeEvents();
}
protected destory() {
super.destory();
}
}
\ No newline at end of file
......@@ -26,8 +26,8 @@ export class Tool {
* 格子高度
*/
public static height = 80// 81.5;
//整体偏移X
public static offsetX = 15// 8.25;
//整体偏移X,为了下面初始化,这里不定义数值
public static offsetX //= 15// 8.25;
//整体偏移Y
public static offsetY = 275 //260;
/**
......@@ -56,11 +56,18 @@ export class Tool {
* 索引位置
*/
private static indexPositions: number[][] = [];
//给出10*10
private static indexToRcMap10: number[][] = [];
private static indexPositions10: number[][] = [];
/**
* 初始化数据
*/
public static init(isTwo: boolean = false) {
this.offsetX = isTwo ? 55 : 15// 49 : 8.25
var ooox = isTwo ? 55 : 15;// 49 : 8.25
//相等的就return,没必要每关都算一次,暂时只有x轴偏移有可能改变
if (this.offsetX == ooox) return;
this.offsetX = ooox;
//都是9*9
//位置信息
var spaceX = this.width,
......@@ -77,11 +84,17 @@ export class Tool {
}
//10*10的格子位置信息
// for (var i = 0; i < this.rowNum + 1; i++) {
// for (var j = 0; j < this.colNum + 1; j++) {
// }
// }
var rowNum = Tool.rowNum + 1;
var colNum = Tool.colNum + 1;
var offsetX = Tool.offsetX
var offsetY = Tool.offsetY
for (var i = 0; i < rowNum; i++) {
for (var j = 0; j < colNum; j++) {
// rcToIndexMap["" + i + j] = i * colNum + j;
this.indexToRcMap10[i * colNum + j] = [i, j];
this.indexPositions10[i * colNum + j] = [offsetX + j * Tool.width, offsetY + i * Tool.height];
}
}
}
/**
* row和col获得index值
......@@ -118,6 +131,13 @@ export class Tool {
return this.indexPositions[index]
}
public static indexToRc10(index: number): number[] {
return this.indexToRcMap10[index]
}
public static getPositionByIndex10(index: number): number[] {
return this.indexPositions10[index]
}
/**
* 根据9*9格子得到中间列数的奇偶性
* 其实只是要知道左右两边空的列数
......@@ -245,7 +265,9 @@ export class Tool {
lat.element.effectType == EffectType.MAGICLION ||
lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG ||
lat.element.hasState(StateType.HAIRBALL)) {
lat.element.hasState(StateType.HAIRBALLGREY) ||
lat.element.hasState(StateType.HAIRBALLBLACK) ||
lat.element.hasState(StateType.HAIRBALLBROWN)) {
return false
}
//剩下情况
......@@ -255,7 +277,7 @@ export class Tool {
}
/**
* 判断能执行消除的元素,
* 包括所有特效和基本元素,石头,果冻,鸡蛋
* 包括所有特效和基本元素,石头,果冻,鸡蛋,各种状态的
* @param lat
*/
public static judgeEliminate(lat: Lattice) {
......@@ -292,6 +314,23 @@ export class Tool {
}
}
/**
* 判断在打乱时,格子上元素是否能移动交换
* @param lat 格子
*/
public static judgeUpsetMove(lat: Lattice) {
if (Tool.judgeBaseEle(lat) &&
!lat.element.hasState(StateType.LOCK) &&
!lat.element.hasState(StateType.HAIRBALLGREY) &&
!lat.element.hasState(StateType.HAIRBALLBLACK) &&
!lat.element.hasState(StateType.HAIRBALLBROWN)
) {
return true;
}
return false;
}
/**
* 判断元素是否可被手势选中和交换
* 主要点击元素判断使用
......@@ -302,7 +341,9 @@ export class Tool {
if (!ele ||
ele.type == ElementType.ROCK ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL) ||
ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN) ||
ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG
) {
......@@ -313,7 +354,7 @@ export class Tool {
/**
* 是否要算分数
* 排除元素 石头,鸡蛋,果冻,
* 排除状态 枷锁,毛球
* 排除状态 枷锁,毛球,因为存在时,元素不会消除
* @param ele 元素
*/
public static judgeHasScore(ele: Element): boolean {
......@@ -323,7 +364,26 @@ export class Tool {
ele.type == ElementType.CHICKEN_EGG ||
ele.type == ElementType.LOLLIPOP ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALL)
ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN)
) {
return false;
}
return true
}
/**
* 判断能否参与魔力鸟旋转的元素
* 无特效,无锁,无毛球,
* @param ele 元素
*/
public static judgeMagicRotate(ele: Element): boolean {
if (!ele ||
ele.effectType != null ||
ele.hasState(StateType.LOCK) ||
ele.hasState(StateType.HAIRBALLGREY) ||
ele.hasState(StateType.HAIRBALLBLACK) ||
ele.hasState(StateType.HAIRBALLBROWN)
) {
return false;
}
......@@ -591,7 +651,9 @@ export class Tool {
lattices[i].element &&
lattices[i].element.type <= 4 &&
!lattices[i].element.hasState(StateType.LOCK) &&
!lattices[i].element.hasState(StateType.HAIRBALL)
!lattices[i].element.hasState(StateType.HAIRBALLGREY) &&
!lattices[i].element.hasState(StateType.HAIRBALLBLACK) &&
!lattices[i].element.hasState(StateType.HAIRBALLGREY)
) {
var type = lattices[i].element.type;
if (!arr[type]) arr[type] = 0;
......
......@@ -4,59 +4,33 @@ import { Pool } from "../Pool";
import { Element } from "../class/Element";
import { Ice } from "../class/Ice";
import { ElementType } from "../enum/ElementType";
import { HairballState } from "../states/HairballState";
export function FlyTargetAni(ele: any, p: number[], con: egret.DisplayObjectContainer) {
export function FlyTargetAni(
type: ElementType,
fromP: number[],
targetP: number[],
con: egret.DisplayObjectContainer
) {
//弄一个替代的
let eleC;
if (ele instanceof Element) {
eleC = Pool.takeOut(RecoverName.ELEMENT);
if (!eleC) {
eleC = new Element(ele.type)
} else {
eleC.reset(ele.type)
}
}
//是冰块
else if (ele instanceof Ice) {
eleC = Pool.takeOut(RecoverName.ICE);
if (!eleC) {
eleC = new Ice()
} else {
eleC.reset()
}
}
//是毛球
else if(ele instanceof HairballState){
eleC = Pool.takeOut(RecoverName.HAIRBALL_STATE);
if (!eleC) {
eleC = new HairballState()
} else {
eleC.reset(1)
}
}
eleC.x = ele.x;
eleC.y = ele.y;
let eleC: egret.Bitmap = Pool.takeOut(RecoverName.FLYIMAGE);
if (!eleC) eleC = new egret.Bitmap();
var texture: egret.Texture = RES.getRes("ele" + type + "_png");
eleC.texture = texture;
//都按格子的中心点
eleC.anchorOffsetX = texture.textureWidth / 2;
eleC.anchorOffsetY = texture.textureHeight / 2;
//重置缩放
eleC.scaleX = 1;
eleC.scaleY = 1;
eleC.x = fromP[0];
eleC.y = fromP[1];
con.addChild(eleC);
var a = { t: 0 };
egret.Tween.get(eleC)
.to({ x: p[0], y: p[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0)
.to({ x: targetP[0], y: targetP[1], scaleX: 0.3, scaleY: 0.3 }, 500 + (Math.random() * 100) >> 0)
.call(() => {
//回收
con.removeChild(eleC);
if (ele instanceof Element) {
Pool.recover(RecoverName.ELEMENT, eleC);
con["elementTargets"].targets[eleC.type].count--
}
//是冰块
else if (ele instanceof Ice) {
Pool.recover(RecoverName.ICE, eleC);
con["elementTargets"].targets[ElementType.ICE].count--
}
//是毛球
else if (ele instanceof HairballState) {
Pool.recover(RecoverName.HAIRBALL_STATE, eleC);
con["elementTargets"].targets[ElementType.HAIRBALL].count--
}
// callback()
Pool.recover(RecoverName.FLYIMAGE, eleC);
con["elementTargets"].targets[type].count--;
})
}
\ No newline at end of file
......@@ -5,14 +5,14 @@ import { ImageAni } from "../class/ImageAni";
* 待写
* 毛球消失动效
*/
export class HairballDisAni extends Ani {
export class HairballGreyDisAni extends Ani {
/**
* 图片
*/
showImage: ImageAni;
constructor() {
super();
this.aniName = "HairballDisAni";
this.aniName = "HairballGreyDisAni";
var arr = []
for (var i = 1; i <= 19; i++) {
arr.push("eleDis" + i + "_png");
......
......@@ -76,7 +76,7 @@ export const Chapters2: ChapterData[] = [
elements: [
{
type: ElementType.ROCK,
count: 34
count: 40
},
{
type: ElementType.CHICKEN,
......
......@@ -10,8 +10,11 @@ import { ChickenEgg } from "./ChickenEgg";
import { State } from "./State";
import { StateType } from "../enum/StateType";
import { LockState } from "../states/LockState";
import { HairballState } from "../states/HairballState";
import { HairballBrownState } from "../states/HairballBrownState";
import { BubbleState } from "../states/BubbleState";
import { HairballGreyState } from "../states/HairballGreyState";
import { HairballBlackState } from "../states/HairballBlackState";
/**
......@@ -192,8 +195,14 @@ export class Element extends eui.Component {
case StateType.BUBBLE:
recoverType = RecoverName.BUBBLE_STATE;
break;
case StateType.HAIRBALL:
recoverType = RecoverName.HAIRBALL_STATE;
case StateType.HAIRBALLGREY:
recoverType = RecoverName.HAIRBALLGREY_STATE;
break;
case StateType.HAIRBALLBLACK:
recoverType = RecoverName.HAIRBALLBLACK_STATE;
break;
case StateType.HAIRBALLBROWN:
recoverType = RecoverName.HAIRBALLBROWN_STATE;
break;
}
Pool.recover(recoverType, state);
......@@ -347,14 +356,32 @@ export class Element extends eui.Component {
this.states[state] = bubbleState;
this.showImage.alpha = 0;
break;
case StateType.HAIRBALL:
let hairBallState = Pool.takeOut(RecoverName.HAIRBALL_STATE);
if (!hairBallState) {
hairBallState = new HairballState(data);
case StateType.HAIRBALLGREY:
let hairballGreyState = Pool.takeOut(RecoverName.HAIRBALLGREY_STATE);
if (!hairballGreyState) {
hairballGreyState = new HairballGreyState();
} else {
hairballGreyState.reset()
}
this.states[state] = hairballGreyState;
break;
case StateType.HAIRBALLBLACK:
let hairballBlackState = Pool.takeOut(RecoverName.HAIRBALLBLACK_STATE);
if (!hairballBlackState) {
hairballBlackState = new HairballBlackState();
} else {
hairballBlackState.reset()
}
this.states[state] = hairballBlackState;
break;
case StateType.HAIRBALLBROWN:
let hairballBrowState = Pool.takeOut(RecoverName.HAIRBALLBROWN_STATE);
if (!hairballBrowState) {
hairballBrowState = new HairballBrownState();
} else {
hairBallState.reset(data)
hairballBrowState.reset()
}
this.states[state] = hairBallState;
this.states[state] = hairballBrowState;
break;
}
//视图添加
......
import { ElementType } from "../enum/ElementType";
export class Ice extends eui.Image {
export class Ice extends egret.Bitmap {
/**
* 消除次数
*/
......@@ -19,7 +19,10 @@ export class Ice extends eui.Image {
constructor(n: number = 2) {
super()
this.source = "ele" + ElementType.ICE + "_png";
var texture: egret.Texture = RES.getRes("ele" + ElementType.ICE + "_png");
this.texture = texture;
this.anchorOffsetX = texture.textureWidth / 2;
this.anchorOffsetY = texture.textureHeight / 2;
if (n == 2) {
this.alpha = 1;
} else {
......
......@@ -10,7 +10,7 @@ export enum ElementType {
CATTLE,//牛2
LION,//狮子3
PIG,//猪4
//特殊元素
ROCK,//石头5
LOLLIPOP,//棒棒糖6
......@@ -22,8 +22,9 @@ export enum ElementType {
ICE,//冰块9
//元素身上状态
HAIRBALL,//毛球10
HAIRBALLGREY,//灰色毛球10
HAIRBALLBROWN,//褐色毛球11
HAIRBALLBLACK,//黑色毛球12
}
var a = [
0, 40, 30, 0, 44, 0, 20, 40, 0,
......
......@@ -12,11 +12,15 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni",
//目标飞入的图片,没有相应的类,直接用egret.Bitmap
FLYIMAGE = "flyImage",
//带回调的动画,和不带的合并不了,因为可能还有其他参数
BONUSSHOOT_ANI = "BonusShootAni",
JELLYSPREAD_ANI = "JellySpreadAni",
PIECETOEGG_ANI = "PieceToEggAni",
BUBBLE_ANI = "BubbleAni",
HAIRBALLBROWNDIVIDE = "HairballBrownDivide",
......@@ -42,7 +46,8 @@ export enum RecoverName {
STEP_ANI = "StepAni",
JELLYDIS_ANI = "JellyDisAni",
EGGBROKEN_ANI = "EggBrokenAni",
HAIRBALLDIS_ANI = "HairballDisAni",
HAIRBALLGREYDIS_ANI = "HairballGreyDisAni",
HAIRBALLBLACKDIS_ANI = "HairballBlackDisAni",
//方形遮罩
RECT_MASK = "RectMask",
......@@ -50,5 +55,8 @@ export enum RecoverName {
//状态的回收
LOCK_STATE = "LockState",
BUBBLE_STATE = "BubbleState",
HAIRBALL_STATE = "HairballState",
HAIRBALLGREY_STATE = "HairballGreyState",
HAIRBALLBLACK_STATE = "HairballGreyState",
HAIRBALLBROWN_STATE = "HairballGreyState",
}
\ No newline at end of file
......@@ -4,5 +4,7 @@
export enum StateType {
LOCK = 0,//锁
BUBBLE,//变色气泡
HAIRBALL,//毛球
HAIRBALLGREY,//灰色毛球 ,一次就消除
HAIRBALLBROWN,//褐色毛球 ,只能特效消除
HAIRBALLBLACK,//黑色毛球 ,两次消除,一次闭眼
}
\ No newline at end of file
/**
* 格子生成口数据格式
*/
export interface GenerateLatData{
export interface GenerateLatData {
/**
* 生成口的索引
*/
......@@ -10,7 +10,7 @@ export interface GenerateLatData{
* 掉落元素类型
* 里面随机类型和下一致
*/
type:number[]
type?: number[]
/**
* 自定义掉落元素
* 十位是基础元素类型,对应数字减1就是基础元素类型
......@@ -21,5 +21,5 @@ export interface GenerateLatData{
* 13
* 14
*/
cus: number[];
cus?: number[];
}
\ No newline at end of file
......@@ -32,8 +32,9 @@ export interface MapData {
* 5果冻
* 6鸡蛋
* 7变色气泡
* 8一级毛球
* 9二级毛球
* 8灰色毛球 一次消除
* 9褐色毛球 特效消除,分裂
* 10黑色毛球 两次消除,一次眩晕,
*/
elements?: number[];
/**
......
......@@ -238,7 +238,7 @@ export class AiControl {
let index = indexs[a];
let lat = thisObj.lattices[index];
let ele = lat.element;
let fromType= ele.type;
let fromType = ele.type;
//计算type
let type: ElementType = 1;
//直接重置类型,为了后续计算,但是要隐藏,待动画播放完显示
......@@ -255,7 +255,7 @@ export class AiControl {
bubbleAni.y = p[1];
thisObj.addChild(bubbleAni);
//播放动画
bubbleAni.play(fromType,type, () => {
bubbleAni.play(fromType, type, () => {
//显示
ele.visible = true;
count++;
......@@ -265,9 +265,6 @@ export class AiControl {
})
}
}
}
/**
......@@ -292,7 +289,13 @@ function judgeHairballExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//必须是基础元素,然后判断状态毛球,有一个就返回true
if (Tool.judgeBaseEle(lattice) && lattice.element.hasState(StateType.HAIRBALL)) return true
if (Tool.judgeBaseEle(lattice) &&
(
lattice.element.hasState(StateType.HAIRBALLGREY) ||
lattice.element.hasState(StateType.HAIRBALLBLACK) ||
lattice.element.hasState(StateType.HAIRBALLBROWN)
)
) return true
}
return false;
}
......
......@@ -150,35 +150,6 @@ function calVet(index: string): number[] {
return [center[0] + dis[arr[1]], center[1] + dis[arr[2]]]
}
//给出10*10
let indexToRcMap10: number[][];
let indexPositions10: number[][];
function get10DataUp() {
indexToRcMap10 = [];
indexPositions10 = [];
var rowNum = Tool.rowNum + 1;
var colNum = Tool.colNum + 1;
var offsetX = Tool.offsetX
var offsetY = Tool.offsetY
for (var i = 0; i < rowNum; i++) {
for (var j = 0; j < colNum; j++) {
// rcToIndexMap["" + i + j] = i * colNum + j;
indexToRcMap10[i * colNum + j] = [i, j];
indexPositions10[i * colNum + j] = [offsetX + j * Tool.width, offsetY + i * Tool.height];
}
}
}
//返回10的索引
function indexToRc10(index: number): number[] {
if (!indexToRcMap10) get10DataUp();
return indexToRcMap10[index]
}
//
function getPositionByIndex10(index: number): number[] {
if (!indexPositions10) get10DataUp();
return indexPositions10[index]
}
/**
* 生成格子背景的路径
* @param lattices
......@@ -203,7 +174,7 @@ export function generateMapBg(lattices: number[]): PathData[] {
//周围至少右一个
// console.log(vertexs)
if (vertexs[i].indexOf(1) > -1) {
var p = getPositionByIndex10(i)
var p = Tool.getPositionByIndex10(i)
//判断是否在groups内
var group = judgeInGroups(i, paths, vertexs[i])
if (group) {
......@@ -256,7 +227,7 @@ function isPointIn(point: number[], points: number[]): boolean {
}
function judgeInGroups(index: number, groups: PathData[], vertex: number[]): PathData {
var p = getPositionByIndex10(index)
var p = Tool.getPositionByIndex10(index)
for (var i = 0; i < groups.length; i++) {
var group = groups[i];
if (isPointIn(p, group.points)) {
......@@ -377,7 +348,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
while (curIndex != index) {
lastIndex = curIndex || index;
//求得行列
var rc = indexToRc10(lastIndex);
var rc = Tool.indexToRc10(lastIndex);
var directionAll = {
"r": rc[1] < Tool.colNum ? lastIndex + 1 : null,
"l": rc[1] > 0 ? lastIndex - 1 : null,
......@@ -408,7 +379,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (curIndex == index) {
group.indexs10.push(lastIndex);
if (lastDirection != direction) {
var point = getPositionByIndex10(lastIndex);
var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]);
lastDirection = direction
}
......@@ -419,7 +390,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
if (lastDirection == direction) {
} else {
var point = getPositionByIndex10(lastIndex);
var point = Tool.getPositionByIndex10(lastIndex);
group.points.push(point[0], point[1]);
lastDirection = direction
}
......@@ -432,7 +403,7 @@ function beenLoop(index: number, vertexs: number[][]): PathData {
//取顶点格子左上角格子索引
function getLeftUp(index: number): number {
var rc = indexToRc10(index);
var rc = Tool.indexToRc10(index);
if (rc[0] > 0 && rc[1] > 0) {
return Tool.rcToIndex(rc[0] - 1, rc[1] - 1)
} else {
......@@ -441,7 +412,7 @@ function getLeftUp(index: number): number {
}
//取顶点格子右上角格子索引
function getRightUp(index: number): number {
var rc = indexToRc10(index);
var rc = Tool.indexToRc10(index);
if (rc[0] > 0 && rc[1] < Tool.colNum) {
return Tool.rcToIndex(rc[0] - 1, rc[1])
} else {
......@@ -450,7 +421,7 @@ function getRightUp(index: number): number {
}
//取顶点格子右下角格子
function getRightDown(index: number): number {
var rc = indexToRc10(index);
var rc = Tool.indexToRc10(index);
if (rc[0] < Tool.rowNum && rc[1] < Tool.colNum) {
return Tool.rcToIndex(rc[0], rc[1])
} else {
......@@ -459,7 +430,7 @@ function getRightDown(index: number): number {
}
//取顶点格子左下角格子
function getLeftDown(index: number): number {
var rc = indexToRc10(index);
var rc = Tool.indexToRc10(index);
if (rc[0] < Tool.rowNum && rc[1] > 0) {
return Tool.rcToIndex(rc[0], rc[1] - 1)
} else {
......@@ -469,8 +440,8 @@ function getLeftDown(index: number): number {
//根据两个顶点索引,有顺序,取下是否有
function getDown(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l);
var rcR = indexToRc10(r);
var rcL = Tool.indexToRc10(l);
var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) {
//正下方
return vertexs[l][2]
......@@ -490,8 +461,8 @@ function getDown(l: number, r: number, vertexs: number[][]) {
}
////根据两个顶点索引,有顺序,取上是否有
function getUp(l: number, r: number, vertexs: number[][]) {
var rcL = indexToRc10(l);
var rcR = indexToRc10(r);
var rcL = Tool.indexToRc10(l);
var rcR = Tool.indexToRc10(r);
if (rcR[1] - rcL[1] == 1) {
//上方
return vertexs[l][1]
......@@ -534,9 +505,9 @@ function clearGroup(group: PathData) {
var one = group.indexs10[0];
var two = group.indexs10[1];
var Last = group.indexs10[group.indexs10.length - 1];
var rc1 = indexToRc10(one);
var rc2 = indexToRc10(two);
var rcL = indexToRc10(Last);
var rc1 = Tool.indexToRc10(one);
var rc2 = Tool.indexToRc10(two);
var rcL = Tool.indexToRc10(Last);
if ((rc1[0] == rc2[0] && rc1[0] == rcL[0]) || (rc1[1] == rc2[1] && rc1[1] == rcL[1])) {
// group.indexs10.shift();
group.points.shift();
......
......@@ -14,7 +14,7 @@ export class BubbleState extends State {
* 显示图片
*/
private showImage: egret.Bitmap;
constructor(type: ElementType) {
super();
this.showImage = new egret.Bitmap();
......@@ -29,7 +29,7 @@ export class BubbleState extends State {
//直接回收
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this);
Pool.recover(RecoverName.BUBBLE_STATE, this);
}
private changeSource(source: string) {
......
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 黑色毛球状态
* 两次消除,需要修改图片,,,再说,还没写
*/
export class HairballBlackState extends State {
private showImage: egret.Bitmap;
/**
* 是否激活
*/
isActive: boolean;
constructor() {
super();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLBLACK + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false;
}
reset() {
this.isActive = false;
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALLBLACK_STATE, this);
}
// private changeSource(source: string) {
// var texture: egret.Texture = RES.getRes(source);
// this.showImage.texture = texture;
// this.showImage.x = -texture.textureWidth / 2;
// this.showImage.y = -texture.textureHeight / 2
// }
}
\ No newline at end of file
......@@ -6,48 +6,30 @@ import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 毛球状态
* 消失动画。和分裂动画都在外面单独掉
* 褐色帽绣毛球状态
* 分裂动画都在外面单独掉
*/
export class HairballState extends State {
export class HairballBrownState extends State {
private showImage: egret.Bitmap;
/**
* 是否激活
*/
isActive: boolean;
/**
* 毛球等级,1或2
*/
private _levelNum: number;
get levelNum() {
return this._levelNum
}
set levelNum(value: number) {
if (this._levelNum == value) return
this._levelNum = value;
var source: string;
if (value == 2) {
source = "hairballDark_png";
} else {
source = "ele" + ElementType.HAIRBALL + "_png"
}
this.changeSource(source)
}
constructor(level: number = 2) {
constructor() {
super();
this.showImage = new egret.Bitmap();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLBROWN + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.levelNum = level;
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
this.isActive = false;
}
reset(level: number = 2) {
this.levelNum = level;
reset() {
this.isActive = false;
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALL_STATE, this);
Pool.recover(RecoverName.HAIRBALLBROWN_STATE, this);
}
private changeSource(source: string) {
......
import { State } from "../class/State";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { ElementType } from "../enum/ElementType";
/**
* 褐色帽绣毛球状态
* 分裂动画都在外面单独掉
*/
export class HairballGreyState extends State {
private showImage: egret.Bitmap;
constructor() {
super();
var texture: egret.Texture = RES.getRes("ele" + ElementType.HAIRBALLGREY + "_png")
this.showImage = new egret.Bitmap(texture);
this.addChild(this.showImage);
this.showImage.x = -texture.textureWidth / 2;
this.showImage.y = -texture.textureHeight / 2;
}
reset() {
}
recover() {
if (this.parent) this.parent.removeChild(this);
Pool.recover(RecoverName.HAIRBALLGREY_STATE, 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