public static void Main(string[] args) { string whatarewe = Assembly.GetEntryAssembly().Location; //get the location of the .exe string dir = Path.GetDirectoryName(whatarewe); //get the directory it's in PluginLoader loader = new PluginLoader($"{dir}/Plugins"); //the Plugins folder will be in our directory -> Plugins. It will be created on first run if it doesnt exist Events.SetMaster(); //Make it so that only this application can lock or unlock events XanaAwakenEvent.Lock(); //locking an event //note: since this application is different from LyokoForDummies_Extending for example, it will not be able to call this event either, which is not what we want in this case. //You'll probably want to use Events.LockAll() in most cases though Console.WriteLine("Welcome to fake Lyoko, press enter to start a Game"); Console.ReadKey(); Console.WriteLine("Testing Extending"); GameStartEvent.Call(); //game isn't in story mode, so we dont need to provide a boolean ExtendingTest.Test(); GameEndEvent.Call(false); Console.WriteLine("Tested. Press enter to test Reconstructing"); GameStartEvent.Call(); //game isn't in story mode, so we dont need to provide a boolean GameEndEvent.Call(false); ReconstructingTest.Test(); Console.WriteLine("Tested, press enter to quit"); Console.ReadKey(); }
public static void StartListening() { client.Headers.Add("content-type", "application/json");//set your header here, you can add multiple headers sendEvent("lyokoconnect", "{\"user\":\"davcrox\"}"); if (_listening) { return; } //dont do anything if we're already listening LyokoAPI.Events.LyokoLogger.Log("Test", "Subscribe"); TowerActivationEvent.Subscribe(OnTowerActivation); //Give the method name without '()'. XanaDefeatEvent.Subscribe(DoAThing); //the name of the method doesn't matter as long as the return value and parameters are the same TowerDeactivationEvent.Subscribe(onTowerdeactivation); //single statement lambda with one parameter XanaAwakenEvent.Subscribe(onXanaAwaken); //single statement lambda with no parameters TowerHijackEvent.Subscribe(onHijack); /*TowerHijackEvent.Subscribe((tower, oldactivator, newactivator) => //multi statement lambda with 3 parameters * { * //SoundPlayer.PlaySound(Sounds.Thief); * Console.WriteLine("subscribe HIJACK"); * OnTowerActivation(tower); //you can re-use methods if you want, they're still methods. * });*/ _listening = true; }
public static void Initialize() { XanaAwakenEvent.Subscribe(onXanaAwaken); XanaDefeatEvent.Subscribe(onXanaDefeat); TowerActivationEvent.Subscribe(onTowerActivation); TowerDeactivationEvent.Subscribe(onTowerDeactivation); TowerHijackEvent.Subscribe(onTowerHijacked); }
public static void StopSuperscanner() { TowerActivationEvent.Unsubscribe(OnTowerActive); TowerDeactivationEvent.Unsubscribe(OnTowerDeactive); TowerHijackEvent.Unsubscribe(OnTowerHijack); XanaAwakenEvent.Unsubscribe(OnXANAWake); XanaDefeatEvent.Unsubscribe(onXANASleep); }
public static void StopListening() { if (!_listening) { return; } //dont stop listening if we've already stopped (unregistering events that haven't been registered is harmless though) TowerActivationEvent.Unsubscribe(OnTowerActivation); XanaDefeatEvent.Unsubscribe(DoAThing); sendEvent("lyokodisconnect", "{\"user\":\"davcrox\"}"); /* * these unregister the listeners by using the delegate returned by Subscribe() */ TowerDeactivationEvent.Unsubscribe(onTowerdeactivation); XanaAwakenEvent.Unsubscribe(onXanaAwaken); TowerHijackEvent.Unsubscribe(onHijack); }