121 lines
3.6 KiB
ActionScript
121 lines
3.6 KiB
ActionScript
package net.pixvi.myr.center
|
|
{
|
|
import net.pixvi.myr.element.npc.PositionNPC;
|
|
import net.pixvi.myr.element.randomevent.RandomEventVo;
|
|
import net.pixvi.myr.element.task.TaskVo;
|
|
import net.pixvi.myr.event.MYREvent;
|
|
import net.pixvi.myr.panel.mainmenu.MainMenu;
|
|
import net.pixvi.myr.panel.randomevent.FarmEventImgPanel;
|
|
import net.pixvi.myr.panel.randomevent.FarmEventStoryPanel;
|
|
import net.pixvi.myr.panel.story.StoryPanel;
|
|
import net.pixvi.myr.panel.taskstartpanel.TaskStartPanel;
|
|
import net.pixvi.pfw.utils.core.Singleton;
|
|
import net.pixvi.psg.ui.PSGPopPanel;
|
|
|
|
public class PosCenter extends Singleton
|
|
{
|
|
|
|
public var curPos:String;
|
|
|
|
public function PosCenter()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function activity(pos:String) : void
|
|
{
|
|
getIns().activity(pos);
|
|
String(123);
|
|
}
|
|
|
|
public static function getIns() : PosCenter
|
|
{
|
|
return Singleton.getInstanceOrCreate(PosCenter) as PosCenter;
|
|
}
|
|
|
|
public function activity(pos:String) : void
|
|
{
|
|
curPos = pos;
|
|
update();
|
|
}
|
|
|
|
public function update() : void
|
|
{
|
|
var task:TaskVo = null;
|
|
var i:int = 0;
|
|
var event:RandomEventVo = null;
|
|
var npcList:Array = [];
|
|
var tasks:Array = Master.tasks;
|
|
for(i = 0; i < tasks.length; )
|
|
{
|
|
task = tasks[i];
|
|
if(!task.canFinish() && task.stepVo != null && task.stepVo.hasTalk(curPos) && task.stepVo.canShow() && task.closed != true)
|
|
{
|
|
if(task.stepVo.auto)
|
|
{
|
|
if(!TaskStartPanel.getIns().showing)
|
|
{
|
|
talkHandler(new MYREvent(MYREvent.TALK,task));
|
|
}
|
|
break;
|
|
}
|
|
npcList.push(task);
|
|
}
|
|
i++;
|
|
}
|
|
if(Master.history.openRandomEvent && RandomEventCenter.getIns().atLeastRefreshOnce)
|
|
{
|
|
for each(var eventTypeId:String in Master.randomEvent)
|
|
{
|
|
event = new RandomEventVo();
|
|
event.typeId = eventTypeId;
|
|
if(event.hasTalk(curPos))
|
|
{
|
|
npcList.push(event);
|
|
}
|
|
}
|
|
}
|
|
for each(var posnpc:PositionNPC in Table.npc_position)
|
|
{
|
|
if(posnpc.position == curPos && posnpc.condition.check() && posnpc.random >= Math.random())
|
|
{
|
|
npcList.push(posnpc);
|
|
}
|
|
}
|
|
MainMenu.getIns().ui.list_npc.setDatas(npcList);
|
|
MainMenu.getIns().ui.list_npc.addEventListener(MYREvent.TALK,talkHandler);
|
|
MainMenu.getIns().ui.npcListReshow();
|
|
}
|
|
|
|
public function talkHandler(e:MYREvent = null) : void
|
|
{
|
|
var p:PSGPopPanel = null;
|
|
var event:RandomEventVo = null;
|
|
var posnpc:PositionNPC = null;
|
|
if(e.data is TaskVo)
|
|
{
|
|
p = MainMenu.getIns().curPanel;
|
|
TaskStartPanel.getIns().start(e.data as TaskVo,p);
|
|
}
|
|
else if(e.data is RandomEventVo)
|
|
{
|
|
event = e.data as RandomEventVo;
|
|
if(event.hasPositionStory)
|
|
{
|
|
FarmEventStoryPanel.getIns().startEvent(event,MainMenu.getIns().curPanel);
|
|
}
|
|
else
|
|
{
|
|
FarmEventImgPanel.getIns().popIn();
|
|
}
|
|
}
|
|
else if(e.data is PositionNPC)
|
|
{
|
|
posnpc = e.data as PositionNPC;
|
|
StoryPanel.getIns().start(posnpc.getStory());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|