Inheritance: MonoBehaviour
Beispiel #1
0
 // Use this for initialization
 void Start()
 {
     bar = GameObject.Find("health").GetComponent<HealthBar>();
     kid = GameObject.Find("player").GetComponent<Player>();
     beam = GameObject.Find("beam").GetComponent<Beam>();
     // score = GetComponent<Text>();
     // score.layer = 200;
 }
        public static void DateLastMark(Drawing croquis, out string revisionMark, out int revisionDateSeconds)
        {
            DrawingHandler drawingHandler = new DrawingHandler();
            Type drawingType = croquis.GetType();
            PropertyInfo propertyInfo = drawingType.GetProperty("Identifier", BindingFlags.Instance | BindingFlags.NonPublic);
            object value = propertyInfo.GetValue(croquis, null);

            Identifier identifier = (Identifier)value;
            Beam fakeBeam = new Beam { Identifier = identifier };

            revisionMark = "";
            fakeBeam.GetReportProperty("REVISION.LAST_MARK", ref revisionMark);

            revisionDateSeconds = 0;
            fakeBeam.GetReportProperty("REVISION.LAST_DATE_CREATE", ref revisionDateSeconds);
        }
        public virtual int[] BestSequence(ISequenceModel ts, int size)
        {
            int length = ts.Length();
            int leftWindow = ts.LeftWindow();
            int rightWindow = ts.RightWindow();
            int padLength = length + leftWindow + rightWindow;
            int[][] tags = new int[padLength][];
            int[] tagNum = new int[padLength];
            for (int pos = 0; pos < padLength; pos++)
            {
                tags[pos] = ts.GetPossibleValues(pos);
                tagNum[pos] = tags[pos].Length;
            }

            var newBeam = new Beam<TagSeq>(beamSize, ScoredComparator.ASCENDING_COMPARATOR);
            TagSeq initSeq = new TagSeq();
            newBeam.Add(initSeq);
            for (int pos = 0; pos < padLength; pos++)
            {
                var oldBeam = newBeam;
                if (pos < leftWindow + rightWindow && exhaustiveStart)
                {
                    newBeam = new Beam<TagSeq>(100000, ScoredComparator.ASCENDING_COMPARATOR);
                }
                else
                {
                    newBeam = new Beam<TagSeq>(beamSize, ScoredComparator.ASCENDING_COMPARATOR);
                }

                for (IEnumerator beamI = oldBeam.GetEnumerator(); beamI.MoveNext(); )
                {
                    Console.Out.Write(@"#");
                    Console.Out.Flush();
                    TagSeq tagSeq = (TagSeq)beamI.Current;
                    for (int nextTagNum = 0; nextTagNum < tagNum[pos]; nextTagNum++)
                    {
                        TagSeq nextSeq = tagSeq.Tclone();
                        if (pos >= leftWindow + rightWindow)
                        {
                            nextSeq.ExtendWith(tags[pos][nextTagNum], ts, size);
                        }
                        else
                        {
                            nextSeq.ExtendWith(tags[pos][nextTagNum]);
                        }

                        newBeam.Add(nextSeq);
                    }
                }

                Console.Out.WriteLine(@" done");
                if (recenter)
                {
                    double max = Double.NegativeInfinity;
                    for (IEnumerator beamI = newBeam.GetEnumerator(); beamI.MoveNext(); )
                    {
                        TagSeq tagSeq = (TagSeq)beamI.Current;
                        if (tagSeq.score > max)
                        {
                            max = tagSeq.score;
                        }
                    }

                    for (IEnumerator beamI = newBeam.GetEnumerator(); beamI.MoveNext(); )
                    {
                        TagSeq tagSeq = (TagSeq)beamI.Current;
                        tagSeq.score -= max;
                    }
                }
            }

            try
            {
                var enumerator = newBeam.GetEnumerator();
                if (enumerator.MoveNext())
                {
                    TagSeq bestSeq = enumerator.Current;
                    int[] seq = bestSeq.Tags();
                    return seq;
                }
                else
                    return null;
            }
            catch (Exception e)
            {
                Console.Error.WriteLine(@"Beam empty -- no best sequence.");
                return null;
            }
        }
        private static bool CreateFittings(Beam targetBeam, double customGap)
        {
            bool Result = false;

            Fitting fitBeam = new Fitting();
            fitBeam.Plane = new Plane();
            fitBeam.Plane.Origin = new Point(customGap, -160, -500);
            fitBeam.Plane.AxisX = new Vector(0.0, 500.0, 0.0);
            fitBeam.Plane.AxisY = new Vector(0.0, 0.0, 1200.0);
            fitBeam.Father = targetBeam;

            if (fitBeam.Insert())
                Result = true;

            return Result;
        }
Beispiel #5
0
        private void Restart()
        {
            engine.Clear();
            bullets.Clear();
            enemies.Clear();

            player = new Player();
            player.Position = new Vector2(400, 525);
            engine.AddBody(player.Body);
            player.Body.ApplyImpulse(new Vector2D(0, 10));

            beam = new Beam(this, 395, 480);
            engine.AddBody(beam.Body);
            FixedHingeJoint fixedHingeJoint = new FixedHingeJoint(beam.Body, new Vector2D(395, 480), new Lifespan());
            engine.AddJoint(fixedHingeJoint);

            waves = new bool[] { false, false, false, false, false, false };

            gameOver = false;
            youWin = false;
            enemyTimer = DateTime.Now;
        }
Beispiel #6
0
 void Start()
 {
     filter = gameObject.GetComponent<MeshFilter>();
     coll = gameObject.GetComponent<MeshCollider>();
     rend = GetComponent<Renderer>();
     starttime = Time.time;
     duration = 1.0f;
     endtime = starttime + duration;
     mybeam = new Beam();
     clamp = 0.0f;
     power = 1.0f;
     offset = new Vector3 (0.0f, 0.5f, 0.0f);
 }
Beispiel #7
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(plotfileDirectory);
                if (dir.Exists)
                {
                    string datetime = DateTime.Now.ToString().Replace(':', '-').Replace('/', '-');
                    System.IO.DirectoryInfo datefolder = new System.IO.DirectoryInfo(plotfileDirectory + @"\" + datetime + @"\");
                    datefolder.Create();
                    System.Diagnostics.Process.Start(datefolder.FullName);
                    DrawingEnumerator drawingEnum = drawingHandler.GetDrawingSelector().GetSelected();
                    while (drawingEnum.MoveNext())
                    {
                        Drawing drawing = (Drawing)drawingEnum.Current;

                        System.Reflection.PropertyInfo propertyInfo = drawing.GetType().GetProperty("Identifier", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
                        object value = propertyInfo.GetValue(drawing, null);

                        Identifier Identifier = (Identifier)value;
                        Beam       fakebeam   = new Beam();
                        fakebeam.Identifier = Identifier;
                        string RevisionMark = "";
                        bool   rev          = fakebeam.GetReportProperty("REVISION.LAST_MARK", ref RevisionMark);
                        string drawingMark  = "";
                        if (drawing is SinglePartDrawing || drawing is AssemblyDrawing)
                        {
                            drawingMark = drawing.Mark.Replace("[", "").Replace(".", "").Replace("]", "") + RevisionMark;
                        }
                        if (drawing is GADrawing)
                        {
                            if (RevisionMark.Length > 0)
                            {
                                RevisionMark = "-" + RevisionMark;
                            }
                            drawingMark = drawing.Title2 + RevisionMark;
                        }
                        System.IO.FileInfo file = new System.IO.FileInfo(dir.FullName + @"\" + drawingMark + ".pdf");
                        if (file.Exists)
                        {
                            if (drawing is SinglePartDrawing)
                            {
                                System.IO.DirectoryInfo singlePartDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\FIT\");
                                singlePartDrawingFolder.Create();
                                file.MoveTo(singlePartDrawingFolder.FullName + file.Name);
                            }
                            if (drawing is AssemblyDrawing)
                            {
                                System.IO.DirectoryInfo assemblyDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\ASS\");
                                assemblyDrawingFolder.Create();

                                for (int i = 0; i < papersizeNames.Count; i++)
                                {
                                    Tekla.Structures.Drawing.Size m = (Tekla.Structures.Drawing.Size)papersizeDimensions[i];
                                    if (drawing.Layout.SheetSize.Height == m.Height && drawing.Layout.SheetSize.Width == m.Width)
                                    {
                                        System.IO.DirectoryInfo assemblyDrawingSizeFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\ASS\" + papersizeNames[i].ToString() + @"\");
                                        assemblyDrawingSizeFolder.Create();
                                        file.MoveTo(assemblyDrawingSizeFolder.FullName + file.Name);
                                    }
                                }
                            }
                            if (drawing is GADrawing)
                            {
                                System.IO.DirectoryInfo gaDrawingFolder = new System.IO.DirectoryInfo(datefolder.FullName + @"\GAS\");
                                gaDrawingFolder.Create();
                                file.MoveTo(gaDrawingFolder.FullName + file.Name);
                            }
                        }
                    }
                }
            }
            catch { }
        }
Beispiel #8
0
        /// <summary>
        /// The Noisewall function.
        /// </summary>
        /// <param name="model">The input model.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A NoisewallOutputs instance containing computed results and the model with any new elements.</returns>
        public static NoisewallOutputs Execute(Dictionary <string, Model> inputModels, NoisewallInputs input)
        {
            // Setup inputs
            var    wallCentres       = input.NoisewallSetoutCentres;
            var    toleranceGap      = input.ToleranceGap;
            double wallHeight        = input.NoisewallPanelHeight;
            var    wallDepth         = input.NoisewallPanelDepth;
            var    wallWidth         = wallCentres - toleranceGap;
            var    setoutPolylineCrv = input.SetoutCurve;
            var    colour            = input.Colour;



            // Model smooth setout crv
            var verts            = setoutPolylineCrv.Vertices as List <Vector3>;
            var bezier           = new Bezier(verts);
            var bezierModelCurve = new ModelCurve(bezier, new Material("Green", Colors.Green));

            // Divide curve
            var grid = new Grid1d(bezier);

            grid.DivideByFixedLength(wallCentres, FixedDivisionMode.RemainderAtBothEnds);
            var cells    = grid.GetCells();
            var lines    = cells.Select(c => c.GetCellGeometry()).OfType <Line>();
            int numWalls = lines.Count();

            List <Wall> walls = new List <Wall>();
            List <Beam> beams = new List <Beam>();


            // Create Beam profile
            var profile = WideFlangeProfileServer.Instance.GetProfileByType(WideFlangeProfileType.W10x100);

            // Model beam at origin
            Line        line        = new Line(Vector3.Origin, new Vector3(0, 0, wallHeight));
            List <Beam> linearBeams = new List <Beam>();

            // Create range between 0 and 2pi with nDivisions
            List <double> normalisedRange = new List <double>();
            double        max             = 2 * Math.PI;
            double        min             = 0;
            int           nDivisions      = numWalls;
            double        diff            = (max - min) / nDivisions;
            double        d = min;

            foreach (int i in Enumerable.Range(0, nDivisions - 1))
            {
                d = d + diff;
                normalisedRange.Add(min + d);
            }


            // Setup random heights within range
            int        wallMinHeight     = 6;
            int        wallMaxHeight     = 9;
            Random     rand              = new Random();
            List <int> randomWallHeights = new List <int>();

            foreach (int i in Enumerable.Range(0, numWalls))
            {
                randomWallHeights.Add(rand.Next(wallMinHeight, wallMaxHeight));
            }



            // // Base sin wave function parameters
            // List<double> normalisedHeights = new List<double>();
            // foreach (double number in normalisedRange)
            // {
            //     normalisedHeights.Add(Math.Sin(number));
            // }

            // // Remap heights
            // List<double> remappedHeights = new List<double>();
            // foreach (double number in normalisedHeights)
            // {
            //     remappedHeights.Add(Remap(number, min, max, wallMinHeight, wallMaxHeight));
            // }


            int increment = 0;

            foreach (var setoutLine in lines)
            {
                // Set wall
                wallHeight = randomWallHeights.ElementAt(increment);
                //  Factor in tolerance Gap using vector math
                // panelHeight = remappedHeights.ElementAt(increment);
                wallHeight = input.NoisewallPanelHeight;


                var     noisewallLength         = wallCentres - toleranceGap * 2;
                Vector3 lineStartPoint          = setoutLine.Start;
                Vector3 lineEndPoint            = setoutLine.End;
                Vector3 lineDirectionUnitVector = (lineEndPoint - lineStartPoint).Unitized();
                var     noisewallCentreline     = new Line(lineStartPoint + lineDirectionUnitVector * toleranceGap, lineEndPoint - lineDirectionUnitVector * toleranceGap);

                // Create beam transforms
                Transform perpFrame         = setoutLine.TransformAt(0);
                Transform centreSetoutPlane = setoutLine.TransformAt(0.5);
                Transform orientBeams       = new Transform(setoutLine.Start, perpFrame.ZAxis, perpFrame.YAxis);

                // Model Beams
                var linearBeam = new Beam(line, profile, BuiltInMaterials.Steel, 0, 0, 0, orientBeams);
                beams.Add(linearBeam);

                // Model Walls
                Material     lightConcrete = new Material("Light Concrete", colour, 0.1, 0.0);
                StandardWall wall          = new StandardWall(noisewallCentreline, wallDepth, wallHeight, lightConcrete);
                walls.Add(wall);
                increment++;
            }

            // Create output object and add parameters
            var output = new NoisewallOutputs(walls.Count);

            // Add elements to output display
            output.Model.AddElement(bezierModelCurve);
            output.Model.AddElements(walls);
            output.Model.AddElements(beams);

            return(output);
        }