Exemple #1
0
        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);
            }
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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;
            }
        }
Exemple #4
0
        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());
                }
            }
        }
Exemple #5
0
 private void ActivateTower(string virtualworld, string sector, int number, APIActivator activator)
 {
     if (HasWorld(virtualworld))
     {
         GetWorld(virtualworld).ActivateTower(sector, number, activator);
     }
 }
Exemple #6
0
        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;
            }
        }
Exemple #7
0
 public void ActivateTower(string sector, int number, APIActivator activator)
 {
     if (hasSector(Name))
     {
         (GetSector(sector) as Sector)?.ActivateTower(number, activator);
     }
 }
Exemple #8
0
        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();
            }
        }
Exemple #9
0
 public void Deactivate()
 {
     if (Activated)
     {
         Activator = APIActivator.NONE;
         TowerDeactivationEvent.Call(VirtualWorld.Name, Sector.Name, Number);
     }
 }
Exemple #10
0
        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);
        }
Exemple #11
0
        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);
        }
Exemple #12
0
 public void Deactivate()
 {
     if (Activated)
     {
         Activator = APIActivator.NONE;
         TowerDeactivationEvent.Call(this);
     }
 }
Exemple #13
0
 public void Activate(APIActivator activator)
 {
     if (!Activated && activator != APIActivator.NONE)
     {
         Activator = activator;
         TowerActivationEvent.Call(this);
     }
 }
Exemple #14
0
 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
 }
Exemple #15
0
 public void Hijack(APIActivator newActivator)
 {
     if (Activated && newActivator != APIActivator.NONE)
     {
         APIActivator oldActivator = Activator;
         Activator = newActivator;
         TowerHijackEvent.Call(this, oldActivator, newActivator);
     }
 }
Exemple #16
0
 public static void Call(APITower tower, APIActivator activator)
 {
     if ((IsLocked && !Assembly.GetCallingAssembly().Equals(Events.Master)))
     {
         return;
     }
     tower.Activator = activator;
     Call(tower);
 }
Exemple #17
0
        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");
        }
Exemple #18
0
 public static bool TryParseActivator(string activatorstring, out APIActivator activator)
 {
     try
     {
         activator = ParseActivator(activatorstring);
         return(true);
     }
     catch (FormatException)
     {
         activator = APIActivator.NONE;
         return(false);
     }
 }
Exemple #19
0
        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);
        }
Exemple #20
0
        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;
            }
        }
Exemple #21
0
        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);
            }
        }
Exemple #22
0
        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);
            }
        }
Exemple #23
0
 public void ActivateRandom(string vworld, APIActivator activator = APIActivator.XANA)
 {
     GetWorld(vworld)?.ActivateRandom(activator);
 }
Exemple #24
0
 private void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator)
 {
     OnTowerDeactivation(tower, oldActivator);
     OnTowerActivation(tower, newActivator);
 }
Exemple #25
0
        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.
        }
Exemple #26
0
 private void OnTowerHijack(ITower tower, APIActivator oldActivator, APIActivator newActivator)
 {
     connection.InvokeAsync("TowerHijackEvent", tower, oldActivator, newActivator);
 }
Exemple #27
0
 public static bool TryParse(this Enum activator, string activatorstring, out APIActivator activatorout)
 {
     return(TryParseActivator(activatorstring, out activatorout));
 }
Exemple #28
0
 public static APIActivator Parse(this APIActivator activator, string activatorstring)
 {
     return(ParseActivator(activatorstring));
 }
Exemple #29
0
 public void TowerHijackEvent(ITower tower, APIActivator oldActivator, APIActivator newActivator)
 {
     Clients.All.SendAsync("TowerHijackEvent", tower, oldActivator, newActivator);
 }
Exemple #30
0
 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);
 }