Ejemplo n.º 1
0
        public void Test1()
        {
            var pb = new PubSub(_redis, "pb_test1");
            var rs = pb.Publish("test");

            Assert.Equal(0, rs);
        }
Ejemplo n.º 2
0
        public void Subscribes()
        {
            var pb = new PubSub(_redis, "pb_t1,pb_t2");

            var source = new CancellationTokenSource(2_000);

            var count = 0;

            Task.Run(() => pb.SubscribeAsync((t, s) =>
            {
                count++;
                XTrace.WriteLine("Consume: [{0}] {1}", t, s);
            }, source.Token));

            Thread.Sleep(100);

            var pb1 = new PubSub(_redis, "pb_t1");
            var rs  = pb1.Publish("test");

            Assert.Equal(1, rs);

            Thread.Sleep(100);
            var pb2 = new PubSub(_redis, "pb_t2");

            pb2.Publish("test2");

            Thread.Sleep(100);
            pb2.Publish("test3");

            Thread.Sleep(100);

            Assert.Equal(3, count);
        }
Ejemplo n.º 3
0
        public void Dispose()
        {
            // Dispose webserver
            Host.Dispose();

            PubSub.Dispose();
        }
Ejemplo n.º 4
0
        public override async Task ConsumeAsync(int index)
        {
            var filename   = $"table-{index}.csv";
            var outputPath = Path.Join(Destination, filename);
            var converter  = new TableEntityConverter();

            using (var tw = File.CreateText(outputPath))
                using (var csv = new CsvWriter(tw))
                {
                    csv.WriteField("PartitionKey");
                    csv.WriteField("RowKey");
                    csv.WriteField("Timestamp");
                    csv.WriteField("Data");
                    await csv.NextRecordAsync();

                    foreach (var row in PubSub.GetConsumingEnumerable())
                    {
                        csv.WriteField(row.PartitionKey);
                        csv.WriteField(row.RowKey);
                        csv.WriteField(row.Timestamp.UtcDateTime.ToString("O"));

                        var data = JsonConvert.SerializeObject(
                            row.Properties,
                            converter
                            );

                        csv.WriteField(data);

                        await csv.NextRecordAsync();
                    }
                }
        }
Ejemplo n.º 5
0
        public MainViewModel(ReadingEntity readingModel)
        {
            // Publish an event with eventName = PubSubTest. Others can subscribe to said eventName, in order to catch when it is raised
            PubSub <object> .PublishEvent("PubSubTest", PubSubCheckedHandler);

            // ReadingModel contains a list of movie objects data fetched from the database
            this.readingModel = readingModel;


            // Initialize other viewmodels
            WatchedMoviesViewModel    = new WatchedMoviesViewModel(readingModel.WatchedMovies);                         // Pass list of movie objects to the WatchedMovies
            NonWatchedMoviesViewModel = new NonWatchedMoviesViewModel(readingModel.NonWatchedMovies);                   // Pass list of movie objects to the NonWatchedMovies
            AddMovieViewModel         = new AddMovieViewModel(this, WatchedMoviesViewModel, NonWatchedMoviesViewModel); // Pass reference for mainviewmodel and both datagrids, so when we add a new movie we know where to put it

            // Subscribe to the ViewModels' OnpropertyChanged event
            WatchedMoviesViewModel.PropertyChanged    += MoviesViewModel_PropertyChanged;
            NonWatchedMoviesViewModel.PropertyChanged += MoviesViewModel_PropertyChanged;
            this.PropertyChanged += MainWindowViewModel_PropertyChanged; // Subscribe to MainViewModels OnPropertyChanged event to check for changes in MainViewModel



            // Register commands so we are able to execute specific buttons
            RegisterCommand(SaveCommand = new ActionCommand(Save, CanSave));
            RegisterCommand(LoadCommand = new ActionCommand(Load, CanLoad));
            RegisterCommand(TestCommand = new ActionCommand(Test, CanTest));
        }
Ejemplo n.º 6
0
    public void Init(Player player)
    {
        this.Player = player;
        this.CurrentMovementDirection = this.Player.StartingMovementDirection;

        this.CanJump = true;

        this.IsBlocking = new BehaviorSubject <CurrentPlayerIsBlocking>(new CurrentPlayerIsBlocking(this.Player, false));

        this.Register(this.IsBlocking);

        this.Rigidbody = this.GetComponent <Rigidbody>();

        if (this.Rigidbody != null)
        {
            PubSub.GetEvent <PlayerMove>().Where(e => e.JoystickID == this.Player.Id).Subscribe(this.Move);
            PubSub.GetEvent <PlayerJump>().Where(e => e.JoystickID == this.Player.Id).Subscribe(this.Jump);
        }

        PubSub.GetEvent <CurrentPlayerOpponent>().Where(e => e.Player == this.Player).Subscribe(e => this.CurrentOpponent = e.Opponent);

        this.Subscribe <FightOver>(e => this.EnableCameraBounds(false));
        this.Subscribe <PlayersSpawned>(e => this.EnableCameraBounds(true));

        this.Subscribe <FightOver>(e => this.EnableInput(false));
        this.Subscribe <RoundStarted>(e => this.EnableInput(true));
    }
Ejemplo n.º 7
0
    private void SpawnPlayers(FightStart fightStart)
    {
        this.Player1Prefab.transform.position = this.PLAYER_1_START_POS;
        this.Player2Prefab.transform.position = this.PLAYER_2_START_POS;

        PubSub.Publish(new PlayersSpawned());
    }
Ejemplo n.º 8
0
 private void finishPerson()
 {
     PubSub.unsubscribe("belt_movement", this);
     PubSub.unsubscribe("bag_inspect_item", this);
     // TODO - Calculate points and consequences
     Destroy(this.gameObject);
 }
    // Start is called before the first frame update
    void Start()
    {
        TV_CONTENTS_BUTTONS_LAYER_MASK = LayerMask.GetMask(new string[] { "TVContentsButton" });
        TV_SCREEN_LAYER_MASK           = LayerMask.GetMask(new string[] { "TVScreen" });

        PubSub.subscribe("ClickTV", this, 99);
    }
Ejemplo n.º 10
0
    public void inspect()
    {
        PubSub.subscribe("inspect_rotate", this);
        PubSub.subscribe("inspect_action", this);
        locationInBag = this.transform.localPosition;
        rotationInBag = this.transform.localRotation;
        parentBag     = this.transform.parent;

        // Turn off casting shadows
        enableShadows(false); // TODO - When action is taken, don't forget to enable shadows again

        // Target object position
        Vector3 targetPosition = Game.instance.gameCamera.transform.position + Game.instance.gameCamera.transform.rotation * (Vector3.forward * 18f);

        this.transform.parent = null;
        Misc.AnimateMovementTo("content-zoom-" + id, this.gameObject, targetPosition);

        // Special method to run when starting inspection on this object
        ActionOnInspect[] actionOnInspects = GetComponents <ActionOnInspect>();
        foreach (ActionOnInspect actionOnInspect in actionOnInspects)
        {
            Debug.Log(actionOnInspect);
            if (actionOnInspect != null)
            {
                actionOnInspect.run();
            }
        }

        inspecting = true;
        BagContentProperties.currentInspectedItem = this;
    }
Ejemplo n.º 11
0
        static void Main(string[] args)
        {
            const int port      = 50052;
            var       pubsubImp = new PubSubImpl();

            Grpc.Core.Server server = new Grpc.Core.Server
            {
                Services = { PubSub.BindService(pubsubImp) },
                Ports    = { new ServerPort("localhost", port, ServerCredentials.Insecure) }
            };

            server.Start();

            Console.WriteLine("RouteGuide server listening on port " + port);
            Console.WriteLine("Insert event. 'q' to quit.");
            string input;

            while ((input = Console.ReadLine()) != "q")
            {
                pubsubImp.Publish(input);
            }

            Console.WriteLine("Press any key to stop the server...");
            Console.ReadKey();

            server.ShutdownAsync().Wait();
        }
Ejemplo n.º 12
0
        private void Start()
        {
            if (!this.IsValidObject())
            {
                return;
            }

            // Setup bindings from view to events or model
            this.PlayerView.DecreaseHealth
            .OnClickAsObservable()
            .Subscribe(_ => PubSub.Publish(new DecreaseHealth(10)));

            this.PlayerView.Reset
            .OnClickAsObservable()
            .Subscribe(_ =>
            {
                this.PlayerModel.CurrentHealth.Value        = this.PlayerModel.MaxHealth.Value;
                this.PlayerView.DecreaseHealth.interactable = true;
            });

            // Setup bindings from model to view
            this.PlayerModel.Name
            .SubscribeToText(this.PlayerView.Name);

            this.PlayerModel.CurrentHealth
            .SubscribeToText(this.PlayerView.CurrentHealth);

            this.PlayerModel.IsDead
            .Where(x => x)
            .Subscribe(_ => this.PlayerView.DecreaseHealth.interactable = false);
        }
Ejemplo n.º 13
0
        public GatewayServer(int region)
        {
            Region = region;
            var app = Http.CreateServer((req, res) => res.End());

            var io = SocketIO.Listen(app);

            port = 1800 + Math.Truncate((int) ( Math.Random() * 4000 ));

            app.Listen(port);
            io.Set("log level", 1);
            myName = "Gateway " + Guid.NewGuid();

            ps = new PubSub(pubSubReady);

            queueManager = new QueueManager(myName);

            queueManager.AddWatcher(new QueueWatcher("GatewayServer", messageReceived));
            queueManager.AddWatcher(new QueueWatcher(myName, messageReceived));

            queueManager.AddPusher(new QueuePusher("GameServer*"));
            queueManager.AddPusher(new QueuePusher("HeadServer"));

            io.Sockets.On("connection", new Action<SocketIOConnection>(userJoin));
        }
Ejemplo n.º 14
0
    // Use this for initialization
    void Start()
    {
        // Init the honks dictionary
        initHonkMapping();

        volume = Game.instance.soundEffectsVolume;

        PubSub.subscribe("Volume:effects", this);

        // Init the audioSource
        soundSource              = gameObject.AddComponent <AudioSource> ();
        soundSource.playOnAwake  = false;
        soundSource.clip         = honks [HonkVariant.SHORT];
        soundSource.spatialBlend = 1f;
        soundSource.volume       = volume;
//		honkSoundSource.Play ();

        if (sirenSound != null)
        {
            // Init the audioSource for siren
            soundSourceSiren              = gameObject.AddComponent <AudioSource> ();
            soundSourceSiren.playOnAwake  = false;
            soundSourceSiren.clip         = sirenSound;
            soundSourceSiren.spatialBlend = 1f;
            soundSourceSiren.loop         = true;
            soundSourceSiren.volume       = volume;
        }
    }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            Console.WriteLine("*** ERPCRAFT - Control your Minecraft world from the real world, anywhere, realtime. ***");
            Console.WriteLine("[[[ https://github.com/Itzanh/ERPCraft ]]]");
            Console.WriteLine("");
            config = Configuracion.readConfiguracion();
            db     = new DBStorage(config);
            // clean the database on start - allow the program to be called from a cron command to clean the DB
            if (args.Length > 0 && args[0].Equals("clean"))
            {
                ajuste = db.getAjuste();
                Console.WriteLine("CLEANING THE DATABASE FOLLOWING THE ACTIVE CONFIG...");
                db.limpiar();
                Console.WriteLine("OK!");
                return;
            }
            db.createDB();
            initDb();

            websocketPubSub = new PubSub(new string[] { "robots", "articulos", "articulosImg", "electrico", "generador", "bateria", "ordenMinado", "almacen", "drones", "usuarios", "config", "apiKeys", "servers", "notificaciones" });

            // admin management (web)
            Thread threadWS = new Thread(new ThreadStart(WaitForWebSocket.Run));

            threadWS.Start();

            // accept OC communication
            GameController.Run();
        }
    private void Connect()
    {
        //Set up connection
        ConnectionCredentials connectionCredentials = new ConnectionCredentials("botty_120", SecretGetter.Api_Token);

        client = new Client();
        pubSub = new PubSub();
        api.Settings.ClientId    = SecretGetter.Client_id;
        api.Settings.AccessToken = SecretGetter.Api_Token;
        client.Initialize(connectionCredentials, channel_name, '!', '!', true);
        client.OverrideBeingHostedCheck = true;
        pubSub.Connect();

        //Bot Subscriptions
        client.OnChatCommandReceived += Client_OnChatCommandReceived;
        client.OnConnected           += Client_OnConnected;
        client.OnDisconnected        += Client_OnDisconnected;

        client.OnBeingHosted    += Client_OnBeingHosted;
        client.OnHostingStopped += Client_OnHostingStopped;

        SubscribeToPubSub();

        client.Connect(); //Connect
        Debug.Log("Connecting!");
    }
Ejemplo n.º 17
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject == this.Player.gameObject)
        {
            return;
        }

        Debug.Log(string.Format("{0} is attacking {1}", this.Player, this.CurrentOpponent));

        switch (this.AttackType)
        {
        case AttackType.LightPunch:
            PubSub.Publish(new PlayerAttacking(this.Player, this.CurrentOpponent, AttackType.LightPunch));
            break;

        case AttackType.HeavyPunch:
            PubSub.Publish(new PlayerAttacking(this.Player, this.CurrentOpponent, AttackType.HeavyPunch));
            break;

        case AttackType.LightKick:
            PubSub.Publish(new PlayerAttacking(this.Player, this.CurrentOpponent, AttackType.LightKick));
            break;

        case AttackType.HeavyKick:
            PubSub.Publish(new PlayerAttacking(this.Player, this.CurrentOpponent, AttackType.HeavyKick));
            break;
        }
    }
Ejemplo n.º 18
0
        public async Task SimplePubSub_InProc()
        {
            // Arrange
            Message incoming = null;
            var     message  = new Message {
                ThisIsAPublishedMessageText = "published a message", Array = new [] { 1, 2, 3, 4 }
            };

            SocketConfiguration config = new ConfigurationTestData().GetSocketConfigInProc;

            config.Logger.SetSilent();
            var sut = new PubSub(config);

            var waitHandle = new ManualResetEvent(false);

            var xtResult = sut.SubscribeHandler <Message>(callback: m => { incoming = m; waitHandle.Set(); }, CancellationToken.None);

            // Act
            await sut.PublishAsync <Message>(message);

            // Assert
            waitHandle.WaitOne();
            Assert.NotNull(incoming);
            Assert.True(xtResult.IsSuccess);
            Assert.Equal(message.Array, incoming.Array);
            Assert.Equal(message.ThisIsAPublishedMessageText, incoming.ThisIsAPublishedMessageText);
            sut.Dispose();
        }
Ejemplo n.º 19
0
        private void GotSubscribed(object sender, IQ iq, object state)
        {
            if (iq.Type != IQType.result)
            {
                FireError(Op.SUBSCRIBE, "Subscription failed", iq);
                return;
            }

            PubSub ps = iq.Query as PubSub;

            if (ps == null)
            {
                FireError(Op.SUBSCRIBE, "Invalid protocol", iq);
                return;
            }

            PubSubSubscriptionType subType;
            PubSubSubscription     sub = ps["subscription", URI.PUBSUB] as PubSubSubscription;

            if (sub != null)
            {
                subType = sub.Type;
            }
            else
            {
                XmlElement ent = ps["entity", URI.PUBSUB];
                if (ent == null)
                {
                    FireError(Op.SUBSCRIBE, "Invalid protocol", iq);
                    return;
                }
                string s = ent.GetAttribute("subscription");
                if (s == "")
                {
                    subType = PubSubSubscriptionType.NONE_SPECIFIED;
                }
                else
                {
                    subType = (PubSubSubscriptionType)Enum.Parse(typeof(PubSubSubscriptionType), s);
                }
            }

            switch (subType)
            {
            case PubSubSubscriptionType.NONE_SPECIFIED:
            case PubSubSubscriptionType.subscribed:
                break;

            case PubSubSubscriptionType.pending:
                FireError(Op.SUBSCRIBE, "Subscription pending authorization", iq);
                return;

            case PubSubSubscriptionType.unconfigured:
                FireError(Op.SUBSCRIBE, "Subscription configuration required.  Not implemented yet.", iq);
                return;
            }

            this[Op.SUBSCRIBE] = STATE.Running;
            GetItemsIfPending();
        }
Ejemplo n.º 20
0
        public void Publish(string node, XmlElement item)
        {
            IQ iq = new IQ(m_Account.Client.Document);

            iq.Type = IQType.set;
            PubSub pubsub = new PubSub(m_Account.Client.Document);

            pubsub.SetAttribute("xmlns", "http://jabber.org/protocol/pubsub");
            Publish publish = new Publish(m_Account.Client.Document);

            publish.SetAttribute("node", node);
            publish.AddChild(item);
            pubsub.AddChild(publish);
            iq.AddChild(pubsub);

            if (m_Account.ConnectionState == AccountConnectionState.Connected)
            {
                m_Account.Send(iq);
            }
            else
            {
                lock (m_Queue) {
                    m_Queue.Enqueue(iq);
                }
            }
        }
Ejemplo n.º 21
0
    private void extractLevelDetails(XmlNode levelNode)
    {
        XmlAttributeCollection levelAttributes = levelNode.Attributes;

        id          = Misc.xmlString(levelAttributes.GetNamedItem("id"));
        name        = Misc.xmlString(levelAttributes.GetNamedItem("name"));
        fileUrl     = Misc.xmlString(levelAttributes.GetNamedItem("fileUrl"));
        iconUrl     = Misc.xmlString(levelAttributes.GetNamedItem("iconUrl"));
        countryCode = Misc.xmlString(levelAttributes.GetNamedItem("countrycode"));
        lon         = Misc.xmlFloat(levelAttributes.GetNamedItem("lon"));
        lat         = Misc.xmlFloat(levelAttributes.GetNamedItem("lat"));

        brief         = Misc.xmlString(levelAttributes.GetNamedItem("brief"));
        randomSeedStr = Misc.xmlString(levelAttributes.GetNamedItem("randomSeed"));
        if (randomSeedStr != null)
        {
            randomSeed = randomSeedStr.GetHashCode();
            //		    DebugFn.print ("Random seed: " + randomSeedStr + ", hash: " + randomSeed);
        }
        date                  = Misc.xmlString(levelAttributes.GetNamedItem("date"), DateTime.Now.ToString("yyyy-MM-dd"));
        timeOfDay             = Misc.xmlString(levelAttributes.GetNamedItem("timeOfDay"), "10:00");
        dateTime              = Misc.parseDateTime(date, timeOfDay);
        timeProgressionFactor = Misc.xmlInt(levelAttributes.GetNamedItem("timeProgressionFactor"), 1);
        timeDisplaySeconds    = Misc.xmlBool(levelAttributes.GetNamedItem("timeDisplaySeconds"), true);

        PubSub.publish("clock:setTime", timeOfDay);
        PubSub.publish("clock:setDisplaySeconds", timeDisplaySeconds);
        PubSub.publish("clock:setSpeed", timeProgressionFactor);
        PubSub.publish("clock:stop");

        country   = Misc.xmlString(levelAttributes.GetNamedItem("country"));
        mapUrl    = Misc.xmlString(levelAttributes.GetNamedItem("mapUrl"));
        configUrl = Misc.xmlString(levelAttributes.GetNamedItem("configUrl"));
    }
Ejemplo n.º 22
0
	void OnBulletHellEnd(PubSub.Signal s) {
		isFiring = false;

		foreach (EmitterSet e in emitterSets) {
			e.gameObject.SetActive(false);
		}
	}
Ejemplo n.º 23
0
        /// <summary>
        ///   Publishes user tune information
        /// </summary>
        public IXmppSession PublishTune(XmppUserTuneEvent tuneEvent)
        {
            var iq      = new IQ();
            var pubsub  = new PubSub();
            var publish = new PubSubPublish();
            var item    = new PubSubItem();
            var tune    = new Tune();

            iq.Items.Add(pubsub);
            pubsub.Items.Add(publish);
            publish.Items.Add(item);

            iq.From      = UserId.ToString();
            iq.ID        = XmppIdentifierGenerator.Generate();
            iq.Type      = IQType.Set;
            publish.Node = XmppFeatures.UserMood;
            item.Item    = tune;
            tune.Artist  = tuneEvent.Artist;
            tune.Length  = tuneEvent.Length;
            tune.Rating  = tuneEvent.Rating;
            tune.Source  = tuneEvent.Source;
            tune.Title   = tuneEvent.Title;
            tune.Track   = tuneEvent.Track;
            tune.Uri     = tuneEvent.Uri;

            Send(iq);

            return(this);
        }
Ejemplo n.º 24
0
    void Awake()
    {
        ItsRandom.setRandomSeed(1234567890, "bags");
        ItsRandom.setRandomSeed(987654321, "people");

        // "Download" people config - TODO - this should be done elsewhere, preloaded per mission
        string peopleConfigUrl = "http://samlingar.com/whatareyoucarryingsir/example-people-config-2.xml";

        StartCoroutine(loadPeopleConfig(peopleConfigUrl));

        // Set framerate only for editor - Should do based on device later?!
//#if UNITY_EDITOR
        QualitySettings.vSyncCount  = 0; // VSync must be disabled
        Application.targetFrameRate = 90;
//#endif

        Game.instance = this;
        CameraHandler.SetPerspectiveCamera(gameCamera);

        swipeRecognizer         = new TKSwipeRecognizer();
        twoTapRecognizer        = new TKTapRecognizer();
        tapRecognizer           = new TKTapRecognizer();
        continousHoldRecognizer = new TKContinousHoldRecognizer();

        // Last in line for click triggering
        PubSub.subscribe("Click", this, Int32.MaxValue);

        pauseGame(true);
    }
Ejemplo n.º 25
0
    private System.Collections.IEnumerator publishCameraMovementAfterDelay(float delay)
    {
        PubSub.publish("CameraMovementStarted");
        yield return(new WaitForSeconds(delay));

        PubSub.publish("CameraMovementFinished");
    }
Ejemplo n.º 26
0
    private void buildMission()
    {
        MissionConfig mission = MissionConfig.Instance;

        // Pick the correct X-ray machine
        string locationXrayMachineName = room.GetComponent <Room>().setLocation(mission.location);

        GameObject locationXrayMachine = null;

        foreach (GameObject xrayMachine in xrayMachines)
        {
            if (xrayMachine.name == locationXrayMachineName)
            {
                locationXrayMachine = xrayMachine;
                break;
            }
        }

        if (locationXrayMachine == null)
        {
            locationXrayMachine = xrayMachines[0];
        }

        GameObject xrayMachineGameObject = Instantiate(locationXrayMachine, locationXrayMachine.transform.position, Quaternion.identity);

        currentXrayMachine = xrayMachineGameObject.GetComponent <XRayMachine> ();
        currentXrayMachine.attachConnectingConveyors();

        // Pick the correct time piece
        GameObject locationClock = null;

        foreach (GameObject clock in clocks)
        {
            if (clock.name == mission.clockType)
            {
                locationClock = clock;
                break;
            }
        }

        if (locationClock == null)
        {
            locationClock = clocks[0];
        }

        GameObject clockObject = Instantiate(locationClock);

        currentClock = clockObject.GetComponent <Clock> ();
        currentClock.setTime(mission.startTime);
        currentClock.speed = mission.timeSpeed;
        currentClock.notifyOnTime(mission.endTime);
        PubSub.subscribe("MISSION_TIME_END", this);
        currentClock.setRandomPosition = false;
        currentClock.clockPosition     = mission.clockPosition;

        // Set the encounter and bag seeds
        ItsRandom.setRandomSeeds(mission.seedsConfig.bags, "bags");
        ItsRandom.setRandomSeeds(mission.seedsConfig.people, "people");
    }
Ejemplo n.º 27
0
        public async Task DoneAsync()
        {
            PubSub.CompleteAdding();

            await Completion.Task;

            await Host.StopAsync();
        }
Ejemplo n.º 28
0
    // Use this for initialization
    void Start()
    {
        BagHandler.instance = this;

        PubSub.subscribe("Click", this);

        BAG_CONTENTS_LAYER_MASK = LayerMask.GetMask(new string[] { "BagContentRootObject" });
    }
Ejemplo n.º 29
0
    private static void DownloadAndCreateMaterial(WWW connection, string id, string type, string filename, string materialKey, bool loadedFromWeb = true)
    {
        // Now create the Texture from the image data
        KeyValuePair <int, int> size = MaterialAvailableSizes [materialKey];
        Texture2D materialTexture    = new Texture2D(size.Key, size.Value);

        connection.LoadImageIntoTexture(materialTexture);
        byte[] pngData = materialTexture.EncodeToPNG();

        if (loadedFromWeb)
        {
            string textureTargetFolder = downloadedMaterialsFolder + type;
            string textureFullFilePath = downloadedMaterialsFolder + filename;
            if (!Directory.Exists(textureTargetFolder))
            {
                Directory.CreateDirectory(textureTargetFolder);
            }
            File.WriteAllBytes(textureFullFilePath, pngData);
            string materialListEntry = type + "|" + StripFilename(filename, false) + "|" + size.Key + "|" + size.Value + "\n";
            File.AppendAllText(downloadedMaterialsFolder + "list.txt", materialListEntry);
        }

        // Now to create a simple material with the texture
        Material material;

        switch (type)
        {
        case "Driveway":
            material = new Material(Shader.Find("Custom/DrivewayShader"));
            break;

        case "Walkway":
            material = new Material(Shader.Find("Custom/WalkwayShader"));
            break;

        case "Roof":
            material             = new Material(Shader.Find("Custom/PlainShader"));
            material.renderQueue = RenderOrder.BUILDING_ROOF;
            break;

        case "Wall":
            material             = new Material(Shader.Find("Custom/PlainShader"));
            material.renderQueue = RenderOrder.BUILDING;
            break;

        default:
            material = new Material(Shader.Find("Custom/PlainShader"));
            break;
        }
        material.mainTexture = materialTexture;

        // Add it to our index
//		Debug.Log ("Adding to index: " + id);
        MaterialIndex.Add(id, material);
//		Debug.Log ("Publishing Material: " + id);
        PubSub.publish("Material-" + id);
//		Debug.Log ("Material indexed: " + id);
    }
 // Use this for initialization
 void Start()
 {
     if (isMainMachine)
     {
         PubSub.subscribe("belt_movement", this);
         PubSub.subscribe("belt_stop", this);
         conveyorSound.clip.LoadAudioData();
     }
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FooterViewModel"/> class.
        /// ViewModel for Footer view
        /// </summary>
        public FooterViewModel()
        {
            this.ChangeEnvironmentCommand = new RelayCommand(this.ChangeEnvironmentHandler);

            this.EnvironmentNames    = new ObservableCollection <string>(EnvironmentConfigurationManager.EnvironmentConfigurations.Select(c => c.Name).ToList());
            this.SelectedEnvironment = EnvironmentConfigurationManager.ActiveEnvironmentConfiguration.Name;

            PubSub <string> .AddEvent(EventNames.EnvironmentChangedEvent, this.EnvironmentChangedEventHandler);
        }
Ejemplo n.º 32
0
 public SyncManager(Node.Node node)
 {
     _pubSub        = node.PubSub;
     _chainManager  = node.ChainManager;
     _coreChain     = _chainManager.CoreChain;
     _storage       = node.Storage;
     _configuration = node.NodeConfiguration;
     _host          = node.Host;
 }
Ejemplo n.º 33
0
	void OnBulletHellStart(PubSub.Signal s) {
		isFiring = true;
		WalkingStateMachine w = s.sender as WalkingStateMachine;
		if (w != null) {
			Debug.Log("[BulletSpawner] Adjusting difficulty to: " + (intervalRatio * GameMgr.Instance.difficultyInterval));
			if (((float) w.level * GameMgr.Instance.difficultyInterval) > 0.0f) {
				intervalRatio *= GameMgr.Instance.difficultyInterval;
			}
		}
	}
Ejemplo n.º 34
0
        public static void RegisterComponents()
        {
			var container = new UnityContainer();

            var pubSub = new PubSub();
            var serializer = new JsonSocketSerializer();
            container.RegisterType<IPubSub, PubSub>(new InjectionFactory(_ => pubSub));
            container.RegisterType<ISocketSerializer, JsonSocketSerializer>(new InjectionFactory(_ => serializer));
            container.RegisterType<ISocketTransport, BaseSocketTransport>();
            
            GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(container);
        }
Ejemplo n.º 35
0
        public HeadServer()
        {
            FS.ReadFile(__dirname + "/index.html", ready);

            pubsub = new PubSub(() => pubsub.Subscribe<string>("PUBSUB.GatewayServers",
                                                               message => {
                                                                   indexForSites.Add(indexPageData.Replace("{{gateway}}", message));
                                                                   gateways.Add(message);
                                                               }));

            Http.CreateServer(handlerWS).Listen(8844);

            Globals.SetInterval(pollGateways, 1000);
            pollGateways();
        }
Ejemplo n.º 36
0
	void OnCollideWithBullet(PubSub.Signal signal) {
		Debug.Log(signal.data["damage"]);
		if (signal.data != null && signal.data.ContainsKey("damage")) {
			horniness -= (int)signal.data["damage"];
		} else {
			horniness -= 10;
		}

		if (horniness <= 0 && !_isDead) {
			GameMgr.Instance.GetPubSubBroker().Publish(PubSub.Channel.PlayerDead, this);
			_isDead = true;
		}

		// Animations
//		SweatForSeconds(2f);
		IntensifyForSeconds(1f);
	}
Ejemplo n.º 37
0
        public void Publish(string node, XmlElement item)
        {
            IQ iq = new IQ(m_Account.Client.Document);
            iq.Type = IQType.set;
            PubSub pubsub = new PubSub(m_Account.Client.Document);
            pubsub.SetAttribute("xmlns", "http://jabber.org/protocol/pubsub");
            Publish publish = new Publish(m_Account.Client.Document);
            publish.SetAttribute("node", node);
            publish.AddChild(item);
            pubsub.AddChild(publish);
            iq.AddChild(pubsub);

            if (m_Account.ConnectionState == AccountConnectionState.Connected) {
                m_Account.Send(iq);
            } else {
                lock (m_Queue) {
                    m_Queue.Enqueue(iq);
                }
            }
        }
Ejemplo n.º 38
0
	void OnPostBulletHellExit(PubSub.Signal s) {
		parentScroller.NextLocation();
		ResetSprites();
		Debug.Log("[BackgroundScroller] should change bg");
	}
Ejemplo n.º 39
0
	void OnWaveEnd(PubSub.Signal signal) {
		horniness += GameMgr.Instance.hpRegenPerLevel;
		if (horniness > MAX_HORNINESS)
			horniness = 100;
	}
Ejemplo n.º 40
0
	void StartBulletHell(PubSub.Signal s) {
		StartSweating();
	}
Ejemplo n.º 41
0
	void StopBulletHell(PubSub.Signal s) {
		StopSweating();
		animator.speed = 1f;
	}
Ejemplo n.º 42
0
            public GatewayServer()
            {
                var http = Global.Require<Http>("http");
                var app = http.CreateServer((req, res) => res.End());

                var io = Global.Require<SocketIOModule>("socket.io").Listen(app);
                var fs = Global.Require<FS>("fs");
                QueueManager queueManager;
                var port = 1800 + Math.Truncate((int)(Math.Random() * 4000));

                app.Listen(port);
                io.Set("log level", 1);
                var myName = "Gateway " + Guid.NewGuid();

                ps = new PubSub(() =>
                {
                    ps.Subscribe<string>("PUBSUB.GatewayServers.Ping", message => ps.Publish("PUBSUB.GatewayServers", string.Format("http://{0}:{1}", IPs.GatewayIP, port)));
                    ps.Publish("PUBSUB.GatewayServers", string.Format("http://{0}:{1}", IPs.GatewayIP, port));
                });

                queueManager = new QueueManager(myName,
                                                new QueueManagerOptions(new[]
                                                {
                                                    new QueueWatcher("GatewayServer", messageReceived),
                                                    new QueueWatcher(myName, messageReceived)
                                                },
                                                                        new[]
                                                                        {
                                                                            "SiteServer",
                                                                            "GameServer*",
                                                                            "DebugServer",
                                                                            "ChatServer",
                                                                            "HeadServer"
                                                                        }));
                io.Sockets.On("connection", (SocketIOConnection socket) =>
                {
                    UserModel user = null;
                    socket.On("Gateway.Message", (GatewayMessageModel data) =>
                    {
                        var channel = "Bad";
                        switch (data.Channel.Split('.')[1])
                        {
                            case "Game":
                                channel = "GameServer";
                                break;
                            case "Site":
                                channel = "SiteServer";
                                break;
                            case "Debug":
                                channel = "GameServer";
                                break;
                            case "Debug2":
                                channel = "DebugServer";
                                break;
                            case "Chat":
                                channel = "ChatServer";
                                break;
                        }
                        queueManager.SendMessage(user, data.GameServer ?? channel, data.Channel, data.Content);
                    });

                    socket.On("Gateway.Login", (GatewayLoginMessageModel data) =>
                    {
                        user = new UserModel();
                        user.Socket = socket;
                        user.UserName = data.UserName;
                        users[data.UserName] = user;
                    });
                    socket.On("disconnect", (string data) => users.Remove(user.UserName));
                });
            }
Ejemplo n.º 43
0
	void OnPlayerDead(PubSub.Signal s) {
		Debug.Log("You Died!");
		PersistentData.levelsDefeated = level;
		FadeOutOverlay.Instance.FadeOut(1.5f, () => Application.LoadLevel("GameOver"));
	}
Ejemplo n.º 44
0
	void ChangeStateToPostBulletHell(PubSub.Signal s) {
		ChangeState(WalkingStates.PostBulletHell);
	}