Commit 46fb343c authored by 邱旭's avatar 邱旭

1

parents 26b0cb54 24f518f2
......@@ -209,5 +209,13 @@
"value": "http://yun.duiba.com.cn/db_games/fishlogo.png"
}
]
},
"16db4bf413f": {
"bindingDataTestObj": [
{
"key": "data.img",
"value": "http://yun.duiba.com.cn/db_games/fishlogo.png"
}
]
}
}
\ No newline at end of file
......@@ -169,9 +169,8 @@ export default class MainBase extends eui.UILayer {
}
for (var i = 0; i < 5; i++) {
RES.getResAsync("ele" + i + "_png")
for (var j = 0; j < 3; j++) {
RES.getResAsync("ele" + i + j + "_png")
}
RES.getResAsync("ele" + i + "Line" + "_png")
RES.getResAsync("ele" + i + "Exp" + "_png")
}
for (var i = 1; i <= 27; i++) {
RES.getResAsync("bonusFra" + i + "_png")
......@@ -179,10 +178,10 @@ export default class MainBase extends eui.UILayer {
for (var i = 1; i <= 19; i++) {
RES.getResAsync("eleDis" + i + "_png")
}
for (var i = 1; i <= 6; i++) {
for (var i = 2; i <= 6; i++) {
RES.getResAsync("ice" + i + "_png")
}
for (var i = 1; i <= 6; i++) {
for (var i = 2; i <= 6; i++) {
RES.getResAsync("rock" + i + "_png")
}
for (var i = 0; i <= 9; i++) {
......@@ -237,6 +236,7 @@ export default class MainBase extends eui.UILayer {
"ele5",
"ele6",
"ele7",
"ele8",
"leftArrow",
"chooseRect",
"lightedStar",
......
......@@ -89,17 +89,8 @@
"name": "signprize"
},
{
<<<<<<< HEAD
"keys": "namebg_png,avatar_png,invite_txtbg_png,invite_icon_png,taskicon_png,friend_avatar_png,ad_icon_png,testavatar_png",
"name": "preload"
},
{
"keys": "invite_bg_png,invite_help_png,invite_invite_png,invite_rule_bg_png,invite_btn_png,invite_prize_ad_png,invite_prize_bg_png,invite_prize_btn_png",
"name": "invite"
=======
"name": "preload",
"keys": "namebg_png,avatar_png,invite_txtbg_png,invite_icon_png,taskicon_png,friend_avatar_png,ad_icon_png,testavatar_png,friend按钮-炫耀_png,friend_icon1_png,friend_icon2_png,friend_icon3_png,friend_itembg_png,friendbg_png,ad_closebtn_png,startpanel_icon1_png,startpanel_icon2_png,startpanel_icon3_png,startpanel_icon_png,startpanel_avatar_png,startpanel_bg2_png"
>>>>>>> e4972da2d589501b0f375aac75d85b8acfb74408
}
],
"resources": [
......
......@@ -2,6 +2,7 @@
"skins": {},
"autoGenerateExmlsList": true,
"exmls": [
"resource/skins/ADSmallSkin.exml",
"resource/skins/AvatarSkin.exml",
"resource/skins/AlertSkin.exml",
"resource/skins/Blood2Skin.exml",
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="ADSmallSkin" width="582" height="203" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<w:Config id="16db4bf413f"/>
<e:Image source="common_adbg_png"/>
<e:Image y="57" horizontalCenter="0" width="493" height="111" source="{data.img}" anchorOffsetY="0"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="BackSkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui">
<e:Component y="710.52" skinName="ADSmallSkin" horizontalCenter="0"/>
<e:Image source="闯关失败_png" y="27" horizontalCenter="0"/>
<e:Button id="closeBtn" label="" x="609" y="197">
<e:skinName>
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="Box2Skin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<w:Config id="16ccc954c14"/>
<e:Component y="739.52" skinName="ADSmallSkin" horizontalCenter="0"/>
<e:Image y="33.76" horizontalCenter="0" source="box2_bg_png"/>
<e:Button id="closeBtn" label="" x="601.94" y="195.3">
<e:skinName>
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="BoxSkin" width="750" height="1205" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<w:Config id="16cc233ca3b"/>
<e:Component y="739.52" skinName="ADSmallSkin" horizontalCenter="0"/>
<e:Image source="boxbg_png" y="33.76" horizontalCenter="0"/>
<e:Image id="img" y="355" touchEnabled="true" source="{data.img}" width="512" height="240" scaleX="0.9" scaleY="0.9" horizontalCenter="0"/>
<e:Button id="closeBtn" label="" x="604.96" y="190.84">
......
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="FailSkin" width="750" height="1206" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Image source="闯关失败_png" y="27" horizontalCenter="0"/>
<e:Button id="closeBtn" label="" x="609" y="197">
<e:Component y="674.52" skinName="ADSmallSkin" horizontalCenter="0"/>
<e:Image source="闯关失败_png" y="-8" horizontalCenter="0"/>
<e:Button id="closeBtn" label="" x="609" y="162">
<e:skinName>
<e:Skin states="up,down,disabled" xmlns:w="http://ns.egret.com/wing">
<e:Image width="100%" height="100%" source="closeCommonBtn_png" source.down="closeCommonBtn_png" source.disabled="closeCommonBtn_png"/>
......@@ -9,7 +10,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="againBtn" label="" y="556" horizontalCenter="0">
<e:Button id="againBtn" label="" y="521" horizontalCenter="0">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="按钮 副本 9_png" source.down="按钮 副本 9_png" source.disabled="按钮 副本 9_png"/>
......
......@@ -51,7 +51,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="recordBtn" label="" x="620.14" y="389.91">
<e:Button id="recordBtn" label="" x="620.14" y="255.91">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="recordbtn_png" source.down="recordbtn_png" source.disabled="recordbtn_png"/>
......@@ -59,7 +59,7 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Button id="signBtn" label="" x="608.69" y="520.57" scaleX="0.9" scaleY="0.9">
<e:Button id="signBtn" label="" x="608.69" y="383.57" scaleX="0.9" scaleY="0.9">
<e:skinName>
<e:Skin states="up,down,disabled">
<e:Image width="100%" height="100%" source="map_signicon_png" source.down="map_signicon_png" source.disabled="recordbtn_png"/>
......@@ -67,6 +67,16 @@
</e:Skin>
</e:skinName>
</e:Button>
<e:Group id="friendBtn" x="13.56" y="126.88" width="171" height="120">
<e:Image source="avatar_png" y="0" horizontalCenter="0"/>
<e:Group x="38.5" y="10">
<e:Image id="avatar" y="0" source="testavatar_png" width="96" height="96" x="0"/>
<e:Rect id="avatarMask" width="96" height="96" x="0" y="0" ellipseWidth="96" ellipseHeight="96"/>
</e:Group>
<e:Image source="namebg_png" horizontalCenter="-4" bottom="-4"/>
<e:Label id="nameTxt" text="La121233bel" y="91.5" size="20" horizontalCenter="1"/>
</e:Group>
<e:Image id="adBtn" y="519.02" source="ad_icon_png" right="12"/>
<e:Button id="taskBtn" label="" x="572.62" y="248.51" visible="false">
<e:skinName>
<e:Skin states="up,down,disabled">
......@@ -148,15 +158,5 @@
</e:Group>
<e:Label text="点击开宝箱" y="791" size="37" horizontalCenter="0" bold="true"/>
</e:Group>
<e:Group id="friendBtn" x="13.56" y="126.88" width="171" height="120">
<e:Image source="avatar_png" y="0" horizontalCenter="0"/>
<e:Group x="38.5" y="10">
<e:Image id="avatar" y="0" source="testavatar_png" width="96" height="96" x="0"/>
<e:Rect id="avatarMask" width="96" height="96" x="0" y="0" ellipseWidth="96" ellipseHeight="96"/>
</e:Group>
<e:Image source="namebg_png" horizontalCenter="-4" bottom="-4"/>
<e:Label id="nameTxt" text="La121233bel" y="91.5" size="20" horizontalCenter="1"/>
</e:Group>
<e:Image id="adBtn" y="648.02" source="ad_icon_png" right="12"/>
<w:Config id="16c89f4ae1a"/>
</e:Skin>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<e:Skin class="NoPrizeSkin" width="750" height="1000" xmlns:e="http://ns.egret.com/eui" xmlns:w="http://ns.egret.com/wing">
<e:Component y="735.52" skinName="ADSmallSkin" horizontalCenter="0"/>
<e:Image id="light" source="common_prizelight_png" x="374.19" y="329.51" anchorOffsetX="375.76" anchorOffsetY="327.27"/>
<e:Image y="109.55" source="擦肩而过弹窗 _png" horizontalCenter="0.5"/>
<e:Button id="closeBtn" label="" x="617" y="279">
......
This diff is collapsed.
import ComponentBase from "../../libs/new_wx/components/ComponentBase";
export default class AdSmallComp extends ComponentBase {
start(data?) {
this.touchEnabled=this.touchChildren=false;
super.start(data);
}
get skinKey(): string { return 'ADSmall' }
}
\ No newline at end of file
......@@ -37,7 +37,7 @@ export default class MapScene extends Scene {
this['avatar'].mask = this['avatarMask'];
setTimeout(() => {
PanelCtrl.instance.show('StartPanel',1);
// PanelCtrl.instance.show('StartPanel',1);
}, 1000);
if (getBgOn() && MapScene['firstPlayBgTag'] == true) {
......
......@@ -2941,7 +2941,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.3,
stepCount: 14+6+5,
stepCount: 14 + 6 + 5,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -2986,7 +2986,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3],
effectInitProbability: 0.03,
stepCount: 20+6,
stepCount: 20 + 6,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3031,7 +3031,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 15+5,
stepCount: 15 + 5,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3076,7 +3076,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0,
stepCount: 20+4,
stepCount: 20 + 4,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3121,7 +3121,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20+5,
stepCount: 20 + 5,
passTarget: {
type: PassType.SCORE_TARGET,
score: 15000
......@@ -3161,7 +3161,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20+4,
stepCount: 20 + 4,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3206,7 +3206,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 15+5,
stepCount: 15 + 5,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3251,7 +3251,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.03,
stepCount: 20+4,
stepCount: 20 + 4,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3296,7 +3296,7 @@ export const Chapters: ChapterData[] = [
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 25+3,
stepCount: 25 + 3,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
......@@ -3312,4 +3312,50 @@ export const Chapters: ChapterData[] = [
15000
]
},
//第八十一关
{
map: {
lattices: [
0, 3, 0, 3, 0, 3, 0, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 3, 3, 3, 3, 3, 3, 0,
3, 3, 3, 3, 3, 3, 3, 3, 3,
0, 3, 0, 3, 0, 3, 0, 3, 0,
],
generateLats: [0, 1, 0, 1, 0, 1, 0, 1, 0],
elements: [
0, 1, 0, 1, 0, 1, 0, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 1, 1, 1, 1, 1, 1, 1, 0,
2, 1, 1, 1, 1, 1, 1, 1, 2,
0, 1, 1, 1, 1, 1, 1, 1, 0,
2, 1, 1, 1, 1, 1, 1, 1, 2,
0, 1, 1, 1, 1, 1, 1, 1, 0,
5, 1, 1, 1, 1, 1, 1, 1, 5,
0, 5, 0, 5, 0, 5, 0, 5, 0,
],
},
baseElementTypes: [0, 1, 2, 3, 4],
effectInitProbability: 0.02,
stepCount: 250 + 3,
passTarget: {
type: PassType.ELEMENT_TARGET,
elements: [
{
type: ElementType.ICE,
count: 65
}
],
},
starScores: [
4000,
8000,
15000
]
},
]
\ No newline at end of file
......@@ -207,8 +207,11 @@ export class Tool {
if (!lat || !lat.element) {
return false
}
//上方元素为石头,或元素为锁定
else if (lat.element.type == ElementType.ROCK || lat.element.isLock) {
//上方元素为石头,或元素为锁定,或者是果冻,或者鸡蛋
else if (lat.element.type == ElementType.ROCK ||
lat.element.isLock ||
lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG) {
return false
}
//剩下情况
......@@ -228,10 +231,12 @@ export class Tool {
if (!lat || !lat.element) {
return false
}
//上方元素为石头,或为冰淇淋,或为魔力鸟
//上方元素为石头,或为冰淇淋,或为魔力鸟,或为果冻,或为鸡蛋
else if (lat.element.type == ElementType.ROCK ||
lat.element.type == ElementType.LOLLIPOP ||
lat.element.effectType == EffectType.MAGICLION) {
lat.element.effectType == EffectType.MAGICLION ||
lat.element.type == ElementType.JELLY ||
lat.element.type == ElementType.CHICKEN_EGG) {
return false
}
//剩下情况
......@@ -241,7 +246,7 @@ export class Tool {
}
/**
* 判断能执行消除的元素,
* 包括所有特效和基本元素
* 包括所有特效和基本元素,石头,果冻,鸡蛋
* @param lat
*/
public static judgeEliminate(lat: Lattice) {
......@@ -249,8 +254,8 @@ export class Tool {
if (!lat || !lat.element) {
return false
}
//上方元素为石头,或为冰淇淋
else if (lat.element.type == ElementType.ROCK || lat.element.type == ElementType.LOLLIPOP) {
//上方元素为冰淇淋
else if (lat.element.type == ElementType.LOLLIPOP) {
return false
}
//剩下情况
......@@ -259,6 +264,24 @@ export class Tool {
}
}
/**
* 判断元素是否可被手势选中和交换
* 主要点击元素判断使用
* @param ele 元素
* @return 返回true为可选,false不可选
*/
public static judgeChosen(ele: Element) {
if (!ele ||
ele.type == ElementType.ROCK ||
ele.isLock ||
ele.type == ElementType.JELLY ||
ele.type == ElementType.CHICKEN_EGG
) {
return false;
}
return true
}
/**
* 检测死图,需要提示
* 需要返回一组提示 两个能互相交换元素,数组
......@@ -501,6 +524,86 @@ export class Tool {
return null
}
/**
* 判断已死
* @param lattices
*/
public static alreadyDie(lattices: Lattice[]) {
//记录基本元素的个数
var arr = {};
//记录是否有特效,两个任意特效,或一个魔力鸟特效,都未锁定
var hasEffect = false;
var effectCount = 0;
//记录是否有两个格子挨着,且未锁定
var hasTwo = false;
//记录是否有三个格子挨着,且未锁定,这个逻辑略烦,暂定至少都未锁定,有bug再改
var hasThree = false;
for (var i = 0; i < lattices.length; i++) {
if (lattices[i] &&
lattices[i].element &&
lattices[i].element.type <= 4 &&
!lattices[i].element.isLock) {
var type = lattices[i].element.type;
if (!arr[type]) arr[type] = 0;
arr[type]++;
var ele = lattices[i].element;
if (ele.effectType == EffectType.MAGICLION) {
hasEffect = true;
}
if (ele.effectType != null) {
effectCount++;
if (effectCount >= 2) {
hasEffect = true;
}
}
var rc = Tool.indexToRc(i);
//右1
if (rc[1] < Tool.colNum - 1) {
var latRight1 = lattices[i + 1];
if (Tool.judgeFall(latRight1) && latRight1.element.type != ElementType.LOLLIPOP) {
hasTwo = true;
}
//右2
if (rc[1] < Tool.colNum - 2) {
var latRight2 = lattices[i + 2];
if (Tool.judgeFall(latRight1) &&
latRight1.element.type != ElementType.LOLLIPOP &&
Tool.judgeFall(latRight2) &&
latRight2.element.type != ElementType.LOLLIPOP) {
hasThree = true;
}
}
}
//下1
var latDown1 = lattices[i + Tool.colNum];
if (Tool.judgeFall(latDown1) && latDown1.element.type != ElementType.LOLLIPOP) {
hasTwo = true;
}
//提前判断下
if (hasTwo && hasEffect) return false;
//下2
var latDown2 = lattices[i + Tool.colNum * 2];
if (Tool.judgeFall(latDown1) &&
latDown1.element.type != ElementType.LOLLIPOP &&
Tool.judgeFall(latDown2) &&
latDown2.element.type != ElementType.LOLLIPOP) {
hasThree = true;
}
if (hasThree) {
for (var a in arr) {
if (arr[a] >= 3) {
return false
}
}
}
}
}
return true
}
/**
* 将有相邻相同的组合,不是基础元素的,都会是单独的
* @param arr
......@@ -699,8 +802,8 @@ export class Tool {
* 获得元素
* @param type
*/
public static getElement(type: ElementType) {
let obj = Pool.takeOut(RecoverName.ELEMENT);
public static getElement(type: ElementType):Element {
let obj:Element = Pool.takeOut(RecoverName.ELEMENT);
if (!obj) {
obj = new Element(type)
} else {
......
......@@ -10,7 +10,7 @@ export class IceAni extends Ani {
constructor() {
super();
this.aniName = "IceAni";
this.showImage = new ImageAni(["ice1_png", "ice2_png", "ice3_png", "ice4_png", "ice5_png", "ice6_png"]);
this.showImage = new ImageAni(["ele7_png", "ice2_png", "ice3_png", "ice4_png", "ice5_png", "ice6_png"]);
this.addChild(this.showImage)
}
......
import { ImageAni } from "../class/ImageAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { playSound, SoundType } from "../../soundCtrl";
/**
* 需要回调的
*
*/
export class JellySpreadAni extends egret.DisplayObjectContainer {
//目标位置的图片,到时根据方向定
targetImage: egret.Bitmap;
imageAni: ImageAni
constructor() {
super()
var texture = RES.getRes("bonusShoot_png")
this.targetImage = new egret.Bitmap(texture);
this.targetImage.anchorOffsetX = 78;
this.targetImage.anchorOffsetY = 37 / 2;
this.addChild(this.targetImage);
var arr = []
for (var i = 1; i <= 27; i++) {
arr.push("bonusFra" + i + "_png");
}
this.imageAni = new ImageAni(arr);
this.addChild(this.imageAni);
}
play(startP: number[], endP: number[], callback: Function) {
this.x = startP[0];
this.y = startP[1];
//判断方向
this.imageAni.play(() => {
callback();
if (this.$parent) {
this.$parent.removeChild(this)
};
Pool.recover(RecoverName.JELLYSPREAD_ANI, this)
})
}
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ export class RockAni extends Ani {
constructor() {
super();
this.aniName = "RockAni";
this.showImage = new ImageAni(["rock1_png", "rock2_png", "rock3_png", "rock4_png", "rock5_png", "rock6_png"]);
this.showImage = new ImageAni(["ele5_png", "rock2_png", "rock3_png", "rock4_png", "rock5_png", "rock6_png"]);
this.addChild(this.showImage)
}
......
/**
* 鸡蛋的状态
*
*/
export class ChickenEgg extends eui.Image {
/**
* 小鸡数量
*/
private chickenNum: number = 0;
/**
* 鸡蛋状态变化 3 2 1 0 再往后,直接加孵鸡次数
*/
private _statusNum: number;
get statusNum() {
return this._statusNum
}
set statusNum(value: number) {
if (value >= 0) {
this._statusNum = value;
} else {
this._statusNum = 0;
this.chickenNum++;
}
}
constructor(n: number = 3) {
super()
this.source = "ele7_png";
//图片需要居中
this.chickenNum = 0;
this._statusNum = n;
}
reset(n: number = 3) {
//图片修改
this.chickenNum = 0;
this._statusNum = n;
}
/**
* 孵蛋动作
*/
hatch(callback: Function) {
if (!this.chickenNum) {
callback();
return
}
}
}
\ No newline at end of file
......@@ -50,7 +50,7 @@ export class Element extends eui.Component {
this.addChildAt(this.magicLionBgAni, 0);
break;
case EffectType.HORIZONTAL:
this.changeSource("ele" + this.type + value + "_png");
this.changeSource("ele" + this.type + "Line" + "_png");
//添加HorizontalBgAni
this.horizontalBgAni = Pool.takeOut(RecoverName.HORIZONTALBG_ANI)
if (!this.horizontalBgAni) {
......@@ -61,7 +61,7 @@ export class Element extends eui.Component {
this.addChildAt(this.horizontalBgAni, 1)
break;
case EffectType.VERTICAL:
this.changeSource("ele" + this.type + value + "_png");
this.changeSource("ele" + this.type + "Line" + "_png");
//添加VerticalBgAni
this.verticalBgAni = Pool.takeOut(RecoverName.VERTICALBG_ANI)
if (!this.verticalBgAni) {
......@@ -72,7 +72,7 @@ export class Element extends eui.Component {
this.addChildAt(this.verticalBgAni, 1)
break;
case EffectType.EXPLOSIVE:
this.changeSource("ele" + this.type + value + "_png");
this.changeSource("ele" + this.type + "Exp" + "_png");
this.explosiveBgAni = Pool.takeOut(RecoverName.EXPLOSIVEBG_ANI)
if (!this.explosiveBgAni) {
this.explosiveBgAni = new ExplosiveBgAni();
......
/**
* 元素类型
* 元素类型 <=4就是基础元素
*/
export enum ElementType {
RABBIT = 0,//兔子0
......@@ -7,9 +7,14 @@ export enum ElementType {
CATTLE,//牛2
LION,//狮子3
PIG,//猪4
ROCK,//石头5
LOLLIPOP,//棒棒糖6
ICE,//冰块7
ICE,//冰块7 有时间重构的话,不适合放这里
JELLY,//果冻8
CHICKEN_EGG,//鸡蛋9
}
export const codeMsgs = {
"E1002090011": "用户关卡记录异常",
......
......@@ -13,6 +13,9 @@ export enum RecoverName {
SCORE_ANI = "ScoreAni",
BONUSSHOOT_ANI = "BonusShootAni",
JELLYSPREAD_ANI = "JellySpreadAni",
//元素身上
LOCK_ANI = "LockAni",
MAGICLIONBG_ANI = "MagicLionBgAni",
......
......@@ -31,6 +31,7 @@ export interface MapData {
* 2石头
* 3棒棒糖
* 4元素枷锁
* 5果冻
*/
elements?:number[]
/**
......
import MainScene from "../../mainScene/MainScene";
import { JellySpreadAni } from "../anis/JellySpreadAni";
import { Pool } from "../Pool";
import { RecoverName } from "../enum/RecoverName";
import { Tool } from "../Tool";
import { ElementType } from "../enum/ElementType";
import { Lattice } from "../class/Lattice";
export class AiControl {
private static _ins: AiControl
static get ins() {
return AiControl._ins || (AiControl._ins = new AiControl())
}
/**
* 判断是否还有果冻,暂时不考虑果冻无中生有,否则逻辑修改
*/
private hasJelly: boolean;
private hasEgg: boolean;
init(lattices: Lattice[]) {
this.hasJelly = judgeJellyExist(lattices);
this.hasEgg = judgeEggExist(lattices);
}
aiMotion(thisObj: MainScene, callback: Function) {
//果冻的
this.jellyMotion(thisObj, () => {
//鸡蛋的
this.eggMotion(thisObj, callback)
})
// if (noAction) {
// callback()
// }
}
private jellyMotion(thisObj: MainScene, callback: Function) {
if (!this.hasJelly || thisObj.jellyBrokeMark) {
thisObj.jellyBrokeMark = false;
//没有果冻,或上一步有果冻被消除,直接回调
callback();
return
}
//标识记为false
thisObj.jellyBrokeMark = false;
//果冻蔓延
var spread = getJellySpreadAni(thisObj.lattices);
if (spread) {
//执行动画
let jellySpreadAni: JellySpreadAni = Pool.takeOut(RecoverName.JELLYSPREAD_ANI)
if (!jellySpreadAni) {
jellySpreadAni = new JellySpreadAni()
}
thisObj.addChild(jellySpreadAni);
jellySpreadAni.play(Tool.getPositionByIndex(spread[0]), Tool.getPositionByIndex(spread[1]), () => {
//播放完后,将终点元素变成果冻
thisObj.lattices[spread[1]].element.reset(ElementType.JELLY);
//执行回调
callback()
})
} else {
callback()
if (spread === 0) {
//如果无果冻了
this.hasJelly = false;
}
}
}
/**
* 鸡蛋得孵化逻辑
* 与果冻不同,需要执行一次threeMatch,如无再执行callback,否则执行eleminate
* @param thisObj
* @param callback
*/
private eggMotion(thisObj: MainScene, callback: Function) {
if (!this.hasEgg) {
callback();
return
}
//逻辑再写,暂时没有
callback();
}
}
/**
* 判断果冻是否存在
* @param lattices
* @return false表示不存在,true表示存在
*/
function judgeJellyExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//没有格子或没有元素或不是果冻 跳过
if (!lattice || !lattice.element || lattice.element.type != ElementType.JELLY) continue
return true
}
return false;
}
/**
* 判断鸡蛋是否存在
* @param lattices
* @return false表示不存在,true表示存在
*/
function judgeEggExist(lattices: Lattice[]) {
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//没有格子或没有元素或不是果冻 跳过
if (!lattice || !lattice.element || lattice.element.type != ElementType.CHICKEN_EGG) continue
return true
}
return false;
}
/**
* 获取能蔓延的
* @param lattices
*/
function getJellySpreadAni(lattices: Lattice[]) {
var indexs: number[] = [];
for (var i = 0; i < lattices.length; i++) {
var lattice = lattices[i]
//没有格子或没有元素或不是果冻 跳过
if (!lattice || !lattice.element || lattice.element.type != ElementType.JELLY) continue
indexs.push(i);
}
if (!indexs.length) return 0
while (indexs.length) {
var rand = Math.floor(Math.random() * indexs.length);
var randIndex = indexs.splice(rand, 1)[0];
var index = judgeSpread(randIndex, lattices);
if (index != null) {
//能蔓延,返回自身索引和蔓延的索引
return [randIndex, index];
}
}
return null;
}
/**
* 判断可蔓延的方向,并返回蔓延的格子索引
* @param index
* @return 没有返回null,注意判断时可能有0
*/
function judgeSpread(index: number, lattices: Lattice[]): number {
//四个方向尽量随机
var arr = [index - Tool.colNum, index + Tool.colNum];
var rc = Tool.indexToRc(index);
var col = rc[1];
//列数大于0才可能有左边格子
if (col > 0) arr.push(index - 1);
//列数不为最右边
if (col < Tool.colNum - 1) arr.push(index + 1);
while (arr.length) {
var rand = Math.floor(Math.random() * arr.length);
var i = arr.splice(rand, 1)[0];
if (lattices[i] &&
lattices[i].element &&
lattices[i].element.type <= 4) {
return i
}
}
return null
}
//
......@@ -384,7 +384,7 @@
],
"remainEnargy": 99,
"askForEnergy": false,
"canReceiveTreasureBoxNum": 0,
"canReceiveTreasureBoxNum": 10,
"nextRangeStarsNum": 150
}
}
\ 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