//创建高架库 #region Create_HighBays public static void Create_HighBays(HighStoreShelf_Parameter HP, MultiHighBay_Parameter MHP, GameObject OBJ) { //HP单个高架库设计尺寸参数 //HSP高架库组合设计的参数 //根据单个高架库设计参数生成高架库 GameObject HighBay = new GameObject(); string name = "HighBay"; HighBay.name = name; // Subassembly.Create_HighStoreShelf(HP, HighBay); HighBay.transform.Rotate(0, 180, 0); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(HighBay); //Debug.Log(00); //根据高架库组合设计的参数生成高架库组合 GameObject HighBayGroup = new GameObject(); HighBayGroup.name = "HighBayGroup"; for (int i = 0; i < MHP.Num; i++) { GameObject clone = Instantiate(HighBay); clone.transform.parent = HighBayGroup.transform; clone.name = name + (i + 1).ToString(); float TempValue = -(HP.Size.x / 2 + i * HP.Size.x + ((i + 1) / 2) * MHP.TunnelWidth + (i / 2) * MHP.HookupDistance); clone.transform.localPosition = new Vector3(TempValue, 0, 0); } //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(HighBayGroup); GameObject OBJ1 = new GameObject(); OBJ1.name = "ConnectPart"; ConnectComponent(HP, MHP, OBJ1); //GameObject.Find("ScriptsContainer").GetComponent<MyClass>().Create2(OBJ1); HighBayGroup.transform.parent = OBJ.transform; HighBayGroup.transform.localPosition = new Vector3(0, 0, 0); OBJ1.transform.parent = OBJ.transform; OBJ1.transform.localPosition = new Vector3(0, 0, 0); DestroyImmediate(HighBay); }
public void TestViewModelConstruction() { Subassembly component = TestHelper.GetTestComponent(); Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, false); Assert.IsTrue(viewModel.Component != null); Assert.IsTrue(viewModel.Component.AssemblyId == component.AssemblyId && viewModel.Component.Notes == component.Notes); }
private void OnAddComponentCommandExecute(int partId) { var component = new Subassembly { AssemblyId = partId }; CurrentAddComponentViewModel = new EditComponentViewModel(_serviceFactory, component, true); CurrentAddComponentViewModel.CancelAddComponent += EditComponentViewModel_CancelEvent; CurrentAddComponentViewModel.ComponentUpdated += EditComponentViewModel_ComponentUpdated; }
public void TestComponentIsValid() { Subassembly component = TestHelper.GetTestComponent(); Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, true); viewModel.Component.PartDescription = ""; Assert.IsFalse(viewModel.Component.IsValid); viewModel.Component.PartDescription = "Description"; Assert.IsTrue(viewModel.Component.IsValid); }
public void TestCanSaveCommand() { Subassembly component = TestHelper.GetTestComponent(); Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, true); Assert.IsFalse(viewModel.SaveCommand.CanExecute(null)); viewModel.Component.Notes = "Black"; Assert.IsTrue(viewModel.SaveCommand.CanExecute(null)); }
public void TestCancelCommand() { Subassembly component = new Subassembly { Id = 1, Notes = "White" }; Mock<IServiceFactory> mockServiceFactory = new Mock<IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, true); bool canceled = false; viewModel.CancelAddComponent += (s, e) => canceled = true; Assert.IsTrue(!canceled); viewModel.CancelCommand.Execute(null); Assert.IsTrue(viewModel.CancelCommand.CanExecute(null)); Assert.IsTrue(canceled); }
// note that this viewmodel is instantiated on-demand from parent and not with DI public EditComponentViewModel(IServiceFactory serviceFactory, Subassembly component, bool isNew) { _serviceFactory = serviceFactory; _isNew = isNew; _component = new Subassembly { Id = component.Id, AssemblyId = component.AssemblyId, SubassemblyId = component.SubassemblyId, PartDescription = component.PartDescription, CostContribution = component.CostContribution, Notes = component.Notes }; LoadParts(); _component.CleanAll(); SaveCommand = new DelegateCommand <object>(OnSaveCommandExecute, OnSaveCommandCanExecute); CancelCommand = new DelegateCommand <object>(OnCancelCommandExecute); }
// note that this viewmodel is instantiated on-demand from parent and not with DI public EditComponentViewModel(IServiceFactory serviceFactory, Subassembly component, bool isNew) { _serviceFactory = serviceFactory; _isNew = isNew; _component = new Subassembly { Id = component.Id, AssemblyId = component.AssemblyId, SubassemblyId = component.SubassemblyId, PartDescription = component.PartDescription, CostContribution = component.CostContribution, Notes = component.Notes }; LoadParts(); _component.CleanAll(); SaveCommand = new DelegateCommand<object>(OnSaveCommandExecute, OnSaveCommandCanExecute); CancelCommand = new DelegateCommand<object>(OnCancelCommandExecute); }
private void OnGUI() { //获取用户输入 path1 = EditorGUILayout.TextField("高架库设计参数文件:", path1); Num = EditorGUILayout.IntField("高架库数目:", Num); TunnelWidth = EditorGUILayout.FloatField("高架库间巷道距离:", TunnelWidth); HookupDistance = EditorGUILayout.FloatField("高架库间连接距离:", HookupDistance); Name = EditorGUILayout.TextField("场景名称:", Name); path2 = EditorGUILayout.TextField("场景输出路径:", path2); enterRollerLength = EditorGUILayout.FloatField("入口滚筒输送机长度:", enterRollerLength); exitRollerLength = EditorGUILayout.FloatField("出口滚筒输送机长度:", exitRollerLength); HighStoreShelf_Parameter HP; string Path1 = path1 + ".txt"; Subassembly.HighBay_ReadTxt(ref Path1, out HP); MultiHighBay_Parameter MHP; MHP.Num = Num; MHP.TunnelWidth = TunnelWidth; MHP.HookupDistance = HookupDistance; ParametersList1 PL; PL.HP = HP; PL.MHP = MHP; PL.Distance = 0;//坐标点到场景起点的Z距离 CreateSize(ref HP, ref MHP, out PL); PositionsList POL; if (GUILayout.Button("生成场景", GUILayout.Height(20))) { Create_PositionsList(ref PL, out POL); string Path2 = path2 + Name; Create_Scene(PL, POL, Path2); //保存场景 //Object tempPrefab = EditorUtility.CreateEmptyPrefab(path2 + Name + ".prefab"); //根据场景输送关键数据 } //if (GUILayout.Button("生成货箱", GUILayout.Height(20))) //{ // GameObject Cargo = new GameObject(); Cargo.name = "Cargo"; // CreateCargo(PL.CargoSize, Cargo); // //Debug.Log(0); //} }
public void TestSaveCommand() { Subassembly component = TestHelper.GetTestComponent(); Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, true); bool componentUpdated = false; string note = ""; viewModel.ComponentUpdated += (s, e) => { componentUpdated = true; note = e.Component.Notes; }; viewModel.SaveCommand.Execute(null); Assert.IsTrue(componentUpdated); Assert.AreEqual(component.Notes, note); }
public void TestCancelCommand() { Subassembly component = new Subassembly { Id = 1, Notes = "White" }; Mock <IServiceFactory> mockServiceFactory = new Mock <IServiceFactory>(); EditComponentViewModel viewModel = new EditComponentViewModel(mockServiceFactory.Object, component, true); bool canceled = false; viewModel.CancelAddComponent += (s, e) => canceled = true; Assert.IsTrue(!canceled); viewModel.CancelCommand.Execute(null); Assert.IsTrue(viewModel.CancelCommand.CanExecute(null)); Assert.IsTrue(canceled); }
private void EditComponentViewModel_ComponentUpdated(object sender, Support.ComponentEventArgs e) { if (!e.IsNew) { Subassembly component = Part.Components.FirstOrDefault(item => item.Id == e.Component.Id); if (component != null) { component.AssemblyId = e.Component.AssemblyId; component.SubassemblyId = e.Component.SubassemblyId; component.PartDescription = e.Component.PartDescription; component.CostContribution = e.Component.CostContribution; component.Notes = e.Component.Notes; } } else { _part.Components = _part.Components.Concat(new[] { e.Component }); } _part.IsDirty = true; CurrentAddComponentViewModel = null; }
public AssemblyCar() { Subassembly engineV6 = new Subassembly() { name = "Engine V6", quantity = 1 }; Subassembly pistonSystem = new Subassembly() { name = "Piston system", quantity = 1 }; Subassembly valueSystem = new Subassembly() { name = "Value system", quantity = 1 }; Subassembly wheel = new Subassembly() { name = "Wheel", quantity = 4 }; Subassembly door = new Subassembly() { name = "Door", quantity = 4 }; Subassembly differential = new Subassembly() { name = "Differential", quantity = 2 }; Detail transmission = new Detail() { name = "Transmission", quantity = 1, weight = 25 }; Detail gasTank = new Detail() { name = "Gas tank", quantity = 1, weight = 27 }; Detail intakeManifold = new Detail() { name = "Intake manifold", quantity = 1, weight = 12 }; Detail exhaustManifold = new Detail() { name = "Exhaust Manifold", quantity = 2, weight = 6 }; Detail radiator = new Detail() { name = "Radiator", quantity = 1, weight = 8 }; Detail piston = new Detail() { name = "Piston", quantity = 4, weight = 1 }; Detail crankshaft = new Detail() { name = "Crankshaft", quantity = 1, weight = 19 }; Detail link = new Detail() { name = "Link", quantity = 4, weight = 0.3f }; Detail gasket = new Detail() { name = "Gasket", quantity = 1, weight = 0.1f }; Detail value = new Detail() { name = "Value", quantity = 24, weight = 0.1f }; Detail camshaft = new Detail() { name = "Camshaft", quantity = 2, weight = 4.52f }; Detail disk = new Detail() { name = "Disk", quantity = 1, weight = 6.5f }; Detail tire = new Detail() { name = "Tire", quantity = 1, weight = 5.2f }; Detail glass = new Detail() { name = "Glass", quantity = 1, weight = 15 }; Detail doorCard = new Detail() { name = "Door kard", quantity = 1, weight = 5 }; Detail gears = new Detail() { name = "Gears", quantity = 5, weight = 0.6f }; Detail bearling = new Detail() { name = "Bearling", quantity = 3, weight = 0.13f }; Detail shank = new Detail() { name = "Shank", quantity = 1, weight = 0.32f }; car.Add(engineV6); car.Add(wheel); car.Add(transmission); car.Add(differential); car.Add(door); car.Add(gasTank); engineV6.Add(pistonSystem); engineV6.Add(valueSystem); engineV6.Add(intakeManifold); engineV6.Add(exhaustManifold); engineV6.Add(radiator); pistonSystem.Add(piston); pistonSystem.Add(crankshaft); pistonSystem.Add(link); pistonSystem.Add(gasket); valueSystem.Add(value); valueSystem.Add(camshaft); wheel.Add(disk); wheel.Add(tire); door.Add(glass); door.Add(doorCard); differential.Add(gears); differential.Add(bearling); differential.Add(shank); differential.CalculateWeight(); door.CalculateWeight(); wheel.CalculateWeight(); valueSystem.CalculateWeight(); pistonSystem.CalculateWeight(); engineV6.CalculateWeight(); car.CalculateWeight(); }
private void OnEditComponentCommandExecute(Subassembly component) { CurrentAddComponentViewModel = new EditComponentViewModel(_serviceFactory, component, false); CurrentAddComponentViewModel.CancelAddComponent += EditComponentViewModel_CancelEvent; CurrentAddComponentViewModel.ComponentUpdated += EditComponentViewModel_ComponentUpdated; }
public ComponentEventArgs(Subassembly component, bool isNew) { Component = component; IsNew = isNew; }