Ejemplo n.º 1
0
 public Coords(GalacticLocation location)
 {
     this._galacticLocation = location;
     this._sectorLocation   = _galacticLocation.ToSectorLocation();
     this._screenLocation   = new ScreenLocation(_sectorLocation);
     this._sectorIndexX     = (uint)(_galacticLocation.X / GalaxyConstants.SectorWidth);
     this._sectorIndexY     = (uint)(_galacticLocation.Y / GalaxyConstants.SectorWidth);
 }
Ejemplo n.º 2
0
 public Coords(uint sectorIndexX, uint sectorIndexY, SectorLocation sectorLocation)
 {
     this._sectorIndexX     = sectorIndexX;
     this._sectorIndexY     = sectorIndexY;
     this._sectorLocation   = new SectorLocation(sectorLocation.X, sectorLocation.Y, sectorLocation.Z);
     this._galacticLocation = new GalacticLocation(sectorIndexX, sectorIndexY, sectorLocation);
     this._screenLocation   = new ScreenLocation(sectorLocation);
 }
Ejemplo n.º 3
0
 public Coords(uint sectorIndexX, uint sectorIndexY, int sX, int sY, int sZ)
 {
     this._sectorIndexX     = sectorIndexX;
     this._sectorIndexY     = sectorIndexY;
     this._sectorLocation   = new SectorLocation(sX, sY, sZ);
     this._galacticLocation = new GalacticLocation(_sectorIndexX, _sectorIndexY, _sectorLocation);
     this._screenLocation   = new ScreenLocation(_sectorLocation);
 }
Ejemplo n.º 4
0
 public Coords(uint sectorIndexX, uint sectorIndexY)
 {
     this._sectorIndexX     = sectorIndexX;
     this._sectorIndexY     = sectorIndexY;
     this._sectorLocation   = new SectorLocation(0, 0, 0);
     this._galacticLocation = new GalacticLocation(sectorIndexX, sectorIndexY, _sectorLocation);
     this._screenLocation   = new ScreenLocation(_sectorLocation);
 }
Ejemplo n.º 5
0
        public static CoordsCalculationResult CalculateNext(Coords actual, Coords dest, float speed, out Coords calculated)
        {
            if (dest == null)
            {
                calculated = actual;
                return(CoordsCalculationResult.None);
            }

            double distanceToDest = actual.Galactic.CalculateDistance(dest.Galactic);

            if (distanceToDest == 0)
            {
                calculated = dest;
                return(CoordsCalculationResult.End);
            }

            double galDiffX = actual.Galactic.X - dest.Galactic.X;
            double galDiffY = actual.Galactic.Y - dest.Galactic.Y;
            double galDiffZ = actual.Galactic.Z - dest.Galactic.Z;

            double speedDiffX = (speed * galDiffX / distanceToDest);
            double speedDiffY = (speed * galDiffY / distanceToDest);
            double speedDiffZ = (speed * galDiffZ / distanceToDest);

            int overflow = 0;

            if (Math.Abs(speedDiffX) >= Math.Abs(galDiffX))
            {
                speedDiffX = galDiffX; overflow++;
            }
            if (Math.Abs(speedDiffY) >= Math.Abs(galDiffY))
            {
                speedDiffY = galDiffY; overflow++;
            }
            if (Math.Abs(speedDiffZ) >= Math.Abs(galDiffZ))
            {
                speedDiffZ = galDiffZ; overflow++;
            }

            if (overflow == 3 || (speedDiffX == 0 && speedDiffY == 0 && speedDiffZ == 0))
            {
                calculated = dest;
                return(CoordsCalculationResult.End);
            }

            GalacticLocation newGalacticLocation = new GalacticLocation(
                actual.Galactic.X - speedDiffX,
                actual.Galactic.Y - speedDiffY,
                actual.Galactic.Z - speedDiffZ
                );

            Coords coords = new Coords(newGalacticLocation);

            calculated = coords;
            return(CoordsCalculationResult.Continues);
        }
Ejemplo n.º 6
0
        public double CalculateDistance(GalacticLocation location)
        {
            double result = 0;

            double XDiference = Math.Abs((float)(location.X - this.X));
            double YDiference = Math.Abs((float)(location.Y - this.Y));
            double ZDiference = Math.Abs((float)(location.Z - this.Z));

            result = Math.Sqrt(Math.Pow(XDiference, 2) + Math.Pow(YDiference, 2) + Math.Pow(ZDiference, 2));

            return(result);
        }
Ejemplo n.º 7
0
        public Coords(SerializationInfo info, StreamingContext context)
        {
            this._sectorIndexX = info.GetUInt32("sectorIndexX");
            this._sectorIndexY = info.GetUInt32("sectorIndexY");
            int sX, sY, sZ;

            sX = info.GetInt32("sX");
            sY = info.GetInt32("sY");
            sZ = info.GetInt32("sZ");

            this._sectorLocation   = new SectorLocation(sX, sY, sZ);
            this._galacticLocation = new GalacticLocation(_sectorIndexX, _sectorIndexY, _sectorLocation);
            this._screenLocation   = new ScreenLocation(_sectorLocation);
        }