當前位置: 首頁>>代碼示例>>C#>>正文


C# Random.NextVector2D方法代碼示例

本文整理匯總了C#中System.Random.NextVector2D方法的典型用法代碼示例。如果您正苦於以下問題:C# Random.NextVector2D方法的具體用法?C# Random.NextVector2D怎麽用?C# Random.NextVector2D使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Random的用法示例。


在下文中一共展示了Random.NextVector2D方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Start

        private void Start()
        {
            // Initialize our rng
            _random = new Random(Environment.TickCount + SeedAddition);

            if (SpawnInitial)
            {
                // Spawn in a bunch of instances initially
                var retryCount = 0;
                while (_instances.Count < Count)
                {
                    var pos = _random.NextVector2D(TargetCamera.position.Xyn(0), Distance);

                    // Make sure the instance can be spawned here
                    if (!IsValidSpawnPosition(pos))
                    {
                        retryCount++;
                        if (retryCount > 10)
                        {
                            Debug.LogWarning("Had to early-bail on spawning.");
                            break;
                        }
                        continue;
                    }

                    // Actually spawn the instance
                    var obj = Instantiate(Prefab);
                    obj.transform.position = pos;
                    obj.transform.parent = gameObject.transform;
                    _instances.Add(obj);
                }
            }
        }
開發者ID:LaylConway,項目名稱:Timepilot,代碼行數:33,代碼來源:Spawner.cs

示例2: Transform1D

        public void Transform1D()
        {
            // Transform forward and inverse and compare with initial values.
              var random = new Random(1234567);

              var s = new Vector2D[16];
              var t = new Vector2D[16];
              for (int i = 0; i < s.Length; i++)
              {
            s[i] = random.NextVector2D(-10, 10);
            t[i] = s[i];
              }

              FastFourierTransformD.Transform1D(t, true);
              FastFourierTransformD.Transform1D(t, false);

              for (int i = 0; i < s.Length; i++)
            Assert.IsTrue(Vector2D.AreNumericallyEqual(s[i], t[i]));
        }
開發者ID:Zolniu,項目名稱:DigitalRune,代碼行數:19,代碼來源:FastFourierTransformDTest.cs

示例3: Transform1DAs2DColumn

        public void Transform1DAs2DColumn()
        {
            // Result of 2D with one row/column must be the same as 1D.
              var fft = new FastFourierTransformD(16);

              var random = new Random(1234567);

              var s1D = new Vector2D[16];
              var s2D = new Vector2D[16, 1];

              for (int i = 0; i < s1D.Length; i++)
              {
            s1D[i] = random.NextVector2D(-10, 10);
            s2D[i, 0] = s1D[i];
              }

              FastFourierTransformD.Transform1D(s1D, true);
              fft.Transform2D(s2D, true);

              for (int i = 0; i < s1D.Length; i++)
            Assert.AreEqual(s1D[i], s2D[i, 0]);
        }
開發者ID:Zolniu,項目名稱:DigitalRune,代碼行數:22,代碼來源:FastFourierTransformDTest.cs

示例4: Transform2D

        public void Transform2D()
        {
            // Transform forward and inverse and compare with initial values.
              var random = new Random(1234567);

              var s = new Vector2D[16, 8];
              var t = new Vector2D[16, 8];
              for (int i = 0; i < s.GetLength(0); i++)
              {
            for (int j = 0; j < s.GetLength(1); j++)
            {
              s[i, j] = random.NextVector2D(-10, 10);
              t[i, j] = s[i, j];
            }
              }

              var fft = new FastFourierTransformD(16);
              fft.Transform2D(t, true);

              Assert.IsFalse(Vector2D.AreNumericallyEqual(s[0, 0], t[0, 0]));

              fft.Transform2D(t, false);

              for (int i = 0; i < s.GetLength(0); i++)
            for (int j = 0; j < s.GetLength(1); j++)
              Assert.IsTrue(Vector2D.AreNumericallyEqual(s[i, j], t[i, j]));
        }
開發者ID:Zolniu,項目名稱:DigitalRune,代碼行數:27,代碼來源:FastFourierTransformDTest.cs


注:本文中的System.Random.NextVector2D方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。