public static Fighter CreateFighter(Map <Coordinate2D, Metric2D, int> map, int team, int number, char type, FighterController control) { Fighter f = new Fighter(map); //common properties f._hp = maxHP; f._letter = type.ToString()[0].ToString(); f._team = team; f._number = number; f._mana = maxMana; f.controller = control; f.SightLength = 50; f.SightAngle = Math.PI / 4; Point p = new Point(team == 0 ? 0 : ((GameBackground)map.Background).Width - 1, 10 * number); f.Location = p; f.BirthLocation = p; f.Angle = team == 0 ? 0 : Math.PI; f.eyeshot = new Metric2D(10000, 10000); switch (type) { case 'P': f.Damage = 70; f.Precision = 50; f.Speed = 15; f.ShotCost = 3; break; case 'M': f.Damage = 40; f.Precision = 100; f.Speed = 12; f.ShotCost = 2; break; case 'S': f.Damage = 100; f.Precision = 90; f.Speed = 10; f.ShotCost = 5; f.SightAngle /= 3; f.SightLength *= 2; break; case 'R': f.Damage = 100; f.Precision = 90; f.Speed = 10; f.ShotCost = 10; f.Radius = 5; break; case 'F': f.Damage = 100; f.Precision = 100; f.Speed = 10; f.ShotCost = 20; f.Radius = 10; break; } return(f); }
private static void Start(string[] args) { if (args.Length != 4) { throw new Exception("Запускать с параметрами: [файл карты] [к-во игроков в одной команде] [программа 1] [программа 2]"); } if (!File.Exists(args[0])) { throw new Exception("Некорректный файл карты"); } if (!File.Exists(args[2])) { throw new Exception("Некорректный файл первой программы"); } if (!File.Exists(args[3])) { throw new Exception("Некорректный файл второй программы"); } int cnt; try { cnt = int.Parse(args[1]); } catch { throw new Exception("Неверное количество игроков"); } GameBackground back = new GameBackground(args[0], cnt); Ether eth = new ListEther(); eth["0"] = new string[cnt]; eth["1"] = new string[cnt]; // creating map with Color in Background's cells and LiteListCells in map's cells Map2D <int> map2D = new Map2D <int>( // its size is simmilar to image size back.Width, back.Height, // delegate for creating new cells delegate(Map2D <int> map, Coordinate2D coord) { return(new ListCell <Coordinate2D, Metric2D, int>(map, coord)); }, // backround of this map is based on image back, // ether of this map (usualy used ListEther) eth); List <ConsoleController> l1 = new List <ConsoleController>(); for (int j = 0; j < 2; j++) { for (int i = 0; i < cnt; i++) { ConsoleController c = new ConsoleController(args[j + 2], j, i); Fighter f = Fighter.CreateFighter(map2D, j, i, c.Letter, c); map2D.Add(new Coordinate2D(f.Location.X, f.Location.Y), f); l1.Add(c); } } Application.Run(new GameForm(back, eth, map2D)); foreach (ConsoleController c in l1) { c.Dispose(); } return; }
public abstract FighterControllerData MakeTurn(Fighter f, List <Fighter> units, string[] eth);