|
@@ -8,7 +8,7 @@ import { AudioManager, MusicType } from "./AudioManager";
|
|
import { GamePool } from "./GamePool";
|
|
import { GamePool } from "./GamePool";
|
|
import { AssetManager } from "../Main/AssetManager";
|
|
import { AssetManager } from "../Main/AssetManager";
|
|
import Gift from "../Main/Gift";
|
|
import Gift from "../Main/Gift";
|
|
-
|
|
|
|
|
|
+import InGameView from "../View/InGameView";
|
|
export class DropRule{
|
|
export class DropRule{
|
|
private static ins:DropRule;
|
|
private static ins:DropRule;
|
|
public progress:any;
|
|
public progress:any;
|
|
@@ -16,7 +16,6 @@ export class DropRule{
|
|
DropRule.ins = this;
|
|
DropRule.ins = this;
|
|
this.Init();
|
|
this.Init();
|
|
this.InitEffect();
|
|
this.InitEffect();
|
|
- this.InitGift();
|
|
|
|
EventManager.StageOn(StageMode.Refresh,this,this.Init);
|
|
EventManager.StageOn(StageMode.Refresh,this,this.Init);
|
|
EventManager.StageOn(StageMode.ReStart,this,this.Pass);
|
|
EventManager.StageOn(StageMode.ReStart,this,this.Pass);
|
|
}
|
|
}
|
|
@@ -119,20 +118,6 @@ export class DropRule{
|
|
this.EffectArray.push(obj);
|
|
this.EffectArray.push(obj);
|
|
}
|
|
}
|
|
|
|
|
|
- //礼盒
|
|
|
|
- InitGift(){
|
|
|
|
- for (let i = 0; i < this.GiftName.length; i++) {
|
|
|
|
- this.GiftReadJson(i)
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- GiftReadJson(i:number){
|
|
|
|
- Laya.loader.create("GiftPrefab/"+this.GiftName[i]+".json",Laya.Handler.create(this,this.GiftCreat));
|
|
|
|
- }
|
|
|
|
- GiftCreat(Prefab:any){
|
|
|
|
- let obj = new Laya.Prefab();
|
|
|
|
- obj.json = Prefab;
|
|
|
|
- this.GiftArray.push(obj);
|
|
|
|
- }
|
|
|
|
|
|
|
|
/**传入分数及位置 克隆相应销毁特效 */
|
|
/**传入分数及位置 克隆相应销毁特效 */
|
|
CreateEffect(_score:number,_pos:Laya.Vector2){
|
|
CreateEffect(_score:number,_pos:Laya.Vector2){
|
|
@@ -187,16 +172,17 @@ export class DropRule{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(this.STAGE >= 9){
|
|
if(this.STAGE >= 9){
|
|
- for (let i = 0; i < Laya.stage.numChildren; i++) {
|
|
|
|
- if(Laya.stage.getChildAt(i).name == "Gift"){
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
- let X = GameTools.RandomANumber(100,500);
|
|
|
|
- let pos = new Laya.Vector2(X, 0);
|
|
|
|
- this.CreateGift(0,pos,this.JudgePropNum(),1);
|
|
|
|
|
|
+ let have = false;
|
|
|
|
+ for (let i = 0; i < InGameView.Instance.prefabbox.numChildren; i++) {
|
|
|
|
+ if(InGameView.Instance.prefabbox.getChildAt(i).name == "Gift"){
|
|
|
|
+ have = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(!have){
|
|
|
|
+ let X = GameTools.RandomANumber(100,500);
|
|
|
|
+ let pos = new Laya.Vector2(X, 0);
|
|
|
|
+ this.CreateGift(0,pos,this.JudgePropNum(),1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -215,14 +201,14 @@ export class DropRule{
|
|
proparray.push(five);
|
|
proparray.push(five);
|
|
for (let i = 0; i < proparray.length; i++) {
|
|
for (let i = 0; i < proparray.length; i++) {
|
|
for (let j = 0; j < proparray.length-i-1; j++) {
|
|
for (let j = 0; j < proparray.length-i-1; j++) {
|
|
- if(proparray[j].value < proparray[j+1].value){
|
|
|
|
|
|
+ if(proparray[j].value > proparray[j+1].value){
|
|
let temp = proparray[j].value;
|
|
let temp = proparray[j].value;
|
|
proparray[j].value = proparray[j+1].value;
|
|
proparray[j].value = proparray[j+1].value;
|
|
proparray[j+1].value = temp;
|
|
proparray[j+1].value = temp;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return proparray[0].value;
|
|
|
|
|
|
+ return Number(proparray[0].key);
|
|
}
|
|
}
|
|
/** 传入盒子序号 传入道具类型 传入道具数量 创建礼盒 */
|
|
/** 传入盒子序号 传入道具类型 传入道具数量 创建礼盒 */
|
|
CreateGift(index:number,_pos:Laya.Vector2,giftindex:number,giftnum:number){
|
|
CreateGift(index:number,_pos:Laya.Vector2,giftindex:number,giftnum:number){
|
|
@@ -255,27 +241,31 @@ export class DropRule{
|
|
else{
|
|
else{
|
|
pre.getComponent(Laya.CircleCollider).enabled = true;
|
|
pre.getComponent(Laya.CircleCollider).enabled = true;
|
|
}
|
|
}
|
|
-
|
|
|
|
- if(index == 1 ){
|
|
|
|
- //倒计时框
|
|
|
|
- let kuang:Laya.Image = new Laya.Image();
|
|
|
|
- kuang.skin = "Game/res/Skin/kuang.png";
|
|
|
|
- kuang.anchorX = 0.5;
|
|
|
|
- kuang.anchorY = 0.5;
|
|
|
|
- pre.addChild(kuang);
|
|
|
|
- kuang.centerX = 0;
|
|
|
|
- kuang.centerY = 0;
|
|
|
|
- //文本
|
|
|
|
- let countdown:Laya.Text = new Laya.Text();
|
|
|
|
- countdown.width = 33;
|
|
|
|
- countdown.height = 24;
|
|
|
|
- countdown.color = "#ffffff";
|
|
|
|
- countdown.align = "center";
|
|
|
|
- countdown.valign = "middle";
|
|
|
|
- countdown.fontSize = 20;
|
|
|
|
- pre.addChild(countdown);
|
|
|
|
- countdown.x = pre.x;
|
|
|
|
- countdown.y = pre.y;
|
|
|
|
|
|
+ let _countdown = pre.getChildByName("CountDown") as Laya.Text;
|
|
|
|
+ if(!_countdown){
|
|
|
|
+ if(index == 1 ){
|
|
|
|
+ //倒计时框
|
|
|
|
+ let kuang:Laya.Image = new Laya.Image();
|
|
|
|
+ kuang.skin = "Game/res/Skin/kuang.png";
|
|
|
|
+ kuang.anchorX = 0.5;
|
|
|
|
+ kuang.anchorY = 0.5;
|
|
|
|
+ pre.addChild(kuang);
|
|
|
|
+ kuang.centerX = 0;
|
|
|
|
+ kuang.centerY = 0;
|
|
|
|
+ //文本
|
|
|
|
+ let countdown:Laya.Text = new Laya.Text();
|
|
|
|
+ let collider = pre.getComponent(Laya.CircleCollider) as Laya.CircleCollider;
|
|
|
|
+ pre.addChild(countdown);
|
|
|
|
+ countdown.color = "#ffffff";
|
|
|
|
+ countdown.align = "left";
|
|
|
|
+ countdown.valign = "top";
|
|
|
|
+ countdown.fontSize = 25;
|
|
|
|
+ countdown.name = "CountDown";
|
|
|
|
+ countdown.width = 15;
|
|
|
|
+ countdown.height = 30;
|
|
|
|
+ countdown.x = collider.radius-5;
|
|
|
|
+ countdown.y = collider.radius-10;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
let script = pre.getComponent(Gift) as Gift;
|
|
let script = pre.getComponent(Gift) as Gift;
|
|
if(!script){
|
|
if(!script){
|
|
@@ -287,8 +277,18 @@ export class DropRule{
|
|
//礼盒种类
|
|
//礼盒种类
|
|
giftscript.type = index;
|
|
giftscript.type = index;
|
|
}
|
|
}
|
|
|
|
+ else{
|
|
|
|
+ //道具种类
|
|
|
|
+ script.GiftIndex = giftindex;
|
|
|
|
+ //道具数量
|
|
|
|
+ script.GiftNum = giftnum;
|
|
|
|
+ //礼盒种类
|
|
|
|
+ script.type = index;
|
|
|
|
+ }
|
|
pre.pos(_pos.x,_pos.y);
|
|
pre.pos(_pos.x,_pos.y);
|
|
- Laya.stage.addChild(pre);
|
|
|
|
|
|
+ Laya.timer.once(1,this,()=>{
|
|
|
|
+ EventManager.StageTrigger(StageMode.Clone,[pre]);
|
|
|
|
+ })
|
|
}
|
|
}
|
|
/** 传入分数获取球的序号*/
|
|
/** 传入分数获取球的序号*/
|
|
GetBallIndex(_score:number):number{
|
|
GetBallIndex(_score:number):number{
|
|
@@ -721,7 +721,7 @@ export class DropRule{
|
|
this.CreatBall2(Number(item.index)-1,Number(item.size),new Laya.Vector2(Number(item.pos.x),Number(item.pos.y)));
|
|
this.CreatBall2(Number(item.index)-1,Number(item.size),new Laya.Vector2(Number(item.pos.x),Number(item.pos.y)));
|
|
}
|
|
}
|
|
else if(item.itemtype == 1){
|
|
else if(item.itemtype == 1){
|
|
- this.CreateGift(item.type,new Laya.Vector2(Number(item.pos.x),Number(item.pos.y)),Number(item.proptype),Number(item.giftnum));
|
|
|
|
|
|
+ this.CreateGift(item.type,new Laya.Vector2(Number(item.pos.x),Number(item.pos.y)),Number(item.proptype),Number(item.propnum));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|