/// <summary> /// Battle Constructor, created once a unit engages an enemy in battle /// </summary> /// <param name="m">The player's unit</param> /// <param name="e">The enemy's unit</param> /// <param name="fregion">The region where the battle was engaged</param> /// <param name="fgoal">The region's condition for victory</param> public Battle(Unit m, Unit e, Region fregion, Objective fgoal) { MainWindow.BackgroundImage = Content.Graphics.Instance.Images.background.bg_smallMenu; orgls = new List<String>(); region = fregion; goal = fgoal; ally = m; enemy = e; tm=new Tilemap("battle"); cmap = new CharMap(tm); cmap.ShowMisc = true; map = new Map(tm); map.ArrowEnabled = true; map.SelectionEnabled = false; map.changeCurp = changeCurp; map.curSelection = sel; map.focus(5, 6); MainWindow.add(map); lbl_actions = new Label("Actions"); lbl_actions.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_actions.Position = new Vector2(280, 390); lbl_actions.Visible = false; MainWindow.add(lbl_actions); menu_actions = new Menu(5); menu_actions.Position = new Vector2(280, 390); menu_actions.Visible = false; MainWindow.add(menu_actions); menu_actions.Enabled = false; menu_actions.ArrowEnabled = false; lbl_moved = new Label("MOVED"); lbl_moved.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.SPECIAL; lbl_moved.Position = new Vector2(520, 414); lbl_moved.Visible = false; MainWindow.add(lbl_moved); lbl_enemyTurn = new Label("DAMAGE"); lbl_enemyTurn.Color = Color.Red; lbl_enemyTurn.Position = new Vector2(50, 50/*420*/); lbl_enemyTurn.Visible = false; MainWindow.add(lbl_enemyTurn); lbl_name = new Label("Name"); lbl_name.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_name.Position = new Vector2(50, 390); MainWindow.add(lbl_name); lbl_charName = new Label("Derp"); lbl_charName.Position = new Vector2(110, 390); MainWindow.add(lbl_charName); lbl_lvl = new Label("Level"); lbl_lvl.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_lvl.Position = new Vector2(50, 420); MainWindow.add(lbl_lvl); lbl_charLvl = new Label("20"); lbl_charLvl.Position = new Vector2(110, 420); MainWindow.add(lbl_charLvl); lbl_exp = new Label("Exp"); lbl_exp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_exp.Position = new Vector2(150, 420); MainWindow.add(lbl_exp); lbl_charExp = new Label("42"); lbl_charExp.Position = new Vector2(200, 420); MainWindow.add(lbl_charExp); lbl_hp = new Label("HP"); lbl_hp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_hp.Position = new Vector2(50, 450); MainWindow.add(lbl_hp); lbl_curHp = new Label("100"); lbl_curHp.Position = new Vector2(90, 450); MainWindow.add(lbl_curHp); lbl_hpSlash = new Label("/"); lbl_hpSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_hpSlash.Position = new Vector2(140, 450); MainWindow.add(lbl_hpSlash); lbl_maxHp = new Label("100"); lbl_maxHp.Position = new Vector2(160, 450); MainWindow.add(lbl_maxHp); lbl_mp = new Label("MP"); lbl_mp.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_mp.Position = new Vector2(50, 480); MainWindow.add(lbl_mp); lbl_curMp = new Label("50"); lbl_curMp.Position = new Vector2(90, 480); MainWindow.add(lbl_curMp); lbl_mpSlash = new Label("/"); lbl_mpSlash.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_mpSlash.Position = new Vector2(140, 480); MainWindow.add(lbl_mpSlash); lbl_maxMp = new Label("50"); lbl_maxMp.Position = new Vector2(160, 480); MainWindow.add(lbl_maxMp); lbl_moveLeft = new Label("Move Left"); lbl_moveLeft.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_moveLeft.Position = new Vector2(50, 510); MainWindow.add(lbl_moveLeft); lbl_move = new Label(""); lbl_move.Position = new Vector2(150, 510); MainWindow.add(lbl_move); lbl_enter = new Label("ENTER"); lbl_enter.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_enter.Position = new Vector2(520, 462); MainWindow.add(lbl_enter); lbl_enterAction = new Label("Select Unit"); lbl_enterAction.Position = new Vector2(600, 462); MainWindow.add(lbl_enterAction); lbl_v = new Label("V"); lbl_v.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_v.Position = new Vector2(520, 438); MainWindow.add(lbl_v); lbl_vAction = new Label("View Character"); lbl_vAction.Position = new Vector2(550, 438); MainWindow.add(lbl_vAction); lbl_esc = new Label("ESC"); lbl_esc.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_esc.Position = new Vector2(520, 486); lbl_esc.Visible = false; MainWindow.add(lbl_esc); lbl_escAction = new Label("Cancel Movement"); lbl_escAction.Position = new Vector2(570, 486); lbl_escAction.Visible = false; MainWindow.add(lbl_escAction); lbl_e = new Label("E"); lbl_e.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.CONTROL; lbl_e.Position = new Vector2(520, 510); MainWindow.add(lbl_e); lbl_eAction = new Label("End Turn"); lbl_eAction.Position = new Vector2(550, 510); MainWindow.add(lbl_eAction); lbl_turnCount = new Label("Turn: " + turnCount + " / 10"); lbl_turnCount.LabelFun = ColorTheme.LabelColorTheme.LabelFunction.BOLD; lbl_turnCount.Position = new Vector2(520, 390); MainWindow.add(lbl_turnCount); lbl_dmg = new Label(""); lbl_dmg.Color = Color.Red; lbl_dmg.Position = new Vector2(0, 0); lbl_dmg.Visible = false; MainWindow.add(lbl_dmg); lbl_actionTaken = new Label(""); lbl_actionTaken.Color = Color.Black; lbl_actionTaken.Position = new Vector2(250, 30); lbl_actionTaken.Font = Content.Graphics.Instance.ActionFont; lbl_actionTaken.Visible = false; MainWindow.add(lbl_actionTaken); lbl_armyTurn = new Label("TO BATTLE, COMRADES!"); lbl_armyTurn.Font = Content.Graphics.Instance.TurnFont; lbl_armyTurn.center(50); lbl_armyTurn.doneShowing = armyTurnDone; lbl_armyTurn.visibleTemp(2000); MainWindow.add(lbl_armyTurn); lbl_battleOutcome = new Label("VICTORY!"); lbl_battleOutcome.Font = Content.Graphics.Instance.TurnFont; lbl_battleOutcome.center(50); lbl_battleOutcome.doneShowing = endOfBattle; lbl_battleOutcome.Visible = false; MainWindow.add(lbl_battleOutcome); deploy(m, true); deploy(e, false); cmap.update(map); freemode = true; actionMode = false; targetMode = false; spellMode = false; itemMode = false; changeCurp(null, new EventArgObject(new Point(5, 6))); scp = new Point(5, 6); endTurnP = new Point(5, 6); setAllNotMoved(); ai = new AI(); ai.set(map, tm, cmap); ai.done = ai_done; MainWindow.InputEnabled = false; }
private void dialog_ret_battle(bool b) { if (b) { GameState.CurrentState.att = 0; lp = GameState.CurrentState.mainCharPos; if (map.CharLs.ContainsKey(dnp)) map.CharLs.Remove(dnp); map.CharLs.Remove(GameState.CurrentState.mainCharPos); map.CharLs.Add(dnp, Graphic.getSprite(GameState.CurrentState.mainChar)); System.Console.Out.WriteLine(GameState.CurrentState.mainCharPos+" "+dnp); City.CitySide atts=City.opposed(City.move2side(GameState.CurrentState.mainCharPos, dnp)); GameState.CurrentState.mainCharPos = dnp; changeCurp(this, new EventArgObject(new Point(dnp.X, dnp.Y))); clearFog(dnp); map.focus(dnp.X, dnp.Y); Tilemap tm = new Tilemap(GameState.CurrentState.citymap["gen"].get(dnp.X, dnp.Y).Name); Objective goal = new Objective(); goal.setDefeatAll(); StateManager.Instance.goForward(new Region(tm, atts, true, GameState.CurrentState.citymap["gen"].get(dnp.X, dnp.Y).EnnemyFactor, goal)); } yn_battle.InputEnabled = false; }
/// <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(); } }