Beispiel #1
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (Input.GetMouseButtonDown(0) && exit_GO.GetComponent <PointerOver>() != null)
     {
         ComponentMonitoring monitor = exit_GO.GetComponent <ComponentMonitoring> ();
         // Check if hero is near to exit (only hero can produce this component thanks to Unity Physics layers)
         Triggered3D triggered = exit_GO.GetComponent <Triggered3D> ();
         if (triggered != null)
         {
             MonitoringManager.trace(monitor, "perform", MonitoringManager.Source.PLAYER);
             GameObjectManager.setGameObjectState(endScreen_GO, true);
             foreach (FSystem sys in FSystemManager.fixedUpdateSystems())
             {
                 sys.Pause = true;
             }
             foreach (FSystem sys in FSystemManager.lateUpdateSystems())
             {
                 sys.Pause = true;
             }
             foreach (FSystem sys in FSystemManager.updateSystems())
             {
                 sys.Pause = true;
             }
         }
     }
 }
Beispiel #2
0
    private void onEnterRoom(GameObject go)
    {
        ComponentMonitoring monitor = go.GetComponent <ComponentMonitoring> ();

        MonitoringManager.trace(monitor, "turnOn", MonitoringManager.Source.PLAYER);
        id2GO.Add(go.GetInstanceID(), go);
    }
Beispiel #3
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (Input.GetMouseButtonDown(0))
     {
         // Only one GO could be under pointer
         GameObject boiler_go = boilers.First();
         if (boiler_go != null)
         {
             // Check if the hero is near to the boiler (only hero can produce this component thanks to Unity Physics layers)
             Triggered3D triggered = boiler_go.GetComponent <Triggered3D> ();
             if (triggered != null)
             {
                 ComponentMonitoring cm = boiler_go.GetComponent <ComponentMonitoring> ();
                 Boiler boiler          = boiler_go.GetComponent <Boiler> ();
                 if (boiler.isOn)
                 {
                     MonitoringManager.trace(cm, "turnOff", MonitoringManager.Source.PLAYER);
                 }
                 else
                 {
                     MonitoringManager.trace(cm, "turnOn", MonitoringManager.Source.PLAYER);
                 }
                 // Check if boiler is on OR boiler is not constrained OR the constraint is ok
                 if (boiler.isOn || boiler.constraint == null || boiler.constraint.activeInHierarchy)
                 {
                     Animator anim = boiler_go.GetComponent <Animator> ();
                     boiler.isOn = !boiler.isOn;
                     anim.SetBool("isOn", boiler.isOn);
                 }
             }
         }
     }
 }
Beispiel #4
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (Input.GetMouseButtonDown(0))
     {
         // Only one GO is under pointer
         GameObject leverFocused_GO = levers.First();
         if (leverFocused_GO != null)
         {
             Lever lever = leverFocused_GO.GetComponent <Lever> ();
             // Check if the hero is near to the boiler (only hero can produce this component thanks to Unity Physics layers)
             Triggered3D triggered = leverFocused_GO.GetComponent <Triggered3D> ();
             if (triggered != null)
             {
                 lever.isOn = !lever.isOn;
                 SpriteRenderer sr = leverFocused_GO.GetComponent <SpriteRenderer> ();
                 if (lever.isOn)
                 {
                     sr.sprite = lever.on;
                     MonitoringManager.trace(fm, "turnOn", MonitoringManager.Source.PLAYER);
                 }
                 else
                 {
                     sr.sprite = lever.off;
                     MonitoringManager.trace(fm, "turnOff", MonitoringManager.Source.PLAYER);
                 }
             }
         }
     }
 }
Beispiel #5
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (Input.GetMouseButtonDown(0))
     {
         // Only one GO is under pointer
         GameObject door_GO = doors.First();
         if (door_GO != null)
         {
             // Check if hero is near to the door (only hero can produce this component thanks to Unity Physics layers)
             Triggered3D triggered = door_GO.GetComponent <Triggered3D> ();
             if (triggered != null)
             {
                 Door door = door_GO.GetComponent <Door> ();
                 ComponentMonitoring monitor = door_GO.GetComponent <ComponentMonitoring> ();
                 if (door.isOpen)
                 {
                     MonitoringManager.trace(monitor, "turnOff", MonitoringManager.Source.PLAYER);
                 }
                 else
                 {
                     MonitoringManager.trace(monitor, "turnOn", MonitoringManager.Source.PLAYER);
                 }
                 // Check if the door is constrained
                 if (door.constraint == null || door.constraint.activeInHierarchy)
                 {
                     Animator anim = door_GO.GetComponentInParent <Animator> ();
                     door.isOpen = !door.isOpen;
                     anim.SetBool("isOpen", door.isOpen);
                 }
             }
         }
     }
 }
        /// <summary>
        /// Method for <see cref="CreateNewServiceCommand"/>
        /// </summary>
        private void CreateNewService()
        {
            // If the new name is empty don't create the new servce
            if (!string.IsNullOrWhiteSpace(NewServiceName))
            {
                MonitoringManager.CreateService(NewServiceUrl, NewServiceName, NewServicePeriod);

                NewServiceName = string.Empty;
            }
        }
Beispiel #7
0
    private void onExitRoom(GameObject go)
    {
        ComponentMonitoring monitor = go.GetComponent <ComponentMonitoring> ();

        // We check this game object still contains a ComponentMonitoring
        if (monitor != null)
        {
            MonitoringManager.trace(monitor, "turnOff", MonitoringManager.Source.PLAYER);
        }
    }
Beispiel #8
0
    private void onExitRoom(int goId)
    {
        GameObject go;

        if (id2GO.TryGetValue(goId, out go))
        {
            ComponentMonitoring monitor = go.GetComponent <ComponentMonitoring> ();
            // We check this game object still contains a ComponentMonitoring
            if (monitor != null)
            {
                MonitoringManager.trace(monitor, "turnOff", MonitoringManager.Source.PLAYER);
            }
            id2GO.Remove(goId);
        }
    }
Beispiel #9
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        if (Input.GetMouseButtonDown(0))
        {
            // Only one GO could be under the pointer

            // Check if player clics on a GameObject near to the hero
            GameObject go = inGameObjects.First();
            if (go != null)
            {
                Takable             item = go.GetComponent <Takable> ();
                ComponentMonitoring cm   = go.GetComponent <ComponentMonitoring> ();
                // move item to inventory
                GameObjectManager.setGameObjectState(item.linkedWith, true);
                GameObjectManager.setGameObjectState(go, false);
                // trace this action
                MonitoringManager.trace(cm, "perform", MonitoringManager.Source.PLAYER);
            }
        }
    }
Beispiel #10
0
 // Use to process your families.
 protected override void onProcess(int familiesUpdateCount)
 {
     if (Input.GetMouseButtonDown(0))
     {
         // Only one GO is under pointer
         GameObject focused_GO = inInventoryObjectsFocused.First();
         if (focused_GO != null)
         {
             bool alreadySelected = false;
             // Reset selected items, only one selection is possible
             GameObject item = itemSelected.First();
             if (item != null)
             {
                 GameObjectManager.removeComponent <CurrentSelection> (item);
                 // Get item monitor
                 ComponentMonitoring cmItem = item.GetComponent <ComponentMonitoring>();
                 if (item.GetInstanceID() == focused_GO.GetInstanceID())
                 {
                     alreadySelected = true;
                     // already selected => player deselect the item
                     MonitoringManager.trace(cmItem, "turnOff", MonitoringManager.Source.PLAYER);
                 }
                 else
                 {
                     // player select another item  => System action to storeback current item
                     MonitoringManager.trace(cmItem, "turnOff", MonitoringManager.Source.SYSTEM);
                 }
             }
             if (!alreadySelected)
             {
                 // Select current go
                 GameObjectManager.addComponent <CurrentSelection> (focused_GO);
                 // Get its monitor
                 ComponentMonitoring cm = focused_GO.GetComponent <ComponentMonitoring>();
                 // player select a new item
                 MonitoringManager.trace(cm, "turnOn", MonitoringManager.Source.PLAYER);
             }
         }
     }
 }
Beispiel #11
0
        public override void Execute()
        {
            log.Info("Finding Dash Buttons...");
            var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var vendors   = Path.Combine(directory, "vendors.json");

            if (!File.Exists(Path.Combine(directory, "vendors.json")))
            {
                log.Error("Vendors file vendors.json not found");
                return;
            }

            var serviceFile = Path.Combine(directory, "service.json");
            ConcurrentDictionary <string, string> buttonsRegister = new ConcurrentDictionary <string, string>();
            ServiceConfig serviceConfig = new ServiceConfig();

            if (File.Exists(serviceFile))
            {
                serviceConfig = JsonConvert.DeserializeObject <ServiceConfig>(File.ReadAllText(serviceFile));
                if (serviceConfig.Buttons == null)
                {
                    serviceConfig.Buttons = new Dictionary <string, ButtonConfig>();
                }

                foreach (var existingButton in serviceConfig.Buttons)
                {
                    buttonsRegister[existingButton.Value.Mac] = existingButton.Key;
                }
            }

            try
            {
                MonitoringManager manager = new MonitoringManager(VedorsManager.Load(vendors));
                manager.StartListening()
                .Where(item => item.Vendor.Organization.ToLower().Contains("amazon"))
                .Subscribe(
                    item =>
                {
                    var name = item.Mac.GetMacName();
                    if (!buttonsRegister.TryAdd(name, name))
                    {
                        log.Info("Existing dashbutton found: {0}", item);
                        return;
                    }

                    log.Info("NEW dashbutton found: {0}", item);
                    lock (serviceConfig)
                    {
                        ButtonConfig config = new ButtonConfig();
                        config.Mac          = name;
                        serviceConfig.Buttons.Add(name, config);
                        config.Actions = new ButtonAction[] { };
                        File.WriteAllText(serviceFile, JsonConvert.SerializeObject(serviceConfig));
                    }
                });
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
Beispiel #12
0
    // Use to process your families.
    protected override void onProcess(int familiesUpdateCount)
    {
        // refresh display

        // Count number of lever on
        int nbLeverOn = 0;

        foreach (GameObject lever_GO in levers)
        {
            Lever lever = lever_GO.GetComponent <Lever> ();
            if (lever.isOn)
            {
                nbLeverOn++;
            }
        }
        // compute target temperature
        float epsilon = 2 * Time.fixedDeltaTime;
        int   step    = 0;

        if (boiler.isOn && temp.current + epsilon < boiler.defaultTemperature + (nbLeverOn * 2))
        {
            step = 1;
        }
        else if (!boiler.isOn || temp.current - epsilon > boiler.defaultTemperature + (nbLeverOn * 2))
        {
            step = -1;
        }

        if (step != 0)
        {
            // check state changing
            float newTemp = temp.current + epsilon * step;
            if (temp.current <= 0 && newTemp > 0)
            {
                // melting
                if (!inTransition)
                {
                    MonitoringManager.trace(iceMonitor, "meltingStart", MonitoringManager.Source.SYSTEM);
                    inTransition = true;
                }
                // Check if animation is over
                bool endOfAnim = false;
                foreach (GameObject iceCube in iceCubes)
                {
                    float curentScale = iceCube.transform.localScale.x;
                    float newScale    = curentScale - epsilon / 20;
                    if (newScale <= 0)
                    {
                        iceCube.transform.localScale = new Vector3(0, 0, 0);
                        iceCollider_GO.GetComponent <BoxCollider> ().enabled = false;
                        endOfAnim = true;
                    }
                    else
                    {
                        iceCube.transform.localScale   = new Vector3(newScale, newScale, newScale);
                        puddle_GO.transform.localScale = new Vector3(puddle_GO.transform.localScale.x, puddle_GO.transform.localScale.y, 0.46f - (0.46f * newScale / 0.25f));
                    }
                }
                if (endOfAnim)
                {
                    temp.current = newTemp;
                    MonitoringManager.trace(iceMonitor, "meltingEnd", MonitoringManager.Source.SYSTEM);
                    inTransition = false;
                }
                else
                {
                    temp.current = 0;
                }
            }
            else if (temp.current >= 0 && newTemp < 0)
            {
                // solidification
                if (!inTransition)
                {
                    if (!boiler.isOn)
                    {
                        MonitoringManager.trace(iceMonitor, "solidifyingStart", MonitoringManager.Source.SYSTEM, true, "l9");
                    }
                    else
                    {
                        MonitoringManager.trace(iceMonitor, "solidifyingStart", MonitoringManager.Source.SYSTEM, true, "l10");
                    }
                    inTransition = true;
                }

                iceCollider_GO.GetComponent <BoxCollider> ().enabled = true;
                // Check if animation is over
                bool endOfAnim = false;
                foreach (GameObject iceCube in iceCubes)
                {
                    float curentScale = iceCube.transform.localScale.x;
                    float newScale    = curentScale + epsilon / 20;
                    if (newScale >= 0.25)
                    {
                        iceCube.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
                        endOfAnim = true;
                    }
                    else
                    {
                        iceCube.transform.localScale   = new Vector3(newScale, newScale, newScale);
                        puddle_GO.transform.localScale = new Vector3(puddle_GO.transform.localScale.x, puddle_GO.transform.localScale.y, 0.46f - (0.46f * newScale / 0.25f));
                    }
                }
                if (endOfAnim)
                {
                    if (!boiler.isOn)
                    {
                        MonitoringManager.trace(iceMonitor, "solidifyingEnd", MonitoringManager.Source.SYSTEM, true, "l7");
                    }
                    else
                    {
                        MonitoringManager.trace(iceMonitor, "solidifyingEnd", MonitoringManager.Source.SYSTEM, true, "l8");
                    }
                    temp.current = newTemp;
                    inTransition = false;
                }
                else
                {
                    temp.current = 0;
                }
            }
            else
            {
                temp.current = newTemp;
            }

            if (temp.current > 120)
            {
                temp.current = 120;
            }
            if (temp.current < -50)
            {
                temp.current = -50;
            }
            temp.gameObject.transform.localScale = new Vector3(1f, (temp.current + 50) / 170 * 2.165f, 1f);              // 1.0353f is the magic constant to align temperature value with asset graduation
        }
    }