/// <inheritdoc /> public bool IsValid(Fleet fleet, Mappable target, EmpireData sender, EmpireData receiver) { if (fleet.InOrbit == null || target == null || !(target is Star)) { Message message = new Message(); message.Audience = fleet.Owner; message.Text = "Fleet " + fleet.Name + " attempted to unload cargo while not in orbit."; Messages.Add(message); return(false); } Star star = target as Star; // Check ownership. if (fleet.Owner != star.Owner) { bool toReturn = false; InvadeTask invade = new InvadeTask(); if (invade.IsValid(fleet, target, sender, receiver)) { toReturn = invade.Perform(fleet, target, sender, receiver); } Messages.AddRange(invade.Messages); return(toReturn); } return(true); }
public IWaypointTask LoadTask(string taskName, XmlNode node) { if (!taskName.Contains("Task")) { taskName += "Task"; } taskName.Replace(" ", ""); switch (taskName.ToLower()) { case "cargotask": Task = new CargoTask(node); break; case "colonisetask": Task = new ColoniseTask(node); break; case "invadetask": Task = new InvadeTask(node); break; case "layminestask": Task = new LayMinesTask(node); break; case "scraptask": Task = new ScrapTask(node); break; case "splitmergetask": Task = new SplitMergeTask(node); break; default: Task = new NoTask(); break; } return(Task); }