public static Boolean battle(CharMap cmap, Tilemap tm, String org, Map map, Unit ally, Unit enemy, Label dmg, Label action, ref Boolean gameOver, ref Boolean defeat, GameTime gameTime) { Character c = cmap.get(map.CursorPosition.X, map.CursorPosition.Y); Character m; Point p; Point ne; if (c != null && c.Organization == org && c.stats.movement != 0) { if(c is Healer) ne = nearest(cmap, map.CursorPosition, "ennemy"); else ne = nearest(cmap, map.CursorPosition, "main"); if (isAdj(map.CursorPosition, ne)) { c.stats.movement = 0; p = map.CursorPosition; } else { //finds path to nearest ennemy p = pathFind(cmap, tm, map.CursorPosition, nearest(cmap, map.CursorPosition, "main"), org); if (c.stats.movement > 0) { cmap.move(map.CursorPosition.X, map.CursorPosition.Y, p.X, p.Y); map.changeCursor(new Point(p.X, p.Y)); } c.stats.movement--; } if (c.stats.movement == 0) { Point tar = targetCharacter(c, p, cmap); if (tar != new Point(-1, -1)) { m = cmap.get(tar.X, tar.Y); map.CurLs.Add(tar, Content.Graphics.Instance.Images.gui.cursorRed); if (c is Fighter) dmg.Text = ((Fighter)c).attack(m); else if (c is Archer) dmg.Text = ((Archer)c).attack(m); else if (c is Scout) dmg.Text = ((Scout)c).attack(m); else if (c is Healer) { dmg.Text = ((Healer)c).heal(m).ToString(); action.Text = "Heal"; } else if (c is Caster) { dmg.Text = ((Caster)c).attack(m, new Spell("DerpCast", 1, 5, 1, 5)); action.Text = "DerpCast"; } else dmg.Text = "Cant"; if (action.Text == "") action.Text = "Attack"; dmg.Position = new Vector2(tar.X * 64 - map.getTlc.X * 64, tar.Y * 64 - map.getTlc.Y * 64 + 20); dmg.visibleTemp(500); action.visibleTemp(500); if (dmg.Text != "miss" || dmg.Text != "Cant") { enemy.set(c.Position.X, c.Position.Y, c); ally.set(m.Position.X, m.Position.Y, m); if (m.stats.hp <= 0) { if (m.isMainChar()) gameOver = true; ally.delete(m.Position.X, m.Position.Y); cmap.set(tar.X, tar.Y, null); cmap.update(map); if (ally.Characters.Count <= 0) defeat = true; } } } } return false; } else { for (int e = cmap.NumY - 1; e >= 0; e--) for (int i = cmap.NumX - 1; i >= 0; i--) if (cmap.isChar(i, e) && cmap.get(i, e).stats.movement != 0 && cmap.get(i, e).Organization == org) { if (map.CursorPosition != new Point(i, e)) { map.CurLs.Clear(); dmg.Visible = false; action.Visible = false; action.Text = ""; map.changeCursor(new Point(i, e)); return false; } } } cmap.resetAllMovement(org); return true; }