/// <summary> /// Initiate battle AI process /// </summary> /// <param name="b"></param> /// <param name="org"></param> public void battle(Battle fbat, String org) { bat = fbat; useUnit = false; bat_step = 0; cc = new Point(-1, -1); type = AI_Type.BATTLE; iorg = org; needDelay = true; isActive = true; }
/// <summary> /// resumes AI process after delay /// </summary> private void region_resume() { if (reg_step == Region_Steps.FIND) { ActionUnit au=ActionUnit.Null; au = findActionUnit(iorg); if (au == ActionUnit.Null) { isActive = false; if (done != null) done(this, null); return; } map.focus(au.unit.X, au.unit.Y); needDelay = true; reg_step = Region_Steps.MOVE; } else if (reg_step == Region_Steps.MOVE) { ActionUnit au = findActionUnit(iorg); Unit mu=umap.get(au.move.X, au.move.Y); Unit eu = umap.get(au.unit.X, au.unit.Y); if (mu!=null&&mu.Organization == "main") { eu.movement = 0; Objective o = new Objective(); o.setDefeatAll(); inBattle = true; Battle b = new Battle(mu, eu, reg, o); b.done = battle_done; reg_step = Region_Steps.FIND; StateManager.Instance.goForward(b); } else { umap.move(au.unit.X, au.unit.Y, au.move.X, au.move.Y); umap.update(map); eu.movement--; map.focus(au.move.X, au.move.Y); needDelay = true; reg_step = Region_Steps.FIND; } umap.remDeadUnit(); } }