public void Test() { var test3 = new TestClass4(); PartContainer.Fill(test3); PartContainer.Fill(typeof(TestClass4)); Assert.Null(TestClass4.TestProp5); Assert.Null(test3.TestProp6); foreach (var test in new[] { TestClass4.TestProp, TestClass4.TestProp2, test3.TestProp3, test3.TestProp4 }) { Assert.NotNull(test); Assert.Equal(2, test.Count()); if (test.First() is TestClass1) { Assert.IsType <TestClass1>(test.First()); Assert.Equal("TestClass1", test.First().ID); Assert.IsType <TestClass2>(test.Last()); Assert.Equal("TestClass2", test.Last().ID); } else { Assert.IsType <TestClass2>(test.First()); Assert.Equal("TestClass2", test.First().ID); Assert.IsType <TestClass1>(test.Last()); Assert.Equal("TestClass1", test.Last().ID); } } }
public void Test() { var test3 = new TestClass3(); PartContainer.Fill(test3); PartContainer.Fill(typeof(TestClass3)); foreach (var test in new[] { TestClass3.TestInterface, TestClass3.TestInterface2, test3.TestInterface3, test3.TestInterface4 }) { Assert.NotNull(test); Assert.Equal(2, test.Count); if (test[0] is TestClass1) { Assert.IsType <TestClass1>(test[0]); Assert.Equal("TestClass1", test[0].ID); Assert.IsType <TestClass2>(test[1]); Assert.Equal("TestClass2", test[1].ID); } else { Assert.IsType <TestClass2>(test[0]); Assert.Equal("TestClass2", test[0].ID); Assert.IsType <TestClass1>(test[1]); Assert.Equal("TestClass1", test[1].ID); } } }
public void PartBoxGetTest() { PartContainer.Noop(); var test = new MyClass { Name = "blqw" }; var p = test.GetType().GetProperty("Name"); var part = PartBox.Default.Get(p, x => new { Get = PartContainer.Invoke <Func <object, object> >("GetValue", x), Set = PartContainer.Invoke <Action <object, object> >("SetValue", x), }, p); Assert.NotNull(part); Assert.NotNull(part.Get); Assert.NotNull(part.Set); var part2 = PartBox.Default.Get(p, x => new { Get = PartContainer.Invoke <Func <object, object> >("GetValue", x), Set = PartContainer.Invoke <Action <object, object> >("SetValue", x), }, p); Assert.NotNull(part2); Assert.NotNull(part2.Get); Assert.NotNull(part2.Set); Assert.Equal(part.Get, part2.Get); Assert.Equal(part.Set, part2.Set); }
private void HandleArrive(PartContainer cont) { foreach (var item in containers) { if (item.partCont == cont) { item.OnReachScreen?.Invoke(); } } }
public void InstanceField() { var test2 = new TestClass2(); Assert.Null(test2.TestInterface2); PartContainer.Fill(test2); Assert.NotNull(test2.TestInterface2); Assert.IsType <TestClass1>(test2.TestInterface2); Assert.Equal("TestClass1", test2.TestInterface2.ID); }
public void Test() { var test2 = new TestClass2(); Assert.Null(test2.GetID); Assert.Null(test2.GetID2); PartContainer.Fill(test2); Assert.NotNull(test2.GetID); Assert.NotNull(test2.GetID2); Assert.Equal("A", test2.GetID()); Assert.Equal("A", test2.GetID2()); }
public void Test() { var test2 = new TestClass2(); Assert.Null(test2.Test1); Assert.Null(test2.Test2); PartContainer.Fill(test2); Assert.NotNull(test2.Test1); Assert.NotNull(test2.Test2); Assert.Equal(typeof(string), test2.Test1.ID); Assert.Equal(typeof(int), test2.Test2.ID); }
public void TestMany() { var test2 = new TestClass2(); Assert.Null(test2.GetID3); PartContainer.Fill(test2); Assert.NotNull(test2.GetID3); Assert.Equal(2, test2.GetID3.Count); var a = test2.GetID3[0](); var b = test2.GetID3[1](); Assert.True((a == "A" && b == "B") || (a == "B" && b == "A")); }
public void Test2() { var test = new TestClass4(); Assert.Null(test.Get1); Assert.Null(test.Get2); Assert.Null(test.Get3); PartContainer.Fill(test); Assert.NotNull(test.Get1); Assert.NotNull(test.Get2); Assert.NotNull(test.Get3); Assert.Equal(typeof(string), test.Get1()); Assert.Equal(typeof(int), test.Get2()); Assert.Equal(typeof(int), test.Get3(1)); }
public void StaticPropertyAndField() { Assert.Null(TestClass3.TestInterface); Assert.Null(TestClass3.TestInterface2); PartContainer.Fill(typeof(TestClass3)); Assert.NotNull(TestClass3.TestInterface); Assert.IsType <TestClass1>(TestClass3.TestInterface); Assert.Equal("TestClass1", TestClass3.TestInterface.ID); Assert.NotNull(TestClass3.TestInterface2); Assert.IsType <TestClass1>(TestClass3.TestInterface2); Assert.Equal("TestClass1", TestClass3.TestInterface2.ID); }
IEnumerator MovingTo(PartContainer target, TransitionData td) { if (target == null) { Debug.LogError("No Target assinged for transitioning! --- PlayMode will be paused"); Debug.Break(); } StartTransition(); if (currContInfo != null) { currContInfo.partCont.StartDeactivation(); //---> Is this necessary? } yield return(new WaitForSeconds(td.waitInCurrent)); currContInfo.partCont = target; MoveCamToCurrent(); currContInfo.partCont.StartActivation(); //Syncro syncroSystem.StartSequence(); //if I am moving to GameScreen if (currContInfo.cointainersType == CointainersTypes.gameScreen) { //ask for tutorial stuff tutSystem.TryTriggerTutorial(LvlManager.instance.currentGameMode); print(LvlManager.instance.currentGameMode.ToString()); } while (!syncroSystem.sequenceCompleted) { yield return(null); } yield return(new WaitForSeconds(td.waitLoadingMin)); ComeBackFromTransition(); yield return(new WaitForSeconds(td.waitInNew)); //REFACTOR this //print("Transition has ended"); HandleArrive(currContInfo.partCont); }
IEnumerator MovingTo(PartContainer target, TransitionData td) { StartTransition(); currCont.StartDeactivation(); yield return(new WaitForSeconds(td.waitInCurrent)); currCont = target; MoveCamToCurrent(); currCont.StartActivation(); //OnLodingGame?.Invoke(); yield return(new WaitForSeconds(td.waitLoadingMin)); ComeBackFromTransition(); yield return(new WaitForSeconds(td.waitInNew)); print("Transition has ended"); OnArriveToGame?.Invoke(); }
public void TestInvoke() { PartContainer.Noop(); var test = new MyClass { Name = "blqw" }; var p = test.GetType().GetProperty("Name"); var getter = PartContainer.Invoke <Func <object, object> >("GetValue", p); var setter = PartContainer.Invoke <Action <object, object> >("SetValue", p); Assert.NotNull(getter); Assert.NotNull(setter); Assert.Equal(getter(test), test.Name); test.Name = "xxxx"; Assert.Equal(getter(test), test.Name); setter(test, "yyyy"); Assert.Equal(getter(test), test.Name); Assert.Equal(test.Name, "yyyy"); }
public PartManager() { _partContainer = new PartContainer(); this.Subscribe(DocManager.Inst); timer = new Timer(Update, _partContainer, 0, 100); }
public void Detect() { foreach (Part myCam in this.vessel.parts) { int cnt = 0; if (myCam.Modules != null) { for (int i = 0; i < myCam.Modules.Count; i++) { if (myCam.Modules[i] is cccam) { cccam myCamMod = (cccam)myCam.Modules[i]; if (!myCams.ContainsKey(myCam.name + cnt.ToString())) { myCamMod.switchOn(); myCamMod.isOn = true; myCamMod.Events["toggleOnOff"].guiName = "Switch Off"; PartContainer pc = new PartContainer(cnt, myCam, myCamMod); myCams.Add(pc.pcIndex, pc); } cnt++; } } } else { Debug.Log("Modules is null"); } } foreach (Vessel ship in FlightGlobals.Vessels) { if (ship.loaded) { foreach (Part myCam in ship.parts) { int cnt = 0; if (myCam.Modules != null) { for (int i = 0; i < myCam.Modules.Count; i++) { if (myCam.Modules[i] is ccrcam) { ccrcam myRemoteCamMod = (ccrcam)myCam.Modules[i]; if (!myCams.ContainsKey(myCam.name + cnt.ToString())) { myRemoteCamMod.switchOn(); myRemoteCamMod.isOn = true; myRemoteCamMod.Events["toggleOnOff"].guiName = "Switch Off"; PartContainer pc = new PartContainer(cnt, myCam, myRemoteCamMod); myCams.Add(pc.pcIndex, pc); } cnt++; } } } else { Debug.Log("Modules is null"); } } } } }
public PartManager() { _partContainer = new PartContainer(); DocManager.Inst.AddSubscriber(this); timer = new Timer(Update, _partContainer, 0, 100); }
public TutorialContainer parseTutorialFromXmlString(XmlNode xmlDocument) { var parts = xmlDocument.SelectSingleNode("TutorialSequence"); var tutorialContainer = new TutorialContainer(); if (parts != null) { // Then goes through each element foreach (XmlNode part in parts.ChildNodes) { var partIdString = ParseHelper.getAttributeValueByName(part, "id"); if (!int.TryParse(partIdString, out var partId)) { throw new Exception($"Could not parse part ID: {partIdString}"); } var partContainer = new PartContainer(partId); tutorialContainer.addPart(partContainer); var checkEvents = part.SelectNodes("CheckEvent"); var helpDisplays = part.SelectNodes("HelpDisplay"); var uiMasks = part.SelectNodes("TutorialUiMask"); if (checkEvents != null) { foreach (XmlNode checkEvent in checkEvents) { var typeString = ParseHelper.getAttributeValueByName(checkEvent, "type"); if (!Enum.TryParse(typeString, out CheckEventType checkEventType)) { throw new Exception($"Could not parse EventType: {typeString}"); } var idString = ParseHelper.getAttributeValueByName(checkEvent, "id"); if (!int.TryParse(idString, out var id)) { throw new Exception($"Could not parse id: {idString}"); } if (checkEventType == CheckEventType.ElementEvent || checkEventType == CheckEventType.PartElementEvent) { var elementIdString = ParseHelper.getAttributeValueByName(checkEvent, "elementId"); if (!int.TryParse(elementIdString, out var elementId)) { throw new Exception($"Could not parse elementId: {elementIdString}"); } if (checkEventType == CheckEventType.ElementEvent) { partContainer.addElement(new ElementCheckEvent(checkEvent.InnerText, elementId), id); } else { partIdString = ParseHelper.getAttributeValueByName(checkEvent, "partId"); if (!int.TryParse(partIdString, out partId)) { throw new Exception($"Could not parse partId: {partIdString}"); } partContainer.addElement(new PartElementCheckEvent(checkEvent.InnerText, partId, elementId), id); } } else if (checkEventType == CheckEventType.GameObjectEvent) { var gameObjectName = ParseHelper.getAttributeValueByName(checkEvent, "name"); partContainer.addElement(new GameObjectCheckEvent(checkEvent.InnerText, gameObjectName), id); } } } if (helpDisplays != null) { foreach (XmlNode helpDisplay in helpDisplays) { var typeString = ParseHelper.getAttributeValueByName(helpDisplay, "type"); if (!Enum.TryParse(typeString, out HelpDisplayType helpDisplayType)) { throw new Exception($"Could not parse EventType: {typeString}"); } var idString = ParseHelper.getAttributeValueByName(helpDisplay, "id"); if (!int.TryParse(idString, out var id)) { throw new Exception($"Could not parse id: {idString}"); } var parameters = new Dictionary <string, string>(); var parameterNodes = helpDisplay.SelectNodes("Parameter"); foreach (XmlNode parameterNode in parameterNodes) { var attributeName = parameterNode.Attributes[0].Value; parameters.Add(attributeName, parameterNode.InnerText); } partContainer.addElement(new HelpDisplayInitializer(helpDisplayType, parameters), id); } } if (uiMasks != null) { foreach (XmlNode uiMask in uiMasks) { var idString = ParseHelper.getAttributeValueByName(uiMask, "id"); if (!int.TryParse(idString, out var id)) { throw new Exception($"Could not parse id: {idString}"); } var parameters = new Dictionary <string, string>(); var parameterNodes = uiMask.SelectNodes("Parameter"); foreach (XmlNode parameterNode in parameterNodes) { var attributeName = parameterNode.Attributes[0].Value; parameters.Add(attributeName, parameterNode.InnerText); } partContainer.addElement(new TutorialUiMaskInitializer(parameters), id); } } } } return(tutorialContainer); }