Ejemplo n.º 1
0
 /// <summary>
 /// remove from composite
 /// </summary>
 /// <param name="c">adding component</param>
 public override void Remove(Component c)
 {
     if (ChildComponents.Count < Capacity)
     {
         ChildComponents.Remove(c);
     }
 }
Ejemplo n.º 2
0
        protected override void InitializeInternal()
        {
            base.InitializeInternal();

            _lightRotationAngle = 0;

            _sceneBounds = new BoundingSphere(new Vector3(), MathF.Sqrt(40 * 40 + 60 * 60));

            _dirLights = new[] {
                new DirectionalLight {
                    Ambient   = new Color(0.2f, 0.2f, 0.2f),
                    Diffuse   = new Color(0.7f, 0.7f, 0.7f),
                    Specular  = new Color(0.8f, 0.8f, 0.8f),
                    Direction = new Vector3(-0.57735f, -0.57735f, 0.57735f)
                },
                new DirectionalLight {
                    Ambient   = new Color(0, 0, 0),
                    Diffuse   = new Color(0.4f, 0.4f, 0.4f),
                    Specular  = new Color(0.2f, 0.2f, 0.2f),
                    Direction = new Vector3(-0.707f, -0.707f, 0)
                },
                new DirectionalLight {
                    Ambient   = new Color(0, 0, 0),
                    Diffuse   = new Color(0.2f, 0.2f, 0.2f),
                    Specular  = new Color(0.2f, 0.2f, 0.2f),
                    Direction = new Vector3(0, 0, -1)
                }
            };

            _originalLightDirs = _dirLights.Select(l => l.Direction).ToArray();

            var device = D3DApp11.I.D3DDevice;

            _shadowMap = new ShadowMap(device, ShadowMapSize, ShadowMapSize);

            BuildShapeGeometryBuffers(device);
            BuildScreenQuadGeometryBuffers(device);

            var context = D3DApp11.I.ImmediateContext;

            _randomTex = TextureLoader.CreateRandomTexture1D(device);

            _flareTexSRV = TextureLoader.CreateTexture2DArray(device, context, new[] { NoireConfiguration.GetFullResourcePath("textures/flare0.png") });
            _fire        = new ParticleSource(RootContainer, this, device, EffectManager11.Instance.GetEffect <FireParticleEffect11>(), _flareTexSRV, _randomTex, 500);
            _fire.Initialize();
            _fire.Visible = _settings.ParticleFlameVisible;
            ChildComponents.Add(_fire);

            _rainTexSRV = TextureLoader.CreateTexture2DArray(device, context, new[] { NoireConfiguration.GetFullResourcePath("textures/raindrop.png") });
            _rain       = new ParticleSource(RootContainer, this, device, EffectManager11.Instance.GetEffect <RainParticleEffect11>(), _rainTexSRV, _randomTex, 10000);
            _rain.Initialize();
            _rain.Visible = _settings.ParticleRainVisible;
            ChildComponents.Add(_rain);

            var basicFx           = EffectManager11.Instance.GetEffect <BasicEffect11>();
            var normalMapFx       = EffectManager11.Instance.GetEffect <NormalMapEffect11>();
            var displacementMapFx = EffectManager11.Instance.GetEffect <DisplacementMapEffect11>();

            InitializeTechniqueTable(basicFx, normalMapFx, displacementMapFx);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// set baggage load for child component with min baggage weight from false baggage load as true
 /// </summary>
 public override void SetBaggedLoad()
 {
     ChildComponents.FirstOrDefault(
         component => component.BaggageWeight == ChildComponents.Where(w => w.IsBaggageLoad == false).Min(
             w => w.BaggageWeight))
     ?.SetBaggedLoad();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// set baggage load for child component with max baggage weight as false
 /// </summary>
 public override void ResetBaggedLoad()
 {
     ChildComponents.FirstOrDefault(
         component => component.BaggageWeight == ChildComponents.Where(w => w.IsBaggageLoad == true).Max(
             w => w.BaggageWeight))
     ?.ResetBaggedLoad();
 }
Ejemplo n.º 5
0
 private void RemoveChildComponent(YuoComponent component)
 {
     if (component == null)
     {
         return;
     }
     ChildComponents.RemoveItem(component.Type, component);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Adds the specified component.
 /// </summary>
 /// <param name="component">The component.</param>
 public override void Add(IComponent component)
 {
     ChildComponents.Add(component);
     if (ChildComponents.Count == 1)
     {
         ActivedTabPageIndex = 0;
     }
     StateHasChanged();
 }
Ejemplo n.º 7
0
        public virtual void Add(IAdd item)//添加组件
        {
            AbstractComponent component = item as AbstractComponent;

            if (component != null)
            {
                component.Owner = this;
                ChildComponents.Add(item);
            }
        }
Ejemplo n.º 8
0
 /// <summary>
 /// add in composite
 /// </summary>
 /// <param name="c">adding component</param>
 /// <exception cref="Exception">capacity overflow</exception>
 public override void Add(Component c)
 {
     if (ChildComponents.Count < Capacity)
     {
         ChildComponents.Add(c);
     }
     else
     {
         throw new Exception("Capacity overflow");
     }
 }
Ejemplo n.º 9
0
 void AddChildComponent(Type type, YuoComponent component)
 {
     if (component == null)
     {
         return;
     }
     ChildComponents.AddItem(type, component);
     if (!Children.Contains(component.Entity))
     {
         Children.Add(component.Entity);
     }
 }
Ejemplo n.º 10
0
 public override void Dispose()
 {
     if (Parent != null)
     {
         ////Используем локальную переменную, чтобы не затирать DataRow.WTPCOMPONENT_PARENTID
         //Parent.PropertyChanged -= Parent_PropertyChanged;
         Parent = null;
     }
     ChildComponents.Dispose();
     ChildRows.Clear();
     ChildRows.Dispose();
     base.Dispose();
 }
Ejemplo n.º 11
0
        protected override void InitializeInternal()
        {
            base.InitializeInternal();

            var clientSize = ControlWindow.ClientSize;

            _swapChainDescription = new SwapChainDescription()
            {
                BufferCount       = 1,
                ModeDescription   = new ModeDescription(clientSize.Width, clientSize.Height, new Rational(60, 1), Format.B8G8R8A8_UNorm),
                IsWindowed        = true,
                OutputHandle      = ControlWindow.Handle,
                SampleDescription = new SampleDescription(1, 0),
                SwapEffect        = SwapEffect.Discard,
                Usage             = Usage.RenderTargetOutput
            };
            SharpDX.Direct3D11.Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, _swapChainDescription, out _d3dDevice, out _swapChain);
            _immediateContext = _d3dDevice.ImmediateContext;
            _factory          = _swapChain.GetParent <Factory>();

            RenderStates11.Initialize(_d3dDevice);
            EffectManager11.Initialize();
            EffectManager11.Instance?.InitializeAllEffects(_d3dDevice);
            TextureLoader.Initialize();
            InputLayouts.InitializeAll(_d3dDevice);
            TextureManager11.Initialize(_d3dDevice);

            _renderTarget = new RenderTarget11(this, this);
            _renderTarget.Initialize();
            ChildComponents.Add(_renderTarget);
            _skybox            = new Skybox(this, this, 5000);
            _skybox.CubeMapSRV = TextureManager11.Instance.QuickCreateCubeMap("snowfield");
            _skybox.Initialize();
            ChildComponents.Add(_skybox);

            ResetSurface(this);
        }
Ejemplo n.º 12
0
 public TestLevel(Game game, GameStateManager manager, SpriteBatch spriteBatch, Rectangle screenRectangle)
     : base(game, manager, spriteBatch, screenRectangle)
 {
     FpsCounter = new FPSCounter(game, manager, spriteBatch, screenRectangle, Vector2.Zero, Color.White, Color.Red, Color.Gray);
     ChildComponents.Add(FpsCounter);
 }
Ejemplo n.º 13
0
        public CAD.AssemblyType ToCADXMLOutput(TestBenchModel.TestBenchBase tb)
        {
            CAD.AssemblyType cadassemblyoutput = new CAD.AssemblyType();
            cadassemblyoutput._id             = UtilityHelpers.MakeUdmID();
            cadassemblyoutput.ConfigurationID = ConfigID;

            CAD.CADComponentType cadassemblycomponentoutput = new CAD.CADComponentType();
            cadassemblycomponentoutput._id                = UtilityHelpers.MakeUdmID();
            cadassemblycomponentoutput.ComponentID        = ConfigID;
            cadassemblycomponentoutput.Type               = "ASSEMBLY";
            cadassemblycomponentoutput.Standalone         = false;
            cadassemblycomponentoutput.SpecialInstruction = "";
            cadassemblycomponentoutput.Name               = this.Name;
            cadassemblycomponentoutput.DisplayName        = DisplayName;
            cadassemblycomponentoutput.MaterialID         = "";
            cadassemblycomponentoutput.Representation     = "";
            cadassemblycomponentoutput.Classification     = "";


            Dictionary <string, List <CAD.ConstraintType> > compidToConstraint = new Dictionary <string, List <CAD.ConstraintType> >();       // Dictionary<Id, List<Constraints>>
            var sortedEdges = ChildEdges.OrderBy(x => x.DstPortName).ToList();

            foreach (CADEdge edge in sortedEdges)        //foreach (CADEdge edge in ChildEdges)
            {
                CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb);
                if (!compidToConstraint.ContainsKey(edge.Dst.Id))
                {
                    compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>());
                }
                compidToConstraint[edge.Dst.Id].Add(constraintout);
            }

            var sortedS2FEdges = ChildSize2FitEdges.OrderBy(x => x.DstPortName).ToList();

            foreach (CADEdge edge in sortedS2FEdges)        //foreach (CADEdge edge in ChildSize2FitEdges)
            {
                CAD.ConstraintType constraintout = edge.ToCADXMLOutput(tb);
                if (!compidToConstraint.ContainsKey(edge.Dst.Id))
                {
                    compidToConstraint.Add(edge.Dst.Id, new List <CAD.ConstraintType>());
                }
                compidToConstraint[edge.Dst.Id].Add(constraintout);
            }

            // META-2885
            //Dictionary<string, CAD.CADComponentType> tmpComponents = new Dictionary<string, CAD.CADComponentType>();
            List <CAD.CADComponentType> tmpComponents = new List <CAD.CADComponentType>();
            var sortedComponents = ChildComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList();

            foreach (CADComponent component in sortedComponents)      //foreach (CADComponent component in ChildComponents.Values)
            {
                CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component));

                // root constraint
                if (component.Id == RootComponentID)
                {
                    bool rootIsAsmType                    = component.ModelType == "Assembly"; //bool rootIsAsmType = component.ModelType == "PART";
                    List <CAD.PairType> pairlist          = new List <CAD.PairType>();
                    CAD.ConstraintType  rootconstraintout = new CAD.ConstraintType();
                    rootconstraintout._id = UtilityHelpers.MakeUdmID();

                    // front pair
                    pairlist.Add(MakeRootConstraint("FRONT",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "FRONT").FirstOrDefault()));

                    // top pair
                    pairlist.Add(MakeRootConstraint("TOP",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "TOP").FirstOrDefault()));

                    // right pair
                    pairlist.Add(MakeRootConstraint("RIGHT",
                                                    component.DisplayID,
                                                    ConfigID,
                                                    rootIsAsmType,
                                                    component.SpecialDatums.Where(d => d.DatumName == "RIGHT").FirstOrDefault()));

                    rootconstraintout.Pair = pairlist.ToArray();

                    componentout.Constraint    = new CAD.ConstraintType[1];
                    componentout.Constraint[0] = rootconstraintout;
                }
                else
                {
                    if (compidToConstraint.ContainsKey(component.Id))
                    {
                        componentout.Constraint = compidToConstraint[component.Id].ToArray();
                    }
                }

                //tmpComponents[component.Id] = componentout;
                tmpComponents.Add(componentout);

                // 3/7/2016 - Export_All_Component_Points at TB level
                pointCoordinatesList.AddRange(component.PointCoordinatesList);
            }

            var size2fitCompSorted = ChildSize2FitComponents.OrderBy(x => x.Value.Name).ToDictionary(x => x.Key, x => x.Value).Values.ToList();

            foreach (CADComponent component in size2fitCompSorted)//foreach (CADComponent component in ChildSize2FitComponents.Values)      // META-2885
            {
                CAD.CADComponentType componentout = component.ToCADXMLOutput(tb.GetRepresentation(component));
                if (compidToConstraint.ContainsKey(component.Id))
                {
                    componentout.Constraint = compidToConstraint[component.Id].ToArray();
                }

                //tmpComponents[component.Id] = componentout;
                tmpComponents.Add(componentout);

                // 3/7/2016 - Export_All_Component_Points at TB level
                pointCoordinatesList.AddRange(component.PointCoordinatesList);
            }

            // Fill MetaLinkData. Only needed in case if data is prepared for Meta-Link communication
            if (MetaLinkData != null && MetaLinkData.Components.Count > 0)
            {
                cadassemblyoutput.MetaLinkData = new CAD.MetaLinkDataType();
                cadassemblyoutput.MetaLinkData.CadComponentMLData = new CAD.CadComponentMLDataType[MetaLinkData.Components.Count];
                int i = 0;
                foreach (MetaLinkData.Component comp in MetaLinkData.Components)
                {
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i]       = new CAD.CadComponentMLDataType();
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ID    = comp.ID;
                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].AvmID = comp.AvmID;
                    if (comp.Connectors.Count > 0)
                    {
                        cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData = new CAD.ConnectorMLDataType[comp.Connectors.Count];
                        int j = 0;
                        foreach (MetaLinkData.Connector conn in comp.Connectors)
                        {
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j]             = new CAD.ConnectorMLDataType();
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].ID          = conn.ID;
                            cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DisplayName = conn.DisplayName;
                            if (conn.Datums.Count > 0)
                            {
                                cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData = new CAD.DatumMLDataType[conn.Datums.Count];
                                int k = 0;
                                foreach (MetaLinkData.Datum d in conn.Datums)
                                {
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k]             = new CAD.DatumMLDataType();
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].ID          = d.ID;
                                    cadassemblyoutput.MetaLinkData.CadComponentMLData[i].ConnectorMLData[j].DatumMLData[k].DisplayName = d.DisplayName;
                                    k++;
                                }
                            }
                            j++;
                        }
                    }
                    i++;
                }
            }

            cadassemblycomponentoutput.CADComponent = tmpComponents.ToArray();       //cadassemblycomponentoutput.CADComponent = tmpComponents.Values.ToArray();
            cadassemblyoutput.CADComponent          = cadassemblycomponentoutput;

            CAD.PropertiesType asmproperties = new CAD.PropertiesType();
            asmproperties._id = UtilityHelpers.MakeUdmID();
            CAD.UnitsType asmunit = new CAD.UnitsType();
            asmunit._id                  = UtilityHelpers.MakeUdmID();
            asmunit.Value                = "value1";
            asmproperties.Units          = asmunit;
            cadassemblyoutput.Properties = asmproperties;
            return(cadassemblyoutput);
        }
Ejemplo n.º 14
0
 public bool RegularComponent(string id)
 {
     return(ChildComponents.ContainsKey(id));
 }
Ejemplo n.º 15
0
 public virtual void Delete(int index)//删除组件
 {
     ChildComponents.Delete(index);
 }
Ejemplo n.º 16
0
 public WTPComponent[] GetChildComponents()
 {
     return(ChildComponents.ToArray());
 }
Ejemplo n.º 17
0
 public void Reset()
 {
     ChildComponents.Clear();
     isPaused      = false;
     drawEquipment = false;
 }
Ejemplo n.º 18
0
 public virtual void Delete(IDelete item)//删除组件
 {
     ChildComponents.Delete(item);
 }
Ejemplo n.º 19
0
        public override void Update(GameTime gameTime)
        {
            if (InputHandler.KeyReleased(Keys.Escape))
            {
                stateManager.PopState();
            }

            player.Update(gameTime);
            sprite.Update(gameTime);

            UpdateMouse();

            Vector2 motion = new Vector2();

            if (InputHandler.KeyDown(Keys.W))
            {
                sprite.CurrentAnimation = AnimationKey.Up;
                motion.Y = -1;
            }
            else if (InputHandler.KeyDown(Keys.S))
            {
                sprite.CurrentAnimation = AnimationKey.Down;
                motion.Y = 1;
            }
            if (InputHandler.KeyDown(Keys.A))
            {
                sprite.CurrentAnimation = AnimationKey.Left;
                motion.X = -1;
            }
            else if (InputHandler.KeyDown(Keys.D))
            {
                sprite.CurrentAnimation = AnimationKey.Right;
                motion.X = 1;
            }

            if (InputHandler.KeyDown(Keys.NumPad7))
            {
                sprite.CurrentAnimation = AnimationKey.UpLeft;
                motion.X = -1;
                motion.Y = -1;
            }
            if (InputHandler.KeyDown(Keys.NumPad9))
            {
                sprite.CurrentAnimation = AnimationKey.UpRight;
                motion.X = 1;
                motion.Y = -1;
            }
            if (InputHandler.KeyDown(Keys.NumPad1))
            {
                sprite.CurrentAnimation = AnimationKey.DownLeft;
                motion.X = -1;
                motion.Y = 1;
            }
            if (InputHandler.KeyDown(Keys.NumPad3))
            {
                sprite.CurrentAnimation = AnimationKey.DownRight;
                motion.X = 1;
                motion.Y = 1;
            }

            if (motion != Vector2.Zero)
            {
                sprite.IsAnimating = true;
                motion.Normalize();
                sprite.Position += motion * sprite.Speed;
                sprite.LockToMap();
                if (player.Camera.CameraMode == CameraMode.Follow)
                {
                    player.Camera.LockToSprite(sprite);
                }
            }
            else
            {
                sprite.IsAnimating = false;
            }
            if (InputHandler.KeyReleased(Keys.C))
            {
                player.Camera.ToggleCameraMode();
                if (player.Camera.CameraMode == CameraMode.Follow)
                {
                    player.Camera.LockToSprite(sprite);
                }
            }


            base.Update(gameTime);

            if (InputHandler.KeyReleased(Keys.I))
            {
                if (ChildComponents.Contains(gameRef.InventoryScreen))
                {
                    ChildComponents.Remove(gameRef.InventoryScreen);
                    //gameRef.IsMouseVisible = false;
                }
                else
                {
                    ChildComponents.Add(gameRef.InventoryScreen);
                    //gameRef.IsMouseVisible = true;
                }
            }
        }