public void DropItems(ItemStats dropItemStats, bool toBackpack = false, params IRecoveryAbility[] ignoredItems) { foreach (var item in GetItems(ItemStoredPlace.Inventory) .Where( x => ignoredItems.All(z => z.Handle != x.Handle) && !DroppedItems.Contains(x) && !disabledItems.Sleeping(x.Handle) && x.IsEnabled && x.IsDroppable && x.GetItemStats().HasFlag(dropItemStats))) { if (toBackpack && ItemsCanBeDisabled()) { if (!item.CanBeMovedToBackpack()) { continue; } var slot = GetItemSlot(item.Handle, ItemStoredPlace.Inventory); item.MoveItem(ItemSlot.BackPack_1); disabledItems.Sleep(6000, item.Handle); UsableAbilities.FirstOrDefault(x => x.Handle == item.Handle)?.SetSleep(6000); if (slot != null) { item.MoveItem(slot.Value); } } else { DropItem(item, ItemStoredPlace.Inventory); } } }
public void AddDroppedItem(Vector2 position, Item item, int amount) // Adds a dropped item to its list. { for (int i = 0; i < amount; i++) { DroppedItems.Add(new DroppedItem(position, item)); } }
public void render() { for (int x = 0; x < tiles.GetLength(0); x++) { for (int y = 0; y < tiles.GetLength(1); y++) { Engine.Engine.Draw(tiles[x, y].GetSprite(), new IntVec(x, y)); } } Environment.Draw(); //drawAStar(); InteractableEnvironment.Draw(); DroppedItems.Draw(); LightSources.Draw(); CharacterEntities.Draw(); //CharacterEntities.InvokeOnAll( (GameCharacter character, IntVec position) => //{ // position.X += character.GetSprite().Direction.X; // position.Y += character.GetSprite().Direction.Y; //}); //foreach (var pair in CharacterEntities.Tuples()) //{ // pair.Item2.X += pair.Item1.GetSprite().Direction.X; // pair.Item2.Y += pair.Item1.GetSprite().Direction.Y; //} }
static void Main(string[] args) { Console.Title = "HISP - Horse Isle Server Emulator"; ConfigReader.OpenConfig(); CrossDomainPolicy.GetPolicy(); Database.OpenDatabase(); GameDataJson.ReadGamedata(); Map.OpenMap(); World.ReadWorldData(); Treasure.Init(); DroppedItems.Init(); WildHorse.Init(); Drawingroom.LoadAllDrawingRooms(); Brickpoet.LoadPoetryRooms(); Multiroom.CreateMultirooms(); Auction.LoadAllAuctionRooms(); Item.DoSpecialCases(); GameServer.StartServer(); }
static void Main(string[] args) { #if (!DEBUG) AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #endif Console.Title = ServerVersion.GetBuildString(); ConfigReader.OpenConfig(); CrossDomainPolicy.GetPolicy(); Database.OpenDatabase(); GameDataJson.ReadGamedata(); Map.OpenMap(); World.ReadWorldData(); Treasure.Init(); DroppedItems.Init(); WildHorse.Init(); Drawingroom.LoadAllDrawingRooms(); Brickpoet.LoadPoetryRooms(); Multiroom.CreateMultirooms(); Auction.LoadAllAuctionRooms(); Item.DoSpecialCases(); GameServer.StartServer(); while (true) { } ; }
public void Dispose() { Player.OnExecuteOrder -= OnExecuteOrder; DroppedItems.Clear(); UsableAbilities.Clear(); abilities.Clear(); items.Clear(); itemSlots.Clear(); }
public void DropItem(Item item, ItemStoredPlace itemStored = ItemStoredPlace.Any, bool saveSlot = true) { if (saveSlot) { SaveItemSlot(item, itemStored); } Hero.DropItem(item, Hero.Position, true); DroppedItems.Add(item); }
public float PickUpItems() { var bottle = UsableAbilities.FirstOrDefault(x => x.Id == AbilityId.item_bottle) as Bottle; if (bottle != null && bottle.TakenFromStash) { var slot = GetSavedItemSlot(bottle.Handle); if (slot != null) { bottle.MoveItem(slot.Value, false); } } if (!DroppedItems.Any(x => x != null && x.IsValid && x.IsVisible)) { return(0); } var physicalItems = EntityManager <PhysicalItem> .Entities.Where( x => x.IsValid && x.IsVisible && x.Distance2D(Hero) < 800 && DroppedItems.Contains(x.Item)) .Reverse() .ToList(); if (!physicalItems.Any()) { return(0); } Hero.Stop(); var sleep = DroppedItems.Count * Game.Ping; foreach (var physicalItem in physicalItems) { if (Hero.PickUpItem(physicalItem, true)) { DroppedItems.Remove(physicalItem.Item); var slot = GetSavedItemSlot(physicalItem.Item); var item = Items.FirstOrDefault(x => x.Handle == physicalItem.Item.Handle); if (slot != null && item != null) { DelayAction.Add( 200 + Hero.Distance2D(physicalItem) / Hero.MovementSpeed, () => { item.MoveItem(slot.Value); }); } } } return(sleep); }
public void Update(ref GameTime gameTime) { // Updates all creatures, if health is less than 0, they die. Removed from the creature less for (int i = Creatures.Count - 1; i >= 0; --i) { Creatures[i].Update(ref gameTime); if (Creatures[i].CurrentHealth <= 0) { Creatures[i] = null; Creatures.RemoveAt(i); } } // Updates all the items dropped on the ground for (int i = DroppedItems.Count - 1; i >= 0; --i) { DroppedItems[i].Update(ref gameTime); if (DroppedItems[i].LifeTime >= 300) // Removed after 5 mins { DroppedItems[i] = null; DroppedItems.RemoveAt(i); } } // Updates all the projectiles, if lifetime is less than or equal to 0, they are removed. for (int i = Projectiles.Count - 1; i >= 0; --i) { Projectiles[i].Update(ref gameTime); if (Projectiles[i].LifeTime <= 0) { Projectiles[i] = null; Projectiles.RemoveAt(i); } } // If the boss of the level is up then they are updates, when dead a text appears to press N to continue. Background.Update(gameTime); if (Boss.IsAlive) { Boss.Update(gameTime); } else { TradingManager.Update(gameTime); if (Game1.InputManager.KeyClicked(Microsoft.Xna.Framework.Input.Keys.N)) { Game1.WindowManager.GetGameplayWindow().NewLevel(NextLevel); } } }
private void OnPickupItemAlert(PickupItemAlert alert) { var existingItem = DroppedItems.FirstOrDefault(i => i.ItemId == alert.Item.ItemId); if (existingItem != null) { existingItem.SetCount(existingItem.Count - alert.Item.Count); if (existingItem.Count <= 0) { DroppedItems.Remove(existingItem); } } Notify("DroppedItems"); }
private void OnDroppedItemsAlert(DroppedItemAlert alert) { var existingItem = DroppedItems.FirstOrDefault(i => i.ItemId == alert.DroppedItem.ItemId); if (existingItem != null) { existingItem.SetCount(existingItem.Count + alert.DroppedItem.Count); } else { var item = new DroppableItem(alert.DroppedItem, DroppedItems); item.OnItemMoved += OnItemMoved; } Notify("DroppedItems"); }
/// <summary> /// Gets a list of distinct item names that are involved in this kill /// </summary> /// <returns></returns> public IEnumerable <string> GetUsedItemNames() { var itemNames = new List <string> { Header.ShipName }; itemNames.AddRange(DestroyedItems.Select(item => item.Name)); itemNames.AddRange(DroppedItems.Select(item => item.Name)); itemNames.AddRange(InvolvedParties.Select(item => item.ShipName)); itemNames.AddRange(InvolvedParties.Select(item => item.WeaponName)); itemNames.Remove(Constants.None); itemNames.Remove(Constants.Unkown); return(itemNames.Distinct()); }
public override void _Ready() { _map = GetNode <YSort>("Map"); _enemySpawns = GetNode <Node2D>("EnemySpawns"); _combat = GetNode <Combat>("Combat"); _combatMenu = _combat.GetNode <CombatMenu>("CombatMenu"); _pauseMenu = GetNode <PauseMenu>("PauseMenu"); _player = _map.GetNode <Player>("Player"); _droppedItemsGUI = GetNode <DroppedItems>("DroppedItems"); _player.birdsSystem.Visible = true; _player.cloudsSystem.Visible = true; _player.Position = SaveManager.SaveData.WorldPosition; if (!AudioSystem.IsMusicPlaying) { AudioSystem.PlayMusic(AudioSystem.MusicCollection.Overworld); } SpawnEnemies(); }
internal void testUpdate() { #if DEBUG if (MouseController.RightClicked()) { IntVec pos = MouseController.MouseGridPosition(); if (KeyboardController.IsDown('8')) { Item[] items = new Item[statRand.Next(2, 8)]; for (int i = 0; i < items.Length; i++) { items[i] = Item.randomItem(DungeonLevel, 1); } InteractableEnvironment.Add(new Chest(items), pos); } if (KeyboardController.IsDown('9')) { CharacterEntities.Add(Enemies.EnemyCreator.GetRandomEnemy(1, DungeonLevel)[0], pos); } if (KeyboardController.IsDown('0')) { CharacterEntities.Add(Enemies.EnemyCreator.GetRandomBoss(DungeonLevel), pos); } } IntVec aMove = new IntVec((KeyboardController.IsTyped('H', 0) ? 1 : 0) - (KeyboardController.IsTyped('F', 0) ? 1 : 0), (KeyboardController.IsTyped('G', 0) ? 1 : 0) - (KeyboardController.IsTyped('T', 0) ? 1 : 0)); IntVec bMove = new IntVec((KeyboardController.IsPressed('M') ? 1 : 0) - (KeyboardController.IsPressed('B') ? 1 : 0), (KeyboardController.IsPressed('N') ? 1 : 0) - (KeyboardController.IsPressed('J') ? 1 : 0)); actionsToTake += (KeyboardController.IsDown('2') ? 1 : 0) - (KeyboardController.IsDown('1') ? 1 : 0); if (aMove.X != 0 || aMove.Y != 0 || bMove.X != 0 || bMove.Y != 0) { if (!isSolid(a + aMove)) { a += aMove; } if (!isSolid(b + bMove)) { b += bMove; } path = AStar.getPathBetween(this, a, b); actionsToTake = 1; int movement = Math.Abs(aMove.X) + Math.Abs(aMove.Y) + Math.Abs(bMove.X) + Math.Abs(bMove.Y); Engine.Engine.Log(string.Format("New A* path length: {0}", path.Length.ToString())); if (previousPathDistance != -1 && Math.Abs(previousPathDistance - path.Length) > movement) { Engine.Engine.Log(string.Format("<INCONSISTENT PATHFIND; MOVEMENTDELTA={0},PATHDELTA={1}>", movement, Math.Abs(previousPathDistance - path.Length))); } //moveset = AStar.getTargetLine(this, startPoint, a, true); //moveset = AStar.getPossiblePositionsFrom(this, a, 15, AStar.CharacterTargeting.TARGET_FIRST, true); moveset = AStar.getPossiblePositionsInBox(this, a, 2, 2, AStar.CharacterTargeting.TARGET_FIRST, true); previousPathDistance = path.Length; } if (KeyboardController.IsPressed('Z')) { for (int i = 0; i < 100; i++) { Item item = Item.getDesireditem(30, 30); Engine.Engine.Log(string.Format("Item Generated: {0}", item.Name)); DroppedItems.Add(item, findRandomOpenPosition()); } } if (KeyboardController.IsPressed('Q')) { for (int i = 0; i < 100; i++) { Item item = Item.randomLegendary(30, 35); Engine.Engine.Log(string.Format("Item Generated: {0}", item.Name)); DroppedItems.Add(item, findRandomOpenPosition()); } } #endif }
public void AddDroppedItem(Vector2 position, Item item) // Adds a dropped item to its list. { DroppedItems.Add(new DroppedItem(position, item)); }