300 lines
12 KiB
JavaScript
300 lines
12 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_Old = null;
|
|
_this.Plant = null;
|
|
return _this;
|
|
}
|
|
GuideManager.prototype.onLoad = function () {
|
|
this.custom = 1;
|
|
};
|
|
GuideManager.prototype.start = function () {
|
|
this.fit();
|
|
};
|
|
GuideManager.prototype.fit = function () {
|
|
var jg = cc.fx.GameTool.setFit();
|
|
if (!jg) {
|
|
}
|
|
};
|
|
//初始化数据
|
|
GuideManager.prototype.init = function () {
|
|
this.voiceSpriteFrame = this.Plant.getChildByName("icon").getComponent(cc.Sprite).spriteFrame;
|
|
"";
|
|
this.node.getChildByName("nextBtn").active = false;
|
|
var name = cc.fx.GameConfig.GM_INFO.gameId + "_guide";
|
|
if (cc.fx.StorageMessage.getStorage(name) != null)
|
|
cc.fx.GameConfig.GM_INFO.guide = cc.fx.StorageMessage.getStorage(name);
|
|
if (cc.fx.GameConfig.GM_INFO.guide == false) {
|
|
this.node.getChildByName("jumpBtn").active = true;
|
|
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": 2,
|
|
},
|
|
{
|
|
"item": "taozi",
|
|
"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_Old.active = true;
|
|
this.Btn_New.active = true;
|
|
this.Btn_Old.getChildByName("nomal").getComponent(cc.Button).interactable = false;
|
|
this.Btn_New.getChildByName("nomal").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_Old.getChildByName("nomal").getComponent(cc.Button).interactable = true;
|
|
_this.Btn_New.getChildByName("nomal").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_Old.getChildByName("nomal").getComponent(cc.Button).interactable = true;
|
|
_this.Btn_New.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_Old") {
|
|
this.choice = 2;
|
|
this.Btn_Old.getChildByName("nomal").getComponent(cc.Button).interactable = false;
|
|
}
|
|
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_Old.getChildByName("nomal").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_Old.getChildByName("nomal").active = true;
|
|
_this.Btn_Old.getChildByName("err").active = false;
|
|
_this.Btn_Old.getChildByName("correct").active = false;
|
|
_this.Btn_Old.getChildByName("nomal").getComponent(cc.Button).interactable = false;
|
|
_this.Btn_New.getChildByName("nomal").getComponent(cc.Button).interactable = false;
|
|
_this.custom += 1;
|
|
if (_this.custom >= 6) {
|
|
_this.node.getChildByName("againBtn").active = true;
|
|
_this.node.getChildByName("startBtn").active = true;
|
|
_this.Btn_Old.active = false;
|
|
_this.Btn_New.active = false;
|
|
cc.fx.GameConfig.GM_INFO.guide = false;
|
|
var name = cc.fx.GameConfig.GM_INFO.gameId + "_guide";
|
|
cc.fx.StorageMessage.setStorage(name, cc.fx.GameConfig.GM_INFO.guide);
|
|
}
|
|
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:
|
|
tipTemp = '这不是这局游戏第一次出现葡萄';
|
|
break;
|
|
case 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_Old", 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(); |