private void ImportCompetition(string[] record) { var shortName = record[2].Trim(); Competition competition; if (Competitions.Any(c => c.ShortName == shortName)) { competition = Competitions.First(c => c.ShortName == shortName); } else { if (Tasks.Count() > 0 || Pilots.Count() > 0) { throw new InvalidOperationException("Competition import is not allowed when there are pilots or tasks defined"); } competition = new Competition() { ShortName = shortName }; Competitions.Add(competition); } competition.Name = record[1].Trim(); }
private void ImportTask(string[] record) { if (Competitions.Count() == 0 || Pilots.Count() == 0) { throw new InvalidOperationException("Task import is not allowed when no competitions or pilots are defined"); } var taskNumber = int.Parse(record[1]); Task task; if (!Tasks.Any(t => t.Number == taskNumber)) { task = new Task() { Number = taskNumber }; Tasks.Add(task); } else { task = Tasks.First(t => t.Number == taskNumber); } var type = record[2].ToUpper().Trim(); if (!Task.Types.Any(t => t.ShortName == type)) { throw new InvalidOperationException("Inexistent task type " + type); } var typeNumber = Task.Types.First(t => t.ShortName == type).Number; task.TypeNumber = typeNumber; if (record.Count() > 3) { var date = (new DateConverter()).ConvertBack(record[3], typeof(DateTime), null, null); if (date is DateTime) { task.Date = (DateTime)date; } else { task.Date = DateTime.Now; } } }
public int AddXwingTeam(int num, int innerRange, int outerRange, int centerX, int centerY, RelationEnum relation) { int rval = -1;//return the leader pilot int leaderIndex = pilots.Count(); int[] followersIndex = new int[num - 1]; for (int i = 0; i < num - 1; i++) { followersIndex[i] = leaderIndex + i + 1; } rval = AddBasicAI(1, innerRange, outerRange, centerX, centerY, relation, TeamRole.LEADER, followersIndex); AddBasicAI(num - 1, innerRange, outerRange, centerX, centerY, relation, TeamRole.FOLLOWER, new int[1] { leaderIndex }); //game.uICombat.controlInformation.AddText("Xwing Team added!", Color.White); return(rval); }