Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
package net.pixvi.myr.net
|
||||
{
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
|
||||
public class NetTask
|
||||
{
|
||||
|
||||
private static const GET_TASK:String = "taskService/taskReceive";
|
||||
|
||||
private static const FINISH_STEP:String = "taskService/taskCompleteStep";
|
||||
|
||||
private static const FINISH_TASK:String = "taskService/taskComplete";
|
||||
|
||||
private static const RESET_LOOPTASK:String = "taskService/taskLoopFlush";
|
||||
|
||||
private static const GET_LOOPTASK:String = "taskService/taskLoopReceive";
|
||||
|
||||
private static const TASK_UPDATE:String = "taskService/taskUpdate";
|
||||
|
||||
private var onGetTaskComplete:Function;
|
||||
|
||||
private var onFinishStepComplete:Function;
|
||||
|
||||
private var onFinishTaskComplete:Function;
|
||||
|
||||
private var onResetLoopTaskComplete:Function;
|
||||
|
||||
private var onGetLoopTaskComplete:Function;
|
||||
|
||||
private var onUpdateTaskComplete:Function;
|
||||
|
||||
public function NetTask()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getIns() : NetTask
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(NetTask) as NetTask;
|
||||
}
|
||||
|
||||
public function getTask(taskTypeId:String, onComplete:Function) : void
|
||||
{
|
||||
onGetTaskComplete = onComplete;
|
||||
var para:Object = {"taskTypeId":taskTypeId};
|
||||
NetCenter.getIns().send("taskService/taskReceive",para,getTaskHandler);
|
||||
}
|
||||
|
||||
private function getTaskHandler(re:Object) : void
|
||||
{
|
||||
if(onGetTaskComplete != null)
|
||||
{
|
||||
onGetTaskComplete(re.task);
|
||||
onGetTaskComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function finishStep(taskId:int, taskTypeId:String, removeIds:Array, battleData:Object, onComplete:Function) : void
|
||||
{
|
||||
onFinishStepComplete = onComplete;
|
||||
var para:Object = {
|
||||
"taskId":taskId,
|
||||
"removeIds":removeIds,
|
||||
"taskTypeId":taskTypeId
|
||||
};
|
||||
if(battleData != null)
|
||||
{
|
||||
para.battleData = battleData;
|
||||
}
|
||||
NetCenter.getIns().send("taskService/taskCompleteStep",para,finishStepHandler);
|
||||
}
|
||||
|
||||
private function finishStepHandler(re:Object) : void
|
||||
{
|
||||
var rewardData:Object = re.reward;
|
||||
if(re.stageReward != null)
|
||||
{
|
||||
rewardData = re.stageReward;
|
||||
}
|
||||
if(onFinishStepComplete != null)
|
||||
{
|
||||
onFinishStepComplete(rewardData,re);
|
||||
onFinishStepComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function finishTask(taskId:int, taskTypeId:String, onComplete:Function) : void
|
||||
{
|
||||
onFinishTaskComplete = onComplete;
|
||||
var para:Object = {
|
||||
"taskId":taskId,
|
||||
"taskTypeId":taskTypeId
|
||||
};
|
||||
NetCenter.getIns().send("taskService/taskComplete",para,finishTaskHandler);
|
||||
}
|
||||
|
||||
private function finishTaskHandler(re:Object) : void
|
||||
{
|
||||
if(onFinishTaskComplete != null)
|
||||
{
|
||||
onFinishTaskComplete(re.reward,re.nextTasks,re.unlockTasks,re.unlockStages);
|
||||
onFinishTaskComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function resetLoopTask(onComplete:Function) : void
|
||||
{
|
||||
onResetLoopTaskComplete = onComplete;
|
||||
var para:Object = {};
|
||||
NetCenter.getIns().send("taskService/taskLoopFlush",para,resetLoopTaskHandler);
|
||||
}
|
||||
|
||||
private function resetLoopTaskHandler(re:Object) : void
|
||||
{
|
||||
if(onResetLoopTaskComplete != null)
|
||||
{
|
||||
onResetLoopTaskComplete(re.loopTask);
|
||||
onResetLoopTaskComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getLoopTask(taskTypeId:String, city:int, onComplete:Function) : void
|
||||
{
|
||||
onGetLoopTaskComplete = onComplete;
|
||||
var para:Object = {
|
||||
"taskTypeId":taskTypeId,
|
||||
"city":city
|
||||
};
|
||||
NetCenter.getIns().send("taskService/taskLoopReceive",para,getLoopTaskHandler);
|
||||
}
|
||||
|
||||
private function getLoopTaskHandler(re:Object) : void
|
||||
{
|
||||
if(onGetLoopTaskComplete != null)
|
||||
{
|
||||
onGetLoopTaskComplete(re.task);
|
||||
onGetLoopTaskComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function updateTask(unlockTasks:Array, receiveTasks:Array, removeTasks:Array, onComplete:Function) : void
|
||||
{
|
||||
onUpdateTaskComplete = onComplete;
|
||||
var para:Object = {
|
||||
"unlockTasks":unlockTasks,
|
||||
"receiveTasks":receiveTasks,
|
||||
"removeTasks":removeTasks
|
||||
};
|
||||
NetCenter.getIns().send("taskService/taskUpdate",para,updateTaskHandler,false);
|
||||
}
|
||||
|
||||
private function updateTaskHandler(re:Object) : void
|
||||
{
|
||||
if(onUpdateTaskComplete != null)
|
||||
{
|
||||
onUpdateTaskComplete(re.unlockTasks,re.receiveTasks);
|
||||
onUpdateTaskComplete = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user