public void TestSetInstanceOverride() { var interfaceObject = new InterfaceObject <TestInterface> (); var gameObject = new GameObject(); var interfaceImpl = gameObject.AddComponent <TestInterfaceImplementation>(); interfaceObject._object = interfaceImpl; Assert.That(interfaceObject.Get(), Is.SameAs(interfaceImpl)); var gameObject2 = new GameObject(); var otherImpl = gameObject2.AddComponent <TestInterfaceImplementation>(); interfaceObject.Set(otherImpl); Assert.That(interfaceObject.Get() != null); Assert.That(interfaceObject.Get(), Is.SameAs(otherImpl)); Assert.That(interfaceObject._object != null); Assert.That(interfaceObject._object == otherImpl); var otherImpl2 = new TestInterfaceImplementationNotBehaviour(); interfaceObject.Set(otherImpl2); Assert.That(interfaceObject.Get() != null); Assert.That(interfaceObject.Get() == otherImpl2); Assert.That(interfaceObject._object == null); }
public void Should_Clone_InterfacesObject() { var original = new InterfaceObject() { BoolValue = true, IntValue = 10, DictionaryValue = new Dictionary <int, BasicObject> { { 1, new BasicObject() { IntValue = 1, LongValue = 10 } }, { 2, new BasicObject() { IntValue = 2, LongValue = 20 } }, { 3, new BasicObject() { IntValue = 3, LongValue = 30 } }, }, }; var cloned = original.Clone(); Assert.AreEqual(original, cloned); }
public static void Should_Clone_InterfacesObject() { var original = new InterfaceObject() { BoolValue = true, IntValue = 10, DictionaryValue = new Dictionary <int, BasicObject> { { 1, new BasicObject() { IntValue = 1, LongValue = 10 } }, { 2, new BasicObject() { IntValue = 2, LongValue = 20 } }, { 3, new BasicObject() { IntValue = 3, LongValue = 30 } }, }, }; InterfaceObject cloned = original.Clone(); cloned.ShouldBe(original); }
public void ParseComponent(InterfaceObject parentInterface, AtlasFeature feature) { Component comp = new Component(feature.Name); this.bragi.AddComponent(comp); if (parentInterface != null) { Socket so = new Socket(comp, parentInterface, (++counter).ToString()); bragi.AddSocket(so); } foreach (AtlasFeature fchild in this.model.GetChildren(feature)) { if (fchild.IsAbstract) { this.ParseInterface(comp, fchild); } else { string iname = (++counter).ToString(); InterfaceObject o = new InterfaceObject(iname, comp); this.bragi.AddInterface(o); SMarty m = new SMarty((++counter).ToString(), SMartyBindingTimeTypes.CompileTime, o); this.bragi.AddAttachment(m); this.ParseComponent(o, fchild); } } }
public void HoverOff(InterfaceObject obj) { if (potential == obj) { potential = null; } }
public static void ModifiedClone_InterfaceObject_ShouldNotBeEqual() { var original = new InterfaceObject() { BoolValue = true, IntValue = 10, DictionaryValue = new Dictionary <int, BasicObject> { { 1, new BasicObject() { IntValue = 1, LongValue = 10 } }, { 2, new BasicObject() { IntValue = 2, LongValue = 20 } }, { 3, new BasicObject() { IntValue = 3, LongValue = 30 } }, }, }; InterfaceObject cloned = original.Clone(); cloned.DictionaryValue[2].StringValue = "Test string"; cloned.ShouldNotBe(original); }
public void Grab(InterfaceObject obj) { if (obj is Block) { Grab((Block)obj, obj.GetContainer()); } }
/// <summary> /// Adds Interface to Danu. Adds its name, minVar, maxVar and bindingTime. /// </summary> public void AddInterface(InterfaceObject io) { SMartyBindingTimeTypes bindingTime = default(SMartyBindingTimeTypes); DanuBindingTime newBindingTime = default(DanuBindingTime); SMarty attach = null; foreach (IAttachment attachment in io.Attachments) { if (attachment.GetType().Equals(typeof(SMarty))) { attach = (SMarty)attachment; } } int minVar = attach.MinSelection; int maxVar = attach.MaxSelection; foreach (IAttachment attachment in io.Attachments) { if (attachment.GetType().Equals(typeof(SMarty))) { SMarty smarty = (SMarty)attachment; bindingTime = smarty.BindingTime; minVar = smarty.MinSelection; maxVar = smarty.MaxSelection; break; } } if (!bindingTime.Equals(default(SMartyBindingTimeTypes))) { switch (bindingTime) { case SMartyBindingTimeTypes.CompileTime: newBindingTime = DanuBindingTime.CompileTime; break; case SMartyBindingTimeTypes.LinkingTime: newBindingTime = DanuBindingTime.LinkingTime; break; case SMartyBindingTimeTypes.Runtime: newBindingTime = DanuBindingTime.Runtime; break; case SMartyBindingTimeTypes.UpdateTime: newBindingTime = DanuBindingTime.UpdateTime; break; } } DanuInterfaceObject newInterface = new DanuInterfaceObject(io.Name, newBindingTime, minVar, maxVar); interfaces.Add(newInterface.Name, newInterface); }
public RectTransform GetInterface(InterfaceObject type) { for (int i = 0; i < interfaceObjects.Length; i++) { if (interfaceObjects[i].Type == type) { return(interfaceObjects[i].Rect); } } return(null); }
public void TestGetFromObject() { var interfaceObject = new InterfaceObject <TestInterface> (); var gameObject = new GameObject(); var interfaceImpl = gameObject.AddComponent <TestInterfaceImplementation>(); interfaceObject._object = gameObject; Assert.That(interfaceObject.Get(), Is.SameAs(interfaceImpl)); }
public void UsingInterfaceConverter() { var obj = new InterfaceObject { Age = 33 }; var json = JsonConvert.Serialize(obj); var deserializedObj = JsonConvert.Deserialize <InterfaceObject>(json); Assert.DoesNotContain("UsedConverter", json); Assert.Equal(obj.Age, deserializedObj.Age); Assert.True(obj.UsedConverter, "Object serialize converter not called."); Assert.True(deserializedObj.UsedConverter, "Object deserialize converter not called."); }
private void bFurnitAdd_Click(object sender, EventArgs e) { if (nFurnituraCounter > furnituraPath.Count - 1) { nFurnituraCounter = 0; } else if (nFurnituraCounter < 0) { nFurnituraCounter = furnituraPath.Count - 1; } try { InterfaceObject obj = null; if (modelsPath[nFurnituraCounter].Contains("fridge")) { obj = new Fridge(0, 0, 0, 1, 1, 2); } else if (modelsPath[nFurnituraCounter].Contains("stove")) { obj = new Stove(-1, -1, 0, 0.5, 0.7, 1.5); } else if (modelsPath[nFurnituraCounter].Contains("table")) { obj = new Table(0, 0, 0, 2, 2, 0); } else if (modelsPath[nFurnituraCounter].Contains("chair")) { obj = new Chair(0, 0, 0, 0.5, 0.5, 0); } else if (modelsPath[nFurnituraCounter].Contains("cupboard")) { obj = new Cupboard(0, 0, 0, 1.5, 0.5, 0); } if (obj != null) { obj.LoadModel(modelsPath[nFurnituraCounter]); } room.AddObj(obj); string num = "" + modelsPath[nFurnituraCounter][modelsPath[nFurnituraCounter].Length - 6]; num += modelsPath[nFurnituraCounter][modelsPath[nFurnituraCounter].Length - 5]; DataForBD.ListZakazMebTeh.Add(new ObjFurnit(DataForBD.IdZakaz, Convert.ToInt32(num), 0, 0)); } catch (Exception ex) { MessageBox.Show("Файл повреждён\r\n" + ex, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Execute(InterfaceObject menuItem) { switch (menuItem) { case InterfaceObject.MainMenu: if (_currentMenu != null) { _currentMenu.Hide(); } _currentMenu = _mainMenu; _currentMenu.Show(); break; //case InterfaceObject.OptionsMenu: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _optionsMenu; // _currentMenu.Show(); // break; //case InterfaceObject.VideoOptions: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _videoOptions; // _currentMenu.Show(); // break; //case InterfaceObject.AudioOptions: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _audioOptions; // _currentMenu.Show(); // break; //case InterfaceObject.GameOptions: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _gameOptions; // _currentMenu.Show(); // break; //case InterfaceObject.MenuPause: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _menuPause; // _currentMenu.Show(); // break; //case InterfaceObject.OptionsPauseMenu: // if (_currentMenu != null) _currentMenu.Hide(); // _currentMenu = _optionsPauseMenu; // _currentMenu.Show(); // break; default: break; } }
public void ParseInterface(Component parentComponent, AtlasFeature feature) { string iname = (++counter).ToString(); InterfaceObject o = new InterfaceObject(iname, parentComponent); this.bragi.AddInterface(o); SMarty m = new SMarty((++counter).ToString(), SMartyBindingTimeTypes.CompileTime, o); this.bragi.AddAttachment(m); foreach (AtlasFeature child in this.model.GetChildren(feature)) { this.ParseComponent(o, child); } }
public void Grab(Block block, InterfaceObject container) { if (isEnabled) { if (IsHolding()) { throw new NotSupportedException("Can not grab multiple items at once."); } held = block; held.GetComponent <Collider2D>().enabled = false; held.SetContainer(null); Vector3 mousePos = MousePosition(); originalOffset = block.transform.position - mousePos; originalOffset.z = 0; originalZ = block.transform.position.z; originalPosition = block.transform.position; originalContainer = container; } }
public void HoverOn(InterfaceObject obj) { potential = obj; }
public RectTransform GetInterface(InterfaceObject type) { return(Interfaces.GetInterface(type)); }
public void SetContainer(InterfaceObject container) { this.container = container; }