コード例 #1
0
ファイル: SunSystem.cs プロジェクト: Danil20-8/FlyOn
        public static SunSystem Random(LineBounds sunRadius, LineBounds <int> planetsCount)
        {
            var sunSystem = new SunSystem();

            sunSystem.sun = new SphereObject()
            {
                radius = UnityEngine.Random.Range(sunRadius.left, sunRadius.right), axisOffset = 0
            };

            sunSystem.planets = new SphereObject[UnityEngine.Random.Range(planetsCount.left, planetsCount.right)];

            float planetStep   = sunSystem.sun.radius * Constants.worldGravity / sunSystem.planets.Length;
            float currPosition = sunSystem.sun.radius * 1.0f;

            for (int i = 0; i < sunSystem.planets.Length; i++)
            {
                float radius = sunSystem.sun.radius * .05f + sunSystem.sun.radius * .3f * UnityEngine.Random.value;
                currPosition += planetStep * UnityEngine.Random.value + radius;

                sunSystem.planets[i]            = new SphereObject();
                sunSystem.planets[i].radius     = radius;
                sunSystem.planets[i].axisOffset = currPosition;

                currPosition += radius;
            }

            return(sunSystem);
        }
コード例 #2
0
ファイル: MainForm.cs プロジェクト: Sunburst275/RAPIS_FIMC
        /// <summary>Calculates the SelectionBounds of each line directly.</summary>
        /// <remarks>Should be directly called when the program loaded a text file.</remarks>
        private void PreCalcSelectionBounds()
        {
            var content = FileContentBox.Text;
            var tmp     = content.Split(Environment.NewLine.ToCharArray());

            string[] splittedContent = tmp.Take(tmp.Count() - 1).ToArray();
            lB = new List <LineBounds>();

            int start = 0;
            int end;
            int index = 0;

            for (int i = 0; i < splittedContent.Length; i++)
            {
                var s = splittedContent[i];

                end = start + s.Length;

                LineBounds tmpLineBounds = new LineBounds(index++, start, end, s);

                lB.Add(tmpLineBounds);

                start = end + 1;
            }
        }
コード例 #3
0
ファイル: MainForm.cs プロジェクト: Sunburst275/RAPIS_FIMC
        private void Initialization()
        {
            FileContentBox.SelectionChanged += FileContentBox_SelectionChanged;
            FromNumericUpDown.Maximum        = int.MaxValue;
            FromNumericUpDown.Minimum        = 0;
            ToNumericUpDown.Maximum          = int.MaxValue;
            ToNumericUpDown.Minimum          = 0;
            currentLine = new LineBounds();
            pd          = new ProcessingDialog();

            file = new FileInfo();

            // GUI Initialization
            FileTextBox.Text    = SelectFileMsg;
            FileContentBox.Text = NoFileSelectedMsg;
            SetCurrentlyOpenedLabel("None");
        }
コード例 #4
0
ファイル: MainForm.cs プロジェクト: Sunburst275/RAPIS_FIMC
        /// <summary>Checks if the selection is valid by checking each line of the loaded file.</summary>
        /// <param name="from">Column from which on content should be removed.</param>
        /// <param name="to">Column up to which content should be removed.</param>
        /// <returns>True when the selection is valid, otherwise false.</returns>
        private bool IsSelectionValid(int from, int to)
        {
            LineBounds preceedingLineBounds = new LineBounds();
            LineBounds trailingLineBounds   = new LineBounds();

            int current = 0;

            // Get the line in which the "from" is in
            for (; current < lB.Count; current++)
            {
                if (from >= lB[current].start && from <= lB[current].end)
                {
                    preceedingLineBounds = lB[current];
                    break;
                }
            }
            // Get the line in which the "to" is in
            if (to >= lB[current].start && to <= lB[current].end)
            {
                trailingLineBounds = lB[current];
            }
            else
            {
                while (current < lB.Count)
                {
                    if (to >= lB[current].start && to <= lB[current].end)
                    {
                        trailingLineBounds = lB[current];
                        break;
                    }
                    else
                    {
                        current++;
                    }
                }
            }

            var res = preceedingLineBounds.Equals(trailingLineBounds);

            if (res)
            {
                currentLine = preceedingLineBounds;
            }
            return(res);
        }
コード例 #5
0
 public ModelValue(string name, double min, double max)
 {
     Name   = name;
     Bounds = new LineBounds <double>(min, max);
 }