Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package myDisplay.window.newvip
- {
- import myDisplay.window.Wnd_Base;
- import com.sincetimes.transport.protocol.RceVipGet;
- import myDisplay.global.GlobalReference;
- import com.sincetimes.transport.Transport;
- import com.sincetimes.transport.protocol.RceVipGetReward;
- import com.sincetimes.transport.protocol.RseVipGetReward;
- import flash.geom.Point;
- import myDisplay.myUI.ScrollSet;
- import com.sincetimes.transport.protocol.RseVipGet;
- import myDisplay.global.GlobalFunction;
- import flash.events.Event;
- import flash.events.MouseEvent;
- import model.GameEvent;
- import com.thor.utils.Locales;
- import flash.display.MovieClip;
- import com.cc.VIP.VIPData;
- import com.sincetimes.transport.protocol.VipReward;
- import com.sincetimes.transport.protocol.LuckyReward;
- import model.bagData.BagCardItemConfig;
- import com.thor.utils.EmbedFontUtil;
- import com.thor.constants.FontNames;
- import myDisplay.WindowManager;
- import Tool.platform.PlatformManager;
- public class Wnd_VipClub extends Wnd_Base
- {
- public function Wnd_VipClub()
- {
- this._menuItems = new Array();
- super();
- self = this;
- }
- private static var self:Wnd_VipClub;
- private static const MAX_CARD_NUM:int = 5;
- private static function requestVipInfo() : void
- {
- GLOBAL._mainLoader.startWaiting(true);
- var _loc1_:RceVipGet = new RceVipGet();
- if(GlobalReference.supportMagicDiamond)
- {
- _loc1_.isMagicDiamond = GlobalReference.isMagicDiamond;
- }
- Transport.Send(_loc1_);
- }
- private static function requestVipGetReward() : void
- {
- GLOBAL._mainLoader.startWaiting(true);
- var _loc1_:RceVipGetReward = new RceVipGetReward();
- Transport.Send(_loc1_);
- }
- public static function rseVipGetReward_hd(param1:RseVipGetReward) : void
- {
- GLOBAL._mainLoader.endWaiting();
- self.upatePanel(param1);
- }
- private var panel:ZZVipClubPanel;
- private var _lastListViewPos:Point;
- private var _scrollSet:ScrollSet;
- private var _rseVipGet:RseVipGet;
- private var _thisLevelReward:ZZVipRewardItem;
- private var _vipExpSlotLen:Number;
- private var _menuItems:Array;
- override protected function excuteBeforeOpen() : void
- {
- this.panel = this.windowMaterial;
- this._vipExpSlotLen = this.panel.vipexpslot.vipexpbar.width;
- this.panel.vipexpslot.vipexpbar.width = 0;
- GlobalFunction.setTextByKey(this.panel.tTitle,"zz_vip_club_title");
- GlobalFunction.setTextByKey(this.panel.youvipleveldesc_tf,"zz_vip_youvipleveldesc");
- GlobalFunction.setTextByKey(this.panel.charge_tf,"zz_vip_addCredit");
- GlobalFunction.setTextByKey(this.panel.vipstorename_tf,"zz_vip_store_title");
- this.panel.help_btn.gotoAndStop(1);
- GlobalFunction.addEventListener(this,this.panel,Event.REMOVED_FROM_STAGE,this.onRemove);
- GlobalFunction.addEventListener(this,this.panel.help_btn,MouseEvent.CLICK,this.onClickHelp);
- GlobalFunction.addEventListener(this,GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.onMouseDownState);
- GlobalFunction.addEventListener(this,GlobalReference.dispatcher,GameEvent.EVENT_GOT_VIP_INFO,this.onGotVipInfo);
- requestVipInfo();
- addTargetEvent(GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.hideTip);
- }
- private function hideTip(param1:MouseEvent) : void
- {
- GLOBAL.RemoveToolTips(false);
- }
- private function onMouseDownState(param1:MouseEvent) : void
- {
- GLOBAL.RemoveToolTips(false);
- }
- private function onClickHelp(param1:Event) : void
- {
- var _loc2_:String = Locales.Get("zz_vip_club_helpmsg");
- GLOBAL.ShowToolTips(param1.currentTarget as MovieClip,_loc2_);
- }
- private function onRemove(param1:Event) : void
- {
- GlobalFunction.removeEventListener(this);
- self = null;
- }
- private function onGotVipInfo(param1:GameEvent) : void
- {
- GLOBAL._mainLoader.endWaiting();
- var _loc2_:RseVipGet = param1.data as RseVipGet;
- if(_loc2_)
- {
- this.initPanel(_loc2_);
- }
- }
- protected function clearGiftGrid(param1:MovieClip) : void
- {
- if(param1 == null)
- {
- return;
- }
- if(param1.card)
- {
- try
- {
- param1.cardpos.removeChild(param1.card);
- param1.card = null;
- param1.reward = null;
- GlobalFunction.setText(param1.num_tf,"");
- GlobalFunction.setText(param1.name_tf,"");
- }
- catch(e:Error)
- {
- }
- }
- }
- private function initMenuItem() : void
- {
- var _loc6_:MovieClip = null;
- var _loc9_:VIPData = null;
- var _loc12_:VipReward = null;
- var _loc13_:LuckyReward = null;
- var _loc14_:BagCardItemConfig = null;
- if(this._rseVipGet == null || this._rseVipGet.rewards == null || this._rseVipGet.rewards.length == 0)
- {
- return;
- }
- GlobalFunction.addEventListener(this,GLOBAL._stage,MouseEvent.MOUSE_DOWN,this.onMouseDown);
- this._scrollSet = new ScrollSet();
- var _loc1_:ZZVipRewardItem = new ZZVipRewardItem();
- var _loc2_:Number = _loc1_.height;
- this._scrollSet.Init(this.panel.maskpanel,ScrollSet.BLUE,ScrollSet.VERTICAL);
- this._scrollSet.itemHeight = _loc2_;
- this._scrollSet.itemMargin = 10;
- this._scrollSet.beginAlterItem();
- var _loc3_:int = this._rseVipGet.viplevel;
- var _loc4_:int = this._rseVipGet.viplevel;
- if(_loc4_ == 0)
- {
- _loc4_ = 1;
- }
- var _loc5_:* = 0;
- var _loc7_:* = "";
- var _loc8_:* = "";
- var _loc10_:* = 0;
- var _loc11_:* = "";
- for each(_loc12_ in this._rseVipGet.rewards)
- {
- _loc7_ = "";
- _loc1_ = new ZZVipRewardItem();
- GlobalFunction.setTextByKey(_loc1_.weekgift_tf,"zz_vip_weekgift",_loc4_);
- if(_loc4_ != _loc3_)
- {
- _loc1_.get_btn.visible = false;
- _loc1_.gettime_tf.visible = false;
- }
- else
- {
- this._thisLevelReward = _loc1_;
- }
- _loc1_.get_tf.visible = false;
- _loc1_.gift_mc.gift_btn.vipLevel = _loc4_;
- _loc1_.gift_mc.gift_btn.origVipLevel = _loc3_;
- EmbedFontUtil.setText(_loc1_.gift_mc.youviplevel_tf,Locales.Get("zz_vip_getreward_warning",{"v1":_loc4_}),FontNames.NORMAL);
- GlobalFunction.addEventListener(this,_loc1_.gift_mc.gift_btn,MouseEvent.MOUSE_UP,this.onClickbtn);
- if(_loc12_.cards.length > 0)
- {
- _loc8_ = "";
- _loc10_ = 0;
- while(_loc10_ < _loc12_.cards.length)
- {
- _loc13_ = _loc12_.cards[_loc10_];
- _loc14_ = BagCardItemConfig.getCardConfigByItemId(_loc13_.cardId);
- if(_loc14_)
- {
- _loc8_ = _loc8_ + (_loc14_.name + "*" + _loc13_.cardNum + "\n");
- }
- _loc10_++;
- }
- if(_loc8_.length > 0)
- {
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_rewardweekly",{"v1":_loc4_});
- _loc11_ = "<font color=\"#FFFF00\">" + Locales.Get("zz_vip_getreward_warning",{"v1":_loc4_}) + "</font>\n" + _loc8_;
- _loc1_.gift_mc.gift_btn.tipStr = _loc11_;
- }
- }
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward2",{"v1":_loc4_});
- _loc9_ = VIPData.getVIPDataBylevel(_loc4_);
- if(_loc9_)
- {
- if(_loc9_.feast_add > 0)
- {
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward3",{"v1":_loc9_.feast_add});
- }
- if(_loc9_.defence_extra_count > 0)
- {
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward4",{"v1":_loc9_.defence_extra_count});
- }
- _loc8_ = "";
- if(_loc9_.capacity_0 > 0)
- {
- _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_0",{"v1":_loc9_.capacity_0}) + ",");
- }
- if(_loc9_.capacity_1 > 0)
- {
- _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_1",{"v1":_loc9_.capacity_1}) + ",");
- }
- if(_loc9_.capacity_2 > 0)
- {
- _loc8_ = _loc8_ + (Locales.Get("zz_VIP_reward5_2",{"v1":_loc9_.capacity_2}) + ",");
- }
- if(_loc8_.length > 0)
- {
- _loc8_ = _loc8_.slice(0,_loc8_.length - 1);
- }
- if(_loc8_.length > 0)
- {
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward5",{"v1":_loc8_});
- }
- if(_loc9_.lianmeng > 0)
- {
- _loc7_ = _loc7_ + Locales.Get("zz_VIP_reward6_" + _loc9_.lianmeng);
- }
- }
- EmbedFontUtil.setHtmlText(_loc1_.reward_tf,_loc7_,FontNames.NORMAL);
- _loc4_++;
- this._scrollSet.addItem(_loc1_);
- }
- this._scrollSet.endAlterItem();
- }
- private function onClickbtn(param1:MouseEvent) : void
- {
- var _loc2_:int = GlobalFunction.getServerSecond();
- if(!(param1.currentTarget.vipLevel == param1.currentTarget.origVipLevel) || this._rseVipGet.nextTime > _loc2_)
- {
- GLOBAL.ShowToolTips(param1.currentTarget as MovieClip,param1.currentTarget.tipStr,0,0,true,true);
- }
- else
- {
- this.onClickGetReward(param1);
- }
- }
- private function onMouseDown(param1:MouseEvent) : void
- {
- this._lastListViewPos = new Point(this._scrollSet.listView.x,this._scrollSet.listView.y);
- }
- private function onClickGetReward(param1:MouseEvent) : void
- {
- if(Point.distance(this._lastListViewPos,new Point(this._scrollSet.listView.x,this._scrollSet.listView.y)) > 10)
- {
- return;
- }
- var _loc2_:int = GlobalFunction.getServerSecond();
- if(_loc2_ <= this._rseVipGet.nextTime)
- {
- return;
- }
- requestVipGetReward();
- }
- private function initPanel(param1:RseVipGet) : void
- {
- if(param1.succ != 0)
- {
- this.showErrMsg(param1.succ);
- return;
- }
- this._rseVipGet = param1;
- GlobalFunction.setTextByKey(this.panel.youviplevel_tf,"zz_vip_level",param1.viplevel);
- GlobalFunction.setText(this.panel.vipexp_tf,param1.haspayed + "/" + param1.nextLevelNeed);
- var _loc2_:Number = this._vipExpSlotLen * param1.haspayed / param1.nextLevelNeed;
- if(_loc2_ < 0)
- {
- _loc2_ = 0;
- }
- else if(_loc2_ > this._vipExpSlotLen)
- {
- _loc2_ = this._vipExpSlotLen;
- }
- this.panel.vipexpslot.vipexpbar.width = _loc2_;
- if((GlobalReference.supportMagicDiamond) && !(param1.isHasQQMagicLimit == 0) && !param1.isQQMagic)
- {
- GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_notmagicdiamond");
- }
- else if(param1.viplevel == 0)
- {
- GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_notVipDesc",param1.nextLevelNeed - param1.haspayed,1);
- }
- else if(param1.haspayed != param1.nextLevelNeed)
- {
- GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_nomalVipDesc",param1.nextLevelNeed - param1.haspayed,param1.viplevel + 1);
- }
- else
- {
- GlobalFunction.setTextByKey(this.panel.viplevelupdesc_tf,"zz_vip_topVipDesc");
- }
- this.initMenuItem();
- GlobalFunction.addEventListener(this,this.panel.charge_btn,MouseEvent.CLICK,this.onClickCharge);
- GlobalFunction.addEventListener(this,this.panel.vipstore_btn,MouseEvent.CLICK,this.onClickVipStore);
- GlobalFunction.addEventListener(this,this.panel,Event.ENTER_FRAME,this.onEnterFrame);
- }
- private function onClickVipStore(param1:Event) : void
- {
- if(this._rseVipGet)
- {
- Wnd_VipStore.rseVipGet = this._rseVipGet;
- Wnd_VipStore.parentWnd = this;
- WindowManager.getInstance().openWindow(WindowManager.ZZVipStore);
- }
- }
- private function onClickCharge(param1:Event) : void
- {
- PlatformManager.getInstance().showChongzhi();
- closeWindow(null);
- }
- private function upatePanel(param1:RseVipGetReward) : void
- {
- var reward:VipReward = null;
- var cardMsg:String = null;
- var card:LuckyReward = null;
- var msg:String = null;
- var errFunc:Function = null;
- var rse:RseVipGetReward = param1;
- if(rse.succ != 0)
- {
- this.showErrMsg(rse.succ);
- return;
- }
- if((this._rseVipGet) && (this._thisLevelReward) && !(this._rseVipGet.rewards.length == 0))
- {
- this._rseVipGet.nextTime = rse.nextTime;
- this._thisLevelReward.get_btn.visible = false;
- this._thisLevelReward.gettime_tf.visible = false;
- reward = this._rseVipGet.rewards[0] as VipReward;
- if((reward) && (reward.cards) && !(reward.cards.length == 0))
- {
- cardMsg = "";
- for each(card in reward.cards)
- {
- cardMsg = cardMsg + (GlobalFunction.getCardNameByID(card.cardId) + "\tx" + card.cardNum + "\n");
- }
- msg = Locales.Get("zz_vip_rewarddesc",{"v1":cardMsg});
- errFunc = function():void
- {
- POPUPS.Next();
- };
- POPUPS.DisplayCCbot(Locales.Get("zz_vip_club_title"),msg,Locales.Get("btn_ok"),errFunc,false,false,true,errFunc);
- }
- }
- }
- private function onEnterFrame(param1:Event) : void
- {
- var _loc2_:* = 0;
- var _loc3_:* = 0;
- if(this._rseVipGet == null || this._thisLevelReward == null)
- {
- return;
- }
- if(this._rseVipGet.viplevel != 0)
- {
- _loc2_ = GlobalFunction.getServerSecond();
- _loc3_ = this._rseVipGet.nextTime - _loc2_ + 1;
- if(_loc3_ < 0)
- {
- this._thisLevelReward.get_btn.visible = false;
- this._thisLevelReward.gettime_tf.visible = false;
- EmbedFontUtil.setText(this._thisLevelReward.gift_mc.lefttime_tf,Locales.Get("ui_canGetGift"),FontNames.NORMAL);
- }
- else
- {
- this._thisLevelReward.get_btn.visible = false;
- this._thisLevelReward.gettime_tf.visible = false;
- if(_loc3_ > 3600 * 24)
- {
- GlobalFunction.setText(this._thisLevelReward.gift_mc.lefttime_tf,GlobalFunction.getDHMByLeftSecond(_loc3_));
- }
- else
- {
- GlobalFunction.setText(this._thisLevelReward.gift_mc.lefttime_tf,GlobalFunction.getHMSByLeftSecond(_loc3_));
- }
- }
- }
- }
- public function showErrMsg(param1:int) : void
- {
- var errType:int = param1;
- var errMsg:String = GlobalFunction.getErrMsgByType(errType);
- var errFunc:Function = function():void
- {
- POPUPS.Next();
- closeWindow();
- };
- POPUPS.DisplayCCbot(Locales.Get("zz_vip_club_title"),errMsg,Locales.Get("btn_ok"),errFunc,false,false,true,errFunc);
- }
- override protected function get windowClassName() : Class
- {
- return ZZVipClubPanel;
- }
- private function get windowMaterial() : ZZVipClubPanel
- {
- return material as ZZVipClubPanel;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement