示例#1
0
        public bool DoTurn(PirateShip ship)
        {
            // Check if halt is needed
            Asteroid[] AsteroidsInRange = Bot.Engine.AllLivingAsteroids.Where(x => Bot.Engine.GetHits(x) == 0 && Filter(x) && x.Distance(ship) - x.Size < (ship.MaxSpeed + x.EffectiveSpeed()) * DangerRange).ToArray();
            if (ship.PushReloadTurns > 0 || AsteroidsInRange.IsEmpty())
            {
                return(false);
            }
            Asteroid NearestAsteroid = AsteroidsInRange.Nearest(ship);

            if (ship.CanPush(NearestAsteroid))
            {
                return(ship.Push(NearestAsteroid, PushLocator(NearestAsteroid, ship)));
            }
            else if (!NearestAsteroid.IsHalted())
            {
                int EffectiveDistance = NearestAsteroid.Distance(ship) - NearestAsteroid.Size;
                if (EffectiveDistance < HaltingRange * (ship.MaxSpeed + NearestAsteroid.EffectiveSpeed()))
                {
                    if (EffectiveDistance < HaltingRange * NearestAsteroid.EffectiveSpeed())
                    {
                        return(ship.Sail(NearestAsteroid.Add(NearestAsteroid.Direction.Normalized().Multiply(NearestAsteroid.EffectiveSpeed() + ship.PushRange))));
                    }
                    else
                    {
                        return(true);
                    }
                }
                else
                {
                    return(false);
                }
            }
            return(false);
        }
示例#2
0
 public override void Deserialize(GenericReader reader)
 {
     base.Deserialize(reader);
     m_PirateShip = reader.ReadItem() as PirateShip;
     bootgespawnt = reader.ReadBool();
     int version = reader.ReadInt();
 }
示例#3
0
 public bool DoTurn(PirateShip ship)
 {
     Delegates.ScoringFunction <SpaceObject> scorer = x =>
                                                      x.UniqueId == ship.UniqueId ? selfBombingScorer((PirateShip)((Pirate)x)) : bombingScorer(x);
     if (ship.StickyBombs.Length > 0)
     {
         /*
          * int remaining = ship.StickyBombs.Select(x => x.Countdown + 1).Min();
          * ship.Sail(MaximalScore(ship, ship.MaxSpeed * remaining).arg0);
          */
         Location direction = Bot.Engine.MyLivingPirates.Where(x => x.StickyBombs.Length <= 0).Select(x => x.Location.Subtract(ship.Location).Multiply(-1)).Concat(
             Bot.Engine.EnemyLivingPirates.Where(x => x.StickyBombs.Length <= 0).Select(x => x.Location.Subtract(ship.Location))).Middle();
         ship.Sail(ship.Location.Add(direction));
         return(true);
     }
     else
     {
         SpaceObject[] bombable = Bot.Engine.PushableSpaceObjects.Concat(new SpaceObject[] { ship })
                                  .Where(x => ship.CanStickBomb(x)).ToArray();
         SpaceObject max = bombable.FirstBy(x => - scorer(x));
         if (scorer(max) > 0 && Bot.Engine.CanStickBomb)
         {
             ship.StickBomb(max);
             return(true);
         }
         return(false);
     }
 }
示例#4
0
 public bool DoTurn(PirateShip ship)
 {
     if (ship.Distance(camp) > sensitivity)
     {
         return(ship.Sail(camp));
     }
     return(false);
 }
示例#5
0
    void pirateShipFireCannon(bool[] done)
    {
        if (ps == null)
        {
            ps = customEvents.findByIdentifier("ps").GetComponent <PirateShip>();
        }

        ps.fireCannonball(done);
    }
示例#6
0
 // sets up parameters so that spawner can start spawning
 // called from pirate ship
 public void setUpSpawner(Point p, PirateShip ship)
 {
     spawnPoint       = p;
     pirateShip       = ship;
     spawnFrequency   = 190;
     spawnTimer       = spawnFrequency;
     piratesRemaining = (int)Random.Range(4, 8);
     setUp            = true;
 }
示例#7
0
 /// <summary>
 /// Plays a single turn of the logic on a specified pirate
 /// </summary>
 /// <param name="pirate">Pirate to play turn with</param>
 /// <returns>Boolean indicating wether the pirate has played</returns>
 public bool DoTurn(PirateShip pirate)
 {
     foreach (PiratePlugin plugin in Plugins)
     {
         if (plugin.DoTurn(pirate))
         {
             return(true);
         }
     }
     return(false);
 }
示例#8
0
    // spawns ship in random location from list of valid spawn points
    private void shipSpawn()
    {
        int   randomNumber = (int)System.Math.Floor((float)UnityEngine.Random.Range(0, spawnPoints.Count));
        Point spawnPoint   = spawnPoints [randomNumber];

        randomNumber = (int)System.Math.Floor((float)UnityEngine.Random.Range(0, destinations.Count));
        Point destination = destinations[randomNumber];

        PirateShip ship = Instantiate(pirateShipPrefab).GetComponent <PirateShip> ();

        ship.setupShip(spawnPoint, destination);
    }
示例#9
0
 public override void HandleInput(InputHelper inputHelper)
 {
     base.HandleInput(inputHelper);
     if (makePirate)
     {
         GameObjectList level      = this.parent.Parent as GameObjectList;
         PirateShip     pirate     = new PirateShip(position + new Vector2(70, 50), 1010, "pirate");
         GameObjectList pirateList = level.Find("pirateList") as GameObjectList;
         pirateList.Add(pirate);
         makePirate = false;
     }
 }
示例#10
0
    //obviously TODO need to organize boss behaviors; ideally it's only a one-liner in the script
    IEnumerator psRoutinePt1()
    {
        if (ps == null)
        {
            ps = customEvents.findByIdentifier("ps").GetComponent <PirateShip>();
        }

        bool[] bossReady = new bool[1];
        customEvents.loadAndPlayBGM(new bool[1], Global.makeParamString("1", "sea_boss(temp)", "1", "1"));
        StartCoroutine(customEvents.setGOActive(bossReady, Global.makeParamString("ps", "1", "0")));

        yield return(new WaitUntil(() => bossReady[0]));

        gameFlow.incrementPointer();
    }
 public bool DoTurn(PirateShip ship)
 {
     foreach (PirateShip p in ship.GetPiratesInPushRange().Where(x => Filter(x)))
     {
         Mothership closestMothership = Bot.Engine.EnemyMotherships.FirstBy(x => x.Distance(p));
         bool       CanKill           = ((Location)(((Point)p).InDirection(closestMothership, ship.MaxSpeed))).DistanceFromBorder() <= ship.PushDistance;
         if (ship.CanPush(p) && CanKill)
         {
             if (ship.Push(p, p.ClosestBorder()))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
 public bool DoTurn(PirateShip ship)
 {
     if (Bot.Engine.Enemy.BotName == "25772")
     {
         if (Bot.Engine.MyCapsules[0].IsAlive() && Bot.Engine.MyCapsules[0].IsHeld() && ship.InPushRange(Bot.Engine.MyLivingCapsules[0]) && ship.IsHeavy)
         {
             ship.Push(Bot.Engine.MyLivingCapsules[0].Holder, Bot.Engine.MyMotherships[0]);
         }
         else if (ship.IsNormal)
         {
             ship.Sail(Bot.Engine.MyMotherships[0]);
         }
         return(true);
     }
     else if (Bot.Engine.Enemy.BotName == "25766")
     {
         PirateShip p       = ship;
         Capsule    capsule = Bot.Engine.MyCapsules[0];
         if (p.Id == 0)
         {
             PirateShip other = Bot.Engine.GetMyPirateById(1);
             Location   dest  = Bot.Engine.Self.Score >= 3 ? new Location(3797, 4358) : new Location(2534, 3936);
             if (!p.Sail(dest) && p.InPushRange(other))
             {
                 p.Push(other, capsule);
             }
         }
         else
         {
             PirateShip other  = Bot.Engine.GetMyPirateById(0);
             bool       IsHeld = capsule.IsAlive() && capsule.IsHeld();
             if (p.IsNormal)
             {
                 if (IsHeld)
                 {
                     ((Pirate)p).SwapStates(other);
                 }
                 else
                 {
                     p.Sail(capsule);
                 }
             }
             else
             {
                 if (IsHeld)
                 {
                     p.Sail(Bot.Engine.MyMotherships[0]);
                 }
                 else
                 {
                     ((Pirate)p).SwapStates(other);
                 }
             }
         }
         return(true);
     }
     else if (Bot.Engine.Enemy.BotName == "26069")
     {
         int id = ship.Id;
         if (id == 0 || id == 2)
         {
             bool     Sailed = ship.Sail(id == 0 ? new Location(3646, 2200) : new Location(3646, 4000));
             Location target = id == 0 ? new Location(4700, 1200) : new Location(4700, 5200);
             if (!Sailed && Bot.Engine.GetEnemyPiratesInRange(target, 500).Count >= 2)
             {
                 Asteroid a = Bot.Engine.AllAsteroids[id / 2];
                 ship.Push(a, target.Add(new Location(225, 0)));
             }
         }
         else
         {
             Squad s = Bot.Engine.GetEnemyPiratesInRange(ship, Bot.Engine.Game.StickBombRange);
             if (s.Count > 0)
             {
                 ((Pirate)ship).StickBomb(s.First());
             }
         }
         return(true);
     }
     return(false);
 }
示例#13
0
 public static Location TangentPush(Asteroid ast, PirateShip ship)
 {
     return(ast.GetLocation().Add(ship.GetLocation().Subtract(ast.GetLocation()).Multiply(-1)));
 }
示例#14
0
        public bool DoTurn(Squad squad)
        {
            if (squad.HasCapsule)
            {
                PirateShip CapsuleHolder     = squad.First(x => x.HasCapsule);
                Mothership ClosestMothership = Bot.Engine.MyMotherships.Nearest(CapsuleHolder);
                Squad      Boosters          = squad.Filter(x => x.UniqueId != CapsuleHolder.UniqueId && x.PushReloadTurns <= 0 && (true || x.Distance(ClosestMothership) - CapsuleHolder.Distance(ClosestMothership) < x.PushRange))
                                               .OrderBy(x => x.Distance(CapsuleHolder)).Take(System.Math.Max(MaxPushes, CapsuleHolder.NumberOfPushesForCapsuleLoss - 1)).ToList();
                int  BoostingDistance = Bot.Engine.GetDistanceAgainst(Boosters, CapsuleHolder);
                bool ShouldPush;
                {
                    Squad        EnemyPirates = Bot.Engine.EnemyLivingPirates.Filter(x => x.Distance(CapsuleHolder) <= x.PushRange + x.MaxSpeed);
                    PirateShip[] Campers;
                    Bot.Engine.CheckForCamper(CampDuration, out Campers);
                    bool ExistsDeeperCamp = Campers.Any(x =>
                    {
                        bool IsFurther              = !EnemyPirates.ContainsPirate(x);
                        bool IsCloserToMothership   = EnemyPirates.All(y => x.Distance(ClosestMothership) < y.Distance(ClosestMothership));
                        Squad LocalBunk             = Bot.Engine.EnemyLivingPirates.Filter(y => y.Distance(CapsuleHolder) <= y.PushRange + y.MaxSpeed && Bot.Engine.GetCampLength(y) >= CampDuration);
                        bool MeetsBunkerRequirement = IsBunker(LocalBunk, LocalBunk.Middle, CapsuleHolder.NumberOfPushesForCapsuleLoss);

                        return(IsFurther && IsCloserToMothership && MeetsBunkerRequirement);
                    });

                    bool IsSafeAfterBoost;
                    {
                        Location NewLocation = (Location)(((Point)CapsuleHolder).InDirection(ClosestMothership, BoostingDistance + CapsuleHolder.MaxSpeed));
                        Squad    LocalBunk   = Bot.Engine.EnemyLivingPirates.Filter(y => y.Distance(CapsuleHolder) <= y.PushRange + y.MaxSpeed && Bot.Engine.GetCampLength(y) >= CampDuration);
                        IsSafeAfterBoost = !IsBunker(LocalBunk, NewLocation, CapsuleHolder.NumberOfPushesForCapsuleLoss);
                    }

                    ShouldPush = CapsuleHolder.Distance(ClosestMothership) <= ClosestMothership.UnloadRange + CapsuleHolder.MaxSpeed + BoostingDistance - 1 ||
                                 (IsBunker(EnemyPirates, CapsuleHolder) && ((!ExistsDeeperCamp && IsSafeAfterBoost) || IgnoreDeeperCamps));
                }

                if (ShouldPush)
                {
                    Boosters = Boosters.Where(x => x.CanPush(CapsuleHolder)).ToList();
                    Boosters.ForEach(x => x.Push(CapsuleHolder, ClosestMothership));
                    CapsuleHolder.Sail(ClosestMothership);
                }
                else
                {
                    CapsuleHolder.Sail(ClosestMothership, x =>
                    {
                        if (x is Pirate pirate)
                        {
                            return(IsBunker(x, CapsuleHolder.NumberOfPushesForCapsuleLoss) ? AvoidingDistance : 0);
                        }
                        return(0);
                    }, true);
                    foreach (PirateShip p in Boosters)
                    {
                        p.Sail(CapsuleHolder.ExpectedLocation);
                    }
                }
                foreach (PirateShip p in squad.FilterOutBySquad(Boosters.AddPirates(CapsuleHolder)))
                {
                    p.Sail(capsule.InitialLocation);
                }
                return(true);
            }
            else if (capsule.IsAlive())
            {
                foreach (PirateShip p in squad)
                {
                    p.Sail(capsule, EnableWarps: true);
                }
                return(true);
            }
            else
            {
                foreach (PirateShip p in squad)
                {
                    p.Sail(capsule.InitialLocation, EnableWarps: true);
                }
                return(true);
            }
            return(false);
        }
示例#15
0
 private bool IsBunker(Squad EnemyPirates, PirateShip target)
 {
     return(EnemyPirates.Count > 0 && (EnemyPirates.Count >= target.NumberOfPushesForCapsuleLoss ||
                                       Bot.Engine.CanKill(EnemyPirates, target)));
 }
示例#16
0
 public bool DoTurn(PirateShip ship)
 {
     return(pusher.DoTurn(new Squad(ship)));
 }
示例#17
0
 public LogicedPirate(PirateShip s, PirateLogic logic)
 {
     this.pirate = s;
     this.logic  = logic;
 }
示例#18
0
        public override void OnThink()
        {
            if (bootgespawnt == false)
            {
                Map map = this.Map;
                if (map == null)
                {
                    return;
                }
                this.Z       = 0;
                m_PirateShip = new PirateShip();
                Point3D loc     = this.Location;
                Point3D loccrew = this.Location;
                loc     = new Point3D(this.X, this.Y - 1, -5);
                loccrew = new Point3D(this.X, this.Y - 1, this.Z);
                m_PirateShip.MoveToWorld(loc, map);
                bootgespawnt = true;

                for (int i = 0; i < 5; ++i)
                {
                    Pirate m_pirate = new Pirate();
                    m_pirate.MoveToWorld(loccrew, map);
                }
            }

            base.OnThink();
            if (DateTime.Now < m_NextPickup)
            {
                return;
            }

            if (m_PirateShip == null)
            {
                return;
            }

            m_NextPickup = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(1, 2));


            feindrichtung = Direction.North;     //default nord
            foreach (Item feind in this.GetItemsInRange(200))
            {
                if (feind is BaseBoat && feind != m_PirateShip && !(feind is PirateShip))
                {
                    List <Mobile>     targets = new List <Mobile>();
                    IPooledEnumerable eable   = feind.GetMobilesInRange(16);

                    foreach (Mobile m in eable)
                    {
                        if (m is PlayerMobile)
                        {
                            targets.Add(m);
                        }
                    }
                    eable.Free();
                    if (targets.Count > 0)
                    {
                        m_feindboot   = feind as BaseBoat;
                        feindrichtung = this.GetDirectionTo(m_feindboot);
                        break;
                    }
                }
            }
            if (m_feindboot == null)
            {
                return;
            }


            if (m_PirateShip != null && m_feindboot != null)
            {
                if (m_PirateShip != null && (feindrichtung == Direction.North) && m_PirateShip.Facing != Direction.North)
                {
                    m_PirateShip.Facing = Direction.North;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.South) && m_PirateShip.Facing != Direction.South)
                {
                    m_PirateShip.Facing = Direction.South;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.East || feindrichtung == Direction.Right || feindrichtung == Direction.Down) && m_PirateShip.Facing != Direction.East)
                {
                    m_PirateShip.Facing = Direction.East;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.West || feindrichtung == Direction.Left || feindrichtung == Direction.Up) && m_PirateShip.Facing != Direction.West)
                {
                    m_PirateShip.Facing = Direction.West;
                }
                m_PirateShip.StartMove(Direction.North, true);                                              //, false); //Vollgas!

                if (m_PirateShip != null && this.InRange(m_feindboot, 10) && m_PirateShip.IsMoving == true) // In Reichweite? Stop!
                {
                    m_PirateShip.StopMove(false);
                }
            }
            else
            {
                if (m_PirateShip != null && m_PirateShip.IsMoving == true)
                {
                    m_PirateShip.StopMove(false);               //keiner da? anhalten.
                }
            }
        }