Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.pfw.ui.containers.PiImgContainer;
|
||||
|
||||
public class AvatarCardUI extends UIComponent
|
||||
{
|
||||
|
||||
public var container_img:PiImgContainer;
|
||||
|
||||
public function AvatarCardUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
container_img.setSize(74,74);
|
||||
}
|
||||
|
||||
public function onData(avatarvo:AvatarVo) : void
|
||||
{
|
||||
container_img.loadNetBitImg(avatarvo.img);
|
||||
}
|
||||
|
||||
public function onDataByAvatarType(type:int) : void
|
||||
{
|
||||
var avatarvo:AvatarVo = new AvatarVo();
|
||||
avatarvo.avatarId = type;
|
||||
onData(avatarvo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
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.Master;
|
||||
import net.pixvi.myr.center.MasterCenter;
|
||||
import net.pixvi.myr.panel.mainmenu.MainMenu;
|
||||
import net.pixvi.pfw.event.MobiEvent;
|
||||
import net.pixvi.pfw.utils.ArrayUtil;
|
||||
import net.pixvi.pfw.utils.broadcast.GlobalBroadcast;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
|
||||
public class AvatarSetPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
public var ui:AvatarSetPanelUI = new AvatarSetPanelUI();
|
||||
|
||||
public function AvatarSetPanel(showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
addChild(ui);
|
||||
super(showTime,hideTime);
|
||||
buffMode = false;
|
||||
ui.btn_close.onClick(closeHandler);
|
||||
ui.btn_save.onClick(saveAvatarHandler);
|
||||
}
|
||||
|
||||
public static function getIns() : AvatarSetPanel
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(AvatarSetPanel) as AvatarSetPanel;
|
||||
}
|
||||
|
||||
override public function init() : void
|
||||
{
|
||||
MasterCenter.getIns().getAvatar(getCompleteHandler);
|
||||
PopCenter.getIns().mask.addEventListener(MobiEvent.CLICK,maskCloseHandler);
|
||||
GlobalBroadcast.addEventListener("androidBack",AndroidBackHandler);
|
||||
}
|
||||
|
||||
private function AndroidBackHandler(e:Event = null) : void
|
||||
{
|
||||
if(PopCenter.getIns().topPanel == this)
|
||||
{
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
public function maskCloseHandler(e:Event = null) : void
|
||||
{
|
||||
if(PopCenter.getInstance().topPanel == this)
|
||||
{
|
||||
closeHandler();
|
||||
}
|
||||
}
|
||||
|
||||
override public function showOut() : void
|
||||
{
|
||||
GlobalBroadcast.removeEventListener("androidBack",AndroidBackHandler);
|
||||
PopCenter.getIns().resetMaskAlpha();
|
||||
PopCenter.getIns().mask.removeEventListener(MobiEvent.CLICK,maskCloseHandler);
|
||||
super.showOut();
|
||||
}
|
||||
|
||||
public function getCompleteHandler(e:Event = null) : void
|
||||
{
|
||||
var curAvatarVo:AvatarVo = new AvatarVo();
|
||||
curAvatarVo.avatarId = Master.avatar;
|
||||
updateCurByAvatarVo(curAvatarVo);
|
||||
var avatars:Array = MasterCenter.getIns().getUseableAvatar();
|
||||
ui.list_avatar.setDatas(avatars);
|
||||
ui.list_avatar.addEventListener("piselect",avatarSelectHandler);
|
||||
var curSelectAvatar:AvatarVo = ArrayUtil.getElementByValue(avatars,"avatarId",Master.avatar) as AvatarVo;
|
||||
ui.list_avatar.selectByData(curSelectAvatar);
|
||||
}
|
||||
|
||||
public function avatarSelectHandler(e:Event = null) : void
|
||||
{
|
||||
}
|
||||
|
||||
public function updateCurByAvatarVo(avatarVo:AvatarVo) : void
|
||||
{
|
||||
ui.ui_avatarCard.onData(avatarVo);
|
||||
}
|
||||
|
||||
public function saveAvatarHandler(e:Event = null) : void
|
||||
{
|
||||
var curSelectAvatar:AvatarVo = ui.list_avatar.curSelectedItemData as AvatarVo;
|
||||
if(curSelectAvatar.avatarId == Master.avatar)
|
||||
{
|
||||
Alert.showMsg(lang("所选头像已经是当前头像了!"));
|
||||
return;
|
||||
}
|
||||
MasterCenter.getIns().setAvatar(curSelectAvatar.avatarId,saveCompleteHandler);
|
||||
}
|
||||
|
||||
public function saveCompleteHandler(e:Event = null) : void
|
||||
{
|
||||
Alert.yes(lang("更换头像"),lang("新的头像已保存!"));
|
||||
updateCurByAvatarVo(ui.list_avatar.curSelectedItemData as AvatarVo);
|
||||
MainMenu.getIns().ui.ui_top.updateAvatar();
|
||||
}
|
||||
|
||||
public function closeHandler(e:Event = null) : void
|
||||
{
|
||||
this.showOut();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.pfw.ui.UIComponent;
|
||||
import net.pixvi.pfw.ui.controls.PiSliderList;
|
||||
import net.pixvi.psg.ui.controller.PiLightButton;
|
||||
|
||||
public class AvatarSetPanelUI extends UIComponent
|
||||
{
|
||||
|
||||
public var btn_close:PiLightButton;
|
||||
|
||||
public var btn_save:PiLightButton;
|
||||
|
||||
public var list_avatar:PiSliderList;
|
||||
|
||||
public var ui_avatarCard:AvatarCardUI;
|
||||
|
||||
public function AvatarSetPanelUI(skin:DisplayObject = null, autoViewSize:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.AvatarSetPanelUI");
|
||||
super(skin,autoViewSize,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
list_avatar.setList(AvatarSliderListItem,10,false,120,5,120);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
import net.pixvi.common.center.SoundCenter;
|
||||
import net.pixvi.common.view.FF;
|
||||
import net.pixvi.myr.element.snd.GameSound;
|
||||
import net.pixvi.pfw.event.MobiEvent;
|
||||
import net.pixvi.pfw.ui.containers.PiImgContainer;
|
||||
import net.pixvi.pfw.ui.controls.PiSliderListItem;
|
||||
|
||||
public class AvatarSliderListItem extends PiSliderListItem
|
||||
{
|
||||
|
||||
public var container_img:PiImgContainer;
|
||||
|
||||
public function AvatarSliderListItem(skin:DisplayObject = null, auto:Boolean = true, w:Number = 50, h:Number = 50)
|
||||
{
|
||||
skin = FF.getMC("ui.AvatarSliderListItemUI");
|
||||
super(skin,auto,w,h);
|
||||
}
|
||||
|
||||
override public function onSkinComplete() : void
|
||||
{
|
||||
container_img.setSize(100,100);
|
||||
this.addEventListener(MobiEvent.CLICK,clickHandler);
|
||||
}
|
||||
|
||||
override public function onData(value:Object) : void
|
||||
{
|
||||
container_img.loadNetBitImg((value as AvatarVo).img);
|
||||
}
|
||||
|
||||
public function clickHandler(e:Event = null) : void
|
||||
{
|
||||
SoundCenter.getIns().play(GameSound.effect_click2);
|
||||
sendSelect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
public class AvatarType
|
||||
{
|
||||
|
||||
public static const FREE:String = "free";
|
||||
|
||||
public static const ACHIVEMENT:String = "achi";
|
||||
|
||||
public static const TASK:String = "task";
|
||||
|
||||
public static const ENTANGLE:String = "entangle";
|
||||
|
||||
public static const SKIN:String = "skin";
|
||||
|
||||
public static const LOCK:String = "lock";
|
||||
|
||||
public function AvatarType()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
package net.pixvi.myr.panel.avatar
|
||||
{
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.GameMath;
|
||||
import net.pixvi.myr.center.AchiCenter;
|
||||
import net.pixvi.myr.center.Master;
|
||||
import net.pixvi.myr.center.MonsterCenter;
|
||||
import net.pixvi.myr.center.Table;
|
||||
import net.pixvi.myr.element.mon.MonsterVo;
|
||||
|
||||
public class AvatarVo
|
||||
{
|
||||
|
||||
public var avatarId:int = 1;
|
||||
|
||||
public function AvatarVo()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function useable() : Boolean
|
||||
{
|
||||
var emon:MonsterVo = null;
|
||||
switch(type)
|
||||
{
|
||||
case "free":
|
||||
return true;
|
||||
case "entangle":
|
||||
emon = MonsterCenter.getIns().getEntangleMonByType(avatarId);
|
||||
if(emon != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case "task":
|
||||
if(Master.history.passTask[task] == true)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case "achi":
|
||||
if(AchiCenter.getIns().checkAchiFinished(int(achi)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case "lock":
|
||||
if(Master.avatars.indexOf(avatarId.toString()) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
case "skin":
|
||||
if(Master.history.unlockSkins.indexOf(avatarId) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
break;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function get type() : String
|
||||
{
|
||||
return table().type;
|
||||
}
|
||||
|
||||
public function get task() : String
|
||||
{
|
||||
return table().task;
|
||||
}
|
||||
|
||||
public function get achi() : String
|
||||
{
|
||||
return table().achi;
|
||||
}
|
||||
|
||||
public function get img() : String
|
||||
{
|
||||
if(type == "entangle")
|
||||
{
|
||||
return "data/img/monster/a/" + avatarId.toString() + "_a_0.png";
|
||||
}
|
||||
return table().img;
|
||||
}
|
||||
|
||||
public function table() : Object
|
||||
{
|
||||
if(GameMath.ModeTrace)
|
||||
{
|
||||
if(Table.avatar_info[avatarId] == null)
|
||||
{
|
||||
Alert.showMsg("找不到头像[" + avatarId + "],检查魔物是否hide。");
|
||||
}
|
||||
}
|
||||
return Table.avatar_info[avatarId];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user