Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,177 @@
|
||||
package net.pixvi.myr.panel.rollpanel
|
||||
{
|
||||
import com.greensock.TweenMax;
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.PopCenter;
|
||||
import net.pixvi.common.center.SoundCenter;
|
||||
import net.pixvi.common.effect.effects.FlashEffect;
|
||||
import net.pixvi.common.system.language.lang;
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.center.BagCenter;
|
||||
import net.pixvi.myr.center.EffectCenter;
|
||||
import net.pixvi.myr.center.ShopCenter;
|
||||
import net.pixvi.myr.element.reward.RewardResultVo;
|
||||
import net.pixvi.myr.element.snd.GameSound;
|
||||
import net.pixvi.myr.panel.reward.RewardShowPanel;
|
||||
import net.pixvi.pfw.event.MobiEvent;
|
||||
import net.pixvi.pfw.utils.Caller;
|
||||
import net.pixvi.pfw.utils.Random;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
|
||||
public class RollPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
public static var cur:RollVo;
|
||||
|
||||
public var ui:RollPanelUI = new RollPanelUI();
|
||||
|
||||
public var flag:int = 0;
|
||||
|
||||
private var buffReward:RewardResultVo;
|
||||
|
||||
public function RollPanel(type:String = "", showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
addChild(ui);
|
||||
if(type != "")
|
||||
{
|
||||
cur = new RollVo(type);
|
||||
}
|
||||
super(showTime,hideTime);
|
||||
buffMode = false;
|
||||
}
|
||||
|
||||
override public function init() : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var b:Boolean = false;
|
||||
ui.btn_close.onClick(closeHandler);
|
||||
ui.btn_roll.onClick(rollHandler);
|
||||
PopCenter.getIns().setMaskAlpha();
|
||||
ui.container_img.loadNetBitImg(cur.bgImgSrc,true,false,0);
|
||||
var items:Array = cur.rewardItems;
|
||||
for(i = 0; i < 6; )
|
||||
{
|
||||
if(i < items.length)
|
||||
{
|
||||
ui["item_" + (i + 1)].onItemVo(items[i]);
|
||||
}
|
||||
b = cur.hideItem();
|
||||
if(b)
|
||||
{
|
||||
ui["item_" + (i + 1)].alpha = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
PopCenter.getIns().mask.addEventListener(MobiEvent.CLICK,closeHandler);
|
||||
update();
|
||||
}
|
||||
|
||||
public function update() : void
|
||||
{
|
||||
var leftNum:int = 0;
|
||||
ui.item_cost.onItemVo(cur.needItemVo);
|
||||
var useAble:Boolean = true;
|
||||
var value:Object = cur.itemExchangeVo;
|
||||
if(value.exchangeCondition != null)
|
||||
{
|
||||
if(value.exchangeCondition.exchangeType == "GLOBAL")
|
||||
{
|
||||
ui.text_condition.text = lang("剩余次数:");
|
||||
}
|
||||
else if(value.exchangeCondition.exchangeType == "EVERYDAY")
|
||||
{
|
||||
ui.text_condition.text = lang("每日次数:");
|
||||
}
|
||||
leftNum = ShopCenter.getIns().getExchangeLeftNum(value.id);
|
||||
if(leftNum <= 0)
|
||||
{
|
||||
useAble = false;
|
||||
}
|
||||
ui.text_condition.text += leftNum + "/" + value.exchangeCondition.exchangeNum;
|
||||
ui.text_condition.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.text_condition.visible = false;
|
||||
}
|
||||
if(BagCenter.getIns().getNum(cur.needItemVo.type) < cur.needItemVo.num)
|
||||
{
|
||||
useAble = false;
|
||||
}
|
||||
if(!useAble)
|
||||
{
|
||||
ui.btn_roll.enabled = false;
|
||||
ui.btn_roll.alpha = 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
ui.btn_roll.enabled = true;
|
||||
ui.btn_roll.alpha = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function closeHandler(e:Event = null) : void
|
||||
{
|
||||
this.showOut();
|
||||
}
|
||||
|
||||
public function rollHandler(e:Event = null) : void
|
||||
{
|
||||
PopCenter.getIns().mask.removeEventListener(MobiEvent.CLICK,closeHandler);
|
||||
ShopCenter.getIns().exchangeItem(cur.itemExchangeID,1,startRollShow,false);
|
||||
}
|
||||
|
||||
public function startRollShow(rewardResult:RewardResultVo) : void
|
||||
{
|
||||
var i:int = 0;
|
||||
var item:Object = null;
|
||||
buffReward = rewardResult;
|
||||
flag = -1;
|
||||
var rewardItem:Object = rewardResult.items[0];
|
||||
for(i = 0; i < 6; )
|
||||
{
|
||||
item = ui["item_" + (i + 1)].getItem();
|
||||
if(item != null)
|
||||
{
|
||||
if(item.type == rewardItem.typeId && item.num == rewardItem.num)
|
||||
{
|
||||
flag = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if(flag == -1)
|
||||
{
|
||||
Alert.showMsg("rewardData error:" + cur.id);
|
||||
return;
|
||||
}
|
||||
var rotation:int = 7170 + 60 * flag + Random.integer(15,45);
|
||||
ui.btn_roll.visible = false;
|
||||
ui.btn_close.visible = false;
|
||||
TweenMax.to(ui.mc_arrow,2.5,{
|
||||
"rotation":rotation,
|
||||
"onComplete":rollShowOver
|
||||
});
|
||||
SoundCenter.getIns().play(GameSound.soundName("effect_rollgame"));
|
||||
}
|
||||
|
||||
public function rollShowOver() : void
|
||||
{
|
||||
EffectCenter.open_effect(ui["item_" + (flag + 1)].x + 35,ui["item_" + (flag + 1)].y + 30);
|
||||
new FlashEffect(900,16777215,1).startEffect(ui["item_" + (flag + 1)]);
|
||||
SoundCenter.getIns().play(GameSound.soundName("effect_rollover"));
|
||||
Caller.delayCall(RewardShowPanel.showByVo,300,1,[buffReward,rewardShowOver,true]);
|
||||
}
|
||||
|
||||
public function rewardShowOver() : void
|
||||
{
|
||||
ui.btn_roll.visible = true;
|
||||
ui.btn_close.visible = true;
|
||||
PopCenter.getIns().setMaskAlpha();
|
||||
update();
|
||||
PopCenter.getIns().mask.addEventListener(MobiEvent.CLICK,closeHandler);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.pixvi.myr.panel.rollpanel
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Sprite;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.myr.panel.task.ItemCardUI;
|
||||
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 RollPanelUI extends UIComponent
|
||||
{
|
||||
|
||||
public var item_1:ItemCardUI;
|
||||
|
||||
public var item_2:ItemCardUI;
|
||||
|
||||
public var item_3:ItemCardUI;
|
||||
|
||||
public var item_4:ItemCardUI;
|
||||
|
||||
public var item_5:ItemCardUI;
|
||||
|
||||
public var item_6:ItemCardUI;
|
||||
|
||||
public var item_cost:ItemCardUI;
|
||||
|
||||
public var text_condition:PiBitTextField;
|
||||
|
||||
public var btn_roll:PiLightButton;
|
||||
|
||||
public var btn_close:PiLightButton;
|
||||
|
||||
public var mc_arrow:Sprite;
|
||||
|
||||
public var container_img:PiImgContainer;
|
||||
|
||||
public function RollPanelUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.RollPanelUI");
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
container_img.setSize(689,709);
|
||||
item_cost.modeNeed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
package net.pixvi.myr.panel.rollpanel
|
||||
{
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.center.BagCenter;
|
||||
import net.pixvi.myr.center.Table;
|
||||
import net.pixvi.myr.element.bag.ItemVo;
|
||||
|
||||
public class RollVo
|
||||
{
|
||||
|
||||
public var id:String = "";
|
||||
|
||||
public function RollVo(id:String)
|
||||
{
|
||||
super();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public function get bgImgSrc() : String
|
||||
{
|
||||
return table().bg;
|
||||
}
|
||||
|
||||
public function get rewardItems() : Array
|
||||
{
|
||||
var i:int = 0;
|
||||
var rulestr:String = null;
|
||||
var strs:Array = null;
|
||||
var type:String = null;
|
||||
var num:int = 0;
|
||||
var item:ItemVo = null;
|
||||
var data:Array = itemExchangeVo.reward.rewards[0].items;
|
||||
var items:Array = [];
|
||||
for(i = 0; i < data.length; )
|
||||
{
|
||||
rulestr = data[i].name;
|
||||
strs = rulestr.split(",");
|
||||
type = strs[0];
|
||||
num = int(strs[1]);
|
||||
item = new ItemVo();
|
||||
item.type = int(type);
|
||||
item.num = num;
|
||||
items.push(item);
|
||||
i++;
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
public function get itemExchangeID() : String
|
||||
{
|
||||
return table().itemExchangeID;
|
||||
}
|
||||
|
||||
public function get itemExchangeVo() : Object
|
||||
{
|
||||
if(Table.exchange_info[itemExchangeID] == null)
|
||||
{
|
||||
Alert.showMsg("can\'t find item by id:" + itemExchangeID);
|
||||
}
|
||||
return Table.exchange_info[itemExchangeID];
|
||||
}
|
||||
|
||||
public function get needItemVo() : ItemVo
|
||||
{
|
||||
var needitemvo:Object = itemExchangeVo.need.items[0];
|
||||
var item:ItemVo = new ItemVo();
|
||||
item.num = needitemvo.num;
|
||||
item.type = needitemvo.typeId;
|
||||
return item;
|
||||
}
|
||||
|
||||
public function get hasItemVo() : ItemVo
|
||||
{
|
||||
var needitemvo:Object = itemExchangeVo.need.items[0];
|
||||
var num:int = BagCenter.getIns().getNum(needitemvo.typeId);
|
||||
var item:ItemVo = new ItemVo();
|
||||
item.num = num;
|
||||
item.type = needitemvo.typeId;
|
||||
return item;
|
||||
}
|
||||
|
||||
public function hideItem() : Boolean
|
||||
{
|
||||
if(table().hideItem != null)
|
||||
{
|
||||
return table().hideItem;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function table() : Object
|
||||
{
|
||||
return Table.activity_info.rollGame[id];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user