Ejemplo n.º 1
0
        public virtual void Set(String a, Vector2 p, NPC n, Vector2 v, int d, bool iE, bool collide, float dT, ManagerHelper mH)
        {
            asset         = a;
            position      = p;
            velocity      = v;
            damage        = d;                  // set damage
            existenceTime = 4;                  // Default 10 seconds
            drawTime      = dT;                 //set up draw time
            affiliation   = n.GetAffiliation(); //Sets up hurting
            creator       = n;

            isExplosive   = iE;
            shouldCollide = collide;

            //Get x and y values from angle and set up direction
            rotation = DWMath.Atan2(velocity.Y, velocity.X);

            //No friction
            drag = 0;

            LoadContent(mH.GetTextureManager());
            if (!(this is Tossable))
            {
                setModeIndex();//set mode index
            }
        }
Ejemplo n.º 2
0
        public static float Direction(Vector2 pA, Vector2 pB)
        {
            //Slope
            float cX    = pB.X - pA.X,
                  cY    = pB.Y - pA.Y;
            float angle = DWMath.Atan2(cY, cX);

            if (angle < 0)
            {
                angle += MathHelper.TwoPi;
            }
            else if (angle >= MathHelper.TwoPi)
            {
                angle -= (MathHelper.TwoPi);
            }

            return(angle);
        }
Ejemplo n.º 3
0
        public bool IsVectorObstructed(Vector2 pA, Vector2 pB)
        {
            var   slope = new Vector2(pB.X - pA.X, pB.Y - pA.Y);
            float theta = DWMath.Atan2(slope.Y, slope.X);

            slope = new Vector2(DWMath.Cos(theta) * 32, DWMath.Sin(theta) * 32);

            pB  /= new Vector2(32);
            pB.X = (int)pB.X;
            pB.Y = (int)pB.Y;

            var t = new Vector2((int)(pA.X / 32), (int)(pA.Y / 32));

            if (t == pB)
            {
                return(false);
            }

            return(RecursiveVectorObstructed(pA, pB, slope));
        }
Ejemplo n.º 4
0
 public static float Direction(Vector2 r)
 {
     return(DWMath.Atan2(r.Y, r.X));
 }