You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							247 lines
						
					
					
						
							9.0 KiB
						
					
					
				
			
		
		
	
	
							247 lines
						
					
					
						
							9.0 KiB
						
					
					
				// Learn TypeScript:
 | 
						|
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/typescript.html
 | 
						|
// Learn Attribute:
 | 
						|
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
 | 
						|
// Learn life-cycle callbacks:
 | 
						|
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html
 | 
						|
 | 
						|
import { ryw_Event } from "../FrameWork/Event/EventEnum";
 | 
						|
import EventMgr from "../FrameWork/Event/EventMgr";
 | 
						|
import GameReport from "../FrameWork/Report/ZyZyReport";
 | 
						|
import User from "../FrameWork/User/User";
 | 
						|
import AppPlatform from "../FrameWork/Util/AppPlatform";
 | 
						|
import Common from "../FrameWork/Util/Common";
 | 
						|
import Common5 from "../Platform/th/Common5";
 | 
						|
import TTAPI from "../Platform/tt/TTAPI";
 | 
						|
import DayUnlock from "../ttFrame/manager/DayUnlock";
 | 
						|
import Game from "./Game";
 | 
						|
 | 
						|
const { ccclass, property } = cc._decorator;
 | 
						|
 | 
						|
@ccclass
 | 
						|
export default class tipsPrefabScript extends cc.Component {
 | 
						|
 | 
						|
 | 
						|
    @property(cc.Node)
 | 
						|
    answerBtnNode: cc.Node = null;
 | 
						|
 | 
						|
    @property(cc.Node)
 | 
						|
    answerNode: cc.Node = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    guizetishiNode: cc.Node = null;
 | 
						|
 | 
						|
    @property(cc.Node)
 | 
						|
    tipNode: cc.Node = null;
 | 
						|
    
 | 
						|
    @property(cc.Label)
 | 
						|
    tipLabe: cc.Label = null;
 | 
						|
    @property(cc.Label)
 | 
						|
    answerLabel: cc.Label = null;
 | 
						|
    @property(cc.Label)
 | 
						|
    guizetishiLabel: cc.Label = null;
 | 
						|
    @property(cc.Label)
 | 
						|
    newTipSpeLabel: cc.Label = null;
 | 
						|
    @property(cc.Label)
 | 
						|
    newTipNormalLabel: cc.Label = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    newTipNode: cc.Node = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    newTipBtnNode: cc.Node = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    newTipContentNode: cc.Node = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    newTipLabel: cc.Node = null;
 | 
						|
    @property(cc.Node)
 | 
						|
    imganswerNode: cc.Node = null;
 | 
						|
    @property(cc.Sprite)
 | 
						|
    answerImg: cc.Sprite = null;
 | 
						|
 | 
						|
 | 
						|
    // LIFE-CYCLE CALLBACKS:
 | 
						|
 | 
						|
    // onLoad () {}
 | 
						|
    curNode = null
 | 
						|
    curData = null
 | 
						|
    start() {
 | 
						|
        this.initText();
 | 
						|
        this.refBtnStat();
 | 
						|
        EventMgr.onEvent_custom(ryw_Event.finish_game,()=>{
 | 
						|
            this.node.removeFromParent();
 | 
						|
            this.node.destroy();
 | 
						|
        },this)
 | 
						|
    }
 | 
						|
    refBtnStat(){
 | 
						|
        let answer = User.getUnlockWordgameAnswer(Common5.selectGameNum);
 | 
						|
        let answerIndex = answer[Common.subLevel];  
 | 
						|
        if (answerIndex == 1) {
 | 
						|
            this.answerBtnNode.active = true;
 | 
						|
            this.answerNode.active = false;
 | 
						|
            this.guizetishiNode.active = false;
 | 
						|
            this.imganswerNode.active = false;
 | 
						|
            this.newTipNode.active = false;
 | 
						|
            this.tipNode.active = true;
 | 
						|
        }
 | 
						|
        else if (answerIndex == 2) {
 | 
						|
            this.answerBtnNode.active = false;
 | 
						|
            if (Common.Type == 0){
 | 
						|
                this.imganswerNode.active = false;
 | 
						|
                this.answerNode.active = true;
 | 
						|
                this.guizetishiNode.active = false;
 | 
						|
                this.newTipNode.active = false;
 | 
						|
            }
 | 
						|
            else if (Common.Type == 1){
 | 
						|
                this.answerNode.active = false;
 | 
						|
                this.guizetishiNode.active = true;
 | 
						|
                this.imganswerNode.active = false;
 | 
						|
                this.newTipNode.active = false;
 | 
						|
            }
 | 
						|
            else if (Common.Type == 2){
 | 
						|
                this.imganswerNode.active = true;
 | 
						|
                this.answerNode.active = false;
 | 
						|
                this.guizetishiNode.active = false;
 | 
						|
                this.newTipNode.active = false;
 | 
						|
            }
 | 
						|
            else if (Common.Type == 3){
 | 
						|
                this.imganswerNode.active = false;
 | 
						|
                this.answerNode.active = false;
 | 
						|
                this.guizetishiNode.active = false;
 | 
						|
                this.newTipNode.active = true;
 | 
						|
            }
 | 
						|
            this.tipNode.active = false;
 | 
						|
        }
 | 
						|
    }
 | 
						|
    answerAd(){
 | 
						|
        let tab = {
 | 
						|
            onClose: (finish) => {
 | 
						|
                if (finish) {                    
 | 
						|
                    GameReport.ADReport('答案',Common5.selectGameInfo.title2,1)
 | 
						|
                    Common5.ReportDY("inLevel", Common5.selectGameInfo.title2 + "-AD-答案");
 | 
						|
                    User.unlockWordgameAnswer(Common5.selectGameNum,Common.subLevel,2);
 | 
						|
                    this.refBtnStat();
 | 
						|
                }
 | 
						|
                else {
 | 
						|
                    GameReport.ADReport('答案',Common5.selectGameInfo.title2,0)
 | 
						|
                    Common5.showTips_custom("广告未观看完");
 | 
						|
                }
 | 
						|
            }, onFailed: () => {
 | 
						|
            }
 | 
						|
        }
 | 
						|
        AppPlatform.playVideo_custom(tab)
 | 
						|
    }
 | 
						|
    initText() {
 | 
						|
        if (Common.GameSubTipConfigs){            
 | 
						|
            let tip = Common.GameSubTipConfigs[Common.subLevel];
 | 
						|
            if (tip){
 | 
						|
                this.tipLabe.string = tip;
 | 
						|
            }
 | 
						|
            let answer = User.getUnlockWordgameAnswer(Common5.selectGameNum);
 | 
						|
            let tipIndex = Common.GameSubTipConfigs.length-1;
 | 
						|
            if (answer){
 | 
						|
                // this.newTipNormalLabel.string = "";
 | 
						|
                let allUnlock = true;
 | 
						|
                this.newTipContentNode.removeAllChildren();
 | 
						|
                for (let i = 0; i < Common.GameSubTipConfigs.length; i++){
 | 
						|
                    let numStr = (i+1).toString();
 | 
						|
                    let tmpStr = "";
 | 
						|
                    let tmpNode = cc.instantiate(this.newTipLabel);
 | 
						|
                    if (i+1 < 10){
 | 
						|
                        numStr = "0"+numStr;
 | 
						|
                    }
 | 
						|
                    let answerIndex = answer[i];
 | 
						|
                    if (answerIndex == 2){
 | 
						|
                        tmpStr =numStr + ":"+Common.GameSubTipConfigs[i];
 | 
						|
                    }
 | 
						|
                    else {
 | 
						|
                        tmpStr =numStr + ":未获得";
 | 
						|
                        allUnlock = false;
 | 
						|
                    }
 | 
						|
                    // if (i < Common.GameSubTipConfigs.length-1){
 | 
						|
                    //     this.newTipNormalLabel.string += "\r\n";
 | 
						|
                    // }
 | 
						|
                    tmpNode.getComponent(cc.Label).string = tmpStr;
 | 
						|
                    this.newTipContentNode.addChild(tmpNode);
 | 
						|
                    tmpNode.active = true;
 | 
						|
                    let isFinish = false;
 | 
						|
                    for(let j = 0; j < Game.ins.finishSub.length; j++){
 | 
						|
                        if (i == Game.ins.finishSub[j]){
 | 
						|
                            isFinish = true;
 | 
						|
                            break;
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                    if (!isFinish){
 | 
						|
                        tipIndex = Math.min(tipIndex,i);
 | 
						|
                        tmpNode.color = cc.color(127,127,127);
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (allUnlock){
 | 
						|
                    this.newTipBtnNode.active = false;
 | 
						|
                }
 | 
						|
                else {
 | 
						|
                    this.newTipBtnNode.active = true;
 | 
						|
                }
 | 
						|
 | 
						|
            }
 | 
						|
            if (Common.SpeTip == ""){
 | 
						|
                console.log(tipIndex)
 | 
						|
                this.newTipSpeLabel.string = Common.GameSubTipConfigs[tipIndex];
 | 
						|
            }
 | 
						|
            else {
 | 
						|
                this.newTipSpeLabel.string = Common.SpeTip;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        if (Common.GameSubAnswerConfigs){
 | 
						|
            
 | 
						|
            let answer = Common.GameSubAnswerConfigs[Common.subLevel];
 | 
						|
            if (answer){
 | 
						|
                this.answerLabel.string = answer;
 | 
						|
            }
 | 
						|
        }
 | 
						|
        if (Common5.selectGameInfo.answerImg && Common5.selectGameInfo.answerImg!=""){
 | 
						|
            Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.subbundle,Common5.selectGameInfo.answerImg,this.answerImg);
 | 
						|
        }
 | 
						|
 | 
						|
        if (Common5.selectGameInfo.answerImgbandle && Common5.selectGameInfo.answerImgbandle!=""){
 | 
						|
            Common5.getSpriteFrameFromBundle(Common5.selectGameInfo.bundle,Common5.selectGameInfo.answerImgbandle,this.answerImg);
 | 
						|
        }
 | 
						|
 | 
						|
 | 
						|
    }
 | 
						|
    newTipBtn(){
 | 
						|
        let tab = {
 | 
						|
            onClose: (finish) => {
 | 
						|
                if (finish) {
 | 
						|
                    GameReport.ADReport('提示',Common5.selectGameInfo.title2,1)
 | 
						|
                    Common5.ReportDY("inLevel", Common5.selectGameInfo.title2 + "-AD-提示");
 | 
						|
                    if (Common.Type == 3){
 | 
						|
                        let index = 0;
 | 
						|
                        let answer = User.getUnlockWordgameAnswer(Common5.selectGameNum)            
 | 
						|
                        if (answer){
 | 
						|
                            for (let i = 0; i < Common.GameSubTipConfigs.length; i++){
 | 
						|
                                if (answer[i]!=2){
 | 
						|
                                    index = i;
 | 
						|
                                    break;
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        User.unlockWordgameAnswer(Common5.selectGameNum,index,2);
 | 
						|
                        Common.subLevel = index;
 | 
						|
                    }
 | 
						|
                    this.initText();
 | 
						|
                    return;
 | 
						|
                }
 | 
						|
                else {
 | 
						|
                    GameReport.ADReport('提示',Common5.selectGameInfo.title2,0)
 | 
						|
                    Common5.showTips_custom("广告未观看完");
 | 
						|
                }
 | 
						|
            }, onFailed: () => {
 | 
						|
            }
 | 
						|
        }
 | 
						|
        AppPlatform.playVideo_custom(tab)
 | 
						|
    }
 | 
						|
    btnClose(){
 | 
						|
        this.node.removeFromParent();
 | 
						|
        this.node.destroy();
 | 
						|
        EventMgr.emitEvent_custom(ryw_Event.tooltipClose);
 | 
						|
    }
 | 
						|
    // update (dt) {}
 | 
						|
}
 | 
						|
 |