Пример #1
0
 public Bullet(Vector position, Vector velocity, Int32 damage)
 {
     Position = position;
     Velocity = velocity;
     Damage = damage;
     Dim = new Size(5, 5);
 }
Пример #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();
 }
Пример #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();
     }
 }
Пример #4
0
 public Vector(Vector a)
 {
     x = a.x;
     y = a.y;
 }
Пример #5
0
 public Vector GetNormalize()
 {
     Vector vec = new Vector(this);
     vec.Normalize();
     return vec;
 }
Пример #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;
 }
Пример #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;
 }
Пример #8
0
 public Vector Cross(Vector v)
 {
     return new Vector((y * v.x) - (x * v.y), (x * v.y) - (y * v.x));
 }
Пример #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;
        }
Пример #10
0
 public static Vector Normalize(Vector v)
 {
     return v.GetNormalize();
 }
Пример #11
0
 public static float Dot(Vector a, Vector b)
 {
     return a.Dot(b);
 }
Пример #12
0
 public static Vector Cross(Vector a, Vector b)
 {
     return a.Cross(b);
 }
Пример #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);
 }