Esempio n. 1
0
        public async Task FindIndex(string URL)
        {
            int         index = Looter.IndexOf(URL);
            IndexedMeme m     = Looter.ForceMeme(index);

            await ReplyAsync((index == -1)? "nichts gefunden" : $"{index}: {m.Meme}");
        }
Esempio n. 2
0
        public async Task Start()
        {
            Looter.Init();

            string token = Config.Current.Token;

            client = new DiscordSocketClient();

            await client.SetGameAsync("mit deiner Mudda");

            commands = new CommandService();

            fallback = new ModuleFallback(ReactionLibrary.GetReactions());

            services = new ServiceCollection()
                       .AddSingleton(client)
                       .AddSingleton(commands)
                       .AddSingleton(fallback)
                       .BuildServiceProvider();

            await InstallCommands();

            client.Log += Log;

            await client.LoginAsync(TokenType.Bot, token);

            await client.StartAsync();

            await Task.Delay(-1);
        }
Esempio n. 3
0
    public Looter ClosestUnit(List <Looter> unitList, int _unitType)
    {
        int           minDistance = 10000;
        Looter        target      = null;
        List <Looter> list;

        if (_unitType == -1)
        {
            list = unitList;
        }
        else
        {
            list = unitList.Where(x => x.unitType == _unitType).ToList();
        }

        foreach (Looter l in list)
        {
            //Console.Error.WriteLine("Looter in list : " + l.unitId + " Type : " + l.unitType);
            if (DistanceFrom(l.position) < minDistance)
            {
                minDistance = DistanceFrom(l.position);
                target      = l;
            }
        }
        //Console.Error.WriteLine("Closest Unit in (" + string.Join(", ", list) + ") : " + target.ToString());

        return(target);
    }
Esempio n. 4
0
        public async Task AddLoot(string url, params string[] tags)
        {
            if (!await RequireUser(Roles.Memer))
            {
                return;
            }
            if (Looter.Contains(url) && !Config.Current.AllowDuplicates)
            {
                await ReplyAsync("Url is schon drin ma boi");

                return;
            }
            var res = Looter.AddURL(url, Context.User.Username, Context.User.Id.ToString(), tags);

            if (!res.success)
            {
                await ReplyAsync("Die Url is retarded.. glaub ich zumindest");

                return;
            }
            await ReplyAsync($"{Context.User} hat in {Context.Channel} einen Eintrag hinzugefügt [{res.index}]");

            if (Config.Current.DeleteAddRequests)
            {
                await Context.Channel.DeleteMessagesAsync(new[] { Context.Message.Id });
            }
        }
Esempio n. 5
0
    internal static object CalculateWreckRoi(Looter looter, Wreck wreck, IEnumerable <Unit> otherUnits)
    {
        var turnsToWreck = Math.Ceiling(Utils.GetDistance(looter, wreck) / Utils.CalculateUnitsPerTurnWithCurrentSpeed(looter.Speed));
        var unitCount    = otherUnits.Where(u => Utils.IsInRange(u, wreck, wreck.Radius * 2)).Count();

        return(wreck.WaterAmount - turnsToWreck);
    }
Esempio n. 6
0
 public async Task ChangeTagGlobally(string o, string n)
 {
     if (!await RequireUser(Roles.Admin))
     {
         return;
     }
     await ReplyAsync($"Es wurden {Looter.ChangeTagGlobally(o, n)} Einträge abgeändert");
 }
Esempio n. 7
0
 public HModules(Core core)
 {
     Cavebot   = new Cavebot(ref core);
     General   = new General(ref core);
     Heal      = new Heal(ref core);
     Looter    = new Looter(ref core);
     Targeting = new Targeting(ref core);
     Scripter  = new Scripter(ref core);
 }
Esempio n. 8
0
        public async Task GetMemes()
        {
            string path = $@"{Directory.GetCurrentDirectory()}\Dump_{Guid.NewGuid()}.html";

            File.WriteAllText(path, Looter.GetHTMLFormattedOverview());
            await Context.Channel.SendFileAsync(path, $":point_down: {Config.Current.RandomCurse} <3");

            File.Delete(path);
        }
Esempio n. 9
0
            public SkillEffect(int type, double x, double y, double radius, int duration, int order, Looter looter) : base(x, y)
            {
                Id = GLOBAL_ID++;

                this.Type     = type;
                this.Radius   = radius;
                this.Duration = duration;
                this.Looter   = looter;
                this.Order    = order;
            }
Esempio n. 10
0
        public async Task DeleteTag(string t, int index)
        {
            if (!Looter.DeleteTag(t, index))
            {
                await ReplyAsync("ne");

                return;
            }
            await ReplyAsync("okay");
        }
Esempio n. 11
0
    internal bool ProcessTargetIfPossible(Looter looter, Unit target)
    {
        if (target != null)
        {
            var throttle = Utils.GetDesiredThrottle(looter, target);
            looter.Throttle(target.Position);
            return(true);
        }

        return(false);
    }
Esempio n. 12
0
    private void OnCollisionEnter(Collision other)
    {
        Looter looter = other.gameObject.GetComponentInParent <Looter>();

        if (looter == null)
        {
            return;
        }

        Destroy(gameObject);
        looter.inventory.Add(loot.ToArray());
    }
Esempio n. 13
0
        public async Task Shortcut(string s)
        {
            var sc = Looter.ProcessShortcut(s);

            if (sc.Index == -1)
            {
                await ReplyAsync($"Der Shortcut {s} is Müll du {Config.Current.RandomCurse}");

                return;
            }

            await ProcessMeme(sc);
        }
Esempio n. 14
0
        public async Task Tag(string t)
        {
            var tag = Looter.ProcessTag(t);

            if (tag.Index == -1)
            {
                await ReplyAsync($"Der Tag {t} is Müll du {Config.Current.RandomCurse}");

                return;
            }

            await ProcessMeme(tag);
        }
Esempio n. 15
0
        public async Task CreateMeme(int index, string upper, string lower)
        {
            IndexedMeme        m    = Looter.ForceMeme(index);
            string             path = Path.Combine(Directory.GetCurrentDirectory(), "Memes");
            MemeCreatorManager mcm  = new MemeCreatorManager(path, null);
            var res = mcm.CreateMeme(m.Meme, upper, lower);

            await Context.Channel.SendFileAsync(res.path, $"{Context.User.Username} is Schuld");

            if (Context.Guild != null)
            {
                await Context.Channel.DeleteMessagesAsync(new[] { Context.Message.Id });
            }

            Array.ForEach(Directory.GetFiles(path), File.Delete);
        }
Esempio n. 16
0
 public async Task AddShortcut(string s, int index)
 {
     try
     {
         if (Looter.AddShortcut(s, index))
         {
             await ReplyAsync($"shortcut {s} wurde überschrieben");
         }
         else
         {
             await ReplyAsync($"shortcut {s} wurde erstellt");
         }
     }
     catch (IndexOutOfRangeException)
     {
         await ReplyAsync($"index {index} ist ungültig");
     }
 }
Esempio n. 17
0
    public override void Decide()
    {
        List <Looter> list = Player.units.ToList();

        if (Player.units.Where(x => x.unitType == 4).ToList().Count == 0)
        {
            Go(new Coordinate(0, 0), throttle);
            return;
        }
        else
        {
            Looter ClosestWreck = null;

            while (ClosestWreck == null)
            {
                ClosestWreck = ClosestUnit(list, 4);

                foreach (Looter l in Player.units.Where(x => x.playerId != -1).Where(x => x.unitType == 0))
                {
                    if (ClosestWreck == null || list.Count == 0)
                    {
                        ClosestWreck = Player.joueurs[0].units[1];
                        break;
                    }

                    if (ClosestWreck.DistanceFrom(l.position) < 200)
                    {
                        list.Remove(ClosestWreck);
                        ClosestWreck = null;
                    }
                }

                Console.Error.WriteLine(ClosestWreck);
            }

            if (ClosestWreck == null)
            {
                ClosestWreck = (Wreck)ClosestUnit(Player.units, 4);
            }

            int acc = (int)Utility.map(DistanceFrom(ClosestWreck.position), 500 / mass, 1000 / mass, 0, throttle);
            Go(ClosestWreck.position, Math.Max(0, acc));
        }
    }
Esempio n. 18
0
        public async Task TagCount(params string[] t)
        {
            if (t is null || t.Length == 0)
            {
                await ReplyAsync($"@{Context.User.Mention} Musst halt schon tags angeben... Spast");

                return;
            }

            var tag = Looter.ProcessTagCombination(t, TagCombiner.MAXCOUNT);

            if (tag.Index == -1)
            {
                await ReplyAsync($"Gibbet net");

                return;
            }

            await ProcessMeme(tag);
        }
Esempio n. 19
0
        public async Task Stats()
        {
            EmbedBuilder sb = new EmbedBuilder()
            {
                Title = $"Alle stats ({Looter.Count} Meme(s))",
                Color = new Color(114, 137, 218)
            };

            var stats = Looter.GetStats();

            foreach (var x in stats.OrderByDescending(s => s.Value))
            {
                sb.AddField(y =>
                {
                    y.Name  = x.Key;
                    y.Value = x.Value;
                });
            }

            await ReplyAsync("Bidde", false, sb.Build());
        }
Esempio n. 20
0
        public async Task AddTags(string t, params int[] indices)
        {
            if (!await RequireUser(Roles.Memer))
            {
                return;
            }
            if (indices == null || indices.Length < 1)
            {
                await ReplyAsync("keine indizes angegeben");

                return;
            }
            int c = 0;

            foreach (var x in indices)
            {
                if (Looter.AddTag(t, x))
                {
                    c++;
                }
            }
            await ReplyAsync($"{c} tags hinzugefügt");
        }
Esempio n. 21
0
        public async Task FindTag(string tag, bool postFull = false)
        {
            if (!await RequireUser(Roles.Admin))
            {
                return;
            }
            var query = Looter.Where(x => x.Tags.Contains(tag));

            if (postFull)
            {
                foreach (var x in query)
                {
                    await ProcessMeme(x);
                }
            }
            else
            {
                int           i  = 0;
                StringBuilder sb = new StringBuilder();
                foreach (var x in query)
                {
                    sb.Append($"{x.Index}[{string.Join(",", x.Meme.Tags)}]\n[{x.Meme.URL}]\n");
                    if (i++ > 10)
                    {
                        i = 0;
                        await ReplyAsync(sb.ToString());

                        sb.Clear();
                    }
                }
                if (i != 0)
                {
                    await ReplyAsync(sb.ToString());
                }
            }
        }
Esempio n. 22
0
        private void Run()
        {
            #region local variables
            Walker walker = new Walker(this);
            Targeting targeting = new Targeting(this);
            Looter looter = new Looter(this);
            List<Objects.Location> corpseLocations = new List<Objects.Location>();
            Objects.Location currentCorpseLocation = Objects.Location.Invalid;
            Waypoint currentWaypoint = null;
            bool cleanupCalled = false;
            Map.TileCollection tileCollection = null;

            #region events
            // create anonymous methods and reference them
            // because we want to unsub them later
            TargetHandler anonTargetKilled = delegate(Target t)
            {
                if (t == null || t.Creature == null) return;
                if (!t.DoLoot) return;
                if (!this.Client.Player.Location.IsOnScreen(t.Creature.Location)) return;
                if (!corpseLocations.Contains(t.Creature.Location)) corpseLocations.Add(t.Creature.Location);
            };
            Targeting.CreatureDiedHandler anonCreatureDied = delegate(Objects.Creature c)
            {
                string name = c.Name.ToLower();
                foreach (Target t in this.GetTargets())
                {
                    if (t.Name.ToLower() == name)
                    {
                        if (!t.DoLoot) break;
                        if (!corpseLocations.Contains(c.Location)) corpseLocations.Add(c.Location);
                        break;
                    }
                }
            };
            Walker.WaypointHandler anonWaypointExecutedEnd = delegate(Waypoint waypoint, bool success)
            {
                if (this.Waypoints.Count == 0) return;
                this.CurrentWaypointIndex++;
            };
            Looter.CorpseOpenedHandler anonCorpseOpened = delegate(Objects.Container container)
            {
                looter.LootItems(container, this.GetLoot(), true);
            };
            Looter.LootingFinishedHandler anonLootingFinished = delegate(Objects.Container container)
            {
                if (this.Waypoints.Count == 0) return;

                if (container.IsOpen) container.Close();
                corpseLocations.Remove(currentCorpseLocation);
                currentCorpseLocation = Objects.Location.Invalid;
            };
            Targeting.ErrorHandler anonTargetingError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Targeting:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            Walker.ErrorHandler anonWalkerError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Waypoints:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            Looter.ErrorOccurredHandler anonLooterError = delegate(Exception ex)
            {
                DateTime dt = DateTime.Now;
                string dtString = dt.Year + "-" + dt.Month + "-" + dt.Day + " " + dt.Hour + ":" + dt.Minute + ":" + dt.Second;
                File.AppendAllText("cavebot-debug.txt", "[" + dtString + "] Looter:\n" + ex.Message + "\n" + ex.StackTrace + "\n");
            };
            CleanupHandler anonCleanup = delegate()
            {
                this.TargetKilled -= anonTargetKilled;
                walker.WaypointExecutedEnd -= anonWaypointExecutedEnd;
                looter.CorpseOpened -= anonCorpseOpened;
                looter.LootingFinished -= anonLootingFinished;
                targeting.CreatureDied -= anonCreatureDied;
                targeting.ErrorOccurred -= anonTargetingError;
                walker.ErrorOccurred -= anonWalkerError;
                looter.ErrorOccurred -= anonLooterError;
                cleanupCalled = true;
            };
            // subscribe to events
            this.TargetKilled += anonTargetKilled;
            walker.WaypointExecutedEnd += anonWaypointExecutedEnd;
            looter.CorpseOpened += anonCorpseOpened;
            looter.LootingFinished += anonLootingFinished;
            targeting.CreatureDied += anonCreatureDied;
            targeting.ErrorOccurred += anonTargetingError;
            walker.ErrorOccurred += anonWalkerError;
            looter.ErrorOccurred += anonLooterError;
            // subscribe to cleanup, as we need to unsub before exiting
            this.CleanupCalled += anonCleanup;
            #endregion
            #endregion

            while (this.IsRunning)
            {
                try
                {
                    Thread.Sleep(500);

                    // check if IsRunning changed or cleanup called while thread was sleeping
                    if (!this.IsRunning || cleanupCalled) break;

                    if (!this.Client.Player.Connected) continue;

                    // check if a script waypoint is currently running
                    if (walker.IsRunning &&
                        currentWaypoint != null &&
                        currentWaypoint.Type == Waypoint.Types.Script)
                    {
                        continue;
                    }

                    Objects.Location playerLoc = this.Client.Player.Location;
                    IEnumerable<Objects.Creature> creatures = this.Client.BattleList.GetCreatures(false, true),
                        visiblePlayers = this.Client.BattleList.GetPlayers(true, true);
                    List<Objects.Creature> visibleCreatures = new List<Objects.Creature>();
                    foreach (Objects.Creature c in creatures)
                    {
                        if (c.IsVisible) visibleCreatures.Add(c);
                    }

                    foreach (Objects.Creature c in targeting.GetKilledCreatures(creatures))
                    {
                        string name = c.Name.ToLower();
                        foreach (Target t in this.GetTargets())
                        {
                            if (t.Name.ToLower() != name) continue;
                            if (!corpseLocations.Contains(c.Location)) corpseLocations.Add(c.Location);
                            break;
                        }
                    }

                    #region targeting
                    if (targeting.IsRunning)
                    {
                        targeting.UpdateCache(tileCollection, visibleCreatures, visiblePlayers);
                        continue;
                    }
                    else if (this.CurrentSettings.KillBeforeLooting || corpseLocations.Count == 0)
                    {
                        Target t = this.GetBestTarget(tileCollection, creatures, this.Client.BattleList.GetPlayers(true, true), true);
                        if (t != null)
                        {
                            if (this.CurrentSettings.KillBeforeLooting && looter.IsRunning) looter.CancelExecution();
                            if (this.Client.TibiaVersion < 810) this.StopwatchExhaust.Restart(); // restart to avoid instant attack->spell/rune
                            targeting.ExecuteTarget(t, tileCollection, visibleCreatures, visiblePlayers);
                            continue;
                        }
                    }
                    #endregion

                    #region looting
                    if (looter.IsRunning)
                    {
                        looter.UpdateCache(tileCollection);
                        continue;
                    }
                    // loot always if there are no waypoints
                    if (this.Waypoints.Count == 0)
                    {
                        List<ushort> ids = new List<ushort>();
                        foreach (Loot loot in this.GetLoot())
                        {
                            ids.Add(loot.ID);
                        }
                        foreach (Objects.Container c in this.Client.Inventory.GetContainers(1))
                        {
                            if (c.Name.Contains("Backpack")) continue;
                            if (c.GetItems(ids).ToArray().Length == 0) continue;

                            looter.LootItems(c, this.GetLoot(), false);
                        }
                    }
                    // check loot locations
                    else if (corpseLocations.Count > 0)
                    {
                        if (this.Client.Player.IsWalking) continue;

                        // find new corpse location
                        if (!currentCorpseLocation.IsValid() || !playerLoc.IsInRange(currentCorpseLocation))
                        {
                            int distance = int.MaxValue;
                            Objects.Location bestLoc = Objects.Location.Invalid;
                            foreach (Objects.Location loc in corpseLocations)
                            {
                                if (!playerLoc.IsInRange(loc)) continue;

                                int corpseDistance = 0;
                                if (playerLoc.IsOnScreen(loc))
                                {
                                    Map.Tile tile = tileCollection.GetTile(loc);
                                    if (tile == null) continue;
                                    Map.TileObject topItem = tile.GetTopUseItem(false);
                                    if (!topItem.HasFlag(Enums.ObjectPropertiesFlags.IsContainer)) continue;

                                    var tilesToLoc = playerLoc.GetTilesToLocation(this.Client, loc,
                                        tileCollection, this.PathFinder, true, true).ToArray();
                                    if (tilesToLoc.Length == 0) continue;

                                    corpseDistance = tilesToLoc.Length - 1;
                                }
                                else corpseDistance = (int)playerLoc.DistanceTo(loc) + 20;

                                if (corpseDistance < distance)
                                {
                                    distance = corpseDistance;
                                    bestLoc = loc;
                                }
                            }
                            if (bestLoc.IsValid()) currentCorpseLocation = bestLoc;
                        }

                        // move to loot location
                        if (currentCorpseLocation.IsValid() && playerLoc.IsInRange(currentCorpseLocation))
                        {
                            if (this.Client.Window.StatusBar.GetText() == Enums.StatusBar.ThereIsNoWay)
                            {
                                corpseLocations.Remove(currentCorpseLocation);
                                currentCorpseLocation = Objects.Location.Invalid;
                                this.Client.Window.StatusBar.SetText(string.Empty);
                                continue;
                            }

                            if (playerLoc.IsOnScreen(currentCorpseLocation))
                            {
                                Map.Tile tile = tileCollection.GetTile(currentCorpseLocation);
                                if (tile == null)
                                {
                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }
                                Map.TileObject topItem = tile.GetTopUseItem(false);
                                if (!topItem.HasFlag(Enums.ObjectPropertiesFlags.IsContainer))
                                {
                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }

                                if (playerLoc.DistanceTo(currentCorpseLocation) >= 2)
                                {
                                    Map.TileCollection adjTiles = tileCollection.GetAdjacentTileCollection(tile);
                                    int adjDistance = playerLoc.GetTilesToLocation(this.Client,
                                        tile.WorldLocation, tileCollection, this.PathFinder, true).ToArray().Length;
                                    Objects.Location adjLoc = Objects.Location.Invalid;
                                    foreach (Map.Tile adjTile in adjTiles.GetTiles())
                                    {
                                        if (!adjTile.IsWalkable()) continue;

                                        var tilesToCorpse = playerLoc.GetTilesToLocation(this.Client,
                                            adjTile.WorldLocation, tileCollection, this.PathFinder, true).ToArray();
                                        if (tilesToCorpse.Length == 0) continue;

                                        int dist = tilesToCorpse.Length - 1;
                                        if (dist < adjDistance)
                                        {
                                            adjDistance = dist;
                                            adjLoc = adjTile.WorldLocation;
                                        }
                                    }

                                    if (adjLoc.IsValid())
                                    {
                                        this.Client.Player.GoTo = adjLoc;
                                        continue;
                                    }

                                    corpseLocations.Remove(currentCorpseLocation);
                                    currentCorpseLocation = Objects.Location.Invalid;
                                    continue;
                                }

                                // we're in range to open the corpse, so let's open it
                                looter.OpenCorpse(tileCollection, tile);
                                continue;
                            }
                            else
                            {
                                this.Client.Player.GoTo = currentCorpseLocation;
                                continue;
                            }
                        }
                        else currentCorpseLocation = Objects.Location.Invalid;
                    }
                    #endregion

                    #region waypoints
                    if (walker.IsRunning)
                    {
                        walker.UpdateCache(tileCollection);
                        continue;
                    }
                    else if (this.Waypoints.Count > 0)
                    {
                        // check if this is the first time we're running the walker
                        // and if waypoint index wasn't set by user
                        // if so, find the closest waypoint
                        if (currentWaypoint == null && this.CurrentWaypointIndex == 0)
                        {
                            int distance = 200;
                            Waypoint closestWaypoint = null;
                            foreach (Waypoint wp in this.GetWaypoints())
                            {
                                if (!playerLoc.IsInRange(wp.Location)) continue;
                                int wpDist = (int)playerLoc.DistanceTo(wp.Location);
                                if (distance > wpDist)
                                {
                                    distance = wpDist;
                                    closestWaypoint = wp;
                                }
                            }
                            if (closestWaypoint == null) continue;
                            currentWaypoint = closestWaypoint;
                        }
                        else currentWaypoint = this.Waypoints[this.CurrentWaypointIndex];

                        walker.ExecuteWaypoint(currentWaypoint, tileCollection);
                    }
                    #endregion
                }
                catch (Exception ex)
                {

                }
            }

            this.CleanupCalled -= anonCleanup;
        }
Esempio n. 23
0
 public async Task Force(int index) => await ProcessMeme(Looter.ForceMeme(index));
Esempio n. 24
0
 public async Task GetURL(int index)
 {
     await ReplyAsync($"[{Looter.ForceMeme(index).Meme.URL}]");
 }
Esempio n. 25
0
    private static int GetSpeedAfterThrottle(Looter looter, int throttle)
    {
        var speed = throttle / looter.Mass;

        return((int)Math.Round(speed * (1 - looter.Friction)));
    }
Esempio n. 26
0
 public async Task DeleteIndex(int index)
 {
     await ReplyAsync(Looter.Delete(index)?$"{Context.User} hat einen Eintrag gelöscht" : $"index {index} konnte nicht gelöscht werden");
 }
Esempio n. 27
0
        public void InitReferee(int playerCount)
        {
            Random random = new Random();

            units       = new List <Unit>();
            looters     = new List <Looter>();
            tankers     = new List <Tanker>();
            deadTankers = new List <Tanker>();
            wrecks      = new List <Wreck>();
            players     = new List <Player>();

            // Create players
            for (int i = 0; i < playerCount; ++i)
            {
                Player player = new Player(i);
                players.Add(player);
            }

            // Create Looters
            foreach (Player player in players)
            {
                for (int i = 0; i < LOOTER_COUNT; ++i)
                {
                    Looter looter = CreateLooter(i, player, 0, 0);
                    player.Looters[i] = looter;
                    units.Add(looter);
                    looters.Add(looter);
                }
            }

            // Random spawns for Looters
            bool finished = false;

            while (!finished)
            {
                finished = true;

                for (int i = 0; i < LOOTER_COUNT && finished; ++i)
                {
                    double distance = random.NextDouble() * (MAP_RADIUS - LOOTER_RADIUS);
                    double angle    = random.NextDouble();

                    foreach (Player player in players)
                    {
                        double looterAngle = (player.Index + angle) * (Math.PI * 2.0 / ((double)playerCount));
                        double cos         = Math.Cos(looterAngle);
                        double sin         = Math.Sin(looterAngle);

                        Looter looter = player.Looters[i];
                        looter.Move(cos * distance, sin * distance);

                        // If the Looter touch A Looter, Reset everyone and try again
                        if (units.Any(u => u != looter && looter.Distance(u) <= looter.Radius + u.Radius))
                        {
                            finished = false;
                            looters.ForEach(l => l.Move(0.0, 0.0));
                            break;
                        }
                    }
                }
            }

            Adjust();
        }
Esempio n. 28
0
 public Transit( Ship self, float ftlCounterForce = 0, float timeOfLaunch = 0 )
     : base(self)
 {
     asteroidSpawner = self.asteroidSpawner;
     gravityComponent = self.gravityComponent;
     this.ftlCounterForce = ftlCounterForce;
     this.timeOfLaunch = timeOfLaunch;
     this.lootCollector = self.lootCollector;
 }
Esempio n. 29
0
        public async Task Delete(string value)
        {
            int c = Looter.Delete(value);

            await ReplyAsync($"{Context.User} hat {((c != 1) ? c + " Einträge" : "einen Eintrag")} gelöscht");
        }
Esempio n. 30
0
    // Initialization event
    void Start()
    {
        //Initialize
        shipInfo = ScriptableObject.CreateInstance<ShipData>();
        defaultDrag = rigidbody.drag;
        engine = GetComponent<Engine>() as Engine;
        engine.enabled = false;
        asteroidSpawner = GetComponent<ObstacleSpawner>();
        lootCollector = GetComponent<Looter>();
        lootCollector.enabled = false;
        if(gravityComponent != null)
            gravityComponent.SetActive(false);

        //Set default stuff
        state = new StateMachine<ShipState>(new Orbit(this));
    }
Esempio n. 31
0
        public async Task Help()
        {
            var builder = new EmbedBuilder()
            {
                Color       = new Color(114, 137, 218),
                Description = "Mögliche Commands:"
            };

            foreach (var m in _service.Modules)
            {
                string moduleDesc = null;
                foreach (var c in m.Commands)
                {
                    var result = await c.CheckPreconditionsAsync(Context);

                    if (result.IsSuccess)
                    {
                        moduleDesc += $"![{(string.Join(",", c.Aliases))}][{string.Join(",", c.Parameters.Select(x => $"{x.Type.Name}:{x.Name}"))}]\n";
                    }
                }
                if (!string.IsNullOrWhiteSpace(moduleDesc))
                {
                    builder.AddField(x =>
                    {
                        x.Name     = m.Name;
                        x.Value    = moduleDesc;
                        x.IsInline = false;
                    });
                }
            }
            builder.AddField(x =>
            {
                x.Name     = "Shortcuts";
                x.Value    = string.Join("\n", Looter.Shorts);
                x.IsInline = false;
            });

            await ReplyAsync("Bidde", false, builder.Build());

            StringBuilder sb   = new StringBuilder();
            var           tags = Looter.GetAllTags()
                                 .Select(y => $"{y.Key} [{y.Value}]")
                                 .ToList();
            int length = 0;

            string NEWLINE           = Environment.NewLine;
            string TAG_HEADER        = "Tags : " + NEWLINE;
            int    ADDITIONAL_LENGTH = (TAG_HEADER + NEWLINE).Length;

            for (int i = 0; i < tags.Count; i++)
            {
                if (length + tags[i].Length + ADDITIONAL_LENGTH >= 2000)
                {
                    await ReplyAsync(TAG_HEADER + sb.ToString());

                    length = 0;
                    sb.Clear();
                }
                sb.Append(tags[i] + NEWLINE);
                length += tags[i].Length + 2;
            }
            if (length > 0)
            {
                await ReplyAsync(TAG_HEADER + sb.ToString());
            }
        }
Esempio n. 32
0
 public static int GetDesiredThrottle(Looter looter, Unit target)
 {
     return(Constants.MaxThrottle);
 }