Esempio n. 1
0
 /// <summary>
 /// Create a triangle primitive.
 /// </summary>
 /// <param name="p1">Fist point, in pixels.</param>
 /// <param name="p2">Second point, in pixels.</param>
 /// <param name="p3">Third point, in pixels.</param>
 private void CreateTriangle(Vector2 p1, Vector2 p2, Vector2 p3)
 {
     VectorList.Add(p1);
     VectorList.Add(p2);
     VectorList.Add(p3);
     VectorList.Add(p1);
 }
Esempio n. 2
0
 /// <summary>
 /// Create a square primitive.
 /// </summary>
 /// <param name="topLeft">Top left hand corner of the square.</param>
 /// <param name="bottomRight">Bottom right hand corner of the square.</param>
 private void CreateSquare(Vector2 topLeft, Vector2 bottomRight)
 {
     VectorList.Add(topLeft);
     VectorList.Add(new Vector2(topLeft.X, bottomRight.Y));
     VectorList.Add(bottomRight);
     VectorList.Add(new Vector2(bottomRight.X, topLeft.Y));
     VectorList.Add(topLeft);
 }
Esempio n. 3
0
 public AssetStore()
 {
     _maxIndex = 1;
     _maxVector = 1;
     _assetList = new VectorList<Asset>();
     _typeList = new Dictionary<long, Type>();
     _typeIndexList= new Dictionary<Type,long>();
     _currentIDList = new Dictionary<long, long>();
     _vectorIDList = new List<VectorID>();
 }
Esempio n. 4
0
        public QuadTree(double x, double y, double w, double h)
            : base(x, y, w, h)
        {
            Objects = new VectorList<ICollidable>();
            Offset = new Vector2D();
            root = this;
            Enabled = false;

            sprite = new PrimitiveLine() { Colour = Color.Red };
            sprite.CreateRectangle(this);
        }
Esempio n. 5
0
        /// <summary>
        /// draw a pie shape
        /// </summary>
        /// <param name="Position">location to draw the pie</param>
        /// <param name="radius">the radius of the pie</param>
        /// <param name="startAngle">the angle to start the pie</param>
        /// <param name="sweepAngle">the sweep angle of the pie</param>
        /// <param name="color">color dat pie</param>
        public void Pie(Vector2 position, float radius, float startAngle, float sweepAngle, Color color)
        {
            Clear();
            Position = position;
            Color    = color;

            VectorList.Add(Vector2.Zero);
            CreateArc(radius, NumCircleSegments, startAngle, sweepAngle);
            VectorList.Add(Vector2.Zero);

            RenderLinePrimitive();
        }
Esempio n. 6
0
        /// <summary>
        /// Creates an ellipse starting from (0, 0) with the given width and height.
        /// Vectors are generated using the parametric equation of an ellipse.
        /// </summary>
        /// <param name="semiMajorAxis">The width of the ellipse at its center.</param>
        /// <param name="semiMinorAxis">The height of the ellipse at its center.</param>
        /// <param name="sides">The number of sides on the ellipse. (64 is average).</param>
        private void CreateEllipse(float semiMajorAxis, float semiMinorAxis, int sides)
        {
            // Local variables.
            float fMax  = (float)MathHelper.TwoPi;
            float fStep = fMax / (float)sides;

            // Create full ellipse.
            for (float fTheta = fMax; fTheta >= -1; fTheta -= fStep)
            {
                VectorList.Add(new Vector2((float)(semiMajorAxis * Math.Cos(fTheta)),
                                           (float)(semiMinorAxis * Math.Sin(fTheta))));
            }
        }
     private static Targeting SetUpTestTargetingData(int range, VectorList cellsHit = null, bool friendly = false, bool moveToCell = false, bool rotatable = false, VectorList validVectors = null, bool targetOrigin = false)
     {
         if (cellsHit == null)
         {
             cellsHit = new VectorList {
                 new Vector(0, 0)
             }
         }
         ;
         return(new Targeting {
             Range = range, CellsHit = cellsHit, Friendly = friendly, MoveToCell = moveToCell, Rotatable = rotatable, ValidVectors = validVectors, TargetOrigin = targetOrigin
         });
     }
 }
    public static int Main()
    {
        VectorList v1 = new VectorList ();

        VectorList v2 = TestVectorList (v1);

        if (v1.a != 1 || v1.b != 2)
            return 1;

        if (v2.a != 2 || v2.b != 3)
            return 2;

        return 0;
    }
Esempio n. 9
0
        /// <summary>
        /// Creates a circle starting from (0, 0).
        /// </summary>
        /// <param name="radius">The radius (half the width) of the circle.</param>
        /// <param name="sides">The number of sides on the circle. (64 is average).</param>
        private void CreateArc(float radius, int sides, float startAngle, float sweepAngle)
        {
            float step = sweepAngle / (float)sides;

            // Create the full circle.
            var numSteps = 0;
            var theta    = startAngle;

            while (numSteps < sides + 1)
            {
                VectorList.Add(new Vector2(radius * (float)Math.Cos(theta),
                                           radius * (float)Math.Sin(theta)));
                numSteps++;
                theta += step;
            }
        }
        /// <summary>
        /// Defines the _vectorListTarget member and adds its events into the editor.
        /// </summary>
        protected void InitializeVector()
        {
            VectorListTarget = target as VectorList;
            TargetTransform  = VectorListTarget.transform;


            OnAwake        -= VectorListTarget.OnAwakened;
            OnMoveVertex   -= VectorListTarget.MovedVertex;
            OnInsertVertex -= VectorListTarget.InsertedVertex;
            OnDeleteVertex -= VectorListTarget.DeletedVertex;

            OnAwake        += VectorListTarget.OnAwakened;
            OnMoveVertex   += VectorListTarget.MovedVertex;
            OnInsertVertex += VectorListTarget.InsertedVertex;
            OnDeleteVertex += VectorListTarget.DeletedVertex;

            VertexOrderList = new VertexOrderList(VectorListTarget.LocalVector3Coords.Count);

            RotationChecker = VectorListTarget.transform.rotation;
        }
Esempio n. 11
0
        public void Lambda_Where()
        {
            VectorList <TestType> vl = new VectorList <TestType>(3);

            vl[0] = new TestType {
                A = "abc", B = 1, C = 1.5
            };
            vl[1] = new TestType {
                A = "def", B = 2, C = 2.5
            };
            vl[2] = new TestType {
                A = "ghi", B = 3, C = 3.5
            };

            VectorList <TestType> vres = vl.Where(x => x.B == 2 || x.B == 3);

            Assert.AreEqual(2, vres.Length);

            Assert.AreEqual("def", vres[0].A);
            Assert.AreEqual("ghi", vres[1].A);
        }
Esempio n. 12
0
        public void Lambda_Any()
        {
            VectorList <TestType> vl = new VectorList <TestType>(3);

            vl[0] = new TestType {
                A = "abc", B = 1, C = 1.5
            };
            vl[1] = new TestType {
                A = "afb", B = 2, C = 2.5
            };
            vl[2] = new TestType {
                A = "ghbi", B = 3, C = 3.5
            };

            bool b1 = vl.Any(x => x.B == 3);

            Assert.AreEqual(true, b1);

            bool b2 = vl.Any(x => x.A.Contains("ab"));

            Assert.AreEqual(true, b2);
        }
Esempio n. 13
0
        public void SineWave(Vector2 start, Vector2 end, float frequency, float amplitude, Color color)
        {
            Clear();
            Color = color;

            //get the length of the sine wave
            var length = (end - start).Length();

            //lay out all the points
            float segmentLength = 5f;
            float xPos          = 0f;
            float mid           = length / 2f;

            while ((xPos + segmentLength) < length)
            {
                var ratio = 1f - (Math.Abs(mid - xPos) / mid);
                VectorList.Add(new Vector2(xPos, ratio * (float)(Math.Sin(frequency * xPos) * amplitude)));
                //VectorList.Add(new Vector2(xPos, 0));
                xPos += segmentLength;
            }

            //add the last line segment at the end
            VectorList.Add(new Vector2(length, 0f));

            //create the rotaion matrix
            Matrix mat = Matrix.CreateRotationZ((end - start).Angle());

            //multiply the rotaion by the translation matrices
            mat *= Matrix.CreateTranslation(start.X, start.Y, 0f);

            //multiply each point by the combined matrix
            for (int i = 0; i < VectorList.Count; i++)
            {
                VectorList[i] = MatrixExtensions.MatrixExt.Multiply(mat, VectorList[i]);
            }

            RenderLinePrimitive();
        }
Esempio n. 14
0
        public void Lambda_Select()
        {
            VectorList <TestType> vl = new VectorList <TestType>(3);

            vl[0] = new TestType {
                A = "abc", B = 1, C = 1.5
            };
            vl[1] = new TestType {
                A = "def", B = 2, C = 2.5
            };
            vl[2] = new TestType {
                A = "ghi", B = 3, C = 3.5
            };

            Assert.AreEqual(3, vl.Length);

            VectorList <TargetType> target = vl.Select(x => new TargetType {
                A1 = x.A, B1 = x.B, C = x.C
            });

            Assert.AreEqual(vl.Length, target.Length);
            Assert.IsInstanceOfType(target[0], typeof(TargetType));
        }
Esempio n. 15
0
 /// <summary>
 /// Create a line primitive.
 /// </summary>
 /// <param name="start">Start of the line, in pixels.</param>
 /// <param name="end">End of the line, in pixels.</param>
 private void CreateLine(Vector2 start, Vector2 end)
 {
     VectorList.Add(start);
     VectorList.Add(end);
 }
Esempio n. 16
0
 /// <summary>
 /// get ready to darw a new primitive
 /// </summary>
 private void Clear()
 {
     Color    = Color.White;
     Position = Vector2.Zero;
     VectorList.Clear();
 }
 private static extern VectorList TestVectorList(VectorList vl);
Esempio n. 18
0
 public void Add(VectorList<ICollidable> obj)
 {
     for (int i = 0; i < obj.Count; i++)
     {
         Add(obj[i]);
     }
 }
Esempio n. 19
0
        public Asset(VectorID vectorID)
        {
            AssetID = vectorID;

            _assets = new VectorList<Asset>();
        }