Ejemplo n.º 1
0
 public Pipe(Vector2 position, PipeSection type, bool rotatable)
 {
     this.rotatable = rotatable;
     this.position  = position;
     this.type      = type;
     pipeSprite     = Sprite.Create(type.image, new Rect(0, 0, type.image.width, type.image.height), new Vector2(0.5f, 0.5f));
 }
Ejemplo n.º 2
0
			public LanguagePipelineStart Build()
			{
				var source = new PipeSection<string, List<LanguageConstruct>>(new RecognizeLines());
				var understandFile = source.AddTransformSequence(new AssembleBlocks());
				if (_handleResults != null) { understandFile.AddListener(_handleResults); }
				return new LanguagePipelineStart(source);
			}
Ejemplo n.º 3
0
    private void PreprocessSections()
    {
        var SectionPrefabs = Resources.LoadAll <PipeSection>(PipeSectionsFolder);

        sectionDictionary = new Dictionary <PipeSection.JointType, List <PipeSection> >();
        sectionInstances  = new List <PipeSection>();
        for (int p = 0; p < SectionPrefabs.Length; p++)
        {
            PipeSection section = Instantiate(SectionPrefabs[p]);
            for (int t = 0; t < section.Tilemaps.Length; t++)
            {
                section.Tilemaps[t].CompressBounds();
                section.Tilemaps[t].ResizeBounds();
            }
            sectionInstances.Add(section);
            if (!sectionDictionary.ContainsKey(section.StartJoint))
            {
                sectionDictionary[section.StartJoint] = new List <PipeSection>();
            }
            sectionDictionary[section.StartJoint].Add(section);

            if (smallToMediumSection == null && section.StartJoint == PipeSection.JointType.Small && section.EndJoint == PipeSection.JointType.Medium)
            {
                smallToMediumSection = section;
            }
        }
    }
Ejemplo n.º 4
0
    private void GenerateTiles()
    {
        Vector3Int cursor = new Vector3Int(0, 0, 0);

        for (int s = 0; s < pipeSections.Count; s++)
        {
            PipeSection pipeSection = pipeSections[s];
            for (int t = 0; t < pipeSection.Tilemaps.Length; t++)
            {
                TileBase[] tiles = pipeSection.Tilemaps[t].GetTilesBlock(pipeSection.SectionSize);

                Vector3Int sectionOffset = new Vector3Int(0, -Mathf.FloorToInt(pipeSection.SectionSize.size.y * 0.5f), 0);
                BoundsInt  writePos      = new BoundsInt(cursor + sectionOffset, pipeSection.SectionSize.size);
                tilemaps[t].SetTilesBlock(writePos, tiles);

                foreach (Transform child in pipeSection.Tilemaps[t].transform)
                {
                    Transform thing = Instantiate(child);
                    thing.parent   = tilemaps[t].transform;
                    thing.position = thing.localPosition + cursor + Vector3Int.right * 6;  // i don't know why
                }
            }

            cursor += Vector3Int.right * pipeSection.SectionSize.size.x + Vector3Int.up * pipeSection.VerticalOffset;
        }
    }
Ejemplo n.º 5
0
        // 架空
        public bool GetPipeNodeParameterOver(int flag, out Vector[] vtxs, out Vector dir, out IPipeSection section, out int FLAG)
        {
            FLAG    = -1;
            vtxs    = null;
            dir     = null;
            section = null;
            IPolyline polyline = null;

            if ((base._geoGroup[1] == null) || ((polyline = base._geoGroup[1] as IPolyline) == null))
            {
                return(false);
            }
            if (polyline.PointCount < 2)
            {
                return(false);
            }
            ISegment seg     = null;
            Vector   vector  = null;
            Vector   vector2 = null;

            vtxs    = new Vector[2];
            section = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, this._vPos, 0.02, 0);
            if (flag == 0)
            {
                vector  = new Vector(polyline.GetPoint(0));
                vtxs[0] = vector;
                seg     = polyline.GetSegment(0);
                if (Math.Abs(seg.EndPoint.Z - seg.StartPoint.Z) > 0.4)
                {
                    FLAG = 1;
                }
                dir     = new Vector(seg);
                dir     = dir.UnitVector();
                vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0));
                vtxs[1] = vector2;
            }
            else
            {
                vector  = new Vector(polyline.GetPoint(polyline.PointCount - 1));
                vtxs[0] = vector;
                seg     = polyline.GetSegment(polyline.PointCount - 2);
                if (Math.Abs(seg.EndPoint.Z - seg.StartPoint.Z) > 0.4)
                {
                    FLAG = 1;
                }
                dir     = new Vector(seg);
                dir     = (-dir).UnitVector();
                vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0));
                vtxs[1] = vector2;
            }
            return(true);
        }
Ejemplo n.º 6
0
    private void GenerateSections(int seed)
    {
        var rng = new System.Random(seed);

        attempts = 0;
        int level_number = Game.Instance != null ? Game.Instance.player.LevelNumber : 0;

        int max_difficulty = difficulty * level_number;

        pipeSections = new List <PipeSection>();
        pipeSections.Add(StartSection);


        PipeSection prevSection = StartSection, nextSection;

        for (int s = 0; s < SectionCount; s++)
        {
            List <PipeSection> possibleSections = prevSection == null ? new List <PipeSection>(sectionInstances) : sectionDictionary[prevSection.EndJoint];
            nextSection = possibleSections[rng.Next(possibleSections.Count)];

            difficulty_cnt += nextSection.difficulty;



            if (difficulty_cnt > max_difficulty || difficulty_cnt < -4 && attempts < 10)
            {
                // reset the counters and go back to the same iteration of the loop
                print("too hard!");
                difficulty_cnt -= nextSection.difficulty;
                s        -= 1;
                attempts += 1;
                continue;
            }
            pipeSections.Add(nextSection);
            prevSection = nextSection;
        }
        if (prevSection.EndJoint == PipeSection.JointType.Small)
        {
            pipeSections.Add(smallToMediumSection);
        }
        pipeSections.Add(EndSection);
    }
Ejemplo n.º 7
0
    void Start()
    {
        GameObject.Find("background").AddComponent <StartWater>();

        if (pipeTextures.Length > 3)
        {
            PipeSection[] pipeTypes = new PipeSection[] {
                new PipeSection(pipeTextures[0], waterTextures[0], new int[4] {
                    1, 0, 1, 0
                }),
                new PipeSection(pipeTextures[1], waterTextures[1], new int[4] {
                    0, 0, 1, 1
                }),
                new PipeSection(pipeTextures[3], waterTextures[3], new int[4] {
                    1, 0, 1, 1
                }),
                new PipeSection(pipeTextures[2], waterTextures[2], new int[4] {
                    1, 1, 1, 1
                })
            };

            lvl = new Level(pipeTypes);

            startX = 0 - ((lvl.grid.GetLength(0) * pipeTextures[0].width) / 2);
            startY = 0 - ((lvl.grid.GetLength(1) * pipeTextures[0].height) / 2);

            for (int x = 0; x < lvl.grid.GetLength(0); x++)
            {
                for (int y = 0; y < lvl.grid.GetLength(1); y++)
                {
                    GameObject g = new GameObject(x + "," + y);
                    g.AddComponent <SpriteRenderer>();
                    g.AddComponent <BoxCollider2D>();
                    g.AddComponent <PipeClick>();
                    g.GetComponent <SpriteRenderer>().sprite = lvl.grid[x, y].pipeSprite;
                    g.transform.position = new Vector3((startX + (x * pipeTextures[0].width)) / 100, (startY + (y * pipeTextures[0].height)) / 100);
                    g.transform.rotation = Quaternion.Euler(new Vector3(0, 0, lvl.grid[x, y].rotation));
                }
            }
        }
    }
Ejemplo n.º 8
0
        void Initialize()
        {
            var profile = (PipeProfile)((Pipe)SimObject).Profile;

            profile.Status = PipeEditorStatus.OK;

            var flowsheet = SimObject.GetFlowsheet();

            var su = flowsheet.FlowsheetOptions.SelectedUnitSystem;
            var nf = flowsheet.FlowsheetOptions.NumberFormat;

            var sectioncontainer = new StackLayout {
                Orientation = Orientation.Horizontal, Padding = new Eto.Drawing.Padding(10), Spacing = 10
            };

            s.CreateAndAddButtonRow(container, "Add Segment", null, (arg1, arg2) =>
            {
                var ps = new PipeSection()
                {
                    Indice = profile.Sections.Count + 1, Incrementos = 10, Comprimento = 1, Quantidade = 1
                };
                profile.Sections.Add(ps.Indice, ps);
                var pscontainer = new DynamicLayout();
                var slcontainer = new StackLayoutItem(pscontainer);
                //pscontainer.BackgroundColor = Eto.Drawing.Colors.White;
                var editor       = new PipeSectionEditor(flowsheet, (Pipe)SimObject, profile.Sections[ps.Indice], pscontainer);
                var btnRemove    = s.CreateAndAddButtonRow(pscontainer, "Remove Segment", null, null);
                btnRemove.Click += (sender, e) =>
                {
                    if (MessageBox.Show("Remove segment?", MessageBoxButtons.YesNo, MessageBoxType.Question, MessageBoxDefaultButton.No) == DialogResult.Yes)
                    {
                        profile.Sections.Remove(ps.Indice);
                        sectioncontainer.Items.Remove(slcontainer);
                    }
                    ;
                };
                sectioncontainer.Items.Add(slcontainer);
            });

            s.CreateAndAddButtonRow(container, "Remove All Segments", null, (arg1, arg2) =>
            {
                if (MessageBox.Show("Remove all segments?", MessageBoxButtons.YesNo, MessageBoxType.Question, MessageBoxDefaultButton.No) == DialogResult.Yes)
                {
                    profile.Sections.Clear();
                    sectioncontainer.RemoveAll();
                    sectioncontainer.Items.Clear();
                }
                ;
            });

            container.Add(new Scrollable {
                Border = BorderType.None, Content = sectioncontainer
            });

            foreach (var section in profile.Sections.Values)
            {
                var pscontainer = new DynamicLayout();
                var slcontainer = new StackLayoutItem(pscontainer);
                //pscontainer.BackgroundColor = Eto.Drawing.Colors.White;
                var editor    = new PipeSectionEditor(flowsheet, (Pipe)SimObject, section, pscontainer);
                var btnRemove = s.CreateAndAddButtonRow(pscontainer, "Remove Segment", null, null);
                btnRemove.Click += (sender, e) =>
                {
                    if (MessageBox.Show("Remove segment?", MessageBoxButtons.YesNo, MessageBoxType.Question, MessageBoxDefaultButton.No) == DialogResult.Yes)
                    {
                        profile.Sections.Remove(section.Indice);
                        sectioncontainer.Items.Remove(slcontainer);
                    }
                    ;
                };
                sectioncontainer.Items.Add(slcontainer);
            }
        }
Ejemplo n.º 9
0
 public Pipe(Vector2 position, PipeSection type) : this(position, type, true)
 {
 }
Ejemplo n.º 10
0
        public bool ShowFlowDirection(int flowDir, out IRenderModelPoint rpt)
        {
            rpt = null;
            if (base._rowInfo == null)
            {
                return(false);
            }

            string str = Application.StartupPath + @"\..\Resource\Images\FlowDirection";

            if (!Directory.Exists(str))
            {
                return(false);
            }
            IImage _imgFlowImg = DrawGeometry.resFactory.CreateImageFromFile(str);

            _imgFlowImg.FrameInterval = 50;

            IPolyline        path        = null;
            IPipeSection     pipeSection = null;
            string           name        = "FlowDirection";
            IDrawDynamicFlow flow        = null;
            IModelPoint      mp          = null;

            try
            {
                IModel    model;
                IModel    model2;
                IPoint    pointValue = null;
                IPolyline polyline2  = null;
                polyline2 = base._geoGroup[1] as IPolyline;
                if ((polyline2 == null) || (polyline2.PointCount < 2))
                {
                    return(false);
                }
                path = polyline2.Clone() as IPolyline;
                for (int i = 0; i < path.PointCount; i++)
                {
                    pointValue = path.GetPoint(i);
                    if (pointValue != null)
                    {
                        pointValue.Z += this.OffsetZ;
                        path.UpdatePoint(i, pointValue);
                    }
                }

                pipeSection = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0);

                flow = ParamModelFactory.Instance.CreateGeometryDraw(ModelType.DynamicFlow, Guid.NewGuid().ToString()) as IDrawDynamicFlow;
                flow.SetParameter(pipeSection, path, flowDir);
                flow.SetTextureRender(new string[] { name });
                if (!flow.Draw(out mp, out model, out model2))
                {
                    return(false);
                }

                #region 需要runtime授权
                IFeatureDataSet  iFeatureDataSet = DF3DPipeCreateApp.App.TempLib.OpenFeatureDataset("FeatureDataSet");
                IResourceManager manager         = iFeatureDataSet as IResourceManager;
                if (!manager.ModelExist(mp.ModelName))
                {
                    manager.AddModel(mp.ModelName, model, null);
                }
                if (!manager.ImageExist(name))
                {
                    manager.AddImage(name, _imgFlowImg);
                }
                #endregion

                IModelPointSymbol symbol = new ModelPointSymbolClass();
                symbol.SetResourceDataSet(iFeatureDataSet);
                symbol.Color       = uint.MaxValue;
                symbol.EnableColor = true;
                mp.ModelEnvelope   = model.Envelope;
                rpt = DrawGeometry.Ocx.ObjectManager.CreateRenderModelPoint(mp, symbol, DrawGeometry.Ocx.ProjectTree.RootID);

                return(true);
            }
            catch (Exception exception)
            {
                return(false);
            }
        }
Ejemplo n.º 11
0
        public bool GetPipeLineParameter(double thick, out List <Vector> vtxs, out IPipeSection section)
        {
            vtxs    = null;
            section = null;
            IPolyline polyline = null;

            if ((base._geoGroup[1] == null) || ((polyline = base._geoGroup[1] as IPolyline) == null))
            {
                return(false);
            }
            if (polyline.PointCount < 2)
            {
                return(false);
            }
            IPoint p       = null;
            Vector vector  = null;
            Vector vector2 = null;
            Vector item    = null;

            vtxs    = new List <Vector>();
            section = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, thick, 0);
            for (int i = 0; i < polyline.PointCount; i++)
            {
                p = polyline.GetPoint(i);
                if (p != null)
                {
                    vector = new Vector(p);
                    if ((this._dia1 > 1.5) || (this._dia2 > 1.5))
                    {
                        item = vector;
                    }
                    else if (i == 0)
                    {
                        // 增加起点退让判断,并对较短管线做处理 FX 2014.04.08
                        vector2 = new Vector(polyline.GetSegment(i));
                        double length = vector2.Length;
                        vector2 = vector2.UnitVector();
                        if (this._isSBackhind)
                        {
                            if (length > (section.Diameter / 1.8))
                            {
                                item = vector + ((Vector)((vector2 * section.Diameter) / 1.8));
                            }
                            else
                            {
                                item = vector + ((Vector)((vector2 * length) / 1.8));
                            }
                        }
                        else
                        {
                            item = vector;
                        }
                    }
                    else if (i == (polyline.PointCount - 1))
                    {
                        // 增加终点退让判断,并对较短管线做处理 FX 2014.04.08
                        vector2 = new Vector(polyline.GetSegment(i - 1));
                        double length = vector2.Length;
                        vector2 = -vector2.UnitVector();
                        if (this._isEBackhind)
                        {
                            if (length > (section.Diameter / 1.8))
                            {
                                item = vector + ((Vector)((vector2 * section.Diameter) / 1.8));
                            }
                            else
                            {
                                item = vector + ((Vector)((vector2 * length) / 1.8));
                            }
                        }
                        else
                        {
                            item = vector;
                        }
                    }
                    else
                    {
                        item = vector;
                    }
                    item.Z += this.OffsetZ;
                    vtxs.Add(item);
                }
            }
            return(true);
        }
Ejemplo n.º 12
0
        // 地下—针对管线较短情况
        public bool GetPipeNodeParameterUnder(int flag, out Vector[] vtxs, out Vector dir, out IPipeSection section)
        {
            vtxs    = null;
            dir     = null;
            section = null;
            IPolyline polyline = null;

            if ((base._geoGroup[1] == null) || ((polyline = base._geoGroup[1] as IPolyline) == null))
            {
                return(false);
            }
            if (polyline.PointCount < 2)
            {
                return(false);
            }
            ISegment seg     = null;
            Vector   vector  = null;
            Vector   vector2 = null;

            vtxs    = new Vector[2];
            section = new PipeSection(this._dia1, this._dia2, HorizontalPos.Center, VerticalPos.Center, 0.02, 0);
            if (flag == 0)
            {
                vector  = new Vector(polyline.GetPoint(0));
                vtxs[0] = new Vector(vector.X, vector.Y, vector.Z + this.OffsetZ);
                seg     = polyline.GetSegment(0);
                dir     = new Vector(seg);
                dir     = dir.UnitVector();
                double length = dir.Length;
                // 针对管线较短情况
                if (length > (section.Diameter / 2))
                {
                    vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0));
                }
                else
                {
                    vector2 = vector + ((Vector)((dir * length) / 2.0));
                }
                vtxs[1] = new Vector(vector2.X, vector2.Y, vector2.Z + this.OffsetZ);
            }
            else
            {
                vector  = new Vector(polyline.GetPoint(polyline.PointCount - 1));
                vtxs[0] = new Vector(vector.X, vector.Y, vector.Z + this.OffsetZ);
                seg     = polyline.GetSegment(polyline.PointCount - 2);
                dir     = new Vector(seg);
                double length = dir.Length;
                dir = -dir.UnitVector();
                // 针对管线较短情况
                if (length > (section.Diameter / 2))
                {
                    vector2 = vector + ((Vector)((dir * section.Diameter) / 2.0));
                }
                else
                {
                    vector2 = vector + ((Vector)((dir * length) / 2.0));
                }
                vtxs[1] = new Vector(vector2.X, vector2.Y, vector2.Z + this.OffsetZ);
            }
            return(true);
        }