Example #1
0
 public Bullet(Vector position, Vector velocity, Int32 damage)
 {
     Position = position;
     Velocity = velocity;
     Damage = damage;
     Dim = new Size(5, 5);
 }
Example #2
0
 public void Build()
 {
     Alive = true;
     HP = 100;
     Dim = new Size(20, 20);
     Position = new Vector(300, 300);
     List<IRobot> Enemies = new List<IRobot>();
     calcRect();
 }
Example #3
0
 public void GoTo(Vector pos)
 {
     Vector delta = pos - Position;
     float p = 0.5f;
     float length = (int)delta.Length();
     float k = length / 50;
     if (length > 0.5)
     {
         if (k < p)
         {
             k = p;
         }
         Vector velocity = (pos - Position).GetNormalize() * k;
         Position = Position + velocity;
         calcRect();
     }
 }
Example #4
0
 public Vector(Vector a)
 {
     x = a.x;
     y = a.y;
 }
Example #5
0
 public Vector GetNormalize()
 {
     Vector vec = new Vector(this);
     vec.Normalize();
     return vec;
 }
Example #6
0
 public bool Equals(Vector a, float epsilon)
 {
     if (Math.Abs(x - a.x) > epsilon)
         return false;
     if (Math.Abs(y - a.y) > epsilon)
         return false;
     return true;
 }
Example #7
0
 /*  public unsafe float this[int index]
 {
     get
     {
         if (index < 0 || index > 1)
             throw new ArgumentOutOfRangeException("index");
         fixed (float* v = &this.x)
         {
             return v[index];
         }
     }
     set
     {
         if (index < 0 || index > 1)
             throw new ArgumentOutOfRangeException("index");
         fixed (float* v = &this.x)
         {
             v[index] = value;
         }
     }
 }*/
 public float Dot(Vector v)
 {
     return x * v.x + y * v.y;
 }
Example #8
0
 public Vector Cross(Vector v)
 {
     return new Vector((y * v.x) - (x * v.y), (x * v.y) - (y * v.x));
 }
Example #9
0
        public void Clamp(Vector min, Vector max)
        {
            if (x < min.x)
                x = min.x;
            else if (x > max.x)
                x = max.x;

            if (y < min.y)
                y = min.y;
            else if (y > max.y)
                y = max.y;
        }
Example #10
0
 public static Vector Normalize(Vector v)
 {
     return v.GetNormalize();
 }
Example #11
0
 public static float Dot(Vector a, Vector b)
 {
     return a.Dot(b);
 }
Example #12
0
 public static Vector Cross(Vector a, Vector b)
 {
     return a.Cross(b);
 }
Example #13
0
 public void FireTo(Vector pos)
 {
     RobotEventArgs e = new RobotEventArgs();
     e.Bullet = new Bullet(Position + (pos - Position).GetNormalize() * 20, (pos - Position).GetNormalize()*50, 5);
     FireEvent(this, e);
 }