public async Task <Ignite.API.Common.UXO.UXO> GetItem(string id)
        {
            var item = await _context.UXOs.Include(uxo => uxo.Contact).FirstAsync(u => u.Id == id);

            if (item != null)
            {
                return(new Ignite.API.Common.UXO.UXO()
                {
                    ContactCallSign = item.Contact.CallSign,
                    ContactFrequency = item.Contact.Frequency,
                    ContactName = item.Contact.Name,
                    ContactPhone = item.Contact.Phone,
                    Id = item.Id,
                    Location = CoordinateExtensions.LonLatToMGRS(item.Longitude, item.Latitude),
                    MissionImpact = item.MissionImpact,
                    NBCContamination = item.NBCContamination,
                    Ordinance = item.OrdinanceType,
                    OrdinanceText = item.OrdinanceType == OrdinanceType.Other ? item.OtherOrdinance : item.OrdinanceType.ToString(),
                    Priority = item.Priority,
                    PriorityText = item.Priority.ToString(),
                    ProtectiveMeasures = item.ProtectiveMeasures,
                    Reported = item.ReportedDate,
                    ReportingUnit = item.ReportingUnit,
                    ResourcesThreatened = item.ResourcesThreatened
                });
            }
            return(null);
        }
        public void IsInRange_CoordinatesAreNotInRange_expectFalse()
        {
            Coordinate coordinate1 = new Coordinate(51.648602, 5.052049);
            Coordinate coordinate2 = new Coordinate(51.649188, 5.052295);

            Assert.False(CoordinateExtensions.IsInRange(coordinate1, coordinate2, 17));
        }
        private BaseDyadCoordinate <Complex, ComplexCalculator> setNonDiagonalElements(
            DispersionParameter dispersion,
            CartesianCoordinate displacement)
        {
            double rmod  = displacement.Norm;
            double rmod2 = rmod * rmod;
            double rmod3 = rmod2 * rmod;

            double kmod = dispersion.WaveVector.Norm;
            double kr   = kmod * rmod;

            BaseDyadCoordinate <Complex, ComplexCalculator> dyadProduct =
                CoordinateExtensions.DyadProduct(ref displacement, ref displacement);

            var initDyad =
                new DiagonalDyadCoordinate <Complex, ComplexCalculator>(rmod2);

            BaseDyadCoordinate <Complex, ComplexCalculator> firstMember = (kmod * kmod) * (dyadProduct - initDyad);


            BaseDyadCoordinate <Complex, ComplexCalculator> secondMember = (1 / rmod2) * (Complex.ImaginaryOne * kr - 1) *
                                                                           (3 * dyadProduct - initDyad);

            Complex multiplier = Complex.FromPolarCoordinates(1 / rmod3, kr);

            return(multiplier * (firstMember + secondMember));
        }
        public void IsInRange_CoordinatesAreInRange_expectTrue()
        {
            Coordinate coordinate1 = new Coordinate(51.648602, 5.052049);
            Coordinate coordinate2 = new Coordinate(51.648725, 5.052186);

            Assert.True(CoordinateExtensions.IsInRange(coordinate1, coordinate2, 17));
        }
        public void GetStepCoordinates_fourCoordinatesInDifferentAngles_expectCorrectCoordinate()
        {
            Coordinate coordinate1     = new Coordinate(51.652613, 5.047075);
            Coordinate coordinateTo1   = new Coordinate(51.652993, 5.047673);
            Coordinate destCoordinate1 = CoordinateExtensions.GetStepCoordinates(coordinate1, coordinateTo1, 10);

            Assert.Equal(51.65267743477073, destCoordinate1.Latitude);
            Assert.Equal(5.0471763995562595, destCoordinate1.Longitude);
        }
        public void GetMaxLatitudeFromBearing_GivenCoordinates_expectCorrectLongitude()
        {
            Coordinate coordinate = new Coordinate(51.647611, 5.050500);

            CoordinateBoundaries boundaries = new CoordinateBoundaries(coordinate, 2.0, DistanceUnit.Meters);

            Assert.Equal(51.647629010716372, CoordinateExtensions.GetMaxLatitudeFromBearing(boundaries, 2));
            Assert.Equal(51.647592989283623, CoordinateExtensions.GetMaxLatitudeFromBearing(boundaries, 91));
            Assert.Equal(51.647629010716372, CoordinateExtensions.GetMaxLatitudeFromBearing(boundaries, 271));
            Assert.Equal(51.647592989283623, CoordinateExtensions.GetMaxLatitudeFromBearing(boundaries, 269));
            Assert.Equal(51.647592989283623, CoordinateExtensions.GetMaxLatitudeFromBearing(boundaries, 180));
        }
        public void GetRelativeBearingToClosestDirection_GiveCoordinates_expectAngles()
        {
            double angle1 = 11.1;
            double angle2 = 89.0;
            double angle3 = 133.0;
            double angle4 = 192.0;
            double angle5 = 259.0;

            Assert.Equal(11.1, CoordinateExtensions.GetRelativeBearingToClosestDirection(angle1));
            Assert.Equal(89.0, CoordinateExtensions.GetRelativeBearingToClosestDirection(angle2));
            Assert.Equal(43.0, CoordinateExtensions.GetRelativeBearingToClosestDirection(angle3));
            Assert.Equal(12.0, CoordinateExtensions.GetRelativeBearingToClosestDirection(angle4));
            Assert.Equal(79.0, CoordinateExtensions.GetRelativeBearingToClosestDirection(angle5));
        }
        public void GetMaxLongitudeFromBearing_GivenCoordinates_expectCorrectLongitude()
        {
            Coordinate coordinate = new Coordinate(51.647611, 5.050500);

            CoordinateBoundaries boundaries = new CoordinateBoundaries(coordinate, 2.0, DistanceUnit.Meters);

            Assert.Equal(5.0505290263055267, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 2));
            Assert.Equal(5.0505290263055267, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 91));
            Assert.Equal(5.0505290263055267, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 179));
            Assert.Equal(5.0505290263055267, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 180));
            Assert.Equal(5.0504709736944742, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 181));
            Assert.Equal(5.0504709736944742, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 279));
            Assert.Equal(5.0504709736944742, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 360));
            Assert.Equal(5.0505290263055267, CoordinateExtensions.GetMaxLongitudeFromBearing(boundaries, 0));
        }
Exemple #9
0
        //To-Do: Add the rest of the stages to the AI. Make green saibaman code.
        //Make the speed of the ship's movements increase with less health, increase the speed of the projectiles, increase how fast the ship goes down on the dash, finish dash afterimage, make the homing projectiles move faster if the player is flying.
        //Boss loot: Drops Undecided material that's used to create a guardian class armor set (frieza cyborg set). Alternates drops between a weapon and accessory, accessory is arm cannon mk2, weapon is a frieza force beam rifle. Expert item is the mechanical amplifier.
        //Spawn condition: Near the ocean you can find a frieza henchmen, if he runs away then you'll get an indicator saying the ship will be coming the next morning.


        public override void AI()
        {
            Player player = Main.player[npc.target];

            npc.TargetClosest(true);

            //Runaway if no players are alive
            if (!player.active || player.dead)
            {
                npc.TargetClosest(false);
                player = Main.player[npc.target];
                if (!player.active || player.dead)
                {
                    npc.velocity = new Vector2(0f, -10f);
                    if (npc.timeLeft > 10)
                    {
                        npc.timeLeft = 10;
                    }
                    return;
                }
            }

            //Make sure the stages loop back around
            if (AIStage == 5)
            {
                AIStage = Stage_Hover;
            }

            //Speed between stages and general movement speed drastically increased with health lost
            if (npc.life < npc.lifeMax * 0.80f)
            {
                hoverCooldown = 400;
                speedAdd      = 1f;
                if (npc.life < npc.lifeMax * 0.50f)
                {
                    hoverCooldown = 250;
                    speedAdd      = 2f;
                }
                if (npc.life < npc.lifeMax * 0.2f)
                {
                    hoverCooldown = 100;
                    speedAdd      = 4f;
                }
            }
            //If the ship is really far away, nullify its movement and set it back to hover
            if (Vector2.Distance(new Vector2(0, player.position.Y), new Vector2(0, npc.position.Y)) > hoverDistance.Y * 3)
            {
                npc.velocity = new Vector2(0, -10f);
            }


            //General movement (stage 0)
            if (AIStage == Stage_Hover)
            {
                //Y Hovering
                if (Vector2.Distance(new Vector2(0, player.position.Y), new Vector2(0, npc.position.Y)) != hoverDistance.Y)
                {
                    if (Vector2.Distance(new Vector2(0, player.position.Y), new Vector2(0, npc.position.Y)) > hoverDistance.Y)
                    {
                        //float hoverSpeedY = (2f + Main.rand.NextFloat(3, 8));
                        //Add a little bit of delay before moving, this lets melee players possibly get a hit in
                        YHoverTimer++;
                        if (YHoverTimer > 15)
                        {
                            npc.velocity.Y = 2f;
                        }
                    }
                    else if (Vector2.Distance(new Vector2(0, player.position.Y), new Vector2(0, npc.position.Y)) < hoverDistance.Y)
                    {
                        //float hoverSpeedY = (-2f + Main.rand.NextFloat(-3, -8));
                        YHoverTimer++;
                        if (YHoverTimer > 15)
                        {
                            npc.velocity.Y = -2f;
                        }
                    }
                }
                else
                {
                    npc.velocity.Y = 0;
                    YHoverTimer    = 0;
                }
                //X Hovering, To-Do: Make the ship not just center itself on the player, have some left and right alternating movement?
                if (Vector2.Distance(new Vector2(0, player.position.X), new Vector2(0, npc.position.X)) != hoverDistance.X)
                {
                    //float hoverSpeedY = (-2f + Main.rand.NextFloat(-3, -8));
                    XHoverTimer++;
                    if (XHoverTimer > 30)
                    {
                        npc.velocity.X = (2.5f * npc.direction) + (speedAdd * npc.direction);
                        if (AITimer > hoverCooldown / 1.2)
                        {
                            npc.velocity.X = (7f * npc.direction) + (speedAdd * 2 * npc.direction);
                        }
                    }
                }
                else
                {
                    npc.velocity.X = 0;
                    XHoverTimer    = 0;
                }

                //Next Stage
                AITimer++;
                if (AITimer > hoverCooldown)
                {
                    StageAdvance();
                    AITimer = 0;
                }
            }


            //Main.NewText("Speed Addition is: " + speedAdd);



            //Slam attack (stage 1) - Quickly moves to directly above the player, then waits a second before slamming straight down.
            //To-Do: Make slam do increased contact damage. Fix bug where the ship flies down into the ground. Fix afterimage on slam not working.

            if (AIStage == Stage_Slam)
            {
                npc.velocity.X = 0;

                locationSelected = true;
                AITimer++;
                if (AITimer > 10)
                {
                    if (AITimer == 11)
                    {
                        npc.noTileCollide = false;
                        if (npc.life <= npc.lifeMax * 0.50)//Double the contact damage if below 50% health
                        {
                            npc.damage = npc.damage * 2;
                        }
                        npc.velocity.Y = 25f;
                    }
                    if (CoordinateExtensions.IsPositionInTile(npc.getRect().Bottom()) || AITimer > 20)//If the bottom of the ship touches a tile, nullify speed and do dust particles
                    {
                        npc.velocity.Y = -8f;
                        if (!hasDoneExplodeEffect)
                        {
                            ExplodeEffect();
                            SoundHelper.PlayCustomSound("Sounds/Kiplosion", npc.position, 1.0f);
                        }
                    }

                    if (npc.velocity.Y == -8f)
                    {
                        slamCoolDownTimer++;
                    }
                    if (slamCoolDownTimer > 20)
                    {
                        StageAdvance();
                        AITimer              = 0;
                        slamCoolDownTimer    = 0;
                        locationSelected     = false;
                        npc.noTileCollide    = true;
                        hasDoneExplodeEffect = false;
                        if (npc.life <= npc.lifeMax * 0.50)//Reset the damage back to its normal amount
                        {
                            npc.damage = npc.damage / 2;
                        }
                    }
                }
            }
            //float ydistance = Vector2.Distance(new Vector2(0, player.position.Y), new Vector2(0, npc.position.Y));
            //Main.NewText("Y Distance is: " + ydistance);
            //Vertical projectile barrage (stage 2) - Fires a barrage of projectiles upwards that randomly spread out and fall downwards which explode on ground contact

            if (AIStage == Stage_Barrage)
            {
                AITimer++;
                npc.velocity.Y = 0;
                npc.velocity.X = 0;

                if (AITimer == 10)
                {
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);


                    if (npc.life < npc.lifeMax * 0.50f) //Fire 16 extra projectiles if below 50% health
                    {
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -6f, mod.ProjectileType("FFBarrageBlast"), npc.damage / 4, 3f, Main.myPlayer);
                    }
                }

                if (AITimer > 60)
                {
                    if (npc.life < npc.lifeMax * 0.70f)
                    {
                        StageAdvance();
                    }
                    else
                    {
                        AIStage = Stage_Hover;
                    }
                    AITimer = 0;
                }
            }

            //Vertical projectile barrage + homing (stage 3) - Fires 2 projectiles in opposite arcs diagonally from the ship, after 3 seconds they stop, after 1 second both will fly towards the player.
            // These projectiles are stronger than the barrage ones, but also slower.

            if (AIStage == Stage_Homing)
            {
                npc.velocity.Y = 0;
                npc.velocity.X = 0;

                if (AITimer == 0)
                {
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 2.5f, -1f, mod.ProjectileType("FFHomingBlast"), npc.damage / 3, 3f, Main.myPlayer);
                    Projectile.NewProjectile(npc.Center.X, npc.Center.Y, -2.5f, -1f, mod.ProjectileType("FFHomingBlast"), npc.damage / 3, 3f, Main.myPlayer);

                    if (npc.life < npc.lifeMax * 0.50f) //Fire an extra stronger projectile upwards if below 50% health
                    {
                        Projectile.NewProjectile(npc.Center.X, npc.Center.Y, 0, -1f, mod.ProjectileType("FFHomingBlast"), npc.damage / 2, 3f, Main.myPlayer);
                    }
                }
                AITimer++;
                if (AITimer > 60)
                {
                    if (npc.life < npc.lifeMax * 0.40f)
                    {
                        StageAdvance();
                    }
                    else
                    {
                        AIStage = Stage_Hover;
                    }
                    AITimer = 0;
                }
            }

            //To-Do: Summon saibamen (stage 4) - Summons a green saiba from the ship, green dust when this happens to make it look smoother (Perhaps make this something after 40% HP)
            if (Main.netMode != 1 && AIStage == Stage_Saiba)
            {
                if (AITimer == 0)
                {
                    int saiba = NPC.NewNPC((int)npc.position.X, (int)npc.position.Y, mod.NPCType("SaibaGreen"));
                    Main.npc[saiba].netUpdate = true;
                    npc.netUpdate             = true;
                }
                AITimer++;
                if (AITimer > 60)
                {
                    StageAdvance();
                    AITimer = 0;
                }
            }

            //Main.NewText(AIStage);
        }