64 lines
1.8 KiB
ActionScript
64 lines
1.8 KiB
ActionScript
package net.pixvi.myr.net
|
|
{
|
|
import net.pixvi.pfw.utils.core.Singleton;
|
|
|
|
public class NetRandomEvent
|
|
{
|
|
|
|
public static const GET_FARMEVENT:String = "gameEventService/getFarmEvent";
|
|
|
|
public static const FINISH_FARMEVENT:String = "gameEventService/finishFarmEvent";
|
|
|
|
private var onGetFarmEventComplete:Function;
|
|
|
|
private var onFinishFarmEventComplete:Function;
|
|
|
|
public function NetRandomEvent()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function getIns() : NetRandomEvent
|
|
{
|
|
return Singleton.getInstanceOrCreate(NetRandomEvent) as NetRandomEvent;
|
|
}
|
|
|
|
public function getFarmEvent(onComplete:Function) : void
|
|
{
|
|
onGetFarmEventComplete = onComplete;
|
|
var para:Object = {};
|
|
NetCenter.getIns().send("gameEventService/getFarmEvent",para,getFarmEventHandler);
|
|
}
|
|
|
|
private function getFarmEventHandler(re:Object) : void
|
|
{
|
|
if(onGetFarmEventComplete != null)
|
|
{
|
|
onGetFarmEventComplete(re.triggerEvent,re.currentTime,re.typeId,re.masterEventTimer);
|
|
onGetFarmEventComplete = null;
|
|
}
|
|
}
|
|
|
|
public function finishFarmEvent(onComplete:Function) : void
|
|
{
|
|
onFinishFarmEventComplete = onComplete;
|
|
var para:Object = {};
|
|
NetCenter.getIns().send("gameEventService/finishFarmEvent",para,finishFarmEventHandler);
|
|
}
|
|
|
|
private function finishFarmEventHandler(re:Object) : void
|
|
{
|
|
if(onFinishFarmEventComplete != null)
|
|
{
|
|
if(re.getTasks == null)
|
|
{
|
|
re.getTasks = [];
|
|
}
|
|
onFinishFarmEventComplete(re.result,re.getTasks,re.unlockTasks);
|
|
onFinishFarmEventComplete = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|