public void ActivateRandom(APIActivator activator = APIActivator.XANA) { List <Sector> randomSectors = Program.ShuffleList(Sectors.Cast <Sector>().ToList()); Boolean found = false; foreach (Sector sector in randomSectors) { try { if (!found) { sector.ActivateRandom(activator); found = true; } } catch (NoFreeTowersException) { //continue } } if (!found) { throw new NoFreeSectorsException(this); } }
private static void onHijack(ITower tower, APIActivator old, APIActivator newactivator) { LyokoAPI.Events.LyokoLogger.Log("Test", "Hijack"); string json = "{\"secteur\": \"" + tower.Sector.Name + "\",\"nombre\": \"" + tower.Number + "\",\"old\": \"" + getActivator(old) + "\",\"new\": \"" + getActivator(newactivator) + "\"}"; sendEvent("hijack", json); }
private void OnTowerDeactivation(ITower tower, APIActivator activator) { if (!HasTower(tower)) { return; } switch (activator) { case APIActivator.XANA: XanaTowers.Remove(tower); if (XanaTowers.Count == 0) { onXanaDefeat(); } break; case APIActivator.HOPPER: HopperTowers.Remove(tower); break; case APIActivator.JEREMIE: JeremieTowers.Remove(tower); break; } }
public void Activate(string activator = "XANA") { var newactivator = LyokoParser.ParseActivator(activator.ToUpper()); if (!Activated) { if (newactivator == APIActivator.NONE) { return; } Activator = newactivator; TowerActivationEvent.Call(VirtualWorld.Name, Sector.Name, Number, newactivator.ToString()); } else { if (newactivator == APIActivator.NONE) { Deactivate(); return; } if (newactivator != Activator) { Hijack(newactivator.ToString()); } } }
private void ActivateTower(string virtualworld, string sector, int number, APIActivator activator) { if (HasWorld(virtualworld)) { GetWorld(virtualworld).ActivateTower(sector, number, activator); } }
private void OnTowerActivation(ITower tower, APIActivator activator) { if (HasTower(tower)) { return; } switch (activator) { case APIActivator.XANA: if (XanaTowers.Count == 0) { onXanaAwaken(); } XanaTowers.Add(tower); break; case APIActivator.HOPPER: HopperTowers.Add(tower); break; case APIActivator.JEREMIE: JeremieTowers.Add(tower); break; } }
public void ActivateTower(string sector, int number, APIActivator activator) { if (hasSector(Name)) { (GetSector(sector) as Sector)?.ActivateTower(number, activator); } }
public void ActivateRandom(APIActivator activator = APIActivator.XANA) { List <VirtualWorld> randomVworlds = Program.ShuffleList(Vworlds); Boolean found = false; foreach (VirtualWorld virtualWorld in randomVworlds) { try { if (!found) { virtualWorld.ActivateRandom(activator); found = true; } } catch (NoFreeSectorsException) { //continue } } if (!found) { throw new NoFreeVirtualWorldsException(); } }
public void Deactivate() { if (Activated) { Activator = APIActivator.NONE; TowerDeactivationEvent.Call(VirtualWorld.Name, Sector.Name, Number); } }
private static void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator) { string title = Main.localize("tower.hijack.title"); string body = String.Format(Main.localize("tower.hijack.subtitle"), tower.Number, Main.localize("sector." + tower.Sector.Name.ToLowerInvariant()), Main.GetUppercaseNames(oldActivator.ToString()), Main.GetUppercaseNames(newActivator.ToString())); FireBasePush.SendMessage(title, body); }
private static void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator) { string title = "Huh? A tower has been hijacked!"; string body = "Tower nº" + tower.Number + " in the " + Main.GetUppercaseNames(tower.Sector.Name) + ", from " + Main.GetUppercaseNames(oldActivator.ToString()) + " to " + Main.GetUppercaseNames(newActivator.ToString()) + "!"; FireBasePush.SendMessage(title, body); }
public void Deactivate() { if (Activated) { Activator = APIActivator.NONE; TowerDeactivationEvent.Call(this); } }
public void Activate(APIActivator activator) { if (!Activated && activator != APIActivator.NONE) { Activator = activator; TowerActivationEvent.Call(this); } }
internal void Activate(APIActivator activator = APIActivator.XANA) { if (Activated) { return; // for APITower, Activated checks if the activator isn't NONE } this.Activator = Activator; //assign activator first TowerActivationEvent.Call(this); //call event second }
public void Hijack(APIActivator newActivator) { if (Activated && newActivator != APIActivator.NONE) { APIActivator oldActivator = Activator; Activator = newActivator; TowerHijackEvent.Call(this, oldActivator, newActivator); } }
public static void Call(APITower tower, APIActivator activator) { if ((IsLocked && !Assembly.GetCallingAssembly().Equals(Events.Master))) { return; } tower.Activator = activator; Call(tower); }
private static string getActivator(APIActivator activator) { switch (activator) { case APIActivator.XANA: return("XANA"); break; case APIActivator.JEREMIE: return("JEREMIE"); break; case APIActivator.HOPPER: return("HOPPER"); break; } return("ERROR"); }
public static bool TryParseActivator(string activatorstring, out APIActivator activator) { try { activator = ParseActivator(activatorstring); return(true); } catch (FormatException) { activator = APIActivator.NONE; return(false); } }
internal void Hijack(APIActivator newActivator) { if (!Activated) { return; } if (Activator.Equals(newActivator)) { return; } APIActivator old = Activator; //the event doesn't change the activator for you Activator = newActivator; //the ol' switcheroo TowerHijackEvent.Call(this, old, newActivator); }
public void Hijack(string activator) { var newactivator = LyokoParser.ParseActivator(activator.ToUpper()); if (!Activated) { Activate(activator); } else if (newactivator == APIActivator.NONE) { Deactivate(); } else if (newactivator != Activator) { TowerHijackEvent.Call(new APITower(VirtualWorld.Name, Sector.Name, Number), newactivator, Activator); Activator = newactivator; } }
public static void Call(ITower tower, APIActivator old, APIActivator newactivator) { if ((IsLocked && !Assembly.GetCallingAssembly().Equals(Events.Master))) { return; } if (old.Equals(APIActivator.NONE)) { TowerActivationEvent.Call(new APITower(tower.Sector.World.Name, tower.Sector.Name, tower.Number), newactivator); } else if (newactivator.Equals(APIActivator.NONE)) { TowerDeactivationEvent.Call(new APITower(tower.Sector.World.Name, tower.Sector.Name, tower.Number)); } else { TowerHijackE?.Invoke(tower, old, newactivator); } }
public void ActivateRandom(APIActivator activator = APIActivator.XANA) { List <Tower> randomTowers = Program.ShuffleList(Towers.Cast <Tower>().ToList()); Boolean found = false; foreach (Tower tower in randomTowers) { if (!found && !tower.Activated) { tower.Activate(activator); found = true; } } if (!found) { throw new NoFreeTowersException(this); } }
public void ActivateRandom(string vworld, APIActivator activator = APIActivator.XANA) { GetWorld(vworld)?.ActivateRandom(activator); }
private void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator) { OnTowerDeactivation(tower, oldActivator); OnTowerActivation(tower, newActivator); }
public void Activate(int i, APIActivator activator = APIActivator.XANA) { Tower foundTower = GetTower(i); //we need our own Tower, because ITower doesn't contain Activate() foundTower?.Activate(activator); //we need to check if the tower actually exists. }
private void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator) { connection.InvokeAsync("TowerHijackEvent", tower, oldActivator, newActivator); }
public static bool TryParse(this Enum activator, string activatorstring, out APIActivator activatorout) { return(TryParseActivator(activatorstring, out activatorout)); }
public static APIActivator Parse(this APIActivator activator, string activatorstring) { return(ParseActivator(activatorstring)); }
public void TowerHijackEvent(ITower tower, APIActivator oldActivator, APIActivator newActivator) { Clients.All.SendAsync("TowerHijackEvent", tower, oldActivator, newActivator); }
private static void onTowerHijacked(ITower tower, APIActivator oldActivator, APIActivator newActivator) { Console.WriteLine("{0} hijacked {1} {2} from {3}", tower.Activator, tower.Sector.Name, tower.Number, oldActivator); }