private void build_button1_Click(object sender, EventArgs e) { if (Form1.credit > 50) { wpnLightLaser w = new wpnLightLaser(); ShipAssaulter s = new ShipAssaulter(1, w); Player.player_ship.Add(s); Form1.credit = Form1.credit - 50; MessageBox.Show("Корабль построен"); } else { MessageBox.Show("Недостаточно ресурсов"); } }
private void build_button1_Click(object sender, EventArgs e) { if (Form1.Game.Player.credit > 50) { wpnLightLaser w = new wpnLightLaser(); ShipAssaulter s = new ShipAssaulter(1, w, new ArmorNone()); Form1.Game.Player.player_ship.Add(s); Form1.Game.Player.fleets[Form1.Game.Player.selectedFleet].ships.Add(s); Form1.Game.Player.credit -= 50; MessageBox.Show("Корабль построен"); } else { MessageBox.Show("Недостаточно ресурсов"); } }
private void CreateShip(ShipType shipType, WeaponType weaponType, Player owner) { Ship newShip; switch (shipType) { case ShipType.Scout: newShip = new ShipScout(owner, weaponType); break; case ShipType.Assaulter: newShip = new ShipAssaulter(owner, weaponType); break; default: throw new ArgumentOutOfRangeException(nameof(shipType), shipType, null); } int minColumnIndex = owner == Player.FirstPlayer ? 0 : this.MapWidth - 2; int maxColumnIndex = owner == Player.FirstPlayer ? 1 : this.MapWidth - 1; newShip.ObjectCoordinates = this.GetRandomVacantHexagon(minColumnIndex, maxColumnIndex, 0, this.MapHeight - 1); this.AddObject(newShip); }
public Fleet(Player player, int size, StarSystem s1) { ships = new List <Ship>(); onWay = false; Capturing = false; Owner = player; path = new StarPath(); int playerID = 1; if (player == null) { playerID = 2; name = "Нейтральный флот"; Random rand = new Random((int)DateTime.Now.Ticks); for (int i = 0; i < size; i++) { int ship_type = rand.Next(0, 2); int weapon_type = rand.Next(0, 2); int armor_type = rand.Next(0, 3); Weapon weapon = null; Ship ship = null; Armor armor = null; switch (weapon_type) { case 0: weapon = new WpnGauss(); break; case 1: weapon = new wpnLightLaser(); break; case 2: weapon = new WpnPlasma(); break; } switch (armor_type) { case 0: armor = new ArmorNone(); break; case 1: armor = new ArmorTitan(); break; case 2: armor = new ArmorMolibden(); break; case 3: armor = new ArmorNanocom(); break; } switch (ship_type) { case 0: ship = new ShipScout(playerID, weapon, armor); break; case 1: ship = new ShipAssaulter(playerID, weapon, armor); break; case 2: ship = new ShipСolonizer(playerID, new WpnNone(), armor); break; } ship.player = playerID; ships.Add(ship); } } else { name = "Флот <" + player.name + ">"; Ship ship = new ShipСolonizer(playerID, new WpnNone(), new ArmorNone()); ship.player = playerID; ships.Add(ship); for (int i = 1; i < size; i++) { ship = new ShipScout(playerID, new WpnNone(), new ArmorNone()); ship.player = playerID; ships.Add(ship); } } this.s1 = s1; x = s1.x; y = s1.y; z = s1.z; }