Наследование: MonoBehaviour, ISwitchable
Пример #1
0
 public Lamp GetLamp()
 {
     Lamp light = new Lamp();
     object[] lampsbyte = _utility.GetDatas(2, 0, "Q0", new KeyValuePair<Type, int>(typeof(bool), 7));
     bool[] lamps =
         ValueHelper.Instance.ObjectArrayToDestinationArray<bool>(
             lampsbyte);
     if (lamps[0])
     {
         light.MainLamp = LightLamp.Green.ToString();
     }
     else if (lamps[1])
     {
         light.MainLamp = LightLamp.Yellow.ToString();
     }
     else
     {
         light.MainLamp = LightLamp.Red.ToString();
     }
     if (lamps[3])
     {
         light.SubLamp = LightLamp.Green.ToString();
     }
     else if (lamps[4])
     {
         light.SubLamp = LightLamp.Yellow.ToString();
     }
     else
     {
         light.SubLamp = LightLamp.Red.ToString();
     }
     light.SetStart(lamps[6]);
     return light;
 }
Пример #2
0
        public ILamp RegisterLamp(IArea area, Enum id, IBinaryOutput output)
        {
            if (area == null) throw new ArgumentNullException(nameof(area));
            if (output == null) throw new ArgumentNullException(nameof(output));

            var lamp = new Lamp(ComponentIdGenerator.Generate(area.Id, id), new PortBasedBinaryStateEndpoint(output));
            area.AddComponent(lamp);

            return lamp;
        }
        /// <summary>
        /// Initialize the lamp acquiring the default instance
        /// </summary>
        /// <returns>async Task</returns>
        private async Task InitializeLampAsync()
        {
            lamp = await Lamp.GetDefaultAsync();

            if (lamp == null)
            {
                await LogStatusAsync("Error: No lamp device was found", NotifyType.ErrorMessage);
                lampToggle.IsEnabled = false;
                return;
            }

            await LogStatusAsync(string.Format(CultureInfo.InvariantCulture, "Default lamp instance acquired, Device Id: {0}", lamp.DeviceId), NotifyType.StatusMessage);
            lampToggle.IsEnabled = true;
        }
		public LampController(X10Configuration configuration, IX10LowLevelDriver lowLevelDriver)
		{
			if (configuration != null){
	            int successUnitCode = configuration.SuccessUnitCode;
                int buildingUnitCode = configuration.BuildingUnitCode;
	           	int failureUnitCode = configuration.FailureUnitCode;
	            LowLevelDriverFactory factory = new LowLevelDriverFactory(configuration);
	            if (lowLevelDriver == null){
	            	lowLevelDriver = factory.getDriver();
				}
				red = new Lamp("red", failureUnitCode, lowLevelDriver);
                yellow = new Lamp("yellow", buildingUnitCode, lowLevelDriver);
				green = new Lamp("green", successUnitCode, lowLevelDriver);
			}
		}
Пример #5
0
 protected override void SetDevice(string deviceName, int deviceId)
 {
     device = new Lamp(deviceName, deviceId);
 }
Пример #6
0
 public RoundLampViewModel(Lamp lamp)
     : base(lamp)
 {
 }
Пример #7
0
 private void RenameDevices(int id, string type, string name)
 {
     using (SmartHouseContext context = new SmartHouseContext())
     {
         if (context.Alarms.Any())
         {
             if (type == context.Alarms.FirstOrDefault().GetType().ToString())
             {
                 Alarm device = context.Alarms.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Conditioners.Any())
         {
             if (type == context.Conditioners.FirstOrDefault().GetType().ToString())
             {
                 Conditioner device = context.Conditioners.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Exhausters.Any())
         {
             if (type == context.Exhausters.FirstOrDefault().GetType().ToString())
             {
                 Exhauster device = context.Exhausters.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Fridges.Any())
         {
             if (type == context.Fridges.FirstOrDefault().GetType().ToString())
             {
                 Fridge device = context.Fridges.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Jalousies.Any())
         {
             if (type == context.Jalousies.FirstOrDefault().GetType().ToString())
             {
                 Jalousie device = context.Jalousies.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Lamps.Any())
         {
             if (type == context.Lamps.FirstOrDefault().GetType().ToString())
             {
                 Lamp device = context.Lamps.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Radiators.Any())
         {
             if (type == context.Radiators.FirstOrDefault().GetType().ToString())
             {
                 Radiator device = context.Radiators.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.Routers.Any())
         {
             if (type == context.Routers.FirstOrDefault().GetType().ToString())
             {
                 Router device = context.Routers.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(Session["CurrentRoom"]);
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.StereoSystems.Any())
         {
             if (type == context.StereoSystems.FirstOrDefault().GetType().ToString())
             {
                 StereoSystem device = context.StereoSystems.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
         if (context.TVs.Any())
         {
             if (type == context.TVs.FirstOrDefault().GetType().ToString())
             {
                 TV device = context.TVs.Find(id);
                 device.Name = name;
                 device.Room = context.Rooms.Find(int.Parse(Session["CurrentRoom"].ToString()));
                 context.SaveChanges();
                 return;
             }
             else
             {
             }
         }
         else
         {
         }
     }
     return;
 }
Пример #8
0
            /// <summary>Initialises the ATS lamps for the specified train using one of the default safety systems</summary>
            internal LampCollection(TrainManager.Train Train)
            {
                bool atsSn = (Train.Specs.DefaultSafetySystems & DefaultSafetySystems.AtsSn) != 0;
                bool atsP  = (Train.Specs.DefaultSafetySystems & DefaultSafetySystems.AtsP) != 0;
                bool atc   = (Train.Specs.DefaultSafetySystems & DefaultSafetySystems.Atc) != 0;
                bool eb    = (Train.Specs.DefaultSafetySystems & DefaultSafetySystems.Eb) != 0;

                Width = 0.0f;
                Lamps = new Lamp[17];
                int Count;

                if (Train.Plugin == null || !Train.Plugin.IsDefault)
                {
                    Count = 0;
                }
                else if (atsP & atc)
                {
                    Lamps[0]  = new Lamp(LampType.Ats);
                    Lamps[1]  = new Lamp(LampType.AtsOperation);
                    Lamps[2]  = new Lamp(LampType.None);
                    Lamps[3]  = new Lamp(LampType.AtsPPower);
                    Lamps[4]  = new Lamp(LampType.AtsPPattern);
                    Lamps[5]  = new Lamp(LampType.AtsPBrakeOverride);
                    Lamps[6]  = new Lamp(LampType.AtsPBrakeOperation);
                    Lamps[7]  = new Lamp(LampType.AtsP);
                    Lamps[8]  = new Lamp(LampType.AtsPFailure);
                    Lamps[9]  = new Lamp(LampType.None);
                    Lamps[10] = new Lamp(LampType.Atc);
                    Lamps[11] = new Lamp(LampType.AtcPower);
                    Lamps[12] = new Lamp(LampType.AtcUse);
                    Lamps[13] = new Lamp(LampType.AtcEmergency);
                    Count     = 14;
                }
                else if (atsP)
                {
                    Lamps[0] = new Lamp(LampType.Ats);
                    Lamps[1] = new Lamp(LampType.AtsOperation);
                    Lamps[2] = new Lamp(LampType.None);
                    Lamps[3] = new Lamp(LampType.AtsPPower);
                    Lamps[4] = new Lamp(LampType.AtsPPattern);
                    Lamps[5] = new Lamp(LampType.AtsPBrakeOverride);
                    Lamps[6] = new Lamp(LampType.AtsPBrakeOperation);
                    Lamps[7] = new Lamp(LampType.AtsP);
                    Lamps[8] = new Lamp(LampType.AtsPFailure);
                    Count    = 9;
                }
                else if (atsSn & atc)
                {
                    Lamps[0] = new Lamp(LampType.Ats);
                    Lamps[1] = new Lamp(LampType.AtsOperation);
                    Lamps[2] = new Lamp(LampType.None);
                    Lamps[3] = new Lamp(LampType.Atc);
                    Lamps[4] = new Lamp(LampType.AtcPower);
                    Lamps[5] = new Lamp(LampType.AtcUse);
                    Lamps[6] = new Lamp(LampType.AtcEmergency);
                    Count    = 7;
                }
                else if (atc)
                {
                    Lamps[0] = new Lamp(LampType.Atc);
                    Lamps[1] = new Lamp(LampType.AtcPower);
                    Lamps[2] = new Lamp(LampType.AtcUse);
                    Lamps[3] = new Lamp(LampType.AtcEmergency);
                    Count    = 4;
                }
                else if (atsSn)
                {
                    Lamps[0] = new Lamp(LampType.Ats);
                    Lamps[1] = new Lamp(LampType.AtsOperation);
                    Count    = 2;
                }
                else
                {
                    Count = 0;
                }

                if (Train.Plugin != null && Train.Plugin.IsDefault)
                {
                    if (Count != 0 & (eb | Train.Specs.HasConstSpeed))
                    {
                        Lamps[Count] = new Lamp(LampType.None);
                        Count++;
                    }

                    if (eb)
                    {
                        Lamps[Count] = new Lamp(LampType.Eb);
                        Count++;
                    }

                    if (Train.Specs.HasConstSpeed)
                    {
                        Lamps[Count] = new Lamp(LampType.ConstSpeed);
                        Count++;
                    }
                }

                Array.Resize(ref Lamps, Count);
                for (int i = 0; i < Count; i++)
                {
                    if (Lamps[i].Width > Width)
                    {
                        Width = Lamps[i].Width;
                    }
                }
            }
Пример #9
0
 private string LampToTxt(Lamp lamp)
 {
     return(lamp.Light ? "ON" : "OFF");
 }
Пример #10
0
 // Constructors
 public Coldstore(uint volume, Lamp lamp)
     : base("coldstore", volume)
 {
     backlight   = lamp;
     Temperature = 0;
 }
Пример #11
0
 private void Awake()
 {
     _light = GetComponentInChildren <Lamp>();
 }
Пример #12
0
 public SquareLampViewModel(Lamp lamp)
     : base(lamp)
 {
 }
Пример #13
0
 protected void LampSwitchOff(MeshRenderer meshRenderer, Lamp lamp)
 {
     meshRenderer.material = lamp.NoLightMaterial;
     lamp.IsOn             = false;
 }
Пример #14
0
 protected void LampSwitchOn(MeshRenderer meshRenderer, Lamp lamp)
 {
     meshRenderer.material = lamp.LightOnMaterial;
     lamp.IsOn             = true;
 }
Пример #15
0
        /// <summary>
        /// Calculate the DJ Points awarded for a given chart
        /// </summary>
        /// <param name="songID">SongID</param>
        /// <param name="diff">Chart difficulty</param>
        /// <param name="score">EX score of best play</param>
        /// <param name="lamp">Best clear lamp</param>
        /// <returns>DJ Points as a decimal value</returns>
        public static decimal CalculateDJP(string songID, Difficulty diff, int score, Lamp lamp)
        {
            var grade = ScoreToGrade(songID, diff, score);
            /* C gets a value of 10 starting from A, with +5 for each grade above that */
            decimal C = (grade >= Grade.A ? 10 : 0) + Math.Max(0, grade - Grade.A) * 5;
            /* L increases by 5 for each lamp above AC (AC being 0), with HC and better increasing the value further by an extra 5 */
            decimal L = Math.Max(0, lamp - Lamp.AC) * 5 + (lamp >= Lamp.HC ? 5 : 0);

            return(score * (100 + C + L) / 10000);
        }
Пример #16
0
 public Switch(Lamp lamp)
 {
     this.lamp = lamp;
 }
Пример #17
0
 public void OnEnter(Lamp lamp)
 {
     Console.WriteLine($"{_breaker.Name} broke the lightbulb!");
 }
 public LampEvents(Lamp This)
 {
     this.This = This;
 }
Пример #19
0
 public OvenInfo(int volume, Lamp lamp)
 {
     Lamp   = lamp;
     Volume = volume;
 }
Пример #20
0
 public void FixLightBulb(Lamp lamp)
 {
     lamp.ChangeState(new NewBulbState());
 }
Пример #21
0
        private void CreateNewDevice(string type, string lampType, string name)
        {
            using (SmartHouseContext context = new SmartHouseContext())
            {
                int id = int.Parse(Session["CurrentRoom"].ToString());
                switch (type)
                {
                case "Alarm":
                    Alarm newAlarm = new Alarm(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarm);
                    break;

                case "Conditioner":
                    Conditioner newConditioner = new Conditioner(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Conditioner.Add(newConditioner);
                    break;

                case "Exhauster":
                    Exhauster newExhauster = new Exhauster(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Exhauster.Add(newExhauster);
                    break;

                case "Fridge":
                    Fridge newFridge = new Fridge(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Fridge.Add(newFridge);
                    break;

                case "Jalousie":
                    Jalousie newJalousie = new Jalousie(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Jalousie.Add(newJalousie);
                    break;

                case "Lamp":
                    Lamp newLamp = new Lamp(name, lampType);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Lamp.Add(newLamp);
                    break;

                case "Radiator":
                    Radiator newRadiator = new Radiator(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Radiator.Add(newRadiator);
                    break;

                case "Router":
                    Router newRouter = new Router(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Router.Add(newRouter);
                    break;

                case "StereoSystem":
                    StereoSystem newStereoSystem = new StereoSystem(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).StereoSystem.Add(newStereoSystem);
                    break;

                case "TV":
                    TV newTV = new TV(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).TV.Add(newTV);
                    break;

                default:
                    Alarm newAlarma = new Alarm(name);
                    context.Rooms.FirstOrDefault(d => d.Id == id).Alarm.Add(newAlarma);
                    break;
                }
                context.SaveChanges();
            }
        }
Пример #22
0
        public override void InitGame()
        {
            #region Program arguments

            //TODO: Program arguments

            #endregion
            #region Entities

            skybox.mesh.material.textureName = "skybox";
            skybox.isLit = false;

            collisionVisuals.mesh.material.textureName = "map0e";
            collisionVisuals.wireFrame = true;
            collisionVisuals.mesh.shader = Shader.collisionShaderCompiled;
            collisionVisuals.writeDepthBuffer = false;
            collisionVisuals.readDepthBuffer = false;
            collisionVisuals.renderPass = 1;

            map1.mesh.material.textureName = "white";
            map1.mesh.useVBO = true;
            map1.mesh.GenerateVBO();
            map2a.mesh.material.textureName = "white";
            map2b.mesh.material.textureName = "white";
            map2c.mesh.material.textureName = "white";
            map2d.mesh.material.textureName = "white";
            map2e.mesh.material.textureName = "white";
            map2f.mesh.material.textureName = "white";
            map2a.mesh.useVBO = true;
            map2b.mesh.useVBO = true;
            map2c.mesh.useVBO = true;
            map2d.mesh.useVBO = true;
            map2e.mesh.useVBO = true;
            map2f.mesh.useVBO = true;
            map2a.mesh.GenerateVBO();
            map2b.mesh.GenerateVBO();
            map2c.mesh.GenerateVBO();
            map2d.mesh.GenerateVBO();
            map2e.mesh.GenerateVBO();
            map2f.mesh.GenerateVBO();
            map2a.mesh.material.baseColor = new Color4(1.0f, 1.0f, 1.0f, 1.0f);
            map2b.mesh.material.baseColor = new Color4(0.2f, 0.2f, 0.2f, 1.0f);
            map2c.mesh.material.baseColor = new Color4(1.0f, 0.9f, 0.6f, 1.0f);
            map2d.mesh.material.baseColor = new Color4(0.1f, 0.1f, 0.1f, 1.0f);
            map2e.mesh.material.baseColor = new Color4(0.3f, 0.3f, 0.3f, 1.0f);
            map2f.mesh.material.baseColor = new Color4(0.5f, 0.9f, 0.1f, 1.0f);

            BasicClock.clockMesh.useVBO = true;
            BasicClock.clockMesh.GenerateVBO();
            clock1.position = new Vector3(1200f, 435f, -5120f);

            cannon.position = new Vector3(3700f, 0f, -5300f);

            hudConsole.enabled = false;
            hudConsole.isVisible = false;
            hudConsole.FontTextureName = "font2";
            hudConsole.NumberOfLines = 30;
            hudConsole.DebugInput += ConsoleInputReceived;

            speedometerBase.width = 256f;
            speedometerBase.height = 64f;
            speedometerPointer.width = 5f;
            speedometerPointer.height = 68f;

            Camera.Instance.friction = new Vector3((float)config.GetDouble("playerFriction"), 1, (float)config.GetDouble("playerFriction"));

            monster.mesh.material.textureName = "huescale";

            testHueScale.mesh.material.textureName = "huescale";
            testHueScale.position = new Vector3(3700f, 75f, -5300f);

            Lamp.lampHeadMesh.material.textureName = Lamp.lampPostMesh.material.textureName = "white";
            Lamp.lampHeadMesh.useVBO = true;
            Lamp.lampHeadMesh.GenerateVBO();
            Lamp.lampPostMesh.useVBO = true;
            Lamp.lampPostMesh.GenerateVBO();

            for(float x = 2500; x <= 3500; x += 250)
            {
                for(float z = -6550; z <= -5550; z += 250)
                {
                    Lamp lamp = new Lamp("lamp1_" + x.ToString("F0") + "_" + z.ToString("F0"));
                    lamp.position.X = x;
                    lamp.position.Z = z;
                    lamp.position.Y = 75f;
                    lamps1.Add(lamp);
                }
            }

            for(float z = -6250; z <= -5850; z += 200)
            {
                Lamp lamp = new Lamp("lamp2_" + z.ToString("F0"));
                lamp.position.X = 1600f;
                lamp.position.Z = z;
                lamp.position.Y = 150f;
                lamps2.Add(lamp);
            }

            lampSwitch1 = new LampSwitch("lampswitch1", lamps1);
            lampSwitch1.position = new Vector3(1950f, 150f, -6050f);
            lampSwitch2 = new LampSwitch("lampswitch2", lamps1);
            lampSwitch2.position = new Vector3(3750f, 75f, -6050f);
            lampSwitch3 = new LampSwitch("lampswitch3", lamps1);
            lampSwitch3.position = new Vector3(3000f, 75f, -6830f);
            lampSwitch4 = new LampSwitch("lampswitch4", lamps1);
            lampSwitch4.position = new Vector3(3000f, 75f, -5250f);
            lampSwitch5 = new LampSwitch("lampswitch5", lamps2);
            lampSwitch5.position = new Vector3(1950f, 150f, -6050f);
            lampSwitch6 = new LampSwitch("lampswitch6", lamps2);
            lampSwitch6.position = new Vector3(1600f, 264f, -5475f);
            lampSwitch7 = new LampSwitch("lampswitch7", lamps2);
            lampSwitch7.position = new Vector3(1600f, 264f, -6625f);
            lampSwitch8 = new LampSwitch("lampswitch8", lamps1);
            lampSwitch8.position = new Vector3(2630f, 715f, -5700f);

            for(int i = 0; i < config.GetInt("numSlides"); i++)
            {
                Entity slide = new Entity("slide" + i.ToString("D2"));
                slide.mesh = new Mesh();
                slide.mesh.polygonList = slideMesh.polygonList;
                slide.mesh.material.textureName = "slide" + i.ToString("D2");
                slide.position.Z = -100 * i;
                slides.Add(slide);
                slideNode.Add(slide);
            }

            slideNode.position = new Vector3(10f, 249.6f, -5100f);

            //map.Add(map1);
            map.Add(map2a);
            map.Add(map2b);
            map.Add(map2c);
            map.Add(map2d);
            map.Add(map2e);
            map.Add(map2f);

            HudBase.Instance.Add(hudDebug);
            HudBase.Instance.Add(hudConsole);
            HudBase.Instance.Add(speedometerBase);
            HudBase.Instance.Add(speedometerPointer);
            HudBase.Instance.Add(ActionTrigger.textField);

            RootNode.Instance.Add(monster);
            RootNode.Instance.Add(skybox);
            RootNode.Instance.Add(collisionVisuals);
            RootNode.Instance.Add(map);
            RootNode.Instance.Add(cannon);
            RootNode.Instance.Add(testHueScale);
            RootNode.Instance.Add(clock1);
            RootNode.Instance.Add(lamps1);
            RootNode.Instance.Add(lamps2);
            RootNode.Instance.Add(lampSwitch1);
            RootNode.Instance.Add(lampSwitch2);
            RootNode.Instance.Add(lampSwitch3);
            RootNode.Instance.Add(lampSwitch4);
            RootNode.Instance.Add(lampSwitch5);
            RootNode.Instance.Add(lampSwitch6);
            RootNode.Instance.Add(lampSwitch7);
            RootNode.Instance.Add(lampSwitch8);
            RootNode.Instance.Add(slideNode);

            #endregion

            Camera.Instance.position = new Vector3(2700, 250, -6075);

            RenderWindow.Instance.KeyPress += HandleKeyPress;
            RenderWindow.Instance.Title = "ReSim";
            InputManager.CursorLockState = CursorLockState.Centered;
            InputManager.HideCursor();

            mapCollision.Add(slideAABB);
        }
Пример #23
0
        public static void Main(string[] args)
        {
            office          = new Office();
            inventory       = new Inventory();
            officeQuery     = new OfficeQuery();
            inventoryOutput = new StreamWriter("inventory.txt");
            officeOutput    = new StreamWriter("office.txt");

            office.SetInventory(inventory);
            officeQuery.SetOffice(office);


            Console.WriteLine("Office/Inventory App\n\nPress enter to generate and display furniture...");
            Console.ReadLine();

            //Generate some furniture
            //UI can be made so that users can create furniture and since it would only call constructors no logic is involved
            Chair chair1 = new Chair("Blue", false, true);
            Chair chair2 = new Chair("Brown", true, true);
            Chair chair3 = new Chair("Black", false, false);
            Chair chair4 = new Chair("White", true, true);
            Lamp  lamp1  = new Lamp("Silver", 20, 20);
            Table table1 = new Table("White", 200, 100, 100);
            Table table2 = new Table("Brown", 300, 100, 80);

            inventory.currentInventory.Add(chair1);
            inventory.currentInventory.Add(chair2);
            inventory.currentInventory.Add(chair3);
            inventory.currentInventory.Add(chair4);
            inventory.currentInventory.Add(lamp1);
            inventory.currentInventory.Add(table1);
            inventory.currentInventory.Add(table2);


            inventory.Write(Console.Out);

            Console.WriteLine("Furniture added to inventory\n\nPress enter to add some furniture to the office...");
            Console.ReadLine();

            office.AddFromInventory(1); //chair2
            office.AddFromInventory(1); //chair3
            office.AddFromInventory(2); //lamp1
            office.AddFromInventory(1); //chair4
            office.AddFromInventory(2); //table 2

            Console.WriteLine("Three chairs, one lamp, and one table added to office from inventory\n\nPress enter to get all the chairs in the office...");
            Console.ReadLine();

            officeQuery.GetNumberOfItems("Chair");

            Console.WriteLine("Press enter to get all the brown items in the office...");
            Console.ReadLine();

            officeQuery.QueryByColor("Brown");

            Console.WriteLine("Press enter to terminate and save inventory and office layout...");
            Console.ReadLine();

            inventory.Write(inventoryOutput); //Write current furniture to Project1/bin/inventory.txt

            //Write current furniture to Project1/bin/office.txt
            foreach (Furniture item in office.furnitureInOffice)
            {
                item.Write(officeOutput);
            }

            officeOutput.Close();
            inventoryOutput.Close();
        }
Пример #24
0
 public void RemoveLamp(Lamp item)
 {
     lamp.Remove(item);
 }
Пример #25
0
        private void OverlayEntities(MapElement entities, Bitmap map, VirtualMap <char> solids, bool background)
        {
            CassetteBlock.Blocks.Clear();

            using (Graphics g = Graphics.FromImage(map)) {
                List <Entity> ents = new List <Entity>();
                for (int i = entities.Children.Count - 1; i >= 0; i--)
                {
                    MapElement child = entities.Children[i];

                    Entity entity = null;
                    if (child.Name.IndexOf("spikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Spikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("triggerSpikes", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? TriggerSpikes.FromElement(child) : null;
                    }
                    else if (child.Name.IndexOf("strawberry", StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("goldenBerry", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("redBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("greenBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("yellowBlocks", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterCabinet", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterCabinet.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCar", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? IntroCar.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clothesLine", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClothesLine.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("colorSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ColorSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorialTextController", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Strawberry.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bonfire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bonfire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trapDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrapDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("movingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? MovingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("sinkingPlatform", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SinkingPlatform.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("clutterDoor", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ClutterDoor.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridge", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bridge.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bridgeFixed", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BridgeFixed.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("jumpThru", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? JumpThru.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("door", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Door.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blockField", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? BlockField.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Lamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hahaha", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Haha.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("waterFall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? WaterFall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("water", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Water.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("key", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Key.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("resortLantern", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ResortLantern.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("bird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Bird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("memorial", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Memorial.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("player", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? PlayerSpawn.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("zipMover", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ZipMover.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("wire", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Wire.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("crumbleBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CrumbleBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("refill", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Refill.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spring", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spring.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fakeWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("exitBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FakeWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lightBeam", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LightBeam.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cobweb", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cobweb.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassette", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Cassette.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("flutterBird", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FlutterBird.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("checkpoint", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Checkpoint.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("fallingBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("introCrusher", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FallingBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("cassetteBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CassetteBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dashBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DashBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("coverupWall", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? CoverupWall.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("npc", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? NPC.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("birdForsakenCityGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? ForsakenCityGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("soundSource", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SoundSource.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("friendlyGhost", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FriendlyGhost.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("floatingDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? FloatingDebris.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("hangingLamp", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HangingLamp.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("lockBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? LockBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("heartGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("blackGem", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? HeartGem.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamMirror", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamMirror.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("darkChaser", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DarkChaser.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("dreamBlock", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? DreamBlock.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("touchSwitch", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TouchSwitch.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("switchGate", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? SwitchGate.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("invisibleBarrier", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? InvisibleBarrier.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("payphone", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Payphone.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("spinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? Spinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("rotateSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? RotateSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("trackSpinner", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TrackSpinner.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("towerViewer", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = background ? TowerViewer.FromElement(child) : null;
                    }
                    else if (child.Name.Equals("foregroundDebris", StringComparison.OrdinalIgnoreCase))
                    {
                        entity = !background?ForegroundDebris.FromElement(child) : null;
                    }
                    else if (background)
                    {
                        Console.WriteLine(child.Name);
                    }
                    if (entity != null)
                    {
                        ents.Add(entity);
                    }
                }

                ents.Sort(delegate(Entity one, Entity two) {
                    int comp = two.Depth.CompareTo(one.Depth);
                    return(comp == 0 ? one.ID.CompareTo(two.ID) : comp);
                });

                for (int i = 0; i < ents.Count; i++)
                {
                    Entity entity = ents[i];
                    entity.Render(g, solids);
                }
            }
        }
Пример #26
0
        private void GenerateButton_Click(object sender, EventArgs e)
        {
            // Check if product type is chosen.
            if (comboBox1.Text == "")
            {
                MessageBox.Show("Er moet een soort worden aangegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Check if boxes are filled.
            else if (NameBox.Text == "" || DescriptionBox.Text == "" || WidthBox.Text == "" || HeigthBox.Text == "" || PriceBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Check if lightbox is filled (only when product type is "Lamp").
            else if (comboBox1.SelectedItem.ToString() == "Lamp" && LightBox.Text == "")
            {
                MessageBox.Show("Alle velden moeten ingevuld zijn.", "Foutmelding", MessageBoxButtons.OK);
            }
            // Check if a image is uploaded.
            else if (image == null)
            {
                MessageBox.Show("Er moet een afbeelding worden meegegeven.", "Foutmelding", MessageBoxButtons.OK);
            }
            else
            {
                // Generate path project is based in.
                string workingPath = Path.Combine(Path.GetDirectoryName(Path.GetDirectoryName(Path.GetDirectoryName(Directory.GetCurrentDirectory()))), "ProductImages");
                // Make the directory "ProductImages" if it doesnt exist.
                if (!Directory.Exists(workingPath))
                {
                    Directory.CreateDirectory(workingPath);
                }
                // Move image if directory exists.
                if (Directory.Exists(workingPath))
                {
                    // Make unique image name so it doesnt overwrite
                    imageName = $@"{DateTime.Now.Ticks.GetHashCode().ToString("x").ToUpper()}.png";
                    // Copy the file to the base of this program.
                    string tempString = Path.Combine(workingPath, imageName);
                    pictureBox1.Image.Save(tempString);
                }
                Product product = null;
                //var mc = new MyContext();
                //using (mc)
                //{
                // Checks the selected product type and adds that product to the database.
                switch (comboBox1.SelectedItem.ToString())
                {
                case "Bank":
                    DatabaseController.AddProducts(product = new Sofa(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Lamp":
                    DatabaseController.AddProducts(product = new Lamp(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName, Int32.Parse(LightBox.Text)));
                    break;

                case "Essentiële":
                    DatabaseController.AddProducts(product = new Essentials(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Stoel":
                    DatabaseController.AddProducts(product = new Chair(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Plant":
                    DatabaseController.AddProducts(product = new Plant(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Tafel":
                    DatabaseController.AddProducts(product = new Table(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Wandaccesoire":
                    DatabaseController.AddProducts(product = new WallAccessories(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;

                case "Kast":
                    DatabaseController.AddProducts(product = new Closet(NameBox.Text, DescriptionBox.Text, Int32.Parse(WidthBox.Text), Int32.Parse(HeigthBox.Text), double.Parse(PriceBox.Text), imageName));
                    break;
                }
                //}
                //catalogPanel.catalogController.AddProductToVanillaList(product);
                catalogPanel.catalogController.RefreshDisplayedItems();
                MessageBox.Show("Het product is toegevoegd aan de catalogus.", "Succes", MessageBoxButtons.OK);
                Close();
            }
        }
Пример #27
0
 public CarAdapter()
 {
     lamp  = new ConcreteLamp();
     sound = new ConcreteSound();
 }
Пример #28
0
        public void LampIsOff_When_Created()
        {
            var lamp = new Lamp();

            Assert.AreEqual("O", lamp.GetColor());
        }
Пример #29
0
 public void SwitchOn(Lamp lamp)
 {
     lamp.ChangeState(new LampOnState());
 }
        private void OnChanged_RaycastObject()
        {
            bool inventoryClosed = InventoryController.Instance.IsClosed;

            if (!inventoryClosed)
            {
                m_OpenMessage.SetActive(false);
                m_GrabMessage.Toggle(false);
                if (m_CurrentCrosshair)
                {
                    m_CurrentCrosshair.SetActive(false);
                }

                return;
            }

            IInventoryTrigger openable = null;
            ItemPickup        pickup   = null;

            Building.Door door = null;
            SleepingBag   bag  = null;
            Lamp          lamp = null;

            var raycastData = Player.RaycastData.Get();

            if (raycastData && raycastData.ObjectIsInteractable)
            {
                openable = raycastData.GameObject.GetComponent <IInventoryTrigger>();
                pickup   = raycastData.GameObject.GetComponent <ItemPickup>();
                door     = raycastData.GameObject.GetComponent <Building.Door>();
                bag      = raycastData.GameObject.GetComponent <SleepingBag>();
                lamp     = raycastData.GameObject.GetComponent <Lamp>();
            }

            m_OpenMessage.SetActive(openable != null);

            if (pickup != null && pickup.ItemToAdd != null)
            {
                m_GrabMessage.Toggle(true);
                m_GrabMessage.SetText(pickup.ItemToAdd.Name + (pickup.ItemToAdd.CurrentInStack > 1 ? (" x " + pickup.ItemToAdd.CurrentInStack) : ""));
            }
            else if (door != null)
            {
                m_GrabMessage.Toggle(true);
                m_GrabMessage.SetText(door.Open ? "Close the door" : "Open the door");
            }
            else if (bag != null)
            {
                m_GrabMessage.Toggle(true);
                m_GrabMessage.SetText(TimeOfDay.Instance.State.Get() == ET.TimeOfDay.Night ? "Sleep..." : "You can only sleep at night time!");
            }
            else if (lamp != null)
            {
                m_GrabMessage.Toggle(true);
                m_GrabMessage.SetText(string.Format("Turn {0}", !lamp.State ? "<color=yellow>ON</color>" : "<color=red>OFF</color>"));
            }
            else
            {
                m_GrabMessage.Toggle(false);
            }

            if (m_CurrentCrosshair)
            {
                bool showCrosshair = !Player.Aim.Active && openable == null && pickup == null && door == null && bag == null;
                m_CurrentCrosshair.SetActive(showCrosshair);
            }
        }
Пример #31
0
 public void SwitchOff(Lamp lamp)
 {
     EmitError();
 }
Пример #32
0
 private void RegisterHit(RaycastHit2D hit)
 {
     if (hit.collider.gameObject.CompareTag("Money"))
     {
         DestroyObject(hit.collider.gameObject);
         if (collectSound != null)
         {
             AudioSource.PlayClipAtPoint(collectSound, Camera.main.transform.position);
         }
         money += 25;
     }
     else if (hit.collider.gameObject.CompareTag("FearPickup"))
     {
         DestroyObject(hit.collider.gameObject);
         if (collectFear != null)
         {
             AudioSource.PlayClipAtPoint(collectFear, Camera.main.transform.position);
         }
         if (fearEnergy < fearEnergyMax)
         {
             fearEnergy       += 2;
             fearEnergy        = Mathf.Min(fearEnergy, fearEnergyMax);
             fearDecayCooldown = fearDecayCooldownMax;
         }
         else
         {
             money += 50;
         }
     }
     else if (hit.collider.gameObject.CompareTag("Person"))
     {
         Person2 p = hit.collider.gameObject.GetComponent <Person2>();
         p.DisplayHP();
     }
     else if (hit.collider.gameObject.CompareTag("Furniture"))
     {
         Furniture f = hit.collider.gameObject.GetComponent <Furniture>();
         f.DisplayHP();
     }
     if (Input.GetMouseButtonDown(0))
     {
         if (currentRoomNumber < RoomsOpen && hit.collider.gameObject.CompareTag("Triangle Up"))
         {
             MoveUp();
         }
         else if (currentRoomNumber > 0 && hit.collider.gameObject.CompareTag("Triangle Down"))
         {
             MoveDown();
         }
     }
     if (!GameVars.IsNight)
     {
         RegisterHitDaytime(hit);
     }
     else if (Input.GetMouseButtonDown(0))
     {
         if (currentAbility != null && currentAbility != listAbilities[1] && currentAbility != listAbilities[4])
         {
             if (hit.collider.gameObject.CompareTag("Room") || hit.collider.gameObject.CompareTag("Node") ||
                 hit.collider.gameObject.CompareTag("Furniture") || hit.collider.gameObject.CompareTag("Person"))
             {
                 if (currentAbility.CanUse())
                 {
                     currentAbility.UseAbility(hit);
                     currentAbility = null;
                 }
             }
         }
         else if (hit.collider.gameObject.CompareTag("Hazard"))
         {
             hit.collider.GetComponent <Hazard>().Fade();
         }
         else if (currentAbility == listAbilities[4] && listAbilities[4].CanUse() && hit.collider.gameObject.CompareTag("Person"))
         {
             currentAbility.UseAbility(hit);
             currentAbility = null;                // possession
         }
         else if (hit.collider.gameObject.CompareTag("Furniture"))
         {
             Furniture f = hit.collider.gameObject.GetComponent <Furniture>();
             if (currentAbility == listAbilities[1] && listAbilities[1].CanUse())
             {
                 currentAbility.UseAbility(hit);
                 currentAbility = null;
             }
             else if (f is Lamp)
             {
                 if (lampSwitch != null)
                 {
                     AudioSource.PlayClipAtPoint(lampSwitch, Camera.main.transform.position);
                 }
                 Lamp l = hit.collider.gameObject.GetComponent <Lamp>();
                 if (l.Durability > 0)
                 {
                     l.Flip();
                 }
             }
             else if (f is Trap && !(f as Trap).Used)
             {
                 Debug.Log("Activating");
                 (f as Trap).Activate();
             }
         }
     }
 }
Пример #33
0
 public Coldstore(uint volume, Lamp lamp)
     : base("coldstore", volume)
 {
     backlight = lamp;
     Temperature = 0;
 }
 public RectangleLampViewModel(Lamp lamp)
     : base(lamp)
 {
 }
        /// <summary>
        /// Event Handler for Lamp Availability Changed. When it fires, we want to update to
        /// Lamp toggle UI to show that lamp is available or not
        /// </summary>
        /// <param name="sender">Contains information regarding  Lamp object that fired event</param>
        /// <param name="e">Contains state information and event data associated with the event</param>
        private async void Lamp_AvailabilityChanged(Lamp sender, LampAvailabilityChangedEventArgs args)
        {
            // Update the Lamp Toggle UI to indicate lamp has been consumed by another application
            await this.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                if (lampToggle.IsOn)
                {
                    lampToggle.IsOn = args.IsAvailable;
                }

                lampToggle.IsEnabled = args.IsAvailable;
            });

            await LogStatusAsync(string.Format(CultureInfo.InvariantCulture,"Lamp Availability Changed Notification has fired, IsAvailable= {0}", args.IsAvailable), NotifyType.StatusMessage);
        }
Пример #36
0
 public void SwitchOff(Lamp lamp)
 {
     Console.WriteLine("Lamp is already off!");
 }
Пример #37
0
 public void BreakLightBulb(Lamp lamp, INamedEntity breaker)
 {
     Console.WriteLine($"{breaker.Name} tried to break the blub, but {_breaker.Name} already broke it!");
 }
Пример #38
0
 // Constructors
 public Coldstore()
 {
     backlight = new Lamp();
 }
Пример #39
0
 public void BreakLightBulb(Lamp lamp, INamedEntity breaker)
 {
     lamp.ChangeState(new BrokenBulbState(breaker));
 }
Пример #40
0
    void Start()
    {
        animalSprite = this.GetComponent<SpriteRenderer> ();
        animalSprite.sprite = startingSprite;
        Conveyor = GameObject.FindGameObjectWithTag ("Conveyor");
        localNodes = Conveyor.GetComponent<ConveyorMoving>().nodes;
        myNode = localNodes [myNodeNumber].transform;
        myNode.gameObject.GetComponent<NodeController>().AssignAnimalToNode(this.gameObject);
        this.GetComponent<TweenPosition> ().duration = Conveyor.GetComponent<ConveyorMoving>().animationTime;
        this.GetComponent<TweenPosition> ().to = myNode.transform.position;
        this.GetComponent<TweenPosition> ().from = new Vector3 (-10.83f, -3.37f, 0);
        this.GetComponent<TweenPosition> ().Play (true);
        this.GetComponent<TweenPosition> ().Reset ();

        firstIcon = (GameObject)Instantiate(IconPrefab, leftIcon.position, Quaternion.identity);
        firstIcon.GetComponent<Icon>().AssignTreatment(neccesaryTreatments[0]);
        firstIcon.transform.parent = leftIcon.transform;

        secondIcon = (GameObject)Instantiate(IconPrefab, rightIcon.position, Quaternion.identity);
        secondIcon.GetComponent<Icon>().AssignTreatment(neccesaryTreatments[1]);
        secondIcon.transform.parent = rightIcon.transform;

        lamp = GameObject.Find("Lamp").GetComponent<Lamp>();
    }
Пример #41
0
 public void FixLightBulb(Lamp lamp)
 {
 }
        /// <summary>
        /// Method to dispose of current Lamp instance
        /// and release all resources
        /// </summary>
        private void DisposeLamp()
        {
            if (lamp == null)
            {
                return;
            }

            lampToggle.IsEnabled = false;
            lamp.AvailabilityChanged -= Lamp_AvailabilityChanged;
            lamp.IsEnabled = false;
            lamp.Dispose();
            lamp = null;
        }
Пример #43
0
 public void OnEnter(Lamp lamp)
 {
     Console.WriteLine("Bulb replaced!");
     lamp._numOfTimesTurnedOn = 0;
 }
Пример #44
0
 //The base means that it inherits Lamp
 public LampViewModel(Lamp lamp)
 {
     Lamp = lamp;
 }
Пример #45
0
        private void AltToggle(object sender, RoutedEventArgs e)
        {
            // Mimicing radio buttons so you cant toggle a button off
            if (AltOption.IsChecked == false)
            {
                AltOption.IsChecked = true;
                return;
            }

            SimpleOption.IsChecked             = false;
            OrbOption.IsChecked                = false;
            Properties.Settings.Default.Simple = SimpleOption.IsChecked;
            Properties.Settings.Default.Orb    = OrbOption.IsChecked;
            Properties.Settings.Default.Alt    = AltOption.IsChecked;

            if (AltOption.IsChecked)
            {
                Report1.SetResourceReference(ContentProperty, "AnsemReportOld1");
                Report2.SetResourceReference(ContentProperty, "AnsemReportOld2");
                Report3.SetResourceReference(ContentProperty, "AnsemReportOld3");
                Report4.SetResourceReference(ContentProperty, "AnsemReportOld4");
                Report5.SetResourceReference(ContentProperty, "AnsemReportOld5");
                Report6.SetResourceReference(ContentProperty, "AnsemReportOld6");
                Report7.SetResourceReference(ContentProperty, "AnsemReportOld7");
                Report8.SetResourceReference(ContentProperty, "AnsemReportOld8");
                Report9.SetResourceReference(ContentProperty, "AnsemReportOld9");
                Report10.SetResourceReference(ContentProperty, "AnsemReportOld10");
                Report11.SetResourceReference(ContentProperty, "AnsemReportOld11");
                Report12.SetResourceReference(ContentProperty, "AnsemReportOld12");
                Report13.SetResourceReference(ContentProperty, "AnsemReportOld13");
                Fire1.SetResourceReference(ContentProperty, "FireOld");
                Fire2.SetResourceReference(ContentProperty, "FireOld");
                Fire3.SetResourceReference(ContentProperty, "FireOld");
                Blizzard1.SetResourceReference(ContentProperty, "BlizzardOld");
                Blizzard2.SetResourceReference(ContentProperty, "BlizzardOld");
                Blizzard3.SetResourceReference(ContentProperty, "BlizzardOld");
                Thunder1.SetResourceReference(ContentProperty, "ThunderOld");
                Thunder2.SetResourceReference(ContentProperty, "ThunderOld");
                Thunder3.SetResourceReference(ContentProperty, "ThunderOld");
                Cure1.SetResourceReference(ContentProperty, "CureOld");
                Cure2.SetResourceReference(ContentProperty, "CureOld");
                Cure3.SetResourceReference(ContentProperty, "CureOld");
                Reflect1.SetResourceReference(ContentProperty, "ReflectOld");
                Reflect2.SetResourceReference(ContentProperty, "ReflectOld");
                Reflect3.SetResourceReference(ContentProperty, "ReflectOld");
                Magnet1.SetResourceReference(ContentProperty, "MagnetOld");
                Magnet2.SetResourceReference(ContentProperty, "MagnetOld");
                Magnet3.SetResourceReference(ContentProperty, "MagnetOld");
                Valor.SetResourceReference(ContentProperty, "ValorOld");
                Wisdom.SetResourceReference(ContentProperty, "WisdomOld");
                Limit.SetResourceReference(ContentProperty, "LimitOld");
                Master.SetResourceReference(ContentProperty, "MasterOld");
                Final.SetResourceReference(ContentProperty, "FinalOld");
                TornPage1.SetResourceReference(ContentProperty, "TornPageOld");
                TornPage2.SetResourceReference(ContentProperty, "TornPageOld");
                TornPage3.SetResourceReference(ContentProperty, "TornPageOld");
                TornPage4.SetResourceReference(ContentProperty, "TornPageOld");
                TornPage5.SetResourceReference(ContentProperty, "TornPageOld");
                Lamp.SetResourceReference(ContentProperty, "GenieOld");
                Ukulele.SetResourceReference(ContentProperty, "StitchOld");
                Baseball.SetResourceReference(ContentProperty, "ChickenLittleOld");
                Feather.SetResourceReference(ContentProperty, "PeterPanOld");
                Nonexistence.SetResourceReference(ContentProperty, "ProofOfNonexistenceOld");
                Connection.SetResourceReference(ContentProperty, "ProofOfConnectionOld");
                Peace.SetResourceReference(ContentProperty, "ProofOfPeaceOld");
                PromiseCharm.SetResourceReference(ContentProperty, "PromiseCharmOld");

                broadcast.Report.SetResourceReference(ContentProperty, "AnsemReportOld");
                broadcast.Peace.SetResourceReference(ContentProperty, "ProofOfPeaceOld");
                broadcast.Nonexistence.SetResourceReference(ContentProperty, "ProofOfNonexistenceOld");
                broadcast.Connection.SetResourceReference(ContentProperty, "ProofOfConnectionOld");
                broadcast.PromiseCharm.SetResourceReference(ContentProperty, "PromiseCharmOld");
                broadcast.Fire.SetResourceReference(ContentProperty, "FireAlt");
                broadcast.Blizzard.SetResourceReference(ContentProperty, "BlizzardAlt");
                broadcast.Thunder.SetResourceReference(ContentProperty, "ThunderAlt");
                broadcast.Cure.SetResourceReference(ContentProperty, "CureAlt");
                broadcast.Reflect.SetResourceReference(ContentProperty, "ReflectAlt");
                broadcast.Magnet.SetResourceReference(ContentProperty, "MagnetAlt");
                broadcast.Valor.SetResourceReference(ContentProperty, "ValorAlt");
                broadcast.Wisdom.SetResourceReference(ContentProperty, "WisdomAlt");
                broadcast.Limit.SetResourceReference(ContentProperty, "LimitAlt");
                broadcast.Master.SetResourceReference(ContentProperty, "MasterAlt");
                broadcast.Final.SetResourceReference(ContentProperty, "FinalAlt");
                broadcast.Baseball.SetResourceReference(ContentProperty, "ChickenLittleAlt");
                broadcast.Lamp.SetResourceReference(ContentProperty, "GenieAlt");
                broadcast.Ukulele.SetResourceReference(ContentProperty, "StitchAlt");
                broadcast.Feather.SetResourceReference(ContentProperty, "PeterPanAlt");

                ((Grid)((Grid)broadcast.Fire.Parent).Parent).RowDefinitions[0].Height = new GridLength(0, GridUnitType.Star);
                ((Grid)((Grid)broadcast.Fire.Parent).Parent).RowDefinitions[2].Height = new GridLength(0, GridUnitType.Star);
                ((Grid)broadcast.Valor.Parent).RowDefinitions[1].Height = new GridLength(5, GridUnitType.Star);
                ((Grid)broadcast.Valor.Parent).RowDefinitions[2].Height = new GridLength(5, GridUnitType.Star);
                ((Grid)broadcast.Lamp.Parent).RowDefinitions[1].Height  = new GridLength(8, GridUnitType.Star);
            }
        }