三连胜提交
This commit is contained in:
@@ -13,6 +13,8 @@ import LoadingCatAnimation from "./LoadingCatAnimation";
|
||||
import Utils from "./module/Pay/Utils";
|
||||
import { starterPackRemaining } from "./module/Config/StarterPack";
|
||||
import NumberToImage from "./NumberToImage";
|
||||
import ThreeWinsPanel, { ThreeWinsSelection } from "./ThreeWinsPanel";
|
||||
import { canCarryStartBoost, infiniteStartBoost, StartBoostProp } from "./StartBoostLoadout";
|
||||
import { MiniGameSdk } from "./Sdk/MiniGameSdk";
|
||||
|
||||
const { ccclass, property } = cc._decorator;
|
||||
@@ -32,6 +34,76 @@ export default class SceneManager extends cc.Component {
|
||||
|
||||
private static activeInstance: SceneManager = null;
|
||||
|
||||
@property(cc.Prefab)
|
||||
threeWinsPrefab: cc.Prefab = null;
|
||||
|
||||
@property(cc.SpriteAtlas)
|
||||
threeWinsFont: cc.SpriteAtlas = null;
|
||||
|
||||
private threeWinsRoot: cc.Node = null;
|
||||
private threeWinsPanel: ThreeWinsPanel = null;
|
||||
|
||||
private threeWinsData() {
|
||||
const info = cc.fx.GameConfig.GM_INFO;
|
||||
const level = cc.fx.GameTool.maxLevel() && info.GameplayType === 1 ? info.endLevelNum : info.level + 1;
|
||||
return { level, threeWinStreak: info.threeWinStreak, tenWinStreak: info.winStreak,
|
||||
hourglassAmount: info.hourglassAmount, rocketAmount: info.rocketAmount,
|
||||
infiniteHourglass: infiniteStartBoost(info, "hourglass"), infiniteRocket: infiniteStartBoost(info, "rocket") };
|
||||
}
|
||||
|
||||
getStartBoostBoxFrame(streak: number): cc.SpriteFrame {
|
||||
return this.threeWinsPrefab.data.getChildByName("box").getChildByName("box" + Math.min(3, streak))
|
||||
.getComponent(cc.Sprite).spriteFrame;
|
||||
}
|
||||
|
||||
openThreeWins(onStart: (selection: ThreeWinsSelection) => void) {
|
||||
if (!this.isPopupRuntimeAlive() || this.threeWinsRoot) return;
|
||||
if (!this.threeWinsPrefab || !this.threeWinsFont) throw new Error("GameScene 未绑定 threeWins 预制体或字体");
|
||||
const root = this.threeWinsRoot = new cc.Node("threeWinsModal");
|
||||
root.setContentSize(cc.winSize);
|
||||
root.addComponent(cc.BlockInputEvents);
|
||||
this.node.addChild(root);
|
||||
root.zIndex = 1000;
|
||||
try {
|
||||
const view = cc.instantiate(this.threeWinsPrefab);
|
||||
root.addChild(view);
|
||||
view.setPosition(0, 0);
|
||||
const mask = view.getChildByName("New Sprite(Splash)");
|
||||
mask.parent = root;
|
||||
mask.setSiblingIndex(0);
|
||||
const panel = this.threeWinsPanel = view.addComponent(ThreeWinsPanel);
|
||||
panel.init(this.threeWinsFont, this.threeWinsData(), {
|
||||
onProp: (prop, selected) => {
|
||||
cc.fx.AudioManager._instance.playEffect("anniu_little", null);
|
||||
if (selected && !canCarryStartBoost(cc.fx.GameConfig.GM_INFO, prop)) {
|
||||
this.openPropBuy(prop);
|
||||
} else panel.setSelected(prop, selected);
|
||||
},
|
||||
onStart: selection => {
|
||||
for (const prop of ["hourglass", "rocket"] as StartBoostProp[]) {
|
||||
if (selection[prop] && !canCarryStartBoost(cc.fx.GameConfig.GM_INFO, prop)) {
|
||||
panel.setSelected(prop, false);
|
||||
this.openPropBuy(prop);
|
||||
return;
|
||||
}
|
||||
}
|
||||
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
|
||||
this.threeWinsRoot = null;
|
||||
this.threeWinsPanel = null;
|
||||
root.active = false;
|
||||
root.destroy();
|
||||
onStart(selection);
|
||||
},
|
||||
});
|
||||
this.finishDynamicPopupLoad("startBoosters");
|
||||
} catch (error) {
|
||||
this.threeWinsRoot = null;
|
||||
this.threeWinsPanel = null;
|
||||
root.destroy();
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
private isPopupRuntimeAlive(): boolean {
|
||||
return cc.isValid(this, true)
|
||||
&& SceneManager.activeInstance === this
|
||||
@@ -1369,6 +1441,7 @@ export default class SceneManager extends cc.Component {
|
||||
if (continueControl && continueControl._touch && MapConroler && MapConroler._instance) {
|
||||
continueControl.setTouch(false);
|
||||
if (!await MapConroler._instance.settleCloudRiseLoss(true) || !this.isPopupRuntimeAlive()) return;
|
||||
MapConroler._instance.threeWinStreak.fail();
|
||||
this.closePause();
|
||||
if (MapConroler._instance.gameStart == true) {
|
||||
// MiniGameSdk.API.showToast("体力值减少");
|
||||
@@ -1838,10 +1911,14 @@ export default class SceneManager extends cc.Component {
|
||||
const target = prop && prop.getChildByName(name);
|
||||
if (!target) throw new Error(`propWindow item is missing: ${name}`);
|
||||
|
||||
["freeze", "hammer", "magic"].forEach((itemName) => {
|
||||
["freeze", "hammer", "magic", "hourglass", "rocket"].forEach((itemName) => {
|
||||
prop.getChildByName(itemName).active = itemName === name;
|
||||
});
|
||||
prop.getChildByName("buy_Btn").getComponent("btnControl").setTouch(true);
|
||||
prop.getChildByName("buy_Btn").active = name !== "hourglass" && name !== "rocket";
|
||||
this.propBuyButton(prop).getComponent("btnControl").setTouch(true);
|
||||
const overOpening = this.threeWinsRoot && this.threeWinsRoot.active;
|
||||
propRoot.parent = overOpening ? this.node : gameRoot;
|
||||
propRoot.zIndex = overOpening ? this.threeWinsRoot.zIndex + 1 : 1000;
|
||||
propRoot.active = true;
|
||||
prop.scale = 0.3;
|
||||
cc.tween(prop)
|
||||
@@ -1871,7 +1948,7 @@ export default class SceneManager extends cc.Component {
|
||||
cc.fx.AudioManager._instance.playEffect("anniu_Big", null);
|
||||
const propRoot = this.getDynamicPopup("propWindow");
|
||||
const prop = propRoot && propRoot.getChildByName("prop");
|
||||
const buyBtn = prop && prop.getChildByName("buy_Btn");
|
||||
const buyBtn = this.propBuyButton(prop);
|
||||
const buyControl = buyBtn && buyBtn.getComponent("btnControl");
|
||||
const map = MapConroler && MapConroler._instance;
|
||||
if (buyControl && buyControl._touch && map && cc.isValid(map, true)) {
|
||||
@@ -1882,14 +1959,45 @@ export default class SceneManager extends cc.Component {
|
||||
map.buyHammer();
|
||||
else if (this.btnName == "magic")
|
||||
map.buyMagic();
|
||||
else if (this.btnName === "hourglass" || this.btnName === "rocket")
|
||||
this.buyStartBoost(this.btnName);
|
||||
}
|
||||
}
|
||||
|
||||
private propBuyButton(prop: cc.Node): cc.Node {
|
||||
if (!prop) return null;
|
||||
if (this.btnName === "hourglass" || this.btnName === "rocket") {
|
||||
return prop.getChildByName(this.btnName).getChildByName("buy_Btn");
|
||||
}
|
||||
return prop.getChildByName("buy_Btn");
|
||||
}
|
||||
|
||||
private buyStartBoost(prop: StartBoostProp) {
|
||||
const cost = prop === "hourglass" ? 200 : 800;
|
||||
if (cc.fx.GameConfig.GM_INFO.coin < cost) {
|
||||
MiniGameSdk.API.showToast("金币不足,无法购买道具");
|
||||
this.resetBtn();
|
||||
const popup = this.getDynamicPopup("propWindow");
|
||||
const canOpen = () => this.isPopupRuntimeAlive() && popup === this.getDynamicPopup("propWindow")
|
||||
&& !!popup && popup.active && this.btnName === prop;
|
||||
this.scheduleOnce(() => {
|
||||
if (canOpen()) this.openShop(null, undefined, canOpen);
|
||||
}, 0.5);
|
||||
return;
|
||||
}
|
||||
cc.fx.GameTool.buyProp(prop === "hourglass" ? 2006 : 2007, () => {
|
||||
if (!this.isPopupRuntimeAlive()) return;
|
||||
this.updateCoin();
|
||||
this.closePropBuy(false);
|
||||
if (this.threeWinsPanel) this.threeWinsPanel.setSelected(prop, true);
|
||||
});
|
||||
}
|
||||
|
||||
resetBtn() {
|
||||
if (!this.isPopupRuntimeAlive()) return;
|
||||
const propRoot = this.getDynamicPopup("propWindow");
|
||||
const prop = propRoot && propRoot.getChildByName("prop");
|
||||
const buyBtn = prop && prop.getChildByName("buy_Btn");
|
||||
const buyBtn = this.propBuyButton(prop);
|
||||
const buyControl = buyBtn && buyBtn.getComponent("btnControl");
|
||||
if (buyControl) buyControl.setTouch(true);
|
||||
}
|
||||
@@ -1940,9 +2048,10 @@ export default class SceneManager extends cc.Component {
|
||||
}
|
||||
|
||||
//打开商店
|
||||
openShop(event, customEventData?: string) {
|
||||
openShop(event, customEventData?: string, canOpen?: () => boolean) {
|
||||
if (event) cc.fx.AudioManager._instance.playEffect("anniu_little", null);
|
||||
if (!this.isPopupRuntimeAlive()) return;
|
||||
if (canOpen && !canOpen()) return;
|
||||
console.log("进入sceneManager openShop");
|
||||
if (!cc.fx.GameConfig.GM_INFO.canIos) {
|
||||
return;
|
||||
@@ -1958,6 +2067,7 @@ export default class SceneManager extends cc.Component {
|
||||
|
||||
const onShopDouble = (res) => {
|
||||
if (!this.isPopupRuntimeAlive()) return;
|
||||
if (canOpen && !canOpen()) return;
|
||||
if (shopPath !== cc.fx.GameConfig.getShopPrefabPath()) return;
|
||||
if (res.code === 1) {
|
||||
let eventName = "";
|
||||
@@ -2076,6 +2186,10 @@ export default class SceneManager extends cc.Component {
|
||||
}
|
||||
|
||||
this.releasePropWindowPanel();
|
||||
if (this.threeWinsRoot && this.threeWinsPanel) {
|
||||
this.threeWinsPanel.refresh(this.threeWinsData());
|
||||
this.threeWinsRoot.active = true;
|
||||
}
|
||||
}
|
||||
|
||||
openRewardWindow(data, callBack) {
|
||||
@@ -2214,7 +2328,11 @@ export default class SceneManager extends cc.Component {
|
||||
// this.node.addChild(reddemCodeNode);
|
||||
}
|
||||
update(dt) {
|
||||
|
||||
if (this.threeWinsPanel) {
|
||||
this.threeWinsPanel.refreshInventory(this.threeWinsData());
|
||||
const transition = this.node.getChildByName("zhuanchang");
|
||||
if (!transition || !transition.active) this.threeWinsPanel.playEntry();
|
||||
}
|
||||
}
|
||||
|
||||
public setPic(url, node) {
|
||||
|
||||
Reference in New Issue
Block a user