示例#1
0
        public Angle(Vector2 a, Vector2 b)
        {
            // get rad angle
            // the value is -3 to 3
            rad  = Calculus.angleFrom(a, b);
            deg  = Calculus.RadianToDegree(rad);
            aPos = a;
            bPos = b;

            if (rad < 0)
            {
                rad += Math.PI * 2;
            }

            deg = Calculus.RadianToDegree(rad);
        }
示例#2
0
        /// <summary>
        /// Obtiene un path y crea puntos entre cada tile del path
        /// </summary>
        public void getPath()
        {
            Path p = new Path(this.tiles);

            pathPositions = p.createPath();

            pathPointLines.Clear();

            // Por cada dos tiles crea una linea entre medio
            for (int i = 0; i < pathPositions.GetLength(0) - 1; i++)
            {
                Vector2 a = new Vector2();
                a.X = pathPositions[i, 0] * 100 + 50;
                a.Y = pathPositions[i, 1] * 100 + 50;

                Vector2 b = new Vector2();
                b.X = pathPositions[i + 1, 0] * 100 + 50;
                b.Y = pathPositions[i + 1, 1] * 100 + 50;


                Vector2 pos = a, vel = Vector2.Zero;
                vel = Calculus.velFromPoints(a, b, 4);

                while (true)
                {
                    // Si la distancia entre el punto acutal al objetivo es menor a 1
                    // entonces se termina el ciclo
                    if (Calculus.distanceFromPoints(pos, b) < 1)
                    {
                        break;
                    }

                    pathPointLines.Add(pos);
                    pos += vel;
                }
            }
            if (_callback != null && pathPointLines.Count > 0)
            {
                _callback("end", true);
            }
        }
示例#3
0
 public void SetDegrees(float degrees)
 {
     Update(Calculus.DegreeToRadian(degrees));
     this.deg = degrees;
 }
示例#4
0
 public void Update(double val)
 {
     this.rad = val;
     this.deg = Calculus.RadianToDegree(val);
 }