public IActionResult Delete(int ID)
        {
            DoorOperator deletedDoorOperator = repository.DeleteDoorOperator(ID);

            if (deletedDoorOperator != null)
            {
                TempData["message"] = $"{deletedDoorOperator.Name} was deleted";
            }
            return(RedirectToAction("List"));
        }
Exemple #2
0
        public void DoorOperator_GivenOneHundredDoors_ShouldCreateDoorWithOneHundredDoors()
        {
            // Arrange
            const int numOfDoors = 100;

            // Act
            var doorOperator = new DoorOperator(numOfDoors);

            // Assert
            Assert.AreEqual(numOfDoors, doorOperator.Doors.Count);
        }
 public IActionResult Edit(DoorOperator doorOperator)
 {
     if (ModelState.IsValid)
     {
         repository.SaveDoorOperator(doorOperator);
         TempData["message"] = $"{doorOperator.Name} has been saved...{doorOperator.DoorOperatorID}";
         return(RedirectToAction("List"));
     }
     else
     {
         // there is something wrong with the data values
         return(View(doorOperator));
     }
 }
Exemple #4
0
        public void Operate_GivenSixDoorsAndTwoPasses_ShouldToggleAllTheDoorStates()
        {
            // Arrange
            const string expectedDoorString = "@#@#@#";

            const int numOfDoors   = 6;
            const int numOfPasses  = 2;
            var       doorOperator = new DoorOperator(numOfDoors);

            // Act
            var actualDoorString = doorOperator.Operate(numOfPasses);

            // Assert
            Assert.AreEqual(expectedDoorString, actualDoorString);
        }
Exemple #5
0
        public void Operate_GivenSixDoorsAndOnePass_ShouldOpenAllDoors()
        {
            // Arrange
            const string expectedDoorString = "@@@@@@";

            const int numOfDoors   = 6;
            const int numOfPasses  = 1;
            var       doorOperator = new DoorOperator(numOfDoors);

            // Act
            var actualDoorString = doorOperator.Operate(numOfPasses);

            // Assert
            Assert.AreEqual(expectedDoorString, actualDoorString);
        }
Exemple #6
0
    void SwitchState_TurnOn()
    {
        foreach (Interactable interact in ConnectedInteractables)
        {
            if ((door = interact.GetComponent <DoorOperator>()) != null)
            {
                door.DoorOperatorCount++;
            }

            interact.DoInteraction();
        }

        if (StartingIsOn)
        {
            StartResetTimer();
        }

        IsOn = true;
    }
    static void SaveDoorStates()
    {
        xmlWriter.WriteWhitespace("\n");
        xmlWriter.WriteComment("This is the list of Doors.");
        xmlWriter.WriteWhitespace("\n\t");

        xmlWriter.WriteStartElement("doors");

        DoorString = "GameSaveController::SaveDoorStates -- All Doors:";
        foreach (Door d in DoorsInWorld)
        {
            DoorString += " InteractableID: '" + d.InteractableID + "', ID: '" + d.GetInstanceID() + "', IsCurrentlyLocked: " + d.IsCurrentlyLocked +
                          ", HasBeenUsedOnce" + d.HasBeenUsedOnce + ", IsOn: " + d.IsOn + ".";

            xmlWriter.WriteWhitespace("\n\t\t");

            xmlWriter.WriteStartElement("door");
            xmlWriter.WriteAttributeString("InteractableID", d.InteractableID);
            xmlWriter.WriteAttributeString("gameObjectInstanceID", d.GetInstanceID().ToString());
            xmlWriter.WriteAttributeString("IsCurrentlyLocked", d.IsCurrentlyLocked.ToString());
            xmlWriter.WriteAttributeString("HasBeenUsedOnce", d.HasBeenUsedOnce.ToString());
            xmlWriter.WriteAttributeString("IsOn", d.IsOn.ToString());

            if (d.GetComponent <DoorOperator> () != null)
            {
                DoorOperator o = (DoorOperator)d;

                xmlWriter.WriteAttributeString("DoorOperatorCount", o.DoorOperatorCount.ToString());
                xmlWriter.WriteAttributeString("DoorOperatorCountTotal", o.DoorOperatorCountTotal.ToString());
            }

            xmlWriter.WriteEndElement();
        }

        xmlWriter.WriteWhitespace("\n\t");
        xmlWriter.WriteEndElement();
        xmlWriter.WriteWhitespace("\n");
    }
Exemple #8
0
    protected override void Start()
    {
        base.Start();

        GameSaveController.SwitchesInWorld.Add(this);

        CheckConnectedInteractablesForSelf();

        // Find all Doors connected to this Interactable and increment their OperatorCounter
        foreach (Interactable interactable in ConnectedInteractables)
        {
            DoorOperator current = interactable.GetComponent <DoorOperator>();

            if (current != null && current.dDoorOpenOperator == DoorOpenOperator.AND)
            {
                current.DoorOperatorCountTotal++;
            }
        }

        // TODO: This needs to load settings from save file.
        IsOn = StartingIsOn;

        anim = GetComponent <Animator> ();
    }
    public static void LoadGame()
    {
        XmlReader xmlReader = XmlReader.Create("saveGameTest.xml");

        while (xmlReader.Read())
        {
            if (xmlReader.NodeType == XmlNodeType.Element)
            {
                // <SaveData SaveFileName="SaveFileName" SaveFileDate="SaveFileDate" SaveFileTime="SaveFileTime" SaveFileTimeOnGame="SaveFileTimeOnGame" stationID="SAVE_STATION_A">
                if (xmlReader.Name == "SaveData")
                {
                    Debug.Log(string.Format("<SaveData SaveFileName=\"{0}\" SaveFileDate=\"{1}\" SaveFileTime=\"{2}\" SaveFileTimeOnGame=\"{3}\" stationID=\"{4}\"",
                                            xmlReader.GetAttribute("SaveFileName"), xmlReader.GetAttribute("SaveFileDate"), xmlReader.GetAttribute("SaveFileTime"),
                                            xmlReader.GetAttribute("SaveFileTimeOnGame"), xmlReader.GetAttribute("stationID")));

                    Player.instance.transform.position = SaveStationLocations.FirstOrDefault(a => a.InteractableID == xmlReader.GetAttribute("stationID")).transform.position;
                }

                //  <abilities JUMP="True" JUMP_DOUBLE="False" JUMP_TRIPLE="False" WALL_SLIDE="False" WALL_JUMP="False" WALL_HIGH_JUMP="False"
                //		DASH="False" DASH_MEGA="False" CHEAT_JUMP="False" CHEAT_DASH="False" WeaponProjectileModifier="1" />
                if (xmlReader.Name == "abilities")
                {
                    while (xmlReader.MoveToNextAttribute())
                    {
                        if (xmlReader.Name == "WeaponProjectileModifier")
                        {
                            Player.instance.WeaponProjectileModifier = float.Parse(xmlReader.Value);
                            break;
                        }

                        foreach (Ability a in Player.instance.Abilities)
                        {
                            if (xmlReader.Name == a.AbilityName)
                            {
                                a.AbilityCollected = bool.Parse(xmlReader.Value);
                                break;
                            }
                        }
                    }
                }

                //  <keys 0="1" 1="0" 2="0" 3="0" 4="0" 5="0" 6="0" />
                if (xmlReader.Name == "keys")
                {
                    while (xmlReader.MoveToNextAttribute())
                    {
                        Player.instance.Keys [int.Parse(xmlReader.Name.Substring(1))] = int.Parse(xmlReader.Value);
                    }
                }

                // <artifacts 0="False" 1="False" 2="False" 3="False" 4="False" 5="False" 6="False" />
                if (xmlReader.Name == "artifacts")
                {
                    while (xmlReader.MoveToNextAttribute())
                    {
                        Player.instance.Artifacts [int.Parse(xmlReader.Name.Substring(1))] = bool.Parse(xmlReader.Value);
                    }
                }

                // <enemy EntityName="Enemy_(63.9, -73.4)" gameObjectInstanceID="-156380" HasBeenKilled="False" PermanentlyKillable="True" />
                if (xmlReader.Name == "enemy")
                {
                    foreach (Enemy e in GameObject.Find("World").GetComponentsInChildren <Enemy>(true))
                    {
                        if (e.EntityName == xmlReader.GetAttribute("EntityName"))
                        {
                            e.HasBeenKilled = bool.Parse(xmlReader.GetAttribute("HasBeenKilled"));
                        }
                    }
                }

                // <item ItemName="ItemDashMega" gameObjectInstanceID="-1222" HasBeenCollected="False" />
                if (xmlReader.Name == "item")
                {
                    foreach (Item i in GameObject.Find("World").GetComponentsInChildren <Item>(true))
                    {
                        if (i.ItemName == xmlReader.GetAttribute("ItemName"))
                        {
                            i.HasBeenCollected = bool.Parse(xmlReader.GetAttribute("HasBeenCollected"));
                        }
                    }
                }

                // TODO: Since we're literally using the same details for both Switch and Door we should just merge the Switch and Door Lists into Interactable.
                // <switch InteractableID="sw" gameObjectInstanceID="-1054" IsCurrentlyLocked="False" HasBeenUsedOnce="False" IsOn="False" />
                if (xmlReader.Name == "switch")
                {
                    foreach (Switch s in GameObject.Find("World").GetComponentsInChildren <Switch>(true))
                    {
                        if (s.InteractableID == xmlReader.GetAttribute("InteractableID"))
                        {
                            s.IsCurrentlyLocked = bool.Parse(xmlReader.GetAttribute("IsCurrentlyLocked"));
                            s.HasBeenUsedOnce   = bool.Parse(xmlReader.GetAttribute("HasBeenUsedOnce"));
                            s.IsOn = bool.Parse(xmlReader.GetAttribute("IsOn"));
                        }
                    }
                }

                // <door InteractableID="ENTITY_DOOR_TEST" gameObjectInstanceID="-1194" IsCurrentlyLocked="True" HasBeenUsedOnce="False" CurrentState="False" />
                if (xmlReader.Name == "door")
                {
                    foreach (Door d in GameObject.Find("World").GetComponentsInChildren <Door>(true))
                    {
                        if (d.InteractableID == xmlReader.GetAttribute("InteractableID"))
                        {
                            d.IsCurrentlyLocked = bool.Parse(xmlReader.GetAttribute("IsCurrentlyLocked"));
                            d.HasBeenUsedOnce   = bool.Parse(xmlReader.GetAttribute("HasBeenUsedOnce"));
                            d.IsOn = bool.Parse(xmlReader.GetAttribute("IsOn"));

                            if (d.GetComponent <DoorOperator> () != null)
                            {
                                DoorOperator o = (DoorOperator)d;

                                o.DoorOperatorCount      = int.Parse(xmlReader.GetAttribute("DoorOperatorCount"));
                                o.DoorOperatorCountTotal = int.Parse(xmlReader.GetAttribute("DoorOperatorCountTotal"));
                            }
                        }
                    }
                }

                // <log InteractableName="Test Log" HasBeenCollected="True" />
                if (xmlReader.Name == "log")
                {
                    LogsFoundByPlayer.Add(xmlReader.GetAttribute("InteractableName"), bool.Parse(xmlReader.GetAttribute("HasBeenCollected")));
                }
            }


            //			if((xmlReader.NodeType == XmlNodeType.Element) && (xmlReader.Name == "saveLocation")) {
//
//				Debug.Log ("SaveLocation");
//
//				if(xmlReader.HasAttributes)
//					Debug.Log(xmlReader.GetAttribute("currency") + ": " + xmlReader.GetAttribute("rate"));
//
//			}
        }
    }