|
@@ -14,46 +14,26 @@ import { pause } from '../../dialog/pause';
|
|
|
import { Util } from '../../framework/util';
|
|
|
import { setting } from '../../homepage/setting';
|
|
|
import { SdkUtil } from '../../framework/sdkUtil';
|
|
|
+import { base_view } from '../base_view';
|
|
|
const { ccclass, property } = _decorator;
|
|
|
|
|
|
@ccclass('view_game_play_shuang_tu_zhao_bu_tong')
|
|
|
-export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
- @property(Node) btn_back:Node;
|
|
|
- @property(Node) btn_pause:Node;
|
|
|
+export class view_game_play_shuang_tu_zhao_bu_tong extends base_view {
|
|
|
@property(Node) btn_amplify:Node;
|
|
|
- @property(Node) btn_tip:Node;
|
|
|
@property(Node) img_1:Node;
|
|
|
@property(Node) img_2:Node;
|
|
|
@property(Node) content_1:Node;
|
|
|
@property(Node) content_2:Node;
|
|
|
@property(Node) lab_amplify_status:Node;
|
|
|
- @property(Node) lab_coin:Node;
|
|
|
- @property(Node) lab_title:Node;
|
|
|
@property(Node) star_list:Node;
|
|
|
- @property(Node) img_touch_err:Node;
|
|
|
- @property(ProgressBar) progressbar:ProgressBar;
|
|
|
- @property(SpriteFrame) sf_btn_start:SpriteFrame;
|
|
|
- @property(SpriteFrame) sf_btn_pause:SpriteFrame;
|
|
|
- @property(Node) btn_look_video:Node = null;
|
|
|
- private categoryid:number = config.PLAY_TYPE.YI_QI_ZHAO_CHA;
|
|
|
- private m_data:server_shuang_tu_zhao_bu_tong_data_item = null;
|
|
|
+ @property(Node) effect:Node = null;
|
|
|
private img_1_sf:SpriteFrame;
|
|
|
private img_2_sf:SpriteFrame;
|
|
|
private cur_amplify_status:number = 0;
|
|
|
- private time_count:number = 0;
|
|
|
- private time_all_count:number = 0;
|
|
|
- private err_node_1:Node = null;
|
|
|
private err_node_2:Node = null;
|
|
|
- private isPause:boolean = false;
|
|
|
private scale_multiple:number = 2;
|
|
|
- private reward:number = 0;
|
|
|
- private isShowWin:boolean = false;
|
|
|
- start() {
|
|
|
+ initUI() {
|
|
|
let self = this;
|
|
|
- this.btn_back.on(Node.EventType.TOUCH_START,()=>{
|
|
|
- gameManager.playBtnSound()
|
|
|
- self.close();
|
|
|
- },this);
|
|
|
this.btn_amplify.on(Node.EventType.TOUCH_START,()=>{
|
|
|
gameManager.playBtnSound()
|
|
|
if(self.cur_amplify_status==0){
|
|
@@ -63,46 +43,10 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
}
|
|
|
self.updateAmplifyStatus();
|
|
|
},this);
|
|
|
- this.btn_look_video.on(Node.EventType.TOUCH_START,()=>{
|
|
|
- SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Earn_coins_AdUnitId,(res)=>{
|
|
|
- if(res.isEnded){
|
|
|
- gameManager.add_coin(gameManager.get_deouble_reward_number())
|
|
|
- ClientEvent.dispatchEvent(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER)
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- this.btn_tip.on(Node.EventType.TOUCH_START,()=>{
|
|
|
- gameManager.playBtnSound()
|
|
|
- if(gameManager.isTestUser()){
|
|
|
- if(self.cur_amplify_status==1){
|
|
|
- self.cur_amplify_status = 0;
|
|
|
- self.updateAmplifyStatus();
|
|
|
- }
|
|
|
- this.onTipBtnClick();
|
|
|
- }else{
|
|
|
- SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Tip_AdUnitId,(res)=>{
|
|
|
- if(res.isEnded){
|
|
|
- self.onTipBtnClick();
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- },this);
|
|
|
-
|
|
|
- this.btn_pause.on(Node.EventType.TOUCH_START,()=>{
|
|
|
- self.isPause = true;
|
|
|
- self.btn_pause.getComponent(Sprite).spriteFrame = self.sf_btn_start;
|
|
|
- gameManager.playBtnSound()
|
|
|
- gameManager.addTopView(config.PREFAB_PATH.setting,(node:Node)=>{
|
|
|
- node.getComponent(setting).show(()=>{
|
|
|
- self.btn_pause.getComponent(Sprite).spriteFrame = self.sf_btn_pause;
|
|
|
- self.isPause = false;
|
|
|
- })
|
|
|
- })
|
|
|
- },this);
|
|
|
|
|
|
this.img_1.on(Node.EventType.TOUCH_END,this.TOUCH_START_IMG_1.bind(this),this);
|
|
|
this.img_2.on(Node.EventType.TOUCH_END,this.TOUCH_START_IMG_2.bind(this),this);
|
|
|
- ClientEvent.on(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER,this.onChangeCoinNumber.bind(this),this);
|
|
|
+
|
|
|
}
|
|
|
|
|
|
TOUCH_START_IMG_1(event: EventTouch){
|
|
@@ -133,12 +77,7 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- onChangeCoinNumber(){
|
|
|
- let num:number = parseInt(this.lab_coin.getComponent(Label).string);
|
|
|
- gameManager.instance.addCoinNumber(this.reward,this.lab_coin.getComponent(Label),num,()=>{
|
|
|
- this.lab_coin.getComponent(Label).string = gameManager.get_user_coin()+"";
|
|
|
- })
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
protected onDestroy(): void {
|
|
|
ClientEvent.off(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER,this.onChangeCoinNumber.bind(this),this);
|
|
@@ -166,15 +105,30 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
}
|
|
|
onTipBtnClick(){
|
|
|
let self = this;
|
|
|
- for (let index = 1; index < self.img_1.children.length; index++) {
|
|
|
- const element = self.img_1.children[index];
|
|
|
- if(!element.getComponent(circle).isFinish()){
|
|
|
- element.getComponent(circle).blinkShow();
|
|
|
- element.getComponent(circle).get_relative_node().blinkShow();
|
|
|
- break;
|
|
|
+ let tip_call = ()=>{
|
|
|
+ for (let index = 1; index < self.img_1.children.length; index++) {
|
|
|
+ const element = self.img_1.children[index];
|
|
|
+ if(!element.getComponent(circle).isFinish()){
|
|
|
+ element.getComponent(circle).blinkShow();
|
|
|
+ element.getComponent(circle).get_relative_node().blinkShow();
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
+ if(gameManager.isTestUser()){
|
|
|
+ if(self.cur_amplify_status==1){
|
|
|
+ self.cur_amplify_status = 0;
|
|
|
+ self.updateAmplifyStatus();
|
|
|
+ }
|
|
|
+ tip_call();
|
|
|
+ }else{
|
|
|
+ SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Tip_AdUnitId,(res)=>{
|
|
|
+ if(res.isEnded){
|
|
|
+ tip_call();
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
onImg1Scroll(){
|
|
@@ -258,7 +212,18 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
relative_node.show()
|
|
|
let count = this.getFinishNumber();
|
|
|
gameManager.playRightSoundByCategoryId(this.categoryid);
|
|
|
- this.star_list.getComponent(star_list).showStartByNumber(count);
|
|
|
+ let star = this.star_list.getComponent(star_list).showStartByNumber(count);
|
|
|
+ //
|
|
|
+ let parent = item.node.parent.name ==="img1"?this.img_1:this.img_2;
|
|
|
+ let new_node:Node = instantiate(this.effect);
|
|
|
+ let start_pos = new Vec3()
|
|
|
+ parent.getComponent(UITransform).convertToWorldSpaceAR(item.node.position,start_pos)
|
|
|
+
|
|
|
+ let end_pos = this.star_list.getComponent(UITransform).convertToWorldSpaceAR(star.position)
|
|
|
+ new_node.parent = this.action_node;
|
|
|
+ new_node.position = start_pos;
|
|
|
+ // new_node.getComponent(component_item).hideMask();
|
|
|
+ tween(new_node).to(0.5, {position: end_pos}).removeSelf().start()
|
|
|
}
|
|
|
|
|
|
if(this.checkAllAnswerFinish()&&!this.isShowWin){
|
|
@@ -266,130 +231,30 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
if(gameManager.isFinishAllLevel(this.categoryid)){
|
|
|
tools.showToast("当前已是最后一关,敬请期待最新版本");
|
|
|
}else{
|
|
|
- gameManager.addTopView(config.PREFAB_PATH.win,(node:Node)=>{
|
|
|
- gameManager.playWinSoundByCategoryId(this.categoryid);
|
|
|
- this.isShowWin = true;
|
|
|
- node.getComponent(win).showZhaoBuTongView(this.reward,this.m_data,this.onWinOrdinaryClick.bind(this),this.onWinDoubleClick.bind(this));
|
|
|
- });
|
|
|
+ this.showWin();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- error_sub_time(){
|
|
|
- let self = this;
|
|
|
- if( (self.time_count + self.m_data.wrong_time) >= self.time_all_count){
|
|
|
- self.time_all_count = 0;
|
|
|
- }else{
|
|
|
- self.time_count += self.m_data.wrong_time;
|
|
|
- }
|
|
|
- self.progressbar.progress = (self.time_all_count-self.time_count)/self.time_all_count;
|
|
|
- }
|
|
|
-
|
|
|
- onWinOrdinaryClick(){
|
|
|
- gameManager.playBtnSound()
|
|
|
- this.nextLevel();
|
|
|
- }
|
|
|
-
|
|
|
- onWinDoubleClick(){
|
|
|
- gameManager.playBtnSound()
|
|
|
- let self = this;
|
|
|
- let list = this.m_data.ads_fold.split(",");
|
|
|
- let start = parseInt(list[0]);
|
|
|
- let end = parseInt(list[1]);
|
|
|
- this.reward *= Util.getRandomInt(start,end);
|
|
|
- SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Super_double_AdUnitId,(res)=>{
|
|
|
- if(res.isEnded){
|
|
|
- self.nextLevel();
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- onFailExtendTimeClick(){
|
|
|
- gameManager.playBtnSound()
|
|
|
- let self = this;
|
|
|
- SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Prolong_AdUnitId,(res)=>{
|
|
|
- if(res.isEnded){
|
|
|
- self.start_time_count(self.m_data.extend_time);
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- onFailReStartClick(){
|
|
|
+ onFailReStartClick(fail_view:fail){
|
|
|
gameManager.playBtnSound()
|
|
|
let self = this;
|
|
|
if(this.m_data.ads_restart==1){
|
|
|
SdkUtil.showVideoAd(config.rewardVideoAdUnitId.Resume_AdUnitId,(res)=>{
|
|
|
if(res.isEnded){
|
|
|
self.initAnswerView()
|
|
|
+ fail_view.close()
|
|
|
}
|
|
|
})
|
|
|
}else{
|
|
|
+ fail_view.close()
|
|
|
self.initAnswerView()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- nextLevel(){
|
|
|
- let is_have_next = gameManager.next_level(this.categoryid,(is_sync:boolean)=>{
|
|
|
- if(is_sync){
|
|
|
- let levels_item = gameManager.get_cur_level_by_categoryid(this.categoryid);
|
|
|
- gameManager.showLoading();
|
|
|
- gameManager.add_coin(this.reward);
|
|
|
- ClientEvent.dispatchEvent(config.EVENT_MSG.ON_CHANGE_COIN_NUMBER);
|
|
|
- http.get(config.static_url.levels_info(this.categoryid,levels_item.level),(err,data)=>{
|
|
|
-
|
|
|
- if(!err){
|
|
|
- let _data = JSON.parse(data)
|
|
|
- if(_data.code===config.MSG_CODE.SUCCESS){
|
|
|
- this.initView(_data.content,true);
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }else{
|
|
|
- gameManager.hideLoading()
|
|
|
- tools.showDialogOne("请检查您的网络状态,重新连接",()=>{
|
|
|
- this.nextLevel()
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
- if(!is_have_next){
|
|
|
- tools.showToast("当前已是最后一关,敬请期待最新版本");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- start_time_count(time:number){
|
|
|
- this.time_all_count = time;
|
|
|
- let self = this;
|
|
|
- this.time_count = 0;
|
|
|
- self.progressbar.progress = 1;
|
|
|
- this.schedule(()=>{
|
|
|
- if(self.isPause){
|
|
|
- return;
|
|
|
- }
|
|
|
- if(self.time_count<=self.time_all_count){
|
|
|
- self.time_count+=1;
|
|
|
- self.progressbar.progress = (self.time_all_count-self.time_count)/self.time_all_count;
|
|
|
- }else{
|
|
|
- self.showFail()
|
|
|
- self.stop_time_count();
|
|
|
- }
|
|
|
-
|
|
|
- },1)
|
|
|
- }
|
|
|
-
|
|
|
- showFail(){
|
|
|
- gameManager.addUiView(config.PREFAB_PATH.fail,(node:Node)=>{
|
|
|
- gameManager.playFailSoundByCategoryId(this.categoryid);
|
|
|
- node.getComponent(fail).showView(this.m_data.extend_time,this.onFailExtendTimeClick.bind(this),this.onFailReStartClick.bind(this),this.m_data.ads_restart)
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- stop_time_count(){
|
|
|
- this.unscheduleAllCallbacks()
|
|
|
- }
|
|
|
-
|
|
|
public initView(data:server_shuang_tu_zhao_bu_tong_data_item,isUpdate=false){
|
|
|
+ this.categoryid = config.PLAY_TYPE.YI_QI_ZHAO_CHA;
|
|
|
this.m_data = data;
|
|
|
let count = 0;
|
|
|
if(!isUpdate){
|
|
@@ -428,22 +293,8 @@ export class view_game_play_shuang_tu_zhao_bu_tong extends Component {
|
|
|
call_back();
|
|
|
})
|
|
|
}
|
|
|
- close(){
|
|
|
- ClientEvent.dispatchEvent(config.EVENT_MSG.ON_BACK_HOME_VIEW);
|
|
|
- this.node.removeFromParent();
|
|
|
- }
|
|
|
+
|
|
|
|
|
|
- decRefSf(){
|
|
|
- let self = this;
|
|
|
- if(self.img_1_sf){
|
|
|
- self.img_1_sf.decRef()
|
|
|
- self.img_1_sf = null;
|
|
|
- }
|
|
|
- if(self.img_2_sf){
|
|
|
- self.img_2_sf.decRef()
|
|
|
- self.img_2_sf = null;
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|