Пример #1
0
        public void TestBoundsZero()
        {
            Bounds b = new Bounds();

            Assert.That(b.TopLeft(), Is.EqualTo(Vector3.zero));
            Assert.That(b.TopCenter(), Is.EqualTo(Vector3.zero));
            Assert.That(b.TopRight(), Is.EqualTo(Vector3.zero));
            Assert.That(b.MiddleLeft(), Is.EqualTo(Vector3.zero));
            Assert.That(b.MiddleCenter(), Is.EqualTo(Vector3.zero));
            Assert.That(b.MiddleRight(), Is.EqualTo(Vector3.zero));
            Assert.That(b.BottomLeft(), Is.EqualTo(Vector3.zero));
            Assert.That(b.BottomCenter(), Is.EqualTo(Vector3.zero));
            Assert.That(b.BottomRight(), Is.EqualTo(Vector3.zero));
            Assert.That(b.TopLeft(2), Is.EqualTo(new Vector3(-2, 2, 0)));
            Assert.That(b.TopCenter(2), Is.EqualTo(new Vector3(0, 2, 0)));
            Assert.That(b.TopRight(2), Is.EqualTo(new Vector3(2, 2, 0)));
            Assert.That(b.MiddleLeft(2), Is.EqualTo(new Vector3(-2, 0, 0)));
            Assert.That(b.MiddleCenter(2), Is.EqualTo(new Vector3(0, 0, 0)));
            Assert.That(b.MiddleRight(2), Is.EqualTo(new Vector3(2, 0, 0)));
            Assert.That(b.BottomLeft(2), Is.EqualTo(new Vector3(-2, -2, 0)));
            Assert.That(b.BottomCenter(2), Is.EqualTo(new Vector3(0, -2, 0)));
            Assert.That(b.BottomRight(2), Is.EqualTo(new Vector3(2, -2, 0)));
        }
Пример #2
0
        public override void Draw(CGRect rect)
        {
            var currentContext = UIGraphics.GetCurrentContext();
            var locations      = new nfloat[] { 0.0f, 1.0f };
            var colors         = new[] { GradientStartColor.CGColor, GradientEndColor.CGColor };
            var rgbColorspace  = CGColorSpace.CreateDeviceRGB();
            var glossGradient  = new CGGradient(rgbColorspace, colors, locations);

            currentContext.DrawLinearGradient(glossGradient, CGPoint.Empty, Bounds.BottomRight(), CGGradientDrawingOptions.DrawsAfterEndLocation);
            glossGradient.Dispose();
            rgbColorspace.Dispose();
            base.BackgroundColor = UIColor.Clear;
            base.Draw((CGRect)rect);
        }
Пример #3
0
        public static void AddRect(
            Bounds b,
            VertexHelper vh,
            Color vertexColor = default(Color),
            Vector2 uv        = default(Vector2))
        {
            uv = new Vector2(0.5f, 0.5f);
            int vertIdx = vh.currentVertCount;

            vh.AddVert(b.BottomLeft(), vertexColor, uv);
            vh.AddVert(b.TopLeft(), vertexColor, uv);
            vh.AddVert(b.BottomRight(), vertexColor, uv);
            vh.AddVert(b.TopRight(), vertexColor, uv);
            vh.AddTriangle(vertIdx, vertIdx + 1, vertIdx + 2);
            vh.AddTriangle(vertIdx + 2, vertIdx + 1, vertIdx + 3);
        }
Пример #4
0
        public FeaturePosition GetNewFeaturePosition()
        {
            /*  # = possible position to return
             *  F = actual room floor
             *             FFFFFF
             *            F000000F
             *            F000000F
             *            F000000F
             *            F000000F
             *             FFFFFF                 */

            Vector3IntMinMax rand = new Vector3IntMinMax();
            Vector3Int       pos  = Vector3Int.zero;
            Direction        d    = _directions[Random.Range(0, _directions.Count)];

            switch (d)
            {
            case Direction.Top:
                rand.Min    = Bounds.TopLeft();
                rand.Min.y += 1;

                rand.Max    = Bounds.TopRight();
                rand.Max.y += 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Left:
                rand.Min    = Bounds.BottomLeft();
                rand.Min.x -= 1;

                rand.Max    = Bounds.TopLeft();
                rand.Max.x -= 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Right:
                rand.Min    = Bounds.BottomRight();
                rand.Min.x += 1;

                rand.Max    = Bounds.TopRight();
                rand.Max.x += 1;

                pos = rand.GetRandomValue();
                break;

            case Direction.Bottom:
                rand.Min    = Bounds.BottomLeft();
                rand.Min.y -= 1;

                rand.Max    = Bounds.BottomRight();
                rand.Max.y -= 1;

                pos = rand.GetRandomValue();
                break;
            }

            _directions.Remove(d);
            return(new FeaturePosition(pos.x, pos.y, d));
        }