Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,365 @@
|
||||
package net.pixvi.myr.view.stack
|
||||
{
|
||||
import com.greensock.TimelineMax;
|
||||
import com.greensock.TweenMax;
|
||||
import com.greensock.easing.Bounce;
|
||||
import com.greensock.easing.Cubic;
|
||||
import com.greensock.easing.Elastic;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.PopCenter;
|
||||
import net.pixvi.common.center.SoundCenter;
|
||||
import net.pixvi.common.driver.SecondDriver;
|
||||
import net.pixvi.common.effect.effects.ShakeEffect;
|
||||
import net.pixvi.common.system.language.lang;
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.common.utils.Gesturer;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.myr.GameMath;
|
||||
import net.pixvi.myr.center.MasterCenter;
|
||||
import net.pixvi.myr.center.StackCenter;
|
||||
import net.pixvi.myr.center.Table;
|
||||
import net.pixvi.myr.element.mon.MonsterVo;
|
||||
import net.pixvi.myr.element.snd.GameSound;
|
||||
import net.pixvi.myr.element.stack.StackVo;
|
||||
import net.pixvi.myr.event.MYREvent;
|
||||
import net.pixvi.myr.panel.egg.EggSelectPanel;
|
||||
import net.pixvi.myr.panel.ground.GroundArea;
|
||||
import net.pixvi.myr.panel.monster.MonsterViewPanel;
|
||||
import net.pixvi.myr.panel.pay.PayPackPanel;
|
||||
import net.pixvi.myr.panel.stack.AddStackPanel;
|
||||
import net.pixvi.myr.panel.stackground.StackGroundPanel;
|
||||
import net.pixvi.myr.view.mon.GroundMon;
|
||||
import net.pixvi.pfw.display.NetBitImg;
|
||||
import net.pixvi.pfw.display.PiSprite;
|
||||
import net.pixvi.pfw.event.PiEvent;
|
||||
import net.pixvi.pfw.utils.Caller;
|
||||
import net.pixvi.pfw.utils.Jumper;
|
||||
import net.pixvi.pfw.utils.Random;
|
||||
import net.pixvi.pfw.utils.broadcast.GlobalBroadcast;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class StackView extends PiSprite
|
||||
{
|
||||
|
||||
public var ui:StackViewUI;
|
||||
|
||||
public var position:int = 0;
|
||||
|
||||
public var vo:StackVo;
|
||||
|
||||
public var eggShakeJumper:Jumper;
|
||||
|
||||
public var groundArea:GroundArea;
|
||||
|
||||
public var img:DisplayObject;
|
||||
|
||||
public var curmode:int = -2;
|
||||
|
||||
public var gesture:Gesturer;
|
||||
|
||||
public var barJumper:Jumper = new Jumper(5);
|
||||
|
||||
public var vipMode:Boolean = false;
|
||||
|
||||
private var shaket:TimelineMax;
|
||||
|
||||
public function StackView(vipMode:Boolean = false)
|
||||
{
|
||||
ui = new StackViewUI(vipMode);
|
||||
addChild(ui);
|
||||
eggShakeJumper = new Jumper(60);
|
||||
super();
|
||||
this.vipMode = vipMode;
|
||||
gesture = new Gesturer(this,true);
|
||||
gesture.dragLength = 20;
|
||||
gesture.start();
|
||||
gesture.addEventListener(Gesturer.DRAG,dragHandler);
|
||||
gesture.addEventListener(Gesturer.TAP_OVER,clickHandler);
|
||||
}
|
||||
|
||||
public function init(vo:StackVo, area:GroundArea) : void
|
||||
{
|
||||
this.vo = vo;
|
||||
this.groundArea = area;
|
||||
PiLightButton.btnTouchLight.setDisplay(this);
|
||||
GlobalBroadcast.addEventListener(MYREvent.MONSTER_MODE_CHANGE,modeChangeHandler);
|
||||
GlobalBroadcast.addEventListener(MYREvent.MONSTER_REMOVE_STACK,removeStackHandler);
|
||||
GlobalBroadcast.addEventListener(MYREvent.MONSTER_ADD_STACK,addStackHandler);
|
||||
GlobalBroadcast.addEventListener(MYREvent.VIP_STATUS_CHANGE,vipUpdateHandler);
|
||||
update();
|
||||
}
|
||||
|
||||
public function shakeEgg(e:Event = null) : void
|
||||
{
|
||||
if(vo.isEmpty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(shaket != null)
|
||||
{
|
||||
shaket.kill();
|
||||
}
|
||||
ui.container_img.rotation = 0;
|
||||
shaket = new TimelineMax();
|
||||
var m:MonsterVo = vo.getMon();
|
||||
var r:Number = 3 + 8 * (m.time_1 - m.timeToNextModeLeft) / m.time_1;
|
||||
r *= Random.direction();
|
||||
shaket.to(ui.container_img,0.1,{
|
||||
"rotation":r,
|
||||
"ease":Cubic.easeOut
|
||||
});
|
||||
shaket.to(ui.container_img,0.1,{
|
||||
"rotation":-r,
|
||||
"ease":Cubic.easeOut
|
||||
});
|
||||
shaket.to(ui.container_img,0.4,{
|
||||
"rotation":0,
|
||||
"ease":Elastic.easeOut
|
||||
});
|
||||
}
|
||||
|
||||
public function update(show:Boolean = false) : void
|
||||
{
|
||||
var monstereggimg:NetBitImg = null;
|
||||
if(vo == null)
|
||||
{
|
||||
ui.modeBlock();
|
||||
return;
|
||||
}
|
||||
if(vo.isNew)
|
||||
{
|
||||
vo.isNew = false;
|
||||
}
|
||||
var mon:MonsterVo = vo.getMon();
|
||||
if(!vo.isEmpty && mon == null)
|
||||
{
|
||||
Alert.showMsg("err:Empty mid=" + vo.monsterId.toString() + " in sid=" + vo.id);
|
||||
return;
|
||||
}
|
||||
if(vo.isEmpty)
|
||||
{
|
||||
if(vipMode && MasterCenter.getIns().getVipDay() <= 0)
|
||||
{
|
||||
ui.modeBlock();
|
||||
return;
|
||||
}
|
||||
if(curmode != -1)
|
||||
{
|
||||
curmode = -1;
|
||||
ui.modeEmpty();
|
||||
}
|
||||
}
|
||||
else if(mon.mode == 0 && curmode != 0)
|
||||
{
|
||||
curmode = 0;
|
||||
ui.modeEgg();
|
||||
cleanImg();
|
||||
secondHandler(true);
|
||||
monstereggimg = new NetBitImg(mon.getCurImg());
|
||||
monstereggimg.x = mon.getCurFix().x;
|
||||
monstereggimg.y = mon.getCurFix().y;
|
||||
img = monstereggimg;
|
||||
ui.container_img.addChild(img);
|
||||
}
|
||||
else if(mon.mode == 1 && curmode != 1)
|
||||
{
|
||||
curmode = 1;
|
||||
ui.modeChild();
|
||||
cleanImg();
|
||||
secondHandler(true);
|
||||
ui.container_img.addChild(img = FF.getBS("ui.StackViewChildImg"));
|
||||
}
|
||||
else if(mon.mode == 2 && curmode != 2)
|
||||
{
|
||||
curmode = 2;
|
||||
ui.modeGrow();
|
||||
}
|
||||
}
|
||||
|
||||
public function cleanImg() : void
|
||||
{
|
||||
if(img != null && img.parent != null)
|
||||
{
|
||||
img.parent.removeChild(img);
|
||||
img = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function addStackHandler(e:PiEvent = null) : void
|
||||
{
|
||||
if(vo != null && (e.data as MonsterVo).id == vo.monsterId)
|
||||
{
|
||||
update(true);
|
||||
TweenMax.from(ui.container_img,1,{
|
||||
"y":ui.container_img.y - 55,
|
||||
"ease":Bounce.easeOut
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public function modeChangeHandler(e:PiEvent = null) : void
|
||||
{
|
||||
if(vo != null && !vo.isEmpty && e.data.id == vo.monsterId)
|
||||
{
|
||||
if(StackGroundPanel.getIns().showing)
|
||||
{
|
||||
update(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
update(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function removeStackHandler(e:PiEvent = null) : void
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
public function dragHandler(e:Event = null) : void
|
||||
{
|
||||
dispatchEvent(new MYREvent(MYREvent.STACK_DRAG,null,true));
|
||||
}
|
||||
|
||||
public function clickHandler(e:Event = null) : void
|
||||
{
|
||||
if(gesture.draging)
|
||||
{
|
||||
dispatchEvent(new MYREvent(MYREvent.STACK_DRAG_OVER,{
|
||||
"speedX":gesture.speedX,
|
||||
"speedY":gesture.speedY
|
||||
},true));
|
||||
return;
|
||||
}
|
||||
SoundCenter.getIns().play(GameSound.effect_click_mon);
|
||||
if(vo == null)
|
||||
{
|
||||
AddStackPanel.position = position;
|
||||
PopCenter.POP(new AddStackPanel());
|
||||
return;
|
||||
}
|
||||
if(!vo.isEmpty)
|
||||
{
|
||||
dispatchEvent(new PiEvent(GroundMon.VIEW_MONSTER,this));
|
||||
MonsterViewPanel.getIns().vo = vo.getMon();
|
||||
PopCenter.POP(MonsterViewPanel.getIns());
|
||||
}
|
||||
else
|
||||
{
|
||||
if(vipMode)
|
||||
{
|
||||
if(MasterCenter.getIns().getVipDay() <= 0)
|
||||
{
|
||||
Alert.yes(lang("提示"),lang("(上面写着特别驯养师专用槽位)"),buyVipHandler);
|
||||
return;
|
||||
}
|
||||
}
|
||||
StackGroundPanel.getIns().ground.pause();
|
||||
EggSelectPanel.getIns().modeSingle();
|
||||
EggSelectPanel.getIns().popIn();
|
||||
EggSelectPanel.getIns().addEventListener("complete",addEgg,false,100);
|
||||
}
|
||||
e.stopImmediatePropagation();
|
||||
}
|
||||
|
||||
public function buyVipHandler(e:Event = null) : void
|
||||
{
|
||||
if(GameMath.OpenPay && Table.setting.closePay != true)
|
||||
{
|
||||
PayPackPanel.getIns().popByPayId("301");
|
||||
}
|
||||
}
|
||||
|
||||
public function addEgg(e:Event = null) : void
|
||||
{
|
||||
var push:Object = null;
|
||||
if(EggSelectPanel.selectedComplete && EggSelectPanel.selectedEgg != null)
|
||||
{
|
||||
push = {
|
||||
"stackid":vo.id,
|
||||
"itemId":EggSelectPanel.selectedEgg.id
|
||||
};
|
||||
StackCenter.getIns().fillEggsToStack([push],vo.id,addEggHandler);
|
||||
}
|
||||
EggSelectPanel.getIns().removeEventListener("complete",addEgg);
|
||||
StackGroundPanel.getIns().ground.resume();
|
||||
}
|
||||
|
||||
private function addEggHandler() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function step() : void
|
||||
{
|
||||
var mon:MonsterVo = vo.getMon();
|
||||
if(eggShakeJumper.jump())
|
||||
{
|
||||
if(!vo.isEmpty && mon.mode == 0 && Math.random() < 0.1)
|
||||
{
|
||||
new ShakeEffect(3,0,0.9).startEffect(ui.container_img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function startOrResume() : void
|
||||
{
|
||||
trace("resumepos");
|
||||
SecondDriver.getInstance().regist(secondHandler);
|
||||
}
|
||||
|
||||
public function pause() : void
|
||||
{
|
||||
SecondDriver.getInstance().remove(secondHandler);
|
||||
}
|
||||
|
||||
public function secondHandler(force:Boolean = false) : void
|
||||
{
|
||||
if(vo == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
var m:MonsterVo = vo.getMon();
|
||||
if(m == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if(force || barJumper.jump())
|
||||
{
|
||||
ui.bar_time.setValue(m.timeToNextMode - m.timeToNextModeLeft,m.timeToNextMode,0,false);
|
||||
}
|
||||
if(m.mode == 0 && Math.random() - 0.3 > m.timeToNextModeLeft / m.time_1)
|
||||
{
|
||||
Caller.delayCall(shakeEgg,Math.random() * 900);
|
||||
}
|
||||
}
|
||||
|
||||
private function vipUpdateHandler(e:Event) : void
|
||||
{
|
||||
if(vipMode)
|
||||
{
|
||||
update(true);
|
||||
}
|
||||
}
|
||||
|
||||
override public function dispose() : void
|
||||
{
|
||||
if(vo != null)
|
||||
{
|
||||
trace("remove" + vo.id);
|
||||
}
|
||||
Caller.stopCall(shakeEgg);
|
||||
GlobalBroadcast.removeEventListener(MYREvent.VIP_STATUS_CHANGE,vipUpdateHandler);
|
||||
PiLightButton.btnTouchLight.removeDisplay(this);
|
||||
SecondDriver.getInstance().remove(secondHandler);
|
||||
GlobalBroadcast.removeEventListener(MYREvent.MONSTER_MODE_CHANGE,modeChangeHandler);
|
||||
GlobalBroadcast.removeEventListener(MYREvent.MONSTER_REMOVE_STACK,removeStackHandler);
|
||||
GlobalBroadcast.removeEventListener(MYREvent.MONSTER_ADD_STACK,addStackHandler);
|
||||
GlobalBroadcast.removeEventListener(MYREvent.VIP_STATUS_CHANGE,vipUpdateHandler);
|
||||
gesture.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
package net.pixvi.myr.view.stack
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.MovieClip;
|
||||
import flash.display.Sprite;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.pfw.ui.controls.PiBar;
|
||||
|
||||
public class StackViewUI extends UIComponent
|
||||
{
|
||||
|
||||
public var mc_front:MovieClip;
|
||||
|
||||
public var container_img:Sprite;
|
||||
|
||||
public var mc_empty:MovieClip;
|
||||
|
||||
public var mc_child:MovieClip;
|
||||
|
||||
public var mc_block:MovieClip;
|
||||
|
||||
public var mc_finish:MovieClip;
|
||||
|
||||
public var bar_time:PiBar;
|
||||
|
||||
public var vipMode:Boolean = false;
|
||||
|
||||
public function StackViewUI(vipMode:Boolean = false, skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
if(skin == null)
|
||||
{
|
||||
this.vipMode = vipMode;
|
||||
if(vipMode)
|
||||
{
|
||||
skin = FF.getMC("ui.StackViewVipUI");
|
||||
}
|
||||
else
|
||||
{
|
||||
skin = FF.getMC("ui.StackViewUI");
|
||||
}
|
||||
}
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
public function modeBlock() : void
|
||||
{
|
||||
mc_child.visible = mc_finish.visible = false;
|
||||
mc_empty.visible = false;
|
||||
container_img.visible = false;
|
||||
mc_block.visible = true;
|
||||
mc_front.visible = false;
|
||||
bar_time.visible = false;
|
||||
}
|
||||
|
||||
public function modeEmpty() : void
|
||||
{
|
||||
mc_child.visible = mc_block.visible = mc_finish.visible = false;
|
||||
mc_empty.visible = true;
|
||||
mc_front.visible = true;
|
||||
container_img.visible = false;
|
||||
bar_time.visible = false;
|
||||
}
|
||||
|
||||
public function modeEgg() : void
|
||||
{
|
||||
mc_child.visible = mc_block.visible = mc_empty.visible = mc_finish.visible = false;
|
||||
container_img.visible = true;
|
||||
mc_front.visible = true;
|
||||
bar_time.visible = true;
|
||||
}
|
||||
|
||||
public function modeChild() : void
|
||||
{
|
||||
mc_block.visible = mc_empty.visible = mc_finish.visible = false;
|
||||
container_img.visible = true;
|
||||
mc_child.visible = true;
|
||||
mc_front.visible = true;
|
||||
bar_time.visible = true;
|
||||
}
|
||||
|
||||
public function modeGrow() : void
|
||||
{
|
||||
mc_finish.visible = true;
|
||||
mc_child.visible = mc_block.visible = mc_empty.visible = false;
|
||||
container_img.visible = false;
|
||||
mc_front.visible = true;
|
||||
bar_time.visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user