Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,381 @@
|
||||
package net.pixvi.myr.panel.taskstartpanel
|
||||
{
|
||||
import flash.events.Event;
|
||||
import net.gaooo.nano.center.GAoNano;
|
||||
import net.pixvi.common.center.SoundCenter;
|
||||
import net.pixvi.common.system.language.lang;
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.center.BattleCenter;
|
||||
import net.pixvi.myr.center.Master;
|
||||
import net.pixvi.myr.center.MonsterCenter;
|
||||
import net.pixvi.myr.center.RewardCenter;
|
||||
import net.pixvi.myr.center.StageCenter;
|
||||
import net.pixvi.myr.center.TaskCenter;
|
||||
import net.pixvi.myr.center.TeamCenter;
|
||||
import net.pixvi.myr.element.battle.BattleData;
|
||||
import net.pixvi.myr.element.battle.BattlePosition;
|
||||
import net.pixvi.myr.element.battle.BattleType;
|
||||
import net.pixvi.myr.element.reward.RewardResultVo;
|
||||
import net.pixvi.myr.element.snd.GameSound;
|
||||
import net.pixvi.myr.element.task.TaskStatusType;
|
||||
import net.pixvi.myr.element.task.TaskStepVo;
|
||||
import net.pixvi.myr.element.task.TaskType;
|
||||
import net.pixvi.myr.element.task.TaskVo;
|
||||
import net.pixvi.myr.net.NetBattle;
|
||||
import net.pixvi.myr.net.NetTask;
|
||||
import net.pixvi.myr.panel.battle.BattlePanel;
|
||||
import net.pixvi.myr.panel.reward.RewardShowPanel;
|
||||
import net.pixvi.myr.panel.story.StoryPanel;
|
||||
import net.pixvi.pfw.event.PiEvent;
|
||||
import net.pixvi.pfw.utils.Caller;
|
||||
import net.pixvi.pfw.utils.Oncer;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.psg.ui.PSGPopPanel;
|
||||
import net.pixvi.psg.utils.Blacker;
|
||||
|
||||
public class TaskStartPanel extends PSGPopPanel
|
||||
{
|
||||
|
||||
public var curTask:TaskVo;
|
||||
|
||||
public var curStep:TaskStepVo;
|
||||
|
||||
public var endPanel:PSGPopPanel;
|
||||
|
||||
public var curPanel:PSGPopPanel;
|
||||
|
||||
public var startStepAnswer:Boolean = false;
|
||||
|
||||
public var stepAnswer:Boolean = true;
|
||||
|
||||
public var rewardResult:RewardResultVo;
|
||||
|
||||
private var battleOver:Boolean = false;
|
||||
|
||||
private var transparentMode:Boolean = false;
|
||||
|
||||
public function TaskStartPanel(showTime:Number = -1, hideTime:Number = -1)
|
||||
{
|
||||
super(showTime,hideTime);
|
||||
}
|
||||
|
||||
public static function getIns() : TaskStartPanel
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(TaskStartPanel) as TaskStartPanel;
|
||||
}
|
||||
|
||||
public function start(task:TaskVo, curPanel:PSGPopPanel = null, startStepDefaultAnswer:Boolean = false) : void
|
||||
{
|
||||
var monTypeId:int = 0;
|
||||
startStepAnswer = startStepDefaultAnswer;
|
||||
stepAnswer = true;
|
||||
this.curPanel = curPanel;
|
||||
this.curTask = task;
|
||||
this.curStep = task.stepVo;
|
||||
if(curTask.type == TaskType.ENTANGLE_TASK)
|
||||
{
|
||||
monTypeId = int(curTask.typeId.substr(1,7));
|
||||
if(MonsterCenter.getIns().getEntangleMonByType(monTypeId) != null)
|
||||
{
|
||||
GAoNano.getIns().para["monName"] = MonsterCenter.getIns().getEntangleMonByType(monTypeId).shortName;
|
||||
}
|
||||
}
|
||||
if(curStep.story != null && curStep.story != "")
|
||||
{
|
||||
transparentMode = GAoNano.getIns().getScriptPara(curStep.story).transparent;
|
||||
}
|
||||
if(!transparentMode)
|
||||
{
|
||||
Blacker.getIns().show(startComplete);
|
||||
}
|
||||
else
|
||||
{
|
||||
startComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private function startComplete() : void
|
||||
{
|
||||
if(curPanel != null && !transparentMode)
|
||||
{
|
||||
curPanel.showOut();
|
||||
}
|
||||
this.popIn();
|
||||
checkTask();
|
||||
}
|
||||
|
||||
private function checkTask() : void
|
||||
{
|
||||
if(!curTask.recieved)
|
||||
{
|
||||
GAoNano.getIns().stage.addEventListener("GAoEvent",gaoEventHandler);
|
||||
}
|
||||
if(!TaskStatusType.isNone(curTask.stepVo.statusType))
|
||||
{
|
||||
if(curTask.stepVo.isStatusComplete())
|
||||
{
|
||||
step2();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(curTask.stepVo.story == "")
|
||||
{
|
||||
step2();
|
||||
return;
|
||||
}
|
||||
step1();
|
||||
}
|
||||
|
||||
private function step1() : void
|
||||
{
|
||||
if(!curTask.recieved)
|
||||
{
|
||||
GAoNano.getIns().stage.addEventListener("GAoEvent",gaoEventHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!TaskStatusType.isNone(curTask.stepVo.statusType))
|
||||
{
|
||||
if(curTask.stepVo.isStatusComplete())
|
||||
{
|
||||
step2();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(curTask.stepVo.story == "")
|
||||
{
|
||||
step2();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!transparentMode)
|
||||
{
|
||||
Blacker.getIns().hide();
|
||||
}
|
||||
StoryPanel.getIns().start(curTask.stepVo.story,step1StartComplete,null,false);
|
||||
}
|
||||
|
||||
public function gaoEventHandler(e:PiEvent = null) : void
|
||||
{
|
||||
if(e.data != null && e.data.indexOf("true") == 0)
|
||||
{
|
||||
startStepAnswer = true;
|
||||
if(!curTask.stepVo.isStartStep)
|
||||
{
|
||||
stepAnswer = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startStepAnswer = false;
|
||||
if(!curTask.stepVo.isStartStep)
|
||||
{
|
||||
stepAnswer = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function step1StartComplete(e:Event = null) : void
|
||||
{
|
||||
if(!transparentMode)
|
||||
{
|
||||
Blacker.getIns().show(step1Complete);
|
||||
}
|
||||
else
|
||||
{
|
||||
step1Complete();
|
||||
}
|
||||
}
|
||||
|
||||
private function step1Complete() : void
|
||||
{
|
||||
StoryPanel.getIns().endOut();
|
||||
if(curTask.stepVo.isStartStep)
|
||||
{
|
||||
if(startStepAnswer)
|
||||
{
|
||||
TaskCenter.getIns().receiveTask(curTask.typeId,true,stepShowOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
stepShowOut();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if(curTask.stepVo.isStatusComplete() && stepAnswer == true)
|
||||
{
|
||||
step2();
|
||||
}
|
||||
else
|
||||
{
|
||||
stepShowOut();
|
||||
}
|
||||
}
|
||||
|
||||
private function step2(e:Event = null) : void
|
||||
{
|
||||
if(curTask.stepVo.hasBattle())
|
||||
{
|
||||
if(TeamCenter.getIns().checkTeamVail(Master.curBattleTeam))
|
||||
{
|
||||
startTaskBattle();
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Blacker.getIns().showing)
|
||||
{
|
||||
Blacker.getIns().hide();
|
||||
}
|
||||
Alert.yes(lang("提示"),lang("当前选择的队伍无法参加战斗!"),stepShowOut);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
finishStep();
|
||||
}
|
||||
}
|
||||
|
||||
private function finishStep() : void
|
||||
{
|
||||
TaskCenter.getIns().finishStep(curTask,false,finishStepHandler);
|
||||
}
|
||||
|
||||
private function finishStepHandler(rewardResult:RewardResultVo) : void
|
||||
{
|
||||
this.rewardResult = rewardResult;
|
||||
step3();
|
||||
}
|
||||
|
||||
private function startTaskBattle() : void
|
||||
{
|
||||
NetBattle.getIns().startBattle(BattleType.TASK_BATTLE,curTask.typeId,null,startTaskBattleHandler);
|
||||
}
|
||||
|
||||
private function startTaskBattleHandler() : void
|
||||
{
|
||||
var pos:BattlePosition = new BattlePosition();
|
||||
pos.battleType = BattleType.TASK_BATTLE;
|
||||
pos.taskTypeId = curTask.typeId;
|
||||
pos.taskStep = curTask.step;
|
||||
BattleCenter.getIns().startBattle(pos,curTask.stepVo.battle,curTask.stepVo.reward,step2Complete);
|
||||
Caller.delayCall(Blacker.getIns().hide,600,1,[BattlePanel.getIns().battleStartReady]);
|
||||
BattlePanel.getIns().onWinCallBack = step2Win;
|
||||
BattlePanel.getIns().onLoseCallBack = null;
|
||||
}
|
||||
|
||||
private function step2Win(battleData:BattleData) : void
|
||||
{
|
||||
NetTask.getIns().finishStep(curTask.id,curTask.typeId,null,battleData.getObj(),step2WinHandler);
|
||||
}
|
||||
|
||||
private function step2WinHandler(rewardData:Object, re:Object) : void
|
||||
{
|
||||
var rewardResult:RewardResultVo = null;
|
||||
var costTi:int = int(re.costTi);
|
||||
var unlockStage:Array = re.unlockStage;
|
||||
var lockStage:Array = re.lockStage;
|
||||
if(rewardData != null)
|
||||
{
|
||||
rewardResult = RewardCenter.getRewardResultVoByData(rewardData);
|
||||
}
|
||||
BattlePanel.getIns().showWin(rewardResult,re.monsterExpInfos);
|
||||
var stageo:Object = curTask.stepVo.isStageBattle();
|
||||
if(stageo != false)
|
||||
{
|
||||
StageCenter.getIns().passLocalStage(stageo.stageid,stageo.level,costTi,unlockStage,lockStage);
|
||||
}
|
||||
}
|
||||
|
||||
private function step2Complete(win:Boolean) : void
|
||||
{
|
||||
if(curStep.afterStory != null && curStep.afterStory != "" && GAoNano.getIns().getScriptPara(curStep.afterStory) == null)
|
||||
{
|
||||
Alert.yes("Error","Undefined Script:" + curStep.afterStory);
|
||||
}
|
||||
else if(!win || curStep.afterStory == "" || !GAoNano.getIns().getScriptPara(curStep.afterStory).stopBgm)
|
||||
{
|
||||
SoundCenter.getIns().bgmPlay(GameSound.bgm_farm);
|
||||
}
|
||||
if(win)
|
||||
{
|
||||
step3();
|
||||
}
|
||||
else
|
||||
{
|
||||
stepShowOut();
|
||||
}
|
||||
}
|
||||
|
||||
private function step3() : void
|
||||
{
|
||||
if(curStep.afterStory == "")
|
||||
{
|
||||
stepPassEnd();
|
||||
return;
|
||||
}
|
||||
StoryPanel.getIns().start(curStep.afterStory,step3StartComplete,null,false);
|
||||
if(Blacker.getIns().showing)
|
||||
{
|
||||
Blacker.getIns().hide();
|
||||
}
|
||||
}
|
||||
|
||||
private function step3StartComplete(e:Event = null) : void
|
||||
{
|
||||
if(!transparentMode)
|
||||
{
|
||||
step3Complete();
|
||||
}
|
||||
else
|
||||
{
|
||||
Blacker.getIns().show(step3Complete);
|
||||
}
|
||||
}
|
||||
|
||||
private function step3Complete() : void
|
||||
{
|
||||
StoryPanel.getIns().endOut();
|
||||
stepPassEnd();
|
||||
}
|
||||
|
||||
private function stepPassEnd() : void
|
||||
{
|
||||
TaskCenter.getIns().completeLocalStep(curTask);
|
||||
stepShowOut();
|
||||
}
|
||||
|
||||
private function stepShowOut() : void
|
||||
{
|
||||
GAoNano.getIns().stage.removeEventListener("GAoEvent",gaoEventHandler);
|
||||
if(curTask.typeId == "1001006" && curTask.step == 4)
|
||||
{
|
||||
rewardResult = null;
|
||||
}
|
||||
if(rewardResult != null)
|
||||
{
|
||||
Oncer.lastRun(RewardShowPanel.show,[rewardResult.getRewardShowArray()]);
|
||||
rewardResult = null;
|
||||
}
|
||||
SoundCenter.getIns().bgmPlay(GameSound.bgm_farm);
|
||||
this.showOut();
|
||||
if(!transparentMode)
|
||||
{
|
||||
if(endPanel != null)
|
||||
{
|
||||
endPanel.popInWith(this);
|
||||
}
|
||||
else if(curPanel != null)
|
||||
{
|
||||
curPanel.popInWith(this);
|
||||
}
|
||||
}
|
||||
curPanel = null;
|
||||
endPanel = null;
|
||||
if(!transparentMode)
|
||||
{
|
||||
Blacker.getIns().hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user