Exemplo n.º 1
0
        /// <summary>
        /// This method is called automatically every few seconds while your ship is flying.
        /// Trading, equipment modification etc. can be done only when landed on a planet,
        /// but you can use this method to attack others!
        /// If you wish to be a peaceful trader, then you can ignore this method, since only pirates
        /// can make any use of it.
        ///
        /// All you have to do is implement this method and the ShipLanded() method - you don't
        /// need to touch the other files in the solution.
        /// Don't forget: post any issues you have on the forum! {FORUM URL HERE}
        /// The starmap and all other information can be found on: {GAME URL HERE}
        /// </summary>
        public static async Task ShipFlying(Guid currentShip)
        {
            //Let's try and buy another ship, if we have the money! The first additional ship costs 10 million credits.
            var ship = await NavigationComputer.GetSpaceshipStatusAsync();

            var ownedShips = await NavigationComputer.GetOwnedShipsAsync();

            if (ship.Money > 10100000 && ownedShips.ToList().Count == 1)
            {
                await NavigationComputer.BuyNewShipAsync();
            }
            else if (ship.Money > 51000000 && ownedShips.ToList().Count == 2)
            {
                await NavigationComputer.BuyNewShipAsync();
            }

            //We can have multiple ships. By checking the value of the currentShip parameter, you can differentiate
            //between your ships and give each of the separate orders.
            //In this example, if this is not the first ship, we'll use it for piracy.

            //if (currentShip != ownedShips.First())
            //{
            //Let's attack the first ship that gets in our sight!
            //Caution: this only makes sense when you have some cannons equipped.
            var raidableShips = await NavigationComputer.GetRaidableShipsAsync();

            if (raidableShips.Length > 0 && ship.CannonCount > 0 && raidableShips.First().Distance < await TradeHelper.CannonRange() && await TradeHelper.AvailableCargoSpace() > 0)
            {
                await NavigationComputer.RaidAsync(raidableShips.First());
            }
            //}
        }