示例#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);
 }