Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import flash.text.TextField;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class GameRoomGameBtnUI extends PiLightButton
|
||||
{
|
||||
|
||||
public var text_coinNum:TextField;
|
||||
|
||||
public var mc_cost:Sprite;
|
||||
|
||||
public var gameVo:MiniGameVo;
|
||||
|
||||
public var oX:Number = -100;
|
||||
|
||||
public var oY:Number;
|
||||
|
||||
public function GameRoomGameBtnUI(skin:DisplayObject = null, auto:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
super(skin,auto,w,h);
|
||||
}
|
||||
|
||||
public function update() : void
|
||||
{
|
||||
text_coinNum.text = "×" + gameVo.coin.toString();
|
||||
if(oX == -100)
|
||||
{
|
||||
oX = this.x;
|
||||
oY = this.y;
|
||||
}
|
||||
if(!gameVo.isOpen)
|
||||
{
|
||||
this.visible = false;
|
||||
this.x = 0;
|
||||
this.y = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.x = oX;
|
||||
this.y = oY;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.geom.Rectangle;
|
||||
import net.pixvi.common.utils.Engine2D;
|
||||
import net.pixvi.common.utils.Gesturer;
|
||||
import net.pixvi.common.utils.StageLocator;
|
||||
import net.pixvi.myr.center.BagCenter;
|
||||
import net.pixvi.myr.center.MiniGameCenter;
|
||||
import net.pixvi.myr.center.PosCenter;
|
||||
import net.pixvi.myr.center.Table;
|
||||
import net.pixvi.myr.event.MYREvent;
|
||||
import net.pixvi.myr.panel.mainmenu.MainMenu;
|
||||
import net.pixvi.myr.panel.shop.ShopListPanel;
|
||||
import net.pixvi.pfw.driver.EnterFrameDriver;
|
||||
import net.pixvi.pfw.utils.Oncer;
|
||||
import net.pixvi.pfw.utils.broadcast.GlobalBroadcast;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class GameRoomPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
public var ui:GameRoomPanelUI = new GameRoomPanelUI();
|
||||
|
||||
private var gesture:Gesturer;
|
||||
|
||||
private var engine:Engine2D;
|
||||
|
||||
public var scaleHeight:int = 600;
|
||||
|
||||
public var prePanel:PSGPopPanel;
|
||||
|
||||
public function GameRoomPanel(showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
addChild(ui);
|
||||
super(showTime,hideTime);
|
||||
gesture = new Gesturer(ui.ui_container,true);
|
||||
gesture.start();
|
||||
gesture.addEventListener(Gesturer.DRAG,dragHandler);
|
||||
engine = new Engine2D(0,0,0,0,0.8);
|
||||
}
|
||||
|
||||
public static function getIns() : GameRoomPanel
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(GameRoomPanel) as GameRoomPanel;
|
||||
}
|
||||
|
||||
public function dragHandler(e:Event = null) : void
|
||||
{
|
||||
engine.speedY = 0;
|
||||
gesture.addEventListener(Gesturer.TAP_OVER,overDragHandler);
|
||||
var rec:Rectangle = new Rectangle(ui.ui_center.x,StageLocator.buildHeight / 2 - ui.ui_center.height + 145,0,ui.ui_center.height - 145);
|
||||
ui.ui_center.startMoveDrag(false,rec);
|
||||
engine.setBoard(StageLocator.buildHeight / 2 - ui.ui_center.height + 145,StageLocator.buildHeight / 2,0,0);
|
||||
}
|
||||
|
||||
public function overDragHandler(e:Event = null) : void
|
||||
{
|
||||
engine.speedY = gesture.speedY;
|
||||
gesture.removeEventListener(Gesturer.TAP_OVER,overDragHandler);
|
||||
ui.ui_center.stopMoveDrag();
|
||||
}
|
||||
|
||||
override public function init() : void
|
||||
{
|
||||
ui.ui_bottom.btn_buyCoin.onClick(buyCoinHandler);
|
||||
ui.btn_close.onClick(closeHandler);
|
||||
addChild(MainMenu.getIns(this));
|
||||
addChild(ui.ui_bottom);
|
||||
addChild(ui.btn_close);
|
||||
MainMenu.getIns().onIn();
|
||||
MainMenu.getIns().ui.gameRoomMode();
|
||||
PosCenter.activity("gameroom");
|
||||
EnterFrameDriver.getIns().regist(enterHandler);
|
||||
for each(var b:PiLightButton in ui.ui_center.btns)
|
||||
{
|
||||
b.onClick(clickHandler);
|
||||
}
|
||||
scaleHeight += StageLocator.MainFixVo.fix[2] * 0.5;
|
||||
enterHandler(null,true);
|
||||
ui.ui_bottom.btn_exchange.loadByBtnData(Table.activity_info.specialBtn.gameRoomExchangeBtn);
|
||||
this.mouseChildren = this.mouseEnabled = false;
|
||||
if(MiniGameCenter.getIns().gameRecords == null)
|
||||
{
|
||||
this.mouseChildren = this.mouseEnabled = false;
|
||||
MiniGameCenter.getIns().getRecord(recordLoadComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.mouseChildren = this.mouseEnabled = true;
|
||||
}
|
||||
GlobalBroadcast.addEventListener(MYREvent.ITEM_NUM_CHANGE,itemNumChangeHandler);
|
||||
update();
|
||||
}
|
||||
|
||||
public function itemNumChangeHandler(e:MYREvent = null) : void
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
public function update(e:Event = null) : void
|
||||
{
|
||||
ui.ui_bottom.text_coin.text = BagCenter.getIns().getNum(20032).toString();
|
||||
}
|
||||
|
||||
private function recordLoadComplete(re:Object = null) : void
|
||||
{
|
||||
this.mouseChildren = this.mouseEnabled = true;
|
||||
}
|
||||
|
||||
public function clickHandler(e:Event = null) : void
|
||||
{
|
||||
if(gesture.draging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var btn:GameRoomGameBtnUI = e.currentTarget as GameRoomGameBtnUI;
|
||||
MiniGameStartPanel.getIns().cur = btn.gameVo;
|
||||
MiniGameStartPanel.getIns().popIn();
|
||||
MiniGameStartPanel.getIns().addEventListener("showout",startShowOutHandler);
|
||||
EnterFrameDriver.getIns().remove(enterHandler);
|
||||
}
|
||||
|
||||
public function startShowOutHandler(e:Event = null) : void
|
||||
{
|
||||
EnterFrameDriver.getIns().regist(enterHandler);
|
||||
}
|
||||
|
||||
public function enterHandler(e:Event = null, force:Boolean = false) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var btn:GameRoomGameBtnUI = null;
|
||||
var scale:Number = NaN;
|
||||
if(engine.speedY == 0 && !gesture.draging && !force)
|
||||
{
|
||||
return;
|
||||
}
|
||||
engine.step(ui.ui_center,false,true);
|
||||
for(i = 0; i < ui.ui_center.btns.length; )
|
||||
{
|
||||
btn = ui.ui_center.btns[i];
|
||||
scale = 1.13 - Math.abs(StageLocator.buildHeight / 2 - ui.ui_center.y - btn.y) / scaleHeight;
|
||||
if(scale < 0.6)
|
||||
{
|
||||
scale = 0.6;
|
||||
}
|
||||
if(scale > 1)
|
||||
{
|
||||
scale = 1;
|
||||
}
|
||||
btn.setScale(scale);
|
||||
i++;
|
||||
}
|
||||
ui.mc_bg.y = StageLocator.MainFixVo.fix[0] - (ui.mc_bg.height - StageLocator.MainFixVo.fixHeight) * (StageLocator.buildHeight / 2 - ui.ui_center.y) / ui.ui_center.height;
|
||||
}
|
||||
|
||||
override public function reset() : void
|
||||
{
|
||||
EnterFrameDriver.getIns().remove(enterHandler);
|
||||
}
|
||||
|
||||
public function buyCoinHandler(e:Event = null) : void
|
||||
{
|
||||
ShopListPanel.showWithTeam("slmzx");
|
||||
}
|
||||
|
||||
public function closeHandler(e:Event = null) : void
|
||||
{
|
||||
if(prePanel != null)
|
||||
{
|
||||
Oncer.lastRun(prePanel.popIn);
|
||||
prePanel = null;
|
||||
}
|
||||
this.showOut();
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
GlobalBroadcast.removeEventListener(MYREvent.ITEM_NUM_CHANGE,itemNumChangeHandler);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.text.TextField;
|
||||
import net.pixvi.myr.panel.stagesp.MYREventButton;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class GameRoomPanelBottomUI extends UIComponent
|
||||
{
|
||||
|
||||
public var btn_buyCoin:PiLightButton;
|
||||
|
||||
public var text_coin:TextField;
|
||||
|
||||
public var btn_exchange:MYREventButton;
|
||||
|
||||
public function GameRoomPanelBottomUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
|
||||
public class GameRoomPanelCenterUI extends UIComponent
|
||||
{
|
||||
|
||||
public var btn_game1:GameRoomGameBtnUI;
|
||||
|
||||
public var btn_game2:GameRoomGameBtnUI;
|
||||
|
||||
public var btn_game3:GameRoomGameBtnUI;
|
||||
|
||||
public var btn_game4:GameRoomGameBtnUI;
|
||||
|
||||
public var btn_game5:GameRoomGameBtnUI;
|
||||
|
||||
public var btn_game6:GameRoomGameBtnUI;
|
||||
|
||||
public var btns:Array = [];
|
||||
|
||||
public function GameRoomPanelCenterUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var btn:GameRoomGameBtnUI = null;
|
||||
btns = [btn_game1,btn_game2,btn_game3,btn_game4,btn_game5,btn_game6];
|
||||
for(i = 0; i < btns.length; )
|
||||
{
|
||||
btn = btns[i];
|
||||
btn.gameVo = new MiniGameVo();
|
||||
btn.gameVo.typeId = i + 1;
|
||||
btn.update();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import net.pixvi.common.utils.StageLocator;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class GameRoomPanelUI extends UIComponent
|
||||
{
|
||||
|
||||
public var ui_bottom:GameRoomPanelBottomUI;
|
||||
|
||||
public var ui_center:GameRoomPanelCenterUI;
|
||||
|
||||
public var btn_close:PiLightButton;
|
||||
|
||||
public var mc_title:Sprite;
|
||||
|
||||
public var mc_bg:Sprite;
|
||||
|
||||
public var ui_container:Sprite;
|
||||
|
||||
public function GameRoomPanelUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.GameRoomPanelUI");
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
StageLocator.setSide(btn_close,"left","bottom",0,28);
|
||||
StageLocator.setSide(ui_bottom,"none","bottom");
|
||||
StageLocator.setSide(mc_title,"left","top",20,135);
|
||||
StageLocator.setfull(mc_bg);
|
||||
mc_bg.x = StageLocator.MainFixVo.fix[3];
|
||||
mc_bg.y = StageLocator.MainFixVo.fix[0];
|
||||
ui_container = new Sprite();
|
||||
addChildAt(ui_container,0);
|
||||
ui_container.addChild(mc_bg);
|
||||
ui_container.addChild(ui_center);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.PopCenter;
|
||||
import net.pixvi.common.system.language.lang;
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.center.BagCenter;
|
||||
import net.pixvi.myr.center.MiniGameCenter;
|
||||
import net.pixvi.myr.element.bag.ItemVo;
|
||||
import net.pixvi.myr.panel.minigame.MiniGamePanel;
|
||||
import net.pixvi.myr.panel.rank.RankPanel;
|
||||
import net.pixvi.pfw.event.MobiEvent;
|
||||
import net.pixvi.pfw.utils.Paster;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
|
||||
public class MiniGameStartPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
public var ui:MiniGameStartPanelUI = new MiniGameStartPanelUI();
|
||||
|
||||
public var cur:MiniGameVo;
|
||||
|
||||
public var game:MiniGamePanel;
|
||||
|
||||
public function MiniGameStartPanel(showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
addChild(ui);
|
||||
super(showTime,hideTime);
|
||||
}
|
||||
|
||||
public static function getIns() : MiniGameStartPanel
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(MiniGameStartPanel) as MiniGameStartPanel;
|
||||
}
|
||||
|
||||
override public function init() : void
|
||||
{
|
||||
update();
|
||||
ui.btn_close.onClick(closeHandler);
|
||||
ui.btn_start.onClick(startHandler);
|
||||
ui.btn_rank.onClick(rankHandler);
|
||||
PopCenter.getIns().setMaskAlpha();
|
||||
PopCenter.getIns().mask.addEventListener(MobiEvent.CLICK,maskClickHandler);
|
||||
}
|
||||
|
||||
public function maskClickHandler(e:Event = null) : void
|
||||
{
|
||||
if(PopCenter.getIns().topPanel == this)
|
||||
{
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public function startHandler(e:Event = null) : void
|
||||
{
|
||||
var coinNum:int = BagCenter.getIns().getNum(int(cur.coinType));
|
||||
if(coinNum < cur.coin)
|
||||
{
|
||||
Alert.showMsg(lang("没有足够的【{0}】",ItemVo.getName(int(cur.coinType))));
|
||||
return;
|
||||
}
|
||||
GameRoomPanel.getIns().visible = false;
|
||||
MiniGameCenter.getIns().miniGameStart(cur.typeId,startCompleteHandler);
|
||||
}
|
||||
|
||||
private function startCompleteHandler(re:Object = null) : void
|
||||
{
|
||||
game = new MiniGamePanel(cur.typeId);
|
||||
this.showOut();
|
||||
PopCenter.POP(game);
|
||||
game.gameStart(gameOverHandler);
|
||||
}
|
||||
|
||||
public function gameOverHandler(point:int) : void
|
||||
{
|
||||
trace(point);
|
||||
this.popIn();
|
||||
GameRoomPanel.getIns().visible = true;
|
||||
this.mouseChildren = this.mouseEnabled = false;
|
||||
MiniGameCenter.getIns().miniGameOver(cur.typeId,point,gameOverCompleteHandler);
|
||||
}
|
||||
|
||||
public function gameOverCompleteHandler(re:Object) : void
|
||||
{
|
||||
this.mouseChildren = this.mouseEnabled = true;
|
||||
update();
|
||||
}
|
||||
|
||||
public function rankHandler(e:Event = null) : void
|
||||
{
|
||||
RankPanel.getIns().setRank(cur.rankType,cur.name,0);
|
||||
PopCenter.POP(RankPanel.getIns());
|
||||
}
|
||||
|
||||
public function closeHandler(e:Event = null) : void
|
||||
{
|
||||
PopCenter.getIns().mask.removeEventListener(MobiEvent.CLICK,maskClickHandler);
|
||||
this.showOut();
|
||||
}
|
||||
|
||||
public function update() : void
|
||||
{
|
||||
ui.text_coinNum.text = "×" + cur.coin;
|
||||
ui.container_img.loadNetBitImg(cur.gameHaibao,true,false,0);
|
||||
ui.mc_title.gotoAndStop(cur.typeId);
|
||||
if(cur.topPoint == 0)
|
||||
{
|
||||
ui.text_top.visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.text_top.visible = true;
|
||||
ui.text_top.htmlText = Paster.font(lang("个人最佳:"),null,18) + Paster.font(cur.topPoint.toString(),"#ffff66");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.text.TextField;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.pfw.ui.containers.PiImgContainer;
|
||||
import net.pixvi.pfw.ui.controls.PiBitTextField;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class MiniGameStartPanelUI extends UIComponent
|
||||
{
|
||||
|
||||
public var btn_close:PiLightButton;
|
||||
|
||||
public var btn_start:PiLightButton;
|
||||
|
||||
public var btn_rank:PiLightButton;
|
||||
|
||||
public var container_img:PiImgContainer;
|
||||
|
||||
public var mc_title:MovieClip;
|
||||
|
||||
public var text_coinNum:TextField;
|
||||
|
||||
public var text_top:PiBitTextField;
|
||||
|
||||
public function MiniGameStartPanelUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.MiniGameStartPanelUI");
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
mc_title.stop();
|
||||
container_img.setSize(427,266);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package net.pixvi.myr.panel.gameroom
|
||||
{
|
||||
import net.pixvi.myr.center.MiniGameCenter;
|
||||
import net.pixvi.myr.center.Table;
|
||||
import net.pixvi.myr.element.npc.ConditionVo;
|
||||
|
||||
public class MiniGameVo
|
||||
{
|
||||
|
||||
private var _typeId:int = 0;
|
||||
|
||||
private var _type:String = "";
|
||||
|
||||
public function MiniGameVo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function get topPoint() : int
|
||||
{
|
||||
var a:Object = MiniGameCenter.getIns().gameRecords;
|
||||
if(a == null)
|
||||
{
|
||||
return MiniGameCenter.getIns().getLocalRecordScore(typeId);
|
||||
}
|
||||
if(a != null && a[typeId] != null)
|
||||
{
|
||||
return a[typeId].maxScore;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function get typeId() : int
|
||||
{
|
||||
return _typeId;
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return _type;
|
||||
}
|
||||
|
||||
public function get ticketType() : int
|
||||
{
|
||||
return table().ticketType;
|
||||
}
|
||||
|
||||
public function set typeId(val:int) : void
|
||||
{
|
||||
for(var key:String in Table.mini_game)
|
||||
{
|
||||
if(Table.mini_game[key].typeId == val.toString())
|
||||
{
|
||||
_typeId = val;
|
||||
_type = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function get name() : String
|
||||
{
|
||||
return table().name;
|
||||
}
|
||||
|
||||
public function get gameHaibao() : String
|
||||
{
|
||||
return "data/img/minigame/game" + typeId + ".png";
|
||||
}
|
||||
|
||||
public function get coin() : int
|
||||
{
|
||||
return table().coin;
|
||||
}
|
||||
|
||||
public function get rankType() : String
|
||||
{
|
||||
return table().rank;
|
||||
}
|
||||
|
||||
public function get coinType() : String
|
||||
{
|
||||
return table().coinType;
|
||||
}
|
||||
|
||||
public function get isOpen() : Boolean
|
||||
{
|
||||
var con:ConditionVo = new ConditionVo(table().condition);
|
||||
return con.check();
|
||||
}
|
||||
|
||||
public function table() : Object
|
||||
{
|
||||
return Table.mini_game[_type];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user