Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,396 @@
|
||||
package net.pixvi.myr.center
|
||||
{
|
||||
import net.pixvi.common.system.language.lang;
|
||||
import net.pixvi.common.utils.Alert;
|
||||
import net.pixvi.myr.GameMath;
|
||||
import net.pixvi.myr.element.battle.BattleMonVo;
|
||||
import net.pixvi.myr.element.battle.BattleTeamVo;
|
||||
import net.pixvi.myr.element.mon.MonsterVo;
|
||||
import net.pixvi.myr.element.team.TeamPositionVo;
|
||||
import net.pixvi.myr.element.team.TeamVo;
|
||||
import net.pixvi.myr.event.MYREvent;
|
||||
import net.pixvi.myr.net.NetTeam;
|
||||
import net.pixvi.pfw.utils.broadcast.GlobalBroadcast;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
|
||||
public class TeamCenter extends Singleton
|
||||
{
|
||||
|
||||
private var onMonOnComplete:Function;
|
||||
|
||||
private var monOn_para:Object;
|
||||
|
||||
private var onMonOffComplete:Function;
|
||||
|
||||
private var monOff_para:Object;
|
||||
|
||||
public var teamPos2battleTeamPos:Object = {
|
||||
"0":"1",
|
||||
"1":"4",
|
||||
"2":"2",
|
||||
"3":"5",
|
||||
"4":"6",
|
||||
"5":"7",
|
||||
"6":"8",
|
||||
"7":"9"
|
||||
};
|
||||
|
||||
public var checkTeamVailType:int = 0;
|
||||
|
||||
public function TeamCenter()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getIns() : TeamCenter
|
||||
{
|
||||
return Singleton.getInstanceOrCreate(TeamCenter) as TeamCenter;
|
||||
}
|
||||
|
||||
public static function getTeamVoByData(data:Object) : TeamVo
|
||||
{
|
||||
var i:int = 0;
|
||||
var team:TeamVo = new TeamVo();
|
||||
team.teamType = data.teamType;
|
||||
team.teamName = data.teamName;
|
||||
team.monsters = [];
|
||||
for(i = 0; i < data.monsters.length; )
|
||||
{
|
||||
if(Table.team_info[data.teamType][i] != null)
|
||||
{
|
||||
team.monsters.push(data.monsters[i]);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return team;
|
||||
}
|
||||
|
||||
public function startUp() : void
|
||||
{
|
||||
}
|
||||
|
||||
public function getTeamPositionArr(teamName:String) : Array
|
||||
{
|
||||
var i:int = 0;
|
||||
var vo:TeamPositionVo = null;
|
||||
var arr:Array = [];
|
||||
var team:TeamVo = getTeamByTeamName(teamName);
|
||||
for(i = 0; i < team.monsters.length; )
|
||||
{
|
||||
vo = new TeamPositionVo();
|
||||
vo.team = team;
|
||||
vo.position = i;
|
||||
arr.push(vo);
|
||||
i++;
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public function getTeamByTeamName(name:String) : TeamVo
|
||||
{
|
||||
var getteam:TeamVo = null;
|
||||
for each(var teamvo:TeamVo in Master.teams)
|
||||
{
|
||||
if(teamvo.teamName == name)
|
||||
{
|
||||
getteam = teamvo;
|
||||
}
|
||||
}
|
||||
if(getteam == null)
|
||||
{
|
||||
getteam = new TeamVo();
|
||||
getteam.teamType = "pveBattleTeam";
|
||||
getteam.teamName = name;
|
||||
getteam.monsters = [0,0,0,0,0,0,0,0,0];
|
||||
Master.teams.push(getteam);
|
||||
}
|
||||
return getteam;
|
||||
}
|
||||
|
||||
public function getTeamByTeamType(teamType:String = "battleTeam") : TeamVo
|
||||
{
|
||||
for each(var teamvo:TeamVo in Master.teams)
|
||||
{
|
||||
if(teamvo.teamType == teamType)
|
||||
{
|
||||
return teamvo;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function monOn(teamName:String, position:int, mid:Number, onComplete:Function) : void
|
||||
{
|
||||
onMonOnComplete = onComplete;
|
||||
monOn_para = {
|
||||
"teamName":teamName,
|
||||
"position":position,
|
||||
"mid":mid
|
||||
};
|
||||
NetTeam.getIns().monOn(mid,teamName,position,monOnHandler);
|
||||
}
|
||||
|
||||
private function monOnHandler(re:Object = null) : void
|
||||
{
|
||||
var offMon:MonsterVo = null;
|
||||
var team:TeamVo = getTeamByTeamName(monOn_para.teamName);
|
||||
if(team.monsters[monOn_para.position] > 0)
|
||||
{
|
||||
offMon = MonsterCenter.getIns().getMonById(team.monsters[monOn_para.position]);
|
||||
}
|
||||
team.monsters[monOn_para.position] = monOn_para.mid;
|
||||
if(offMon != null)
|
||||
{
|
||||
GlobalBroadcast.dispatchEvent(new MYREvent(MYREvent.MONSTER_REMOVE_TEAM,{"mid":offMon.id}));
|
||||
offMon = null;
|
||||
}
|
||||
GlobalBroadcast.dispatchEvent(new MYREvent(MYREvent.MONSTER_ADD_FIGHTSTACK,{"mid":monOn_para.mid}));
|
||||
if(onMonOnComplete != null)
|
||||
{
|
||||
onMonOnComplete();
|
||||
onMonOnComplete = null;
|
||||
}
|
||||
monOn_para = null;
|
||||
}
|
||||
|
||||
public function checkMonsterInTeam(monId:Number) : Boolean
|
||||
{
|
||||
for each(var t:TeamVo in Master.teams)
|
||||
{
|
||||
if(t.monsters.indexOf(monId) != -1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getAllTeamMonsterId() : Array
|
||||
{
|
||||
var arr:Array = [];
|
||||
for each(var t:TeamVo in Master.teams)
|
||||
{
|
||||
arr = arr.concat(t.monsters);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
public function monOff(teamname:String = "", position:int = 1, onComplete:Function = null) : void
|
||||
{
|
||||
onMonOffComplete = onComplete;
|
||||
monOff_para = {
|
||||
"teamname":teamname,
|
||||
"position":position
|
||||
};
|
||||
NetTeam.getIns().monOff(teamname,position,monOffHandler);
|
||||
}
|
||||
|
||||
private function monOffHandler(re:Object = null) : void
|
||||
{
|
||||
var teamVo:TeamVo = getTeamByTeamName(monOff_para.teamname);
|
||||
GlobalBroadcast.dispatchEvent(new MYREvent(MYREvent.MONSTER_REMOVE_TEAM,{"mid":teamVo.monsters[monOff_para.position]}));
|
||||
teamVo.monsters[monOff_para.position] = 0;
|
||||
monOff_para = null;
|
||||
if(onMonOffComplete != null)
|
||||
{
|
||||
onMonOffComplete();
|
||||
onMonOffComplete = null;
|
||||
}
|
||||
}
|
||||
|
||||
public function getBattleTeamVo(choseTeamName:String = "") : BattleTeamVo
|
||||
{
|
||||
var i:int = 0;
|
||||
var m:BattleMonVo = null;
|
||||
if(choseTeamName == "")
|
||||
{
|
||||
choseTeamName = (Master.teams[0] as TeamVo).teamName;
|
||||
}
|
||||
var teamVo:TeamVo = getTeamByTeamName(choseTeamName);
|
||||
var battleTeamVo:BattleTeamVo = new BattleTeamVo();
|
||||
battleTeamVo.ap = Master.ap;
|
||||
battleTeamVo.apMax = battleTeamVo.ap;
|
||||
battleTeamVo.numMax = TeamCenter.getIns().fightMonsterNum;
|
||||
battleTeamVo.team = 1;
|
||||
battleTeamVo.name = Master.name;
|
||||
for(i = 0; i < teamVo.monsters.length; )
|
||||
{
|
||||
if(teamVo.monsters[i] > 0)
|
||||
{
|
||||
m = MonsterCenter.getIns().getBattleMonVoByMid(teamVo.monsters[i]);
|
||||
if(m != null)
|
||||
{
|
||||
m.team = 1;
|
||||
m.from = "master";
|
||||
m.apRecovery = true;
|
||||
battleTeamVo.mons.push(m);
|
||||
m.teamPos = teamPos2battleTeamPos[i];
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return battleTeamVo;
|
||||
}
|
||||
|
||||
public function checkTeamLegal(teamName:String, show:Boolean = false) : Object
|
||||
{
|
||||
var illegal:Array = null;
|
||||
var team:TeamVo = null;
|
||||
var mons:Array = null;
|
||||
var max:int = 0;
|
||||
var cur:int = 0;
|
||||
if(Table.team_info.teamMonTypes[teamName] != null)
|
||||
{
|
||||
illegal = [];
|
||||
team = TeamCenter.getIns().getTeamByTeamName(teamName);
|
||||
mons = MonsterCenter.getIns().getMonByIds(team.monsters);
|
||||
for each(var mon:MonsterVo in mons)
|
||||
{
|
||||
if(Table.team_info.teamMonTypes[teamName].indexOf(mon.type) == -1)
|
||||
{
|
||||
illegal.push(mon);
|
||||
}
|
||||
}
|
||||
if(illegal.length > 0)
|
||||
{
|
||||
if(show)
|
||||
{
|
||||
Alert.showMsg(lang("队伍中有不符合类型规定的魔物。"));
|
||||
}
|
||||
return illegal;
|
||||
}
|
||||
}
|
||||
if(Table.team_info.teamStar[teamName] != null)
|
||||
{
|
||||
max = int(Table.team_info.teamStar[teamName]);
|
||||
cur = TeamCenter.getIns().getTeamAllStar(teamName);
|
||||
if(max != 0 && cur > max)
|
||||
{
|
||||
Alert.showMsg(lang("队伍中的魔物星级总数已超出规定。"));
|
||||
return cur - max;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getTeamAllStar(teamName:String) : int
|
||||
{
|
||||
var i:int = 0;
|
||||
var m:MonsterVo = null;
|
||||
var count:int = 0;
|
||||
var teamVo:TeamVo = getTeamByTeamName(teamName);
|
||||
for(i = 0; i < teamVo.monsters.length; )
|
||||
{
|
||||
if(teamVo.monsters[i] > 0)
|
||||
{
|
||||
m = MonsterCenter.getIns().getMonById(teamVo.monsters[i]);
|
||||
count += m.star;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
public function checkTeamVail(teamName:String = "", show:Boolean = false) : Boolean
|
||||
{
|
||||
var teamvo:TeamVo = null;
|
||||
var mon:MonsterVo = null;
|
||||
teamvo = getTeamByTeamName(teamName);
|
||||
var num:int = 0;
|
||||
for each(var s:int in teamvo.monsters)
|
||||
{
|
||||
if(s > 0)
|
||||
{
|
||||
mon = MonsterCenter.getIns().getMonById(s);
|
||||
if(mon.inExploreTeam)
|
||||
{
|
||||
checkTeamVailType = 1;
|
||||
if(show)
|
||||
{
|
||||
Alert.showMsg(lang("战阵中的魔物正在外出探索。"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
num++;
|
||||
}
|
||||
}
|
||||
if(num > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
checkTeamVailType = 0;
|
||||
if(show)
|
||||
{
|
||||
Alert.showMsg(lang("战阵中没有可用的魔物。"));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function checkTeamHasEmpty(teamName:String = "") : Boolean
|
||||
{
|
||||
var teamvo:TeamVo = null;
|
||||
if(teamName == "")
|
||||
{
|
||||
teamName = Master.curBattleTeam;
|
||||
}
|
||||
teamvo = getTeamByTeamName(teamName);
|
||||
if(teamvo.hasEmpty() > 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getFightStackMonsters(teamName:String = "") : Array
|
||||
{
|
||||
var mons:Array = [];
|
||||
var teamVo:TeamVo = getTeamByTeamName(teamName);
|
||||
for each(var mid:Number in teamVo.monsters)
|
||||
{
|
||||
if(mid > 0)
|
||||
{
|
||||
mons.push(MonsterCenter.getIns().getMonById(mid));
|
||||
}
|
||||
}
|
||||
return mons;
|
||||
}
|
||||
|
||||
public function get fightMonsterNum() : int
|
||||
{
|
||||
var j:int = 0;
|
||||
var i:int = 0;
|
||||
for(j = 0; Table.team_info.battleTeam[j.toString()] != null; )
|
||||
{
|
||||
if(Master.level >= Table.team_info.battleTeam[j].level)
|
||||
{
|
||||
i++;
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if(i > 4)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
public function getTeamZdl(teamName:String) : int
|
||||
{
|
||||
var i:int = 0;
|
||||
var mon:MonsterVo = null;
|
||||
var zdl:int = 0;
|
||||
var teamVo:TeamVo = getTeamByTeamName(teamName);
|
||||
for(i = 0; i < teamVo.monsters.length; )
|
||||
{
|
||||
if(teamVo.monsters[i] > 0)
|
||||
{
|
||||
mon = MonsterCenter.getIns().getMonById(teamVo.monsters[i]);
|
||||
zdl += GameMath.zl_monVo(mon);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return zdl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user