ShenNong/library/imports/ef/effe29e5-3670-444b-81fd-b45338af7f19.js
2024-08-07 19:03:10 +08:00

363 lines
15 KiB
JavaScript

"use strict";
cc._RF.push(module, 'effe2nlNnBES4H9tFM4r38Z', 'GuideManager');
// Script/GuideManager.ts
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
// 主游戏控制类
var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
var GuideManager = /** @class */ (function (_super) {
__extends(GuideManager, _super);
function GuideManager() {
var _this = _super !== null && _super.apply(this, arguments) || this;
_this.Tip = null;
_this.FoodPlist = null;
_this.Btn_New = null;
_this.Btn_Hear = null;
_this.Btn_See = null;
_this.Btn_Firewood = null;
_this.Plant = null;
return _this;
}
GuideManager.prototype.onLoad = function () {
this.custom = 0;
};
GuideManager.prototype.start = function () {
this.fit();
};
GuideManager.prototype.fit = function () {
var jg = cc.fx.GameTool.setFit();
if (!jg) {
this.Btn_Firewood.y = -600;
}
this.Btn_Firewood.getComponent(cc.Button).interactable = true;
};
//初始化数据
GuideManager.prototype.init = function () {
this.voiceSpriteFrame = this.Plant.getChildByName("icon").getComponent(cc.Sprite).spriteFrame;
"";
this.node.getChildByName("jumpBtn").active = true;
this.node.getChildByName("nextBtn").active = false;
cc.tween(this.node.getChildByName("jumpBtn"))
.to(0.35, { opacity: 255 })
.start();
var tip = cc.fx.tipType.tipOne;
var label = this.node.getChildByName("tip1").getComponent(cc.Label);
cc.fx.GameTool.typingAni(label, tip, this.startGame.bind(this), this);
this.initData();
};
GuideManager.prototype.initData = function () {
this.customData = [
{
"item": "putao",
"type": 1,
"right": 1,
},
{
"item": "taozi",
"type": 2,
"right": 1,
},
{
"item": "putao",
"type": 2,
"right": 3,
},
{
"item": "muchai",
"type": 1,
"right": 1,
},
{
"item": "taozi",
"type": 1,
"right": 2,
},
{
"item": "putao",
"type": 1,
"right": 2,
},
];
};
GuideManager.prototype.passVoice = function () {
var _this = this;
// cc.fx.AudioManager._instance.playMusicGame();
var voice = this.node.getChildByName("voiceTip");
voice.getChildByName("startBtn").getComponent(cc.Button).interactable = false;
voice.getChildByName("playBtn").getComponent(cc.Button).interactable = false;
cc.tween(voice)
.to(0.5, { opacity: 0 })
.call(function () {
voice.active = false;
})
.start();
setTimeout(function () {
_this.init();
}, 1000);
};
GuideManager.prototype.playVoice = function () {
cc.fx.AudioManager._instance.playEffect("taozi_audio", null);
};
GuideManager.prototype.jumpClick = function () {
cc.director.loadScene("GameScene");
};
GuideManager.prototype.nextClick = function () {
var _this = this;
//第一步
this.node.getChildByName("nextBtn").active = false;
var label = this.node.getChildByName("tip1").getComponent(cc.Label);
if (this.custom == 0) {
cc.tween(this.node.getChildByName("tip1"))
.to(0.2, { opacity: 0 })
.call(function () {
label.string = "";
})
.to(0.1, { opacity: 255 })
.call(function () {
var tip = cc.fx.tipType.tipTwo;
cc.fx.GameTool.typingAni(label, tip, _this.startGame.bind(_this), _this);
})
.start();
}
else if (this.custom == 1) {
this.node.getChildByName("nextBtn").active = false;
this.node.getChildByName("jumpBtn").active = false;
cc.tween(this.node.getChildByName("tip1"))
.to(0.2, { opacity: 0 })
.call(function () {
label.string = "";
_this.nextLevel();
})
.start();
}
this.custom += 1;
};
GuideManager.prototype.nextLevel = function () {
var _this = this;
this.choice = 0;
this.Btn_Hear.active = true;
this.Btn_New.active = true;
this.Btn_See.active = true;
this.Btn_Firewood.active = true;
this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = false;
this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = false;
this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = false;
if (this.custom == 5) {
this.node.getChildByName("muchai").active = true;
this.node.getChildByName("hand").active = true;
}
this.Btn_Firewood.getComponent(cc.Button).interactable = false;
var name = this.customData[this.custom - 2].item;
if (this.customData[this.custom - 2].type == 1) {
this.Plant.getChildByName("name").getComponent(cc.Label).string = cc.fx.GameTool.getFoodName(name);
name = "prop_" + name;
this.Plant.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.FoodPlist["_spriteFrames"][name];
this.now_Food = name;
cc.tween(this.Plant)
.to(0.2, { opacity: 255 })
.call(function () {
_this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = true;
_this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = true;
_this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = true;
if (_this.custom == 5) {
_this.Btn_Firewood.getComponent(cc.Button).interactable = true;
}
})
.start();
}
else {
this.Plant.getChildByName("name").getComponent(cc.Label).string = "";
this.Plant.getChildByName("icon").getComponent(cc.Sprite).spriteFrame = this.voiceSpriteFrame;
var audioName = name + "_audio";
name = "audio" + name;
this.now_Food = name;
cc.fx.AudioManager._instance.playEffect(audioName, null);
cc.tween(this.Plant)
.to(0.2, { opacity: 255 })
.call(function () {
_this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = true;
_this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = true;
_this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = true;
})
.start();
}
//关卡+1
};
//新植物按钮
GuideManager.prototype.click_Btn = function (customData, data) {
var _this = this;
//关掉计时器 处理逻辑之前,先行关掉按钮开关
if (data == "Btn_New") {
this.choice = 1;
this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = false;
}
else if (data == "Btn_Hear") {
this.choice = 2;
this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = false;
}
else if (data == "Btn_See") {
this.choice = 3;
this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = false;
}
else if (data == "Btn_Firewood") {
this.Btn_Firewood.getChildByName("fireBg").active = true;
this.Btn_Firewood.getChildByName("fire").active = true;
setTimeout(function () {
if (_this.Btn_Firewood) {
_this.Btn_Firewood.getChildByName("fireBg").active = false;
_this.Btn_Firewood.getChildByName("fire").active = false;
}
}, 1050);
console.log("正确点火");
this.Btn_Firewood.getComponent(cc.Button).interactable = false;
this.node.getChildByName("muchai").active = false;
this.node.getChildByName("hand").active = false;
return;
}
var target = this[data];
var label = this.Tip.getChildByName("content").getComponent(cc.Label);
//正确
if (this.choice == this.customData[this.custom - 2].right) {
cc.fx.AudioManager._instance.playEffect("yes", null);
this.Tip.stopAllActions();
this.Tip.active = false;
this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = false;
this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = false;
this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = false;
this.Btn_Firewood.getComponent(cc.Button).interactable = false;
target.getChildByName("err").active = false;
target.getChildByName("correct").active = true;
setTimeout(function () {
_this.Btn_New.getChildByName("nomal").active = true;
_this.Btn_New.getChildByName("err").active = false;
_this.Btn_New.getChildByName("correct").active = false;
_this.Btn_Hear.getChildByName("nomal").active = true;
_this.Btn_Hear.getChildByName("err").active = false;
_this.Btn_Hear.getChildByName("correct").active = false;
_this.Btn_See.getChildByName("nomal").active = true;
_this.Btn_See.getChildByName("err").active = false;
_this.Btn_See.getChildByName("correct").active = false;
_this.Btn_Hear.getChildByName("nomal").getComponent(cc.Button).interactable = false;
_this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = false;
_this.Btn_See.getChildByName("nomal").getComponent(cc.Button).interactable = false;
_this.custom += 1;
if (_this.custom >= 8) {
_this.node.getChildByName("againBtn").active = true;
_this.node.getChildByName("startBtn").active = true;
_this.Btn_Hear.active = false;
_this.Btn_New.active = false;
_this.Btn_See.active = false;
_this.Btn_Firewood.active = false;
}
else
_this.nextLevel();
}, 1000);
}
else {
cc.fx.AudioManager._instance.playEffect("yes", null);
var tipTemp = '葡萄刚才出现过呢';
this.Tip.active = true;
target.getChildByName("err").active = true;
target.getChildByName("correct").active = false;
switch ((this.custom - 2)) {
case 0:
tipTemp = "这是这局游戏第一次出现葡萄";
break;
case 1:
tipTemp = "这是这局游戏第一次出现桃子";
break;
case 2:
if (this.choice == 2)
tipTemp = '上次遇到葡萄时,似乎不是听到的吧';
break;
case 3:
tipTemp = "这是这局游戏第一次出现木柴";
break;
case 4:
if (this.choice == 3)
tipTemp = '上次遇到桃子时,似乎不是看到的吧';
else
tipTemp = '桃子刚才出现过呢';
break;
case 5:
if (this.choice == 3)
tipTemp = '之前确实看到过葡萄,但最近一次似乎不是看到的呢';
break;
}
label.string = tipTemp;
this.Tip.opacity = 255;
this.Tip.stopAllActions();
var self = this;
var action = cc.callFunc(function () {
self.Tip.active = false;
});
this.Tip.runAction(cc.sequence(cc.delayTime(2), cc.fadeIn(0.5), action));
}
};
//开始游戏
GuideManager.prototype.startGame = function () {
this.node.getChildByName("nextBtn").active = true;
cc.tween(this.node.getChildByName("nextBtn"))
.to(0.35, { opacity: 255 })
.start();
};
GuideManager.prototype.againClick = function () {
cc.director.loadScene("GuideScene");
};
GuideManager.prototype.onEnable = function () {
// cc.fx.Notifications.on("clickSun", this.clickSun, this);
};
GuideManager.prototype.onDisable = function () {
// cc.fx.Notifications.off("clickSun", this.clickSun);
};
GuideManager.prototype.update = function (dt) {
};
__decorate([
property(cc.Node)
], GuideManager.prototype, "Tip", void 0);
__decorate([
property(cc.SpriteAtlas)
], GuideManager.prototype, "FoodPlist", void 0);
__decorate([
property(cc.Node)
], GuideManager.prototype, "Btn_New", void 0);
__decorate([
property(cc.Node)
], GuideManager.prototype, "Btn_Hear", void 0);
__decorate([
property(cc.Node)
], GuideManager.prototype, "Btn_See", void 0);
__decorate([
property(cc.Node)
], GuideManager.prototype, "Btn_Firewood", void 0);
__decorate([
property(cc.Node)
], GuideManager.prototype, "Plant", void 0);
GuideManager = __decorate([
ccclass
], GuideManager);
return GuideManager;
}(cc.Component));
exports.default = GuideManager;
cc._RF.pop();