private void aiMomentary() { if (!player.ship.canMove()) { Ships.Engine engine = player.ship.findBestEngine(); if (engine != null) { player.ship.removeComponent(engine); player.ship.setEngine(engine); } } while (player.ship.cannons.Count < player.ship.getHull().number_of_cannons) { Ships.Cannon cannon = player.ship.findBestCannon(); if (cannon == null) { break; } player.ship.removeComponent(cannon); player.ship.addCannon(cannon); } for (int i = 0; i < player.attack.Count; i++) { player.ship.shot(player.attack[i]); } }
public static void generate(XmlDocument config) { foreach (XmlNode table in config.DocumentElement) { String id = rs(table.Attributes["id"]); int level = ri(table.Attributes["level"]); int type = ri(table.Attributes["type"]); switch (table.Name) { case "cannon": { int damage = ri(table.Attributes["damage"]); int radius = ri(table.Attributes["radius"]); int rate = ri(table.Attributes["rate"]); Ships.Cannon cannon = new Ships.Cannon(); cannon.damage = damage; cannon.radius = radius; cannon.rate = rate; cannon.level = level; cannon.type = type; Economy.cannons.Add(cannon); Registry.getInstance().addElement(cannon, id); } break; case "engine": { int power = ri(table.Attributes["power"]); Ships.Engine engine = new Ships.Engine(); engine.power = power; engine.level = level; engine.type = type; Economy.engines.Add(engine); Registry.getInstance().addElement(engine, id); } break; case "hull": { float protection = rf(table.Attributes["protection"]); int cannons = ri(table.Attributes["cannons"]); int slots = ri(table.Attributes["slots"]); Ships.Hull hull = new Ships.Hull(); hull.protection = protection; hull.number_of_cannons = cannons; hull.number_of_free_slots = slots; hull.level = level; hull.type = type; Economy.hulls.Add(hull); Registry.getInstance().addElement(hull, id); } break; } } }
public ShotView(Cannon model, GCore.Point from, GCore.Point to) { load("DATA\\Shots\\shot1.png"); setAxis(0, height / 2); ratio = false; width = GCore.Point.distance(from, to); height = 5; rotationZ = GCore.Point.angle(from, to); x = from.x; y = from.y; timer.interval = 300; timer.addEventListener(GCore.TimerEvent.TIMER, onTimer); timer.start(); }
public Cannon findBestCannon() { float max = Single.MinValue; Cannon best = null; for (int i = 0; i < hold.Count; i++) { if (hold[i] is Cannon) { if (hold[i].score > max) { max = hold[i].score; best = (Cannon)hold[i]; } } } return(best); }
public void removeCannon(Cannon cannon) { cannons.Remove(cannon); }
public void addCannon(Cannon cannon) { cannons.Add(cannon); }