2042 lines
61 KiB
ActionScript
2042 lines
61 KiB
ActionScript
package net.pixvi.myr.battle
|
|
{
|
|
import com.greensock.TimelineMax;
|
|
import com.greensock.TweenMax;
|
|
import com.greensock.easing.Back;
|
|
import com.greensock.easing.Cubic;
|
|
import com.greensock.easing.Quint;
|
|
import flash.display.MovieClip;
|
|
import flash.display.Sprite;
|
|
import flash.events.Event;
|
|
import flash.geom.Point;
|
|
import flash.geom.Rectangle;
|
|
import net.pixvi.common.center.PopCenter;
|
|
import net.pixvi.common.center.SoundCenter;
|
|
import net.pixvi.common.center.TipCenter;
|
|
import net.pixvi.common.control.Key;
|
|
import net.pixvi.common.driver.SecondDriver;
|
|
import net.pixvi.common.driver.StageDriver;
|
|
import net.pixvi.common.effect.effects.FlashEffect;
|
|
import net.pixvi.common.pool.BasePool;
|
|
import net.pixvi.common.utils.Alert;
|
|
import net.pixvi.common.utils.Cooldowner;
|
|
import net.pixvi.common.utils.Gesturer;
|
|
import net.pixvi.common.utils.StageLocator;
|
|
import net.pixvi.common.view.FF;
|
|
import net.pixvi.common.view.font.BitNumber;
|
|
import net.pixvi.myr.GameMath;
|
|
import net.pixvi.myr.battle.view.BattleMon;
|
|
import net.pixvi.myr.battle.view.BattleSkillUI;
|
|
import net.pixvi.myr.battle.view.BulletView;
|
|
import net.pixvi.myr.battle.view.piece.BattleCostUI;
|
|
import net.pixvi.myr.center.EffectCenter;
|
|
import net.pixvi.myr.center.Game;
|
|
import net.pixvi.myr.center.Table;
|
|
import net.pixvi.myr.element.battle.BaseBattleArea;
|
|
import net.pixvi.myr.element.battle.BattleTeamVo;
|
|
import net.pixvi.myr.element.battle.BattleVo;
|
|
import net.pixvi.myr.element.battle.battlearea.BattleAreaType;
|
|
import net.pixvi.myr.element.battle.battlecontroller.BaseBattleController;
|
|
import net.pixvi.myr.element.battle.battlecontroller.BattleControllerType;
|
|
import net.pixvi.myr.element.battle.moncontroller.BaseMonController;
|
|
import net.pixvi.myr.element.battle.trigger.BattleTrigger;
|
|
import net.pixvi.myr.element.snd.GameSound;
|
|
import net.pixvi.myr.event.BattleEvent;
|
|
import net.pixvi.myr.panel.battle.BattlePanel;
|
|
import net.pixvi.myr.panel.battle.BattlePausePanel;
|
|
import net.pixvi.myr.panel.battle.BattleRecords;
|
|
import net.pixvi.myr.panel.boss.BossStagePanel;
|
|
import net.pixvi.myr.panel.story.StoryPanel;
|
|
import net.pixvi.myr.view.groundobj.BaseGroundObject;
|
|
import net.pixvi.myr.view.groundobj.GroundObjectType;
|
|
import net.pixvi.myr.view.skill.BaseSkill;
|
|
import net.pixvi.myr.view.touchline.TouchLine;
|
|
import net.pixvi.pfw.display.BitFactory;
|
|
import net.pixvi.pfw.display.BitMovieClip;
|
|
import net.pixvi.pfw.display.BitSprite;
|
|
import net.pixvi.pfw.display.NetBitImg;
|
|
import net.pixvi.pfw.display.PiSprite;
|
|
import net.pixvi.pfw.driver.EnterFrameDriver;
|
|
import net.pixvi.pfw.event.MobiEvent;
|
|
import net.pixvi.pfw.event.PiEvent;
|
|
import net.pixvi.pfw.utils.ArrayUtil;
|
|
import net.pixvi.pfw.utils.Caller;
|
|
import net.pixvi.pfw.utils.Director;
|
|
import net.pixvi.pfw.utils.Jumper;
|
|
import net.pixvi.pfw.utils.Locator;
|
|
import net.pixvi.pfw.utils.Oncer;
|
|
import net.pixvi.pfw.utils.Paster;
|
|
import net.pixvi.pfw.utils.Pointer;
|
|
import net.pixvi.pfw.utils.Random;
|
|
import net.pixvi.pfw.utils.Saver;
|
|
import net.pixvi.pfw.utils.Sorter;
|
|
import net.pixvi.psg.ui.PSGYesNoPanel;
|
|
|
|
public class BattleGround extends PiSprite
|
|
{
|
|
|
|
public static var line:TouchLine;
|
|
|
|
public static var mc_select:BitMovieClip;
|
|
|
|
public static var mc_cost:BattleCostUI;
|
|
|
|
public static var mc_moveWave:BitSprite;
|
|
|
|
public static var mc_startMov:MovieClip;
|
|
|
|
public static var ui_battleTip:BattleStartTipUI;
|
|
|
|
public static var hitNumPool:BasePool;
|
|
|
|
public static var cureNumPool:BasePool;
|
|
|
|
public var run:Boolean = false;
|
|
|
|
public var battleIsStart:Boolean = false;
|
|
|
|
public var vo:BattleVo;
|
|
|
|
public var monsters:Array;
|
|
|
|
public var bullets:Array;
|
|
|
|
public var objects:Array;
|
|
|
|
public var areas:Array;
|
|
|
|
public var ui:BattleGroundUI;
|
|
|
|
public var container:Sprite;
|
|
|
|
public var containerTop:Sprite;
|
|
|
|
public var containerBottom:Sprite;
|
|
|
|
public var sortJump:Jumper;
|
|
|
|
public var controllers:Array;
|
|
|
|
public var trigger:BattleTrigger;
|
|
|
|
public var curControlMon:BattleMon;
|
|
|
|
public var curTargetMon:BattleMon;
|
|
|
|
public var curSelectMon:BattleMon;
|
|
|
|
public var curPoint:Point = new Point();
|
|
|
|
public var winnerTeam:int = 0;
|
|
|
|
public var onComplete:Function;
|
|
|
|
public var battleTime:Cooldowner;
|
|
|
|
public var apTime:Cooldowner;
|
|
|
|
public var areaEffectTime:Cooldowner;
|
|
|
|
public var someSkillUsedInTheStep:Boolean = false;
|
|
|
|
public var paused:Boolean = false;
|
|
|
|
public var stop:Boolean = false;
|
|
|
|
public var storyPlaying:Boolean = false;
|
|
|
|
public var gestureContainer:Gesturer;
|
|
|
|
public var gestureBG:Gesturer;
|
|
|
|
private var _autoSkill:Boolean = false;
|
|
|
|
private var autoMIDCount:int = 1;
|
|
|
|
private var controlling:Boolean = false;
|
|
|
|
public var key:Key;
|
|
|
|
private var monsterLCache:Object = {};
|
|
|
|
public var battleRecords:BattleRecords;
|
|
|
|
public var quickSkill:Boolean = false;
|
|
|
|
private var loadedMovie:Object;
|
|
|
|
private var useSkillContinueFunc:Function;
|
|
|
|
private var skillstartmov:BitMovieClip;
|
|
|
|
private var bossPointT:TweenMax;
|
|
|
|
private var startStageX:Number;
|
|
|
|
private var startStageY:Number;
|
|
|
|
private var startGroundX:Number;
|
|
|
|
private var startGroundY:Number;
|
|
|
|
public function BattleGround()
|
|
{
|
|
super();
|
|
monsters = [];
|
|
bullets = [];
|
|
areas = [];
|
|
controllers = [];
|
|
battleRecords = new BattleRecords();
|
|
sortJump = new Jumper(3);
|
|
container = new Sprite();
|
|
containerBottom = new Sprite();
|
|
containerTop = new Sprite();
|
|
containerBottom.mouseChildren = containerBottom.mouseEnabled = false;
|
|
containerTop.mouseChildren = containerTop.mouseEnabled = false;
|
|
ui = new BattleGroundUI();
|
|
autoMIDCount = 1;
|
|
line.x = line.y = 0;
|
|
addChild(ui);
|
|
addChild(containerBottom);
|
|
addChild(container);
|
|
addChild(containerTop);
|
|
addChild(ui.ui_bottom);
|
|
addChild(ui.ui_top);
|
|
gestureContainer = new Gesturer(container,true);
|
|
gestureBG = new Gesturer(ui.mc_bg,true);
|
|
this.mouseChildren = this.mouseEnabled = false;
|
|
if(GameMath.ModeTrace)
|
|
{
|
|
key = new Key(80);
|
|
key.addEventListener("keyDown",damageAll);
|
|
}
|
|
}
|
|
|
|
public static function firstStartUp() : void
|
|
{
|
|
FF.getFC("mov.DeadBoom");
|
|
FF.getFC("mov.skillStart");
|
|
line = new TouchLine();
|
|
mc_startMov = FF.getMC("ui.BattleStartMov");
|
|
mc_startMov.stop();
|
|
mc_select = FF.getBMC("mov.ui_BattleSelect");
|
|
mc_select.stop();
|
|
mc_cost = new BattleCostUI();
|
|
mc_moveWave = FF.getBS("ui.BattleMoveWave");
|
|
ui_battleTip = new BattleStartTipUI();
|
|
hitNumPool = new BasePool(BitNumber);
|
|
cureNumPool = new BasePool(BitNumber);
|
|
}
|
|
|
|
public static function getIns() : BattleGround
|
|
{
|
|
return BattlePanel.getIns().ground;
|
|
}
|
|
|
|
private function damageAll(e:Event = null) : void
|
|
{
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
if(m.team == 2)
|
|
{
|
|
m.beHurt(7,null,200,false,true,6,0,600);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function battlePauseHandler(e:Event = null) : Boolean
|
|
{
|
|
if(!BattleGround.getIns().someSkillUsedInTheStep && BattleGround.getIns().battleIsStart && !BattleGround.getIns().paused)
|
|
{
|
|
BattleGround.getIns().pause();
|
|
PopCenter.POP(BattlePausePanel.getIns());
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function loadMovies() : void
|
|
{
|
|
loadedMovie = {};
|
|
var skillLevels:Object = {};
|
|
for each(var teamvo:BattleTeamVo in vo.teams)
|
|
{
|
|
for each(var m:BattleMon in teamvo.mons)
|
|
{
|
|
skillLevels[m.monVo.skill_1_lv] = true;
|
|
skillLevels[m.monVo.skill_2_lv] = true;
|
|
}
|
|
}
|
|
for(var skillLevel:String in skillLevels)
|
|
{
|
|
if(int(skillLevel) > 1)
|
|
{
|
|
loadedMovie["mov.SkillStartLevel" + skillLevel] = true;
|
|
FF.getBMC("mov.SkillStartLevel" + skillLevel);
|
|
}
|
|
}
|
|
var myTeam:BattleTeamVo = vo.getTeam(1);
|
|
if(myTeam != null)
|
|
{
|
|
for each(var myMon:BattleMon in myTeam.mons)
|
|
{
|
|
if(myMon != null)
|
|
{
|
|
cacheSkillMovs(myMon.skill_1);
|
|
cacheSkillMovs(myMon.skill_2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private function cacheSkillMovs(skill:BaseSkill) : void
|
|
{
|
|
if(skill == null)
|
|
{
|
|
return;
|
|
}
|
|
var movs:Array = skill.getCacheMovs();
|
|
for each(var mov:String in movs)
|
|
{
|
|
if(mov != null && mov != "" && !BitFactory.hasBitFrameCollector(mov))
|
|
{
|
|
FF.getFC(mov);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function gcMovies() : void
|
|
{
|
|
}
|
|
|
|
public function init(vo:BattleVo) : void
|
|
{
|
|
this.vo = vo;
|
|
if(Game.getIns().setting.quickSkill != null)
|
|
{
|
|
this.quickSkill = Game.getIns().setting.quickSkill;
|
|
}
|
|
if(vo.battleMode == BattleModeType.PVE)
|
|
{
|
|
apTime = new Cooldowner(GameMath.apCD / Table.game_setting.pveApSpeedScale);
|
|
}
|
|
else
|
|
{
|
|
apTime = new Cooldowner(GameMath.apCD);
|
|
}
|
|
battleTime = new Cooldowner(vo.time * 1000);
|
|
areaEffectTime = new Cooldowner(125);
|
|
battleTime.activity();
|
|
battleTime.pause();
|
|
buildMonster();
|
|
buildGround();
|
|
buildController();
|
|
update();
|
|
trigger = new BattleTrigger(this);
|
|
if(Saver.getAuto("autoSkill") != null && Saver.getAuto("autoSkill").autoSkill == false)
|
|
{
|
|
setAutoSkill(false);
|
|
}
|
|
else
|
|
{
|
|
setAutoSkill(true);
|
|
}
|
|
if(vo.battleMode != BattleModeType.BOSS || BossStagePanel.getIns().curVo.currentHp <= 0)
|
|
{
|
|
ui.ui_top.ui_bossPoint.visible = false;
|
|
}
|
|
else
|
|
{
|
|
ui.ui_top.ui_bossPoint.visible = true;
|
|
ui.ui_top.ui_bossPoint.text_pointName.text = BossStagePanel.getIns().curVo.pointName;
|
|
}
|
|
ui.ui_bottom.ui_skill1.addEventListener(MobiEvent.CLICK,skillBtnHandler,false,200);
|
|
ui.ui_bottom.ui_skill2.addEventListener(MobiEvent.CLICK,skillBtnHandler,false,200);
|
|
ui.ui_bottom.btn_autoSkill.addEventListener(MobiEvent.CLICK,autoSkillHandler,false,300);
|
|
ui.ui_bottom.list_team1.addEventListener("piselect",monListSelectHandler);
|
|
}
|
|
|
|
public function monListSelectHandler(e:Event = null) : void
|
|
{
|
|
selectMonster(ui.ui_bottom.list_team1.curSelectedItemData as BattleMon);
|
|
}
|
|
|
|
public function removeMonster(mon:BattleMon) : void
|
|
{
|
|
if(curSelectMon == mon)
|
|
{
|
|
lostSelect();
|
|
}
|
|
ArrayUtil.remove(monsters,mon);
|
|
mon.teamVo.monDead(mon);
|
|
}
|
|
|
|
public function addMonster(mon:BattleMon, autoMid:Boolean = false, isSummonMonster:Boolean = false) : void
|
|
{
|
|
var monteam:BattleTeamVo = null;
|
|
var gp:Point = null;
|
|
var joinaction:String = null;
|
|
if(autoMid)
|
|
{
|
|
mon.monVo.mid = BattlePanel.getTempMID();
|
|
}
|
|
if(isSummonMonster)
|
|
{
|
|
mon.monVo.countUnit = false;
|
|
}
|
|
if(battleTime.passTime > 1 && mon.monVo.apRecovery)
|
|
{
|
|
mon.monVo.apRecovery = false;
|
|
monteam = vo.getTeam(mon.team);
|
|
monteam.ap += monteam.apMax * Table.game_setting.addApByJoinMon;
|
|
if(monteam.ap > monteam.apMax)
|
|
{
|
|
monteam.ap = monteam.apMax;
|
|
}
|
|
if(mon.monVo.team == 1)
|
|
{
|
|
new FlashEffect(600,6750207).startEffect(ui.ui_bottom.bar_ap);
|
|
updateApInfo();
|
|
gp = ui.ui_bottom.bar_ap.localToGlobal(new Point(41,35));
|
|
EffectCenter.open_effect(gp.x,gp.y,40,1,1);
|
|
}
|
|
}
|
|
mon.teamVo.monJoin(mon);
|
|
monsters.push(mon);
|
|
if(mon.x < vo.mapAreas.area_battlefield.x)
|
|
{
|
|
mon.engine.speedX += 10;
|
|
if(mon.monVo.joinAction == null || mon.monVo.joinAction == "none")
|
|
{
|
|
if(!mon.monVo.isObject)
|
|
{
|
|
mon.status = 1;
|
|
}
|
|
}
|
|
}
|
|
if(mon.x > vo.mapAreas.area_battlefield.x + vo.mapAreas.area_battlefield.w)
|
|
{
|
|
mon.engine.speedX -= 10;
|
|
if(mon.monVo.joinAction == null || mon.monVo.joinAction == "none")
|
|
{
|
|
if(!mon.monVo.isObject)
|
|
{
|
|
mon.status = 1;
|
|
}
|
|
}
|
|
}
|
|
if(mon.team == 1)
|
|
{
|
|
if(!mon.monVo.controlImmune && !mon.monVo.isObject)
|
|
{
|
|
updateStageMonList();
|
|
}
|
|
mon.addEventListener("monsterControl",startControlHandler);
|
|
}
|
|
mon.addEventListener(BattleEvent.MONSTER_SELECT,startSelectHandler);
|
|
mon.addEventListener(BattleEvent.MONSTER_BE_HURT,hurtHandler);
|
|
mon.addEventListener("monsterDead",deadHandler);
|
|
mon.startController();
|
|
if(mon.monVo.joinAction == "auto")
|
|
{
|
|
joinaction = "none";
|
|
if(mon.canFly && !isSummonMonster && !mon.monVo.isObject)
|
|
{
|
|
joinaction = "flyDown";
|
|
}
|
|
mon.leg.startWithAction(joinaction);
|
|
}
|
|
else
|
|
{
|
|
mon.leg.startWithAction(mon.monVo.joinAction);
|
|
}
|
|
mon.setAutoSkill(_autoSkill);
|
|
container.addChild(mon);
|
|
mon.joined = true;
|
|
if(paused)
|
|
{
|
|
mon.pause();
|
|
}
|
|
}
|
|
|
|
public function startSelectHandler(e:Event = null) : void
|
|
{
|
|
if(curSelectMon != e.target)
|
|
{
|
|
selectMonster(e.target as BattleMon);
|
|
}
|
|
}
|
|
|
|
public function selectMonster(mon:BattleMon) : void
|
|
{
|
|
if(curSelectMon != null)
|
|
{
|
|
curSelectMon.ui.keepShow = false;
|
|
}
|
|
curSelectMon = mon;
|
|
mc_select.gotoAndStop(curSelectMon.team);
|
|
if(Game.HQ)
|
|
{
|
|
TweenMax.fromTo(mc_select,0.2,{
|
|
"alpha":0,
|
|
"scaleX":0.4,
|
|
"scaleY":0.4
|
|
},{
|
|
"scaleX":1,
|
|
"scaleY":1,
|
|
"alpha":1,
|
|
"ease":Back.easeOut
|
|
});
|
|
}
|
|
curSelectMon.shadow.addChild(mc_select);
|
|
curSelectMon.ui.keepShow = true;
|
|
ui.ui_top.updateByMon(curSelectMon);
|
|
ui.ui_bottom.list_team1.selectByValue(curSelectMon);
|
|
curSelectMon.addEventListener(BattleEvent.MONSTER_BE_HURT,selectMonHurtHandler);
|
|
if(curSelectMon.team == 1 && !curSelectMon.monVo.controlImmune)
|
|
{
|
|
ui.ui_bottom.ui_skill1.onSkill(curSelectMon.skill_1);
|
|
ui.ui_bottom.ui_skill2.onSkill(curSelectMon.skill_2);
|
|
}
|
|
else
|
|
{
|
|
ui.ui_bottom.ui_skill1.visible = false;
|
|
ui.ui_bottom.ui_skill2.visible = false;
|
|
}
|
|
}
|
|
|
|
public function someOneUseSkill(mon:BattleMon, func:Function, baseskill:BaseSkill) : void
|
|
{
|
|
var bmc:BitMovieClip = null;
|
|
var iimg:NetBitImg = null;
|
|
var lscale:Number = NaN;
|
|
var fx:int = 0;
|
|
var tl:TimelineMax = null;
|
|
someSkillUsedInTheStep = true;
|
|
useSkillContinueFunc = func;
|
|
if(baseskill.startShow)
|
|
{
|
|
ui.ui_bottom.mouseChildren = ui.ui_bottom.mouseEnabled = false;
|
|
pause();
|
|
TweenMax.to(ui.mc_bg,Game.HQ ? 0.2 : 0,{"colorTransform":{
|
|
"tint":0,
|
|
"tintAmount":0.5
|
|
}});
|
|
if(mon.team == 1)
|
|
{
|
|
SoundCenter.getIns().play(GameSound.effect_skillStart);
|
|
}
|
|
else
|
|
{
|
|
SoundCenter.getIns().play(GameSound.effect_skillStart,0.2);
|
|
}
|
|
if(skillstartmov == null)
|
|
{
|
|
if(quickSkill)
|
|
{
|
|
skillstartmov = FF.getBMC("mov.skillStartSpd");
|
|
}
|
|
else
|
|
{
|
|
skillstartmov = FF.getBMC("mov.skillStart");
|
|
}
|
|
}
|
|
skillstartmov.gotoAndPlay(1);
|
|
skillstartmov.scaleX = skillstartmov.scaleY = 1.5;
|
|
skillstartmov.x = mon.centerX;
|
|
skillstartmov.y = mon.centerY;
|
|
Director.playOnce(skillstartmov,skillMovComplete);
|
|
container.addChild(skillstartmov);
|
|
if(baseskill.lv > 1)
|
|
{
|
|
bmc = FF.getBMC("mov.SkillStartLevel" + baseskill.lv);
|
|
bmc.gotoAndPlay(1);
|
|
bmc.scaleX = bmc.scaleY = 1.5;
|
|
bmc.y = mon.centerY;
|
|
bmc.x = mon.centerX;
|
|
Director.playOnce(bmc);
|
|
container.addChild(bmc);
|
|
}
|
|
if(mon.vo.star > 2 && !mon.vo.npc && mon.monVo.mode == 2 && baseskill == mon.skill_1)
|
|
{
|
|
if(mon.team == 1)
|
|
{
|
|
GameSound.playMonVoice(mon.vo.type.toString(),"skill",true,true,-0.3);
|
|
}
|
|
if(monsterLCache[mon.vo.skinShowType] != null)
|
|
{
|
|
iimg = monsterLCache[mon.vo.skinShowType];
|
|
}
|
|
else
|
|
{
|
|
iimg = new NetBitImg(mon.vo.getImg("l"));
|
|
monsterLCache[mon.vo.skinShowType] = iimg;
|
|
}
|
|
lscale = 0.7;
|
|
iimg.setScale(lscale);
|
|
BattlePanel.getIns().addChild(iimg);
|
|
iimg.y = mon.vo.imgFix["l"].y * lscale + 600 + StageLocator.MainFixVo.fix[2];
|
|
fx = mon.vo.imgFix["l"].x * lscale;
|
|
tl = new TimelineMax();
|
|
if(mon.team == 1)
|
|
{
|
|
tl.fromTo(iimg,0.35,{
|
|
"alpha":0,
|
|
"x":fx + 200
|
|
},{
|
|
"alpha":1,
|
|
"x":fx + 225,
|
|
"ease":Quint.easeOut
|
|
});
|
|
tl.to(iimg,0.35,{
|
|
"alpha":0,
|
|
"x":fx + 250,
|
|
"ease":Quint.easeIn,
|
|
"onComplete":iimg.dispose
|
|
});
|
|
}
|
|
else
|
|
{
|
|
tl.fromTo(iimg,0.35,{
|
|
"alpha":0,
|
|
"x":fx + StageDriver.stageWidth - 175
|
|
},{
|
|
"alpha":1,
|
|
"x":fx + StageDriver.stageWidth - 200,
|
|
"ease":Quint.easeOut
|
|
});
|
|
tl.to(iimg,0.35,{
|
|
"alpha":0,
|
|
"x":fx + StageDriver.stageWidth - 225,
|
|
"ease":Quint.easeIn,
|
|
"onComplete":iimg.removeFromStage
|
|
});
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
skillMovComplete();
|
|
}
|
|
if(mon.monVo.team == 1)
|
|
{
|
|
updateApInfo();
|
|
}
|
|
trigger.checkSkillTrigger(mon.monVo.team);
|
|
}
|
|
|
|
public function skillMovComplete() : void
|
|
{
|
|
if(winnerTeam != 0)
|
|
{
|
|
return;
|
|
}
|
|
if(skillstartmov != null)
|
|
{
|
|
skillstartmov.dispose();
|
|
skillstartmov = null;
|
|
TweenMax.to(ui.mc_bg,Game.HQ ? 0.2 : 0,{
|
|
"colorTransform":{
|
|
"tint":0,
|
|
"tintAmount":0
|
|
},
|
|
"removeTint":true
|
|
});
|
|
if(!controlling)
|
|
{
|
|
resume();
|
|
}
|
|
ui.ui_bottom.mouseChildren = ui.ui_bottom.mouseEnabled = true;
|
|
}
|
|
if(useSkillContinueFunc != null)
|
|
{
|
|
useSkillContinueFunc();
|
|
useSkillContinueFunc = null;
|
|
}
|
|
}
|
|
|
|
public function update() : void
|
|
{
|
|
ui.ui_top.text_name1.text = vo.getTeam(1).name;
|
|
if(vo.getTeam(2).name.length == 7)
|
|
{
|
|
ui.ui_top.text_name2.htmlText = Paster.font(vo.getTeam(2).name,null,18);
|
|
}
|
|
else if(vo.getTeam(2).name.length == 8)
|
|
{
|
|
ui.ui_top.text_name2.htmlText = Paster.font(vo.getTeam(2).name,null,16);
|
|
}
|
|
else if(vo.getTeam(2).name.length >= 9)
|
|
{
|
|
ui.ui_top.text_name2.htmlText = Paster.font(vo.getTeam(2).name,null,14);
|
|
}
|
|
else
|
|
{
|
|
ui.ui_top.text_name2.text = vo.getTeam(2).name;
|
|
}
|
|
updateApInfo();
|
|
updateWaitMonNum();
|
|
updateTime();
|
|
updateStageMonList();
|
|
}
|
|
|
|
public function updateApInfo() : void
|
|
{
|
|
ui.ui_bottom.text_ap.text = vo.getTeam(1).ap.toString() + "/" + vo.getTeam(1).apMax.toString();
|
|
ui.ui_bottom.bar_ap.setValue(vo.getTeam(1).ap,vo.getTeam(1).apMax);
|
|
}
|
|
|
|
public function updateWaitMonNum() : void
|
|
{
|
|
ui.ui_top.text_wait1.text = vo.getTeam(1).getWaitMonster().length.toString();
|
|
ui.ui_top.text_wait2.text = vo.getTeam(2).getWaitMonster().length.toString();
|
|
}
|
|
|
|
public function updateStageMonList() : void
|
|
{
|
|
var i:int = 0;
|
|
var mons:Array = [];
|
|
var team:BattleTeamVo = vo.teamDic[1] as BattleTeamVo;
|
|
mons = team.stageMons.concat();
|
|
for(i = 0; i < mons.length; )
|
|
{
|
|
if((mons[i] as BattleMon).monVo.summonUnit)
|
|
{
|
|
mons.splice(i,1);
|
|
i--;
|
|
}
|
|
i++;
|
|
}
|
|
mons.sortOn("teamPos",16);
|
|
ui.ui_bottom.list_team1.setDatas(mons);
|
|
if(curSelectMon != null)
|
|
{
|
|
ui.ui_bottom.list_team1.selectByValue(curSelectMon);
|
|
}
|
|
}
|
|
|
|
public function updateTime() : void
|
|
{
|
|
trace("timepass:",Paster.secondFormat(battleTime.leftTime / 1000,"mm:ss",true));
|
|
ui.ui_top.text_time.text = Paster.secondFormat(battleTime.leftTime / 1000,"mm:ss",true);
|
|
}
|
|
|
|
public function selectMonHurtHandler(e:Event = null) : void
|
|
{
|
|
if(curSelectMon != null)
|
|
{
|
|
ui.ui_top.updateHpByMon(curSelectMon);
|
|
}
|
|
}
|
|
|
|
public function lostSelect(e:Event = null) : void
|
|
{
|
|
if(curSelectMon != null && curSelectMon.ui != null)
|
|
{
|
|
curSelectMon.ui.keepShow = false;
|
|
}
|
|
ui.ui_top.lostSelect();
|
|
curSelectMon.removeEventListener(BattleEvent.MONSTER_BE_HURT,selectMonHurtHandler);
|
|
curSelectMon = null;
|
|
if(mc_select.parent != null)
|
|
{
|
|
mc_select.parent.removeChild(mc_select);
|
|
}
|
|
ui.ui_bottom.ui_skill1.visible = ui.ui_bottom.ui_skill2.visible = false;
|
|
}
|
|
|
|
public function startControlHandler(e:Event = null) : void
|
|
{
|
|
if(e != null)
|
|
{
|
|
curControlMon = e.target as BattleMon;
|
|
}
|
|
if(curControlMon.buff.get_stun || curControlMon.buff.get_bosou)
|
|
{
|
|
return;
|
|
}
|
|
selectMonster(curControlMon);
|
|
if(curControlMon.monVo.apCost > vo.getTeam(1).ap)
|
|
{
|
|
new FlashEffect(500,16711680).startEffect(ui.ui_bottom.text_ap);
|
|
return;
|
|
}
|
|
curControlMon.ui.keepShow = true;
|
|
controlling = true;
|
|
pause();
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
if(m != curControlMon && m.team == 1)
|
|
{
|
|
m.monMov.alpha = 0.35;
|
|
}
|
|
}
|
|
ui.ui_bottom.mouseChildren = ui.ui_top.mouseChildren = false;
|
|
ui.ui_bottom.mouseEnabled = ui.ui_top.mouseEnabled = false;
|
|
TweenMax.to(ui.mc_bg,Game.HQ ? 0.3 : 0,{"colorTransform":{
|
|
"tint":0,
|
|
"tintAmount":0.5
|
|
}});
|
|
mc_cost.prepareShow();
|
|
mc_cost.x = curControlMon.x;
|
|
mc_cost.y = curControlMon.y + curControlMon.ui.y + 17;
|
|
mc_cost.text_cost.text = curControlMon.monVo.apCost.toString();
|
|
container.addChild(mc_cost);
|
|
line.lightBlue();
|
|
line.start();
|
|
this.addEventListener(MobiEvent.MOUSE_MOVE,controlMoveHandler);
|
|
this.addEventListener(MobiEvent.MOUSE_UP,controlUpHandler);
|
|
}
|
|
|
|
public function addMovInGround(mov:String, fps:int = 0, mx:Number = 0, my:Number = 0, scaleX:Number = 1, scaleY:Number = 1, rotation:Number = 0, loop:int = 1, top:Boolean = true, inContainer:Boolean = false) : BitMovieClip
|
|
{
|
|
var bmc:BitMovieClip = FF.getBMC(mov,fps);
|
|
bmc.scaleX = scaleX;
|
|
bmc.scaleY = scaleY;
|
|
bmc.rotation = rotation;
|
|
bmc.x = mx;
|
|
bmc.y = my;
|
|
bmc.mouseChildren = bmc.mouseEnabled = false;
|
|
if(inContainer)
|
|
{
|
|
container.addChild(bmc);
|
|
}
|
|
else if(top)
|
|
{
|
|
BattlePanel.getIns().ground.addChild(bmc);
|
|
}
|
|
else
|
|
{
|
|
BattlePanel.getIns().ground.containerBottom.addChild(bmc);
|
|
}
|
|
Director.playOnce(bmc,null,null,loop);
|
|
return bmc;
|
|
}
|
|
|
|
public function getBattleArea() : Object
|
|
{
|
|
return BattleGround.getIns().vo.getBattleArea();
|
|
}
|
|
|
|
public function controlMoveHandler(e:Object = null) : void
|
|
{
|
|
var mon:BattleMon = null;
|
|
var curDis:Number = NaN;
|
|
var cx:Number = ui.mc_bg.mouseX;
|
|
var cy:Number = ui.mc_bg.mouseY;
|
|
var area:Object = vo.mapAreas.area_battlefield;
|
|
if(cx > area.x + area.w)
|
|
{
|
|
cx = area.x + area.w;
|
|
}
|
|
else if(cx < area.x)
|
|
{
|
|
cx = Number(area.x);
|
|
}
|
|
if(cy > area.y + area.h)
|
|
{
|
|
cy = area.y + area.h;
|
|
}
|
|
else if(cy < area.y - 110)
|
|
{
|
|
cy = area.y - 110;
|
|
}
|
|
line.set(curControlMon.centerX,curControlMon.centerY,cx,cy);
|
|
if(!contains(line))
|
|
{
|
|
addChild(line);
|
|
}
|
|
var range:int = Math.pow(50,2);
|
|
var mon_dis:Number = 2147483647;
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
curDis = Locator.getPow(m.centerX,m.centerY,cx,cy);
|
|
if(m.team != curControlMon.team && curDis < range)
|
|
{
|
|
if(mon == null || curDis < mon_dis)
|
|
{
|
|
mon = m;
|
|
mon_dis = curDis;
|
|
}
|
|
}
|
|
}
|
|
if(mon == null)
|
|
{
|
|
if(cy < area.y)
|
|
{
|
|
cy = Number(area.y);
|
|
}
|
|
curPoint.x = cx;
|
|
curPoint.y = cy;
|
|
if(curTargetMon != null)
|
|
{
|
|
if(curTargetMon.ui != null && curTargetMon != curSelectMon)
|
|
{
|
|
curTargetMon.ui.keepShow = false;
|
|
}
|
|
TweenMax.to(curTargetMon.container,Game.HQ ? 0.3 : 0,{
|
|
"colorTransform":{
|
|
"tint":16711680,
|
|
"tintAmount":0
|
|
},
|
|
"removeTint":true
|
|
});
|
|
line.lightBlue();
|
|
curTargetMon = null;
|
|
}
|
|
}
|
|
else if(curTargetMon != mon)
|
|
{
|
|
if(curTargetMon != null && curTargetMon.ui != null)
|
|
{
|
|
curTargetMon.ui.keepShow = false;
|
|
TweenMax.to(curTargetMon.container,Game.HQ ? 0.3 : 0,{
|
|
"colorTransform":{
|
|
"tint":16711680,
|
|
"tintAmount":0
|
|
},
|
|
"removeTint":true
|
|
});
|
|
}
|
|
line.lightRed();
|
|
curTargetMon = mon;
|
|
curTargetMon.ui.keepShow = true;
|
|
TweenMax.to(curTargetMon.container,Game.HQ ? 0.3 : 0,{"colorTransform":{
|
|
"tint":16711680,
|
|
"tintAmount":0.3
|
|
}});
|
|
}
|
|
}
|
|
|
|
public function controlUpHandler(e:Event = null) : void
|
|
{
|
|
var area:Object = null;
|
|
var mvs:TimelineMax = null;
|
|
controlling = false;
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
if(m.team == 1)
|
|
{
|
|
m.monMov.alpha = 1;
|
|
}
|
|
}
|
|
if(curTargetMon != null)
|
|
{
|
|
TweenMax.to(curTargetMon.container,0.3,{
|
|
"colorTransform":{
|
|
"tint":16711680,
|
|
"tintAmount":0
|
|
},
|
|
"removeTint":true
|
|
});
|
|
if(curSelectMon != curTargetMon && curTargetMon.ui != null)
|
|
{
|
|
curTargetMon.ui.keepShow = false;
|
|
}
|
|
curControlMon.targetMon = curTargetMon;
|
|
curControlMon.lockTarget = true;
|
|
curControlMon.targetPoint = null;
|
|
}
|
|
else if(curPoint != null)
|
|
{
|
|
curControlMon.targetPoint = curPoint;
|
|
area = vo.mapAreas.area_battlefield;
|
|
if(curPoint.x < area.x)
|
|
{
|
|
curPoint.x = area.x;
|
|
}
|
|
if(curPoint.y < area.y)
|
|
{
|
|
curPoint.y = area.y;
|
|
}
|
|
mc_moveWave.x = curPoint.x;
|
|
mc_moveWave.y = curPoint.y;
|
|
mvs = new TimelineMax();
|
|
mvs.fromTo(mc_moveWave,0.1,{
|
|
"scaleX":0.9,
|
|
"scaleY":0.9
|
|
},{
|
|
"scaleX":1.1,
|
|
"scaleY":1.1,
|
|
"ease":Cubic.easeOut
|
|
});
|
|
mvs.fromTo(mc_moveWave,0.1,{
|
|
"scaleX":1.1,
|
|
"scaleY":1.1
|
|
},{
|
|
"scaleX":0.6,
|
|
"scaleY":0.6,
|
|
"ease":Cubic.easeIn,
|
|
"onComplete":mc_moveWave.removeFromStage
|
|
});
|
|
container.addChildAt(mc_moveWave,0);
|
|
curControlMon.targetMon = null;
|
|
curControlMon.lockTarget = false;
|
|
}
|
|
ui.ui_bottom.mouseChildren = ui.ui_top.mouseChildren = true;
|
|
ui.ui_bottom.mouseEnabled = ui.ui_top.mouseEnabled = true;
|
|
if(contains(line))
|
|
{
|
|
removeChild(line);
|
|
}
|
|
mc_cost.showHide();
|
|
if(Game.HQ)
|
|
{
|
|
new FlashEffect(500,16777215).startEffect(ui.ui_bottom.text_ap);
|
|
}
|
|
vo.getTeam(1).ap = vo.getTeam(1).ap - curControlMon.monVo.apCost;
|
|
curControlMon.onControl();
|
|
updateApInfo();
|
|
this.removeEventListener(MobiEvent.MOUSE_MOVE,controlMoveHandler);
|
|
this.removeEventListener(MobiEvent.MOUSE_UP,controlUpHandler);
|
|
TweenMax.to(ui.mc_bg,Game.HQ ? 0.3 : 0,{
|
|
"colorTransform":{
|
|
"tint":0,
|
|
"tintAmount":0
|
|
},
|
|
"removeTint":true
|
|
});
|
|
resume();
|
|
curPoint = new Point();
|
|
}
|
|
|
|
public function hurtHandler(e:PiEvent) : void
|
|
{
|
|
var damage:int = int(e.data.damage);
|
|
var mon:BattleMon = e.target as BattleMon;
|
|
if(mon.monVo.bossPoint == -1)
|
|
{
|
|
battleRecords.bossPoint.val += damage;
|
|
Oncer.lastRun(updateBossDamage);
|
|
}
|
|
}
|
|
|
|
public function updateBossDamage() : void
|
|
{
|
|
ui.ui_top.ui_bossPoint.text_bossPoint.text = battleRecords.bossPoint.val.toString();
|
|
if(bossPointT != null)
|
|
{
|
|
bossPointT.kill();
|
|
}
|
|
bossPointT = TweenMax.fromTo(ui.ui_top.ui_bossPoint.text_bossPoint,1,{"tint":16763904},{"removeTint":true});
|
|
}
|
|
|
|
public function deadHandler(e:Event = null) : void
|
|
{
|
|
var mon:BattleMon = e.target as BattleMon;
|
|
trigger.checkMonDeadTrigger(mon);
|
|
if(curSelectMon == mon)
|
|
{
|
|
lostSelect();
|
|
}
|
|
if(mon.monVo.protectTarget)
|
|
{
|
|
ui.ui_top.showProtectKill();
|
|
vo.protectNum--;
|
|
}
|
|
if(mon.monVo.destroyTarget)
|
|
{
|
|
ui.ui_top.showDestroyKill();
|
|
vo.destroyNum--;
|
|
}
|
|
if(mon.monVo.leader)
|
|
{
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
if(m.team == mon.team && m.monVo.hp > 0 && m.monVo.mid != mon.monVo.mid)
|
|
{
|
|
m.showFace(4);
|
|
}
|
|
}
|
|
}
|
|
var ranmon:BattleMon = Random.element(monsters) as BattleMon;
|
|
if(ranmon.monVo.mid != mon.monVo.mid && ranmon.team == mon.team)
|
|
{
|
|
if(ranmon.curface == 0)
|
|
{
|
|
ranmon.showFace(6);
|
|
}
|
|
}
|
|
ArrayUtil.remove(monsters,mon);
|
|
mon.teamVo.monDead(mon);
|
|
if(mon.teamVo.numOnStage == 1 && mon.teamVo.stageMons[0] != null)
|
|
{
|
|
mon.teamVo.stageMons[0].showFace(6);
|
|
}
|
|
checkWave();
|
|
mon.removeEventListener("monsterControl",startControlHandler);
|
|
mon.removeEventListener("monsterDead",deadHandler);
|
|
mon.removeEventListener(BattleEvent.MONSTER_SELECT,startSelectHandler);
|
|
if(mon.team != 1 && !mon.monVo.isObject && mon.monVo.mode == 2)
|
|
{
|
|
if(battleRecords.killMons[mon.monVo.type] == null)
|
|
{
|
|
battleRecords.killMons[mon.monVo.type] = 0;
|
|
}
|
|
battleRecords.killMons[mon.monVo.type]++;
|
|
}
|
|
if(mon.monVo.bossPoint > 0)
|
|
{
|
|
battleRecords.bossPoint.val += mon.monVo.bossPoint;
|
|
Oncer.lastRun(updateBossDamage);
|
|
}
|
|
if(mon.team == 1)
|
|
{
|
|
updateStageMonList();
|
|
}
|
|
if(mon.getTotalHurtRecort() == 0)
|
|
{
|
|
BattlePanel.battleData.cheatNum += 1000;
|
|
BattlePanel.battleData.cheatRecords.addRecord("+1k_cheatDead" + mon.monVo.type + "_" + mon.monVo.hp + "/" + mon.monVo.hpMax);
|
|
}
|
|
if(mon.vo != null && mon.vo.mode == 2 && mon.team == 1)
|
|
{
|
|
GameSound.playMonVoice(mon.vo.type.toString(),"dead",true,true);
|
|
}
|
|
Caller.stopCall(checkGameOver,1000);
|
|
Caller.delayCall(checkGameOver,1000);
|
|
trace("[monDead]",mon.name);
|
|
}
|
|
|
|
public function checkWave() : void
|
|
{
|
|
for each(var team:BattleTeamVo in vo.teams)
|
|
{
|
|
if(!(team.waitingWave || team.waveUnlock[team.wave + 1] == null))
|
|
{
|
|
var _loc5_:int = 0;
|
|
var _loc4_:Array = team.mons;
|
|
do
|
|
{
|
|
for each(var m:BattleMon in _loc4_)
|
|
{
|
|
}
|
|
var _loc7_:int = 0;
|
|
var _loc6_:Array = team.stageMons;
|
|
do
|
|
{
|
|
for each(var stagem:BattleMon in _loc6_)
|
|
{
|
|
}
|
|
team.waitingWave = true;
|
|
Caller.delayCall(processWave,700,1,[team]);
|
|
break;
|
|
}
|
|
while(stagem.wave != team.wave);
|
|
break;
|
|
}
|
|
while(m.wave != team.wave);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function processWave(team:BattleTeamVo) : void
|
|
{
|
|
team.wave++;
|
|
team.waveUnlock[team.wave] = true;
|
|
team.waitingWave = false;
|
|
trigger.checkTeamWaveStart(team.team,team.wave);
|
|
}
|
|
|
|
public function checkGameOver() : void
|
|
{
|
|
var gameover:Boolean = false;
|
|
var timeup:Boolean = battleTime.leftTime == 0;
|
|
var team1LiveNum:int = 0;
|
|
var teamOtherLiveNum:int = 0;
|
|
winnerTeam = 0;
|
|
if(timeup)
|
|
{
|
|
if(vo.winType.indexOf(2) != -1)
|
|
{
|
|
winnerTeam = 1;
|
|
}
|
|
else
|
|
{
|
|
winnerTeam = 2;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for each(var teamvo:BattleTeamVo in vo.teams)
|
|
{
|
|
if(teamvo.team == 1)
|
|
{
|
|
team1LiveNum = teamvo.mons.length + teamvo.stageMons.length;
|
|
}
|
|
else
|
|
{
|
|
for each(var m:BattleMon in teamvo.mons)
|
|
{
|
|
if(!m.monVo.isObject)
|
|
{
|
|
teamOtherLiveNum++;
|
|
}
|
|
}
|
|
teamOtherLiveNum += teamvo.stageMons.length;
|
|
}
|
|
}
|
|
if(run)
|
|
{
|
|
winnerTeam = 2;
|
|
}
|
|
else if(team1LiveNum == 0)
|
|
{
|
|
winnerTeam = 2;
|
|
}
|
|
else if(vo.winType.indexOf(1) != -1 && teamOtherLiveNum == 0)
|
|
{
|
|
winnerTeam = 1;
|
|
}
|
|
else if(vo.loseType.indexOf(3) != -1 && vo.protectNum != vo.protectMaxNum)
|
|
{
|
|
winnerTeam = 2;
|
|
}
|
|
else if(vo.loseType.indexOf(4) != -1 && vo.protectNum == 0)
|
|
{
|
|
winnerTeam = 2;
|
|
}
|
|
else if(vo.winType.indexOf(3) != -1 && vo.destroyMaxNum != vo.destroyNum)
|
|
{
|
|
winnerTeam = 1;
|
|
}
|
|
else if(vo.winType.indexOf(4) != -1 && vo.destroyNum == 0)
|
|
{
|
|
winnerTeam = 1;
|
|
}
|
|
}
|
|
if(winnerTeam != 0 && onComplete != null)
|
|
{
|
|
battleStop();
|
|
onComplete();
|
|
onComplete = null;
|
|
}
|
|
}
|
|
|
|
public function addBullet(b:BulletView) : void
|
|
{
|
|
bullets.push(b);
|
|
container.addChild(b);
|
|
if(paused)
|
|
{
|
|
b.pause();
|
|
}
|
|
}
|
|
|
|
public function buildMonster() : void
|
|
{
|
|
var i:int = 0;
|
|
vo.fixMonTeamBeforeBuild();
|
|
for(i = 0; i < vo.teams.length; )
|
|
{
|
|
(vo.teams[i] as BattleTeamVo).buildMonster();
|
|
i++;
|
|
}
|
|
}
|
|
|
|
public function buildGround() : void
|
|
{
|
|
ui.buildByType(vo.groundType,buildGroundStep2);
|
|
}
|
|
|
|
public function buildGroundStep2() : void
|
|
{
|
|
var groundobject:BaseGroundObject = null;
|
|
objects = [];
|
|
if(vo.battleFieldVo.mapObjects.length == 0)
|
|
{
|
|
buildGroundStep3();
|
|
return;
|
|
}
|
|
for each(var o:Object in vo.battleFieldVo.mapObjects)
|
|
{
|
|
groundobject = GroundObjectType.createGroundObjectByType(o.type);
|
|
groundobject.init(o);
|
|
addGroundObject(groundobject);
|
|
}
|
|
EnterFrameDriver.getIns().regist(buildGroundStep2EnterHandler);
|
|
}
|
|
|
|
public function addGroundObject(groundobject:BaseGroundObject) : void
|
|
{
|
|
objects.push(groundobject);
|
|
if(groundobject.data.layer == 1)
|
|
{
|
|
container.addChild(groundobject);
|
|
}
|
|
else if(groundobject.data.layer == 0)
|
|
{
|
|
containerBottom.addChild(groundobject);
|
|
}
|
|
else
|
|
{
|
|
containerTop.addChild(groundobject);
|
|
}
|
|
}
|
|
|
|
public function buildGroundStep2EnterHandler() : void
|
|
{
|
|
if(ArrayUtil.check(objects,"loaded",true))
|
|
{
|
|
EnterFrameDriver.getIns().remove(buildGroundStep2EnterHandler);
|
|
buildGroundStep3();
|
|
}
|
|
}
|
|
|
|
public function buildGroundStep3() : void
|
|
{
|
|
var cp:Object = null;
|
|
var stageCenterX:Number = NaN;
|
|
this.y = (StageDriver.stage.stageHeight - ui.bg.height) / 2;
|
|
if(!vo.rollmapMode)
|
|
{
|
|
this.x = (StageDriver.stage.stageWidth - ui.bg.width) / 2;
|
|
}
|
|
else
|
|
{
|
|
cp = ArrayUtil.getElementByValue(vo.battleFieldVo.mapPoints,"id","point_team1_fore2");
|
|
if(cp != null)
|
|
{
|
|
stageCenterX = StageDriver.stage.stageWidth / 2 - cp.x;
|
|
if(stageCenterX > 0)
|
|
{
|
|
stageCenterX = 0;
|
|
}
|
|
TweenMax.to(this,1,{
|
|
"x":stageCenterX,
|
|
"delay":0.4
|
|
});
|
|
}
|
|
}
|
|
for each(var areavo:Object in vo.battleFieldVo.mapAreas)
|
|
{
|
|
areas.push(BattleAreaType.getByVo(areavo));
|
|
}
|
|
prepareTimeMonster();
|
|
}
|
|
|
|
public function setMonToPoint(mon:BattleMon, pointname:String = "") : void
|
|
{
|
|
var mid:int = 0;
|
|
var tmon:BattleMon = null;
|
|
if(pointname == "")
|
|
{
|
|
pointname = mon.monVo.joinPoint;
|
|
}
|
|
if(vo.mapPoints[pointname] == null && pointname.indexOf("mon_") == -1)
|
|
{
|
|
Alert.resumeMsg();
|
|
Alert.showMsg("can\'t find point[" + pointname + "]");
|
|
return;
|
|
}
|
|
if(pointname.indexOf("mon_") == 0)
|
|
{
|
|
mid = int(pointname.replace("mon_",""));
|
|
tmon = findMonByMid(mid,true);
|
|
if(tmon != null)
|
|
{
|
|
mon.x = tmon.x;
|
|
mon.y = tmon.y;
|
|
mon.faceTo(tmon.curFaceto());
|
|
return;
|
|
}
|
|
if(mon.team == 1)
|
|
{
|
|
pointname = "point_team1_wait1";
|
|
}
|
|
else
|
|
{
|
|
pointname = "point_team2_wait1";
|
|
}
|
|
}
|
|
mon.x = vo.mapPoints[pointname].x + Math.random() * vo.mapPoints[pointname].w;
|
|
mon.y = vo.mapPoints[pointname].y + Math.random() * vo.mapPoints[pointname].h;
|
|
mon.faceTo(vo.mapPoints[pointname].face);
|
|
}
|
|
|
|
public function prepareTeamMonster() : void
|
|
{
|
|
var mon:BattleMon = null;
|
|
var haschange:Boolean = false;
|
|
for each(var teamvo:BattleTeamVo in vo.teams)
|
|
{
|
|
while(teamvo.numOnStage < teamvo.numMax && teamvo.mons.length > 0)
|
|
{
|
|
mon = teamvo.mons.shift();
|
|
if(mon.monVo.joinPoint == "")
|
|
{
|
|
mon.monVo.joinPoint = vo.getTeamWaitPointName(mon.team);
|
|
}
|
|
haschange = true;
|
|
setMonToPoint(mon);
|
|
addMonster(mon,mon.monVo.mid <= 0);
|
|
}
|
|
}
|
|
if(haschange)
|
|
{
|
|
updateWaitMonNum();
|
|
sortContainer();
|
|
}
|
|
}
|
|
|
|
public function prepareTimeMonster() : void
|
|
{
|
|
var numadd:int = 0;
|
|
var i:int = 0;
|
|
var haschange:Boolean = false;
|
|
var addMons:Array = [];
|
|
var passtime:int = battleTime.passTime / 1000;
|
|
trace("passtime",passtime);
|
|
for each(var teamvo:BattleTeamVo in vo.teams)
|
|
{
|
|
numadd = 0;
|
|
for each(var mon:BattleMon in teamvo.mons)
|
|
{
|
|
if(mon.forceToStage || mon.monVo.joinTime <= passtime && teamvo.waveUnlock[mon.monVo.wave])
|
|
{
|
|
if(mon.forceToStage || (!mon.monVo.countUnit || teamvo.numOnStage + numadd < teamvo.numMax))
|
|
{
|
|
trace(mon.name,"加入",mon.monVo.countUnit,teamvo.numOnStage,numadd,teamvo.numMax);
|
|
haschange = true;
|
|
if(mon.monVo.countUnit)
|
|
{
|
|
numadd++;
|
|
}
|
|
if(mon.monVo.joinPoint == "")
|
|
{
|
|
mon.monVo.joinPoint = vo.getTeamWaitPointName(mon.team);
|
|
}
|
|
addMons.push(mon);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if(haschange)
|
|
{
|
|
for(i = 0; i < addMons.length; )
|
|
{
|
|
setMonToPoint(addMons[i]);
|
|
addMonster(addMons[i],addMons[i].monVo.mid <= 0);
|
|
for each(var moncon:BaseMonController in addMons[i].controllers)
|
|
{
|
|
if(moncon.type == "buffMovie")
|
|
{
|
|
moncon.start();
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
updateWaitMonNum();
|
|
sortContainer();
|
|
}
|
|
}
|
|
|
|
public function battleStart(onComplete:Function) : void
|
|
{
|
|
this.mouseChildren = this.mouseEnabled = true;
|
|
run = false;
|
|
battleIsStart = true;
|
|
this.onComplete = onComplete;
|
|
startStep();
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
m.startController();
|
|
if(m.monVo.monsterVo.isFlying())
|
|
{
|
|
m.status = 1;
|
|
m.leg.start();
|
|
}
|
|
}
|
|
gestureContainer.addEventListener(Gesturer.DRAG,dragHandler);
|
|
gestureContainer.addEventListener(Gesturer.TAP_OVER,tapHandler);
|
|
container.addEventListener(MobiEvent.MOUSE_DOWN,downHandler);
|
|
gestureBG.addEventListener(Gesturer.DRAG,bgDragHandler);
|
|
if(vo.rollmapMode)
|
|
{
|
|
gestureBG.start();
|
|
}
|
|
gestureContainer.start();
|
|
}
|
|
|
|
public function downHandler(e:Object = null) : void
|
|
{
|
|
startStageX = e.stageX;
|
|
startStageY = e.stageY;
|
|
startGroundX = ui.mc_bg.mouseX;
|
|
startGroundY = ui.mc_bg.mouseY;
|
|
}
|
|
|
|
public function dragHandler(e:Event = null) : void
|
|
{
|
|
var area:int = 150;
|
|
if(vo.rollmapMode)
|
|
{
|
|
area = 110;
|
|
}
|
|
var mon:BattleMon = findNearestMon(startGroundX,startGroundY,area,1,-1,false,true);
|
|
if(mon != null)
|
|
{
|
|
curControlMon = mon;
|
|
startControlHandler();
|
|
}
|
|
else if(mon == null && vo.rollmapMode)
|
|
{
|
|
bgDragHandler();
|
|
}
|
|
}
|
|
|
|
public function bgDragHandler(e:Event = null) : void
|
|
{
|
|
var rec:Rectangle = Locator.getInStageRectangleByDisplay(this.ui.bg);
|
|
Locator.fixDragRecWithBorder(rec,1,33,50);
|
|
this.startMoveDrag(false,rec);
|
|
StageDriver.stage.addEventListener(MobiEvent.MOUSE_UP,removeStageDragHandler);
|
|
}
|
|
|
|
public function removeStageDragHandler(e:Event = null) : void
|
|
{
|
|
StageDriver.stage.removeEventListener(MobiEvent.MOUSE_UP,removeStageDragHandler);
|
|
this.stopMoveDrag();
|
|
}
|
|
|
|
public function tapHandler(e:Event = null) : void
|
|
{
|
|
var mon:BattleMon = findNearestMon(startGroundX,startGroundY,100);
|
|
if(mon != null)
|
|
{
|
|
selectMonster(mon);
|
|
}
|
|
}
|
|
|
|
public function findNearestMon(x:Number, y:Number, dis:int, team:int = -1, exceptMon:Number = -1, exceptTeamMode:Boolean = false, exceptControlImmune:Boolean = false) : BattleMon
|
|
{
|
|
var nearmon:BattleMon = null;
|
|
var nearlen:int = 0;
|
|
var monlen:int = 0;
|
|
var mon:BattleMon = null;
|
|
var i:int = 0;
|
|
var len:int = 0;
|
|
if(monsters.length > 0)
|
|
{
|
|
nearlen = 2147483647;
|
|
monlen = int(monsters.length);
|
|
for(i = 0; i < monlen; )
|
|
{
|
|
mon = monsters[i];
|
|
if((team == -1 || exceptTeamMode && team != mon.team || !exceptTeamMode && mon.team == team) && (exceptMon == -1 || mon.monVo.mid != exceptMon) && (!exceptControlImmune || !(mon.monVo.isObject || mon.monVo.controlImmune)) && !mon.monVo.dead)
|
|
{
|
|
len = Locator.getLength(mon.x,mon.centerY,x,y);
|
|
if(len < nearlen && len < dis)
|
|
{
|
|
nearlen = len;
|
|
nearmon = mon;
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
return nearmon;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function findMonsByArea(x:int, y:int, w:int, h:int, exceptTeam:int = -1, exceptMon:Number = -1) : Array
|
|
{
|
|
var monlen:int = 0;
|
|
var mon:BattleMon = null;
|
|
var i:int = 0;
|
|
var arr:Array = [];
|
|
if(monsters.length > 0)
|
|
{
|
|
monlen = int(monsters.length);
|
|
for(i = 0; i < monlen; )
|
|
{
|
|
mon = monsters[i];
|
|
if((exceptTeam == -1 || mon.team != exceptTeam) && (exceptMon == -1 || mon.monVo.mid != exceptMon))
|
|
{
|
|
if(mon.x < x + w && mon.y < y + h && mon.x > x && mon.y > y)
|
|
{
|
|
arr.push(mon);
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
return arr;
|
|
}
|
|
|
|
public function findMonByMid(mid:Number, includeDeadMon:Boolean = false) : BattleMon
|
|
{
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
if(m.mid == mid)
|
|
{
|
|
return m;
|
|
}
|
|
}
|
|
loop1:
|
|
for each(var t:BattleTeamVo in vo.teams)
|
|
{
|
|
for each(var mon:BattleMon in t.mons)
|
|
{
|
|
if(mon.mid == mid)
|
|
{
|
|
return mon;
|
|
}
|
|
}
|
|
if(includeDeadMon)
|
|
{
|
|
var _loc12_:int = 0;
|
|
var _loc11_:Array = t.deadMons;
|
|
do
|
|
{
|
|
for each(var mondead:BattleMon in _loc11_)
|
|
{
|
|
}
|
|
continue loop1;
|
|
}
|
|
while(mondead.mid != mid);
|
|
return mondead;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
public function findMonsByTeam(monteam:int = 1, exceptMode:Boolean = false) : Array
|
|
{
|
|
var i:int = 0;
|
|
var arr:Array = [];
|
|
for(i = 0; i < monsters.length; )
|
|
{
|
|
if(monsters[i].team == monteam && !exceptMode || exceptMode && monsters[i].team != monteam)
|
|
{
|
|
arr.push(monsters[i]);
|
|
}
|
|
i++;
|
|
}
|
|
return arr;
|
|
}
|
|
|
|
public function findRandomMonsByTeam(monteam:int = 1, exceptMode:Boolean = false) : Array
|
|
{
|
|
return Random.randomArr(findMonsByTeam(monteam,exceptMode));
|
|
}
|
|
|
|
public function findMonsByExcept(exceptTeam:int = -1, exceptMonid:Number = -1) : Array
|
|
{
|
|
var bm:BattleMon = null;
|
|
var i:int = 0;
|
|
var l:int = int(monsters.length);
|
|
var mons:Array = [];
|
|
for(i = 0; i < l; )
|
|
{
|
|
bm = monsters[i];
|
|
if((exceptTeam == -1 || bm.team != exceptTeam) && (exceptMonid == -1 || bm.monVo.mid != exceptMonid))
|
|
{
|
|
mons.push(bm);
|
|
}
|
|
i++;
|
|
}
|
|
return mons;
|
|
}
|
|
|
|
public function findMonsByMonNear(mon:BattleMon, w:int, h:int, exceptTeam:int = -1, exceptMon:Boolean = true) : Array
|
|
{
|
|
return findMonsByArea(mon.x - w,mon.y - h,2 * w,2 * h,exceptTeam,exceptMon ? mon.monVo.mid : -1);
|
|
}
|
|
|
|
public function findMonsByPointNear(x:int, y:int, w:int, h:int, exceptTeam:int = -1) : Array
|
|
{
|
|
return findMonsByArea(x - w,y - h,2 * w,2 * h,exceptTeam);
|
|
}
|
|
|
|
public function battleStop() : void
|
|
{
|
|
if(PSGYesNoPanel.getInstance().showing)
|
|
{
|
|
PSGYesNoPanel.getInstance().showOut();
|
|
}
|
|
stop = true;
|
|
Caller.stopCall(processWave);
|
|
SecondDriver.getInstance().remove(secondHandler);
|
|
this.mouseChildren = this.mouseEnabled = false;
|
|
pauseStep();
|
|
pause();
|
|
trigger.stop();
|
|
if(BattlePausePanel.getIns().showing)
|
|
{
|
|
BattlePausePanel.getIns().showOut();
|
|
}
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
m.battleDispose();
|
|
m.removeEventListener(BattleEvent.MONSTER_SELECT,startSelectHandler);
|
|
m.removeEventListener("monsterControl",startControlHandler);
|
|
m.removeEventListener("monsterDead",deadHandler);
|
|
}
|
|
}
|
|
|
|
public function autoCheckMonNumInGround() : void
|
|
{
|
|
prepareTeamMonster();
|
|
}
|
|
|
|
public function getMonByLine(startPoint:Point, endPoint:Point, lineWidth:Number, exceptTeam:int) : Array
|
|
{
|
|
var findmon:Array = null;
|
|
var mons:Array = [];
|
|
trace(startPoint,"to",endPoint);
|
|
do
|
|
{
|
|
startPoint = Pointer.Point2Point(startPoint,endPoint,lineWidth / 2,false);
|
|
trace("step",startPoint);
|
|
findmon = findMonsByPointNear(startPoint.x,startPoint.y,lineWidth / 2,lineWidth / 2,exceptTeam);
|
|
for each(var bm:BattleMon in findmon)
|
|
{
|
|
if(mons.indexOf(bm) == -1)
|
|
{
|
|
mons.push(bm);
|
|
}
|
|
}
|
|
trace(startPoint,endPoint);
|
|
}
|
|
while(Math.abs(startPoint.x - endPoint.x) > 5 || Math.abs(startPoint.y - endPoint.y) > 5);
|
|
return mons;
|
|
}
|
|
|
|
public function addAp() : void
|
|
{
|
|
for each(var t:BattleTeamVo in vo.teams)
|
|
{
|
|
if(t.ap < t.apMax)
|
|
{
|
|
t.ap++;
|
|
}
|
|
}
|
|
updateApInfo();
|
|
}
|
|
|
|
public function step() : void
|
|
{
|
|
var m:BattleMon = null;
|
|
var i:int = 0;
|
|
var b:BulletView = null;
|
|
var j:int = 0;
|
|
if(paused)
|
|
{
|
|
pause();
|
|
}
|
|
if(battleTime.leftTime == 0)
|
|
{
|
|
checkGameOver();
|
|
return;
|
|
}
|
|
for each(var bc:BaseBattleController in controllers)
|
|
{
|
|
bc.step();
|
|
}
|
|
if(areaEffectTime.cooldown)
|
|
{
|
|
areaEffectTime.activity();
|
|
activityAreaFunction();
|
|
trigger.step();
|
|
}
|
|
if(sortJump.jump())
|
|
{
|
|
if(apTime.cooldown)
|
|
{
|
|
apTime.activity();
|
|
addAp();
|
|
}
|
|
sortContainer();
|
|
}
|
|
for(i = 0; i < monsters.length; )
|
|
{
|
|
m = monsters[i];
|
|
m.aiStep();
|
|
if(m.remove)
|
|
{
|
|
i--;
|
|
}
|
|
else
|
|
{
|
|
for each(var tarmon:BattleMon in monsters)
|
|
{
|
|
if(tarmon != m && m.hittestG(tarmon))
|
|
{
|
|
m.hitSomeOne(tarmon);
|
|
}
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
for(j = 0; j < bullets.length; )
|
|
{
|
|
b = bullets[j];
|
|
b.step();
|
|
if(b.remove)
|
|
{
|
|
bullets.splice(j,1);
|
|
j--;
|
|
}
|
|
j++;
|
|
}
|
|
someSkillUsedInTheStep = false;
|
|
}
|
|
|
|
public function skillBtnHandler(e:Event = null) : void
|
|
{
|
|
e.stopImmediatePropagation();
|
|
var vo:BattleSkillUI = e.currentTarget as BattleSkillUI;
|
|
TipCenter.hide(ui.ui_bottom.ui_skill1);
|
|
TipCenter.hide(ui.ui_bottom.ui_skill2);
|
|
if(!Game.LQ)
|
|
{
|
|
new FlashEffect(600).startEffect(vo);
|
|
}
|
|
if(vo.curSkill.cder.cooldown)
|
|
{
|
|
if(!useSkill(vo.curSkill))
|
|
{
|
|
new FlashEffect(500,16711680,0.7).startEffect(vo);
|
|
}
|
|
}
|
|
}
|
|
|
|
public function autoSkillHandler(e:Event = null) : void
|
|
{
|
|
e.stopImmediatePropagation();
|
|
ui.ui_bottom.btn_autoSkill.switchSelectStatus();
|
|
setAutoSkill(ui.ui_bottom.btn_autoSkill.selected,true);
|
|
}
|
|
|
|
public function useSkill(skillVo:BaseSkill) : Boolean
|
|
{
|
|
if(!skillVo.mon.buff.get_stun && !skillVo.mon.buff.get_bosou && skillVo != null && skillVo.cder.cooldown)
|
|
{
|
|
if(skillVo.mon.teamVo.ap >= skillVo.cost)
|
|
{
|
|
skillVo.activity();
|
|
skillVo.mon.teamVo.ap -= skillVo.cost;
|
|
if(skillVo.mon.team == 1)
|
|
{
|
|
updateApInfo();
|
|
new FlashEffect(500,16777215).startEffect(ui.ui_bottom.text_ap);
|
|
}
|
|
return true;
|
|
}
|
|
if(skillVo.mon.team == 1)
|
|
{
|
|
updateApInfo();
|
|
new FlashEffect(500,16711680).startEffect(ui.ui_bottom.text_ap);
|
|
}
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public function secondHandler(e:Event = null) : void
|
|
{
|
|
prepareTimeMonster();
|
|
trigger.checkTimeTrigger();
|
|
updateTime();
|
|
}
|
|
|
|
public function startStep() : void
|
|
{
|
|
EnterFrameDriver.getInstance().regist(step);
|
|
SecondDriver.getInstance().regist(secondHandler);
|
|
battleTime.resume();
|
|
}
|
|
|
|
public function pauseStep() : void
|
|
{
|
|
EnterFrameDriver.getInstance().remove(step);
|
|
}
|
|
|
|
public function activityAreaFunction() : void
|
|
{
|
|
for each(var a:BaseBattleArea in areas)
|
|
{
|
|
if(a.cd())
|
|
{
|
|
a.activitycd();
|
|
for each(var m:BattleMon in monsters)
|
|
{
|
|
a.autoMon(m);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public function pause(e:Event = null) : void
|
|
{
|
|
var i:int = 0;
|
|
var j:int = 0;
|
|
var k:int = 0;
|
|
var i2:int = 0;
|
|
var i3:int = 0;
|
|
trace("battle pause");
|
|
paused = true;
|
|
pauseStep();
|
|
trigger.pause();
|
|
for(i = 0; i < monsters.length; )
|
|
{
|
|
monsters[i].pause();
|
|
i++;
|
|
}
|
|
for(j = 0; j < bullets.length; )
|
|
{
|
|
bullets[j].pause();
|
|
j++;
|
|
}
|
|
for(k = 0; k < objects.length; )
|
|
{
|
|
objects[k].pauseAction();
|
|
k++;
|
|
}
|
|
for(i2 = 0; i2 < areas.length; )
|
|
{
|
|
areas[i2].pause();
|
|
i2++;
|
|
}
|
|
for(i3 = 0; i3 < controllers.length; )
|
|
{
|
|
controllers[i3].pause();
|
|
i3++;
|
|
}
|
|
apTime.pause();
|
|
battleTime.pause();
|
|
}
|
|
|
|
public function resume(e:Event = null) : void
|
|
{
|
|
var i:int = 0;
|
|
var j:int = 0;
|
|
var k:int = 0;
|
|
var i2:int = 0;
|
|
var i3:int = 0;
|
|
if(storyPlaying || stop)
|
|
{
|
|
return;
|
|
}
|
|
trace("battle resume");
|
|
paused = false;
|
|
startStep();
|
|
trigger.resume();
|
|
for(i = 0; i < monsters.length; )
|
|
{
|
|
monsters[i].resume();
|
|
i++;
|
|
}
|
|
for(j = 0; j < bullets.length; )
|
|
{
|
|
bullets[j].resume();
|
|
j++;
|
|
}
|
|
for(k = 0; k < objects.length; )
|
|
{
|
|
objects[k].startAction();
|
|
k++;
|
|
}
|
|
for(i2 = 0; i2 < areas.length; )
|
|
{
|
|
areas[i2].resume();
|
|
i2++;
|
|
}
|
|
for(i3 = 0; i3 < controllers.length; )
|
|
{
|
|
controllers[i3].resume();
|
|
i3++;
|
|
}
|
|
apTime.resume();
|
|
battleTime.resume();
|
|
}
|
|
|
|
public function checkTrigger() : void
|
|
{
|
|
}
|
|
|
|
public function storyStart(story:String) : void
|
|
{
|
|
storyPlaying = true;
|
|
pause();
|
|
StoryPanel.getIns().start(story,storyEndHandler,null,false,true,false);
|
|
}
|
|
|
|
private function storyEndHandler(e:Event = null) : void
|
|
{
|
|
storyPlaying = false;
|
|
StoryPanel.getIns().endOut();
|
|
resume();
|
|
}
|
|
|
|
public function sortContainer() : void
|
|
{
|
|
Sorter.sortContainerByY(container);
|
|
}
|
|
|
|
public function buildController() : void
|
|
{
|
|
var controller:BaseBattleController = null;
|
|
for each(var o:Object in vo.controller)
|
|
{
|
|
controller = BattleControllerType.getByType(o.type);
|
|
controller.buildByObject(o);
|
|
controllers.push(controller);
|
|
}
|
|
}
|
|
|
|
public function setAutoSkill(val:Boolean, save:Boolean = false) : void
|
|
{
|
|
var i:int = 0;
|
|
var mon:BattleMon = null;
|
|
_autoSkill = val;
|
|
var myMons:Array = [];
|
|
var team:BattleTeamVo = vo.teamDic[1];
|
|
myMons = myMons.concat(team.stageMons);
|
|
myMons = myMons.concat(team.mons);
|
|
ui.ui_bottom.btn_autoSkill.selected = val;
|
|
if(val)
|
|
{
|
|
ui.ui_bottom.mc_autoSkill.play();
|
|
}
|
|
else
|
|
{
|
|
ui.ui_bottom.mc_autoSkill.stop();
|
|
}
|
|
i = 0;
|
|
while(i < myMons.length)
|
|
{
|
|
mon = myMons[i];
|
|
mon.setAutoSkill(val);
|
|
i++;
|
|
}
|
|
if(save)
|
|
{
|
|
Saver.saveAuto("autoSkill",{"autoSkill":val});
|
|
}
|
|
}
|
|
|
|
public function getAutoSkill() : Boolean
|
|
{
|
|
return _autoSkill;
|
|
}
|
|
|
|
override public function dispose() : void
|
|
{
|
|
if(contains(line))
|
|
{
|
|
removeChild(line);
|
|
}
|
|
if(key != null)
|
|
{
|
|
key.dispose();
|
|
}
|
|
pause();
|
|
gcMovies();
|
|
super.dispose();
|
|
}
|
|
}
|
|
}
|
|
|