예제 #1
0
파일: Travel.cs 프로젝트: andy-uq/Echo
        public void IntraSolarSystem()
        {
            var universe = new Universe();
            var sol = new SolarSystem { Location = universe };

            var ship = new Ship(new Agent(new Corporation())) {Speed = 2d, Name = "S1" };
            sol.EnterSystem(ship, new Vector(10, 0, 0));

            ship.Destination = Vector.Zero;

            for (int i=10; i >= 0; i-=2)
            {
                Assert.AreEqual(i, ship.DistanceToDestination, "Ship is heading in the wrong direction!");
                ship.Tick((uint )i);
            }
        }
예제 #2
0
파일: HardPoints.cs 프로젝트: andy-uq/Echo
        public void TrackAnotherShip()
        {
            const double toDegrees = (0.5/Math.PI)*360d;

            var universe = new Universe();
            var ship = new Ship(new Corporation() { Location = universe }.Recruit()) { Name="GG", Speed = 0.5d, Location = universe };
            var track = new Ship(new Corporation() { Location = universe }.Recruit()) { Name="BG", Speed = 100d, UniversalCoordinates = new Vector(100, -1000, 0), Location = universe };

            var hardPoint = new HardPoint(ship, HardPointPosition.Right);

            ship.Destination = new Vector(0, 10, 0);
            track.Destination = new Vector(100, 1000, 0);

            ulong tick = 0;
            while (ship.HasDestination)
            {
                ship.Tick(tick);
                track.Tick(tick);

                Vector target = (track.UniversalCoordinates - ship.UniversalCoordinates);
                Console.WriteLine("Distance to target: {0:n2}, Hardpoint angle to target: {1:n2}* (delta: {2:n2}*)", target.Magnitude, Vector.Angle(hardPoint.Origin, target) * toDegrees, Vector.Angle(hardPoint.Orientation, target) * toDegrees);

                bool inRange = hardPoint.InRange(track);
                bool canTrack = hardPoint.CanTrack(track);

                bool isTracking = hardPoint.AimAt(track);
                Console.WriteLine("{0} {1} target {2}", ship.Name, isTracking ? "has" : "does not have", (inRange) ? (canTrack ? hardPoint.Inclination.ToString("n2")+"*" : "[Out of position]") : "[Out of range]");

                tick++;
            }
        }