public bool AddItem(IInventoryObject obj, int count) { if (obj != null && count > 0) { ServerInventoryItem servItem = new ServerInventoryItem(obj, count); if (HasSpaceForItems(servItem)) { if (items.ContainsKey(servItem.Object.Id)) { ServerInventoryItem existingItem = null; if (items.TryGetValue(servItem.Object.Id, out existingItem)) { existingItem.Add(count); return(true); } } else { items.TryAdd(servItem.Object.Id, servItem); return(true); } } } return(false); }
private void GenerateScheme(DropManager dropManager, int lootLevel, Workshop lootWorkshop, Difficulty d, ConcurrentDictionary <string, ServerInventoryItem> newObjects, float remapWeight) { var moduleTemplate = resource.ModuleTemplates.RandomModule(lootWorkshop, CommonUtils.RandomEnumValue <ShipModelSlotType>()); var schemeDropper = dropManager.GetSchemeDropper(lootWorkshop, lootLevel, remapWeight); IInventoryObject schemeObject = schemeDropper.Drop() as IInventoryObject; newObjects.TryAdd(schemeObject.Id, new ServerInventoryItem(schemeObject, 1)); //log.InfoFormat("scheme of level = {0} generated", schemeObject.Level); }
private void GenerateWeapon(DropManager dropManager, int lootLevel, Workshop lootWorkshop, Difficulty d, ConcurrentDictionary <string, ServerInventoryItem> newObjects, float remapWeight) { ObjectColor color = resource.ColorRes.GenColor(ColoredObjectType.Weapon).color; WeaponDropper.WeaponDropParams weaponParams = new WeaponDropper.WeaponDropParams(resource, lootLevel, lootWorkshop, WeaponDamageType.damage, Difficulty.none); var weaponDropper = dropManager.GetWeaponDropper(weaponParams, remapWeight); IInventoryObject weaponObject = weaponDropper.Drop() as IInventoryObject; newObjects.TryAdd(weaponObject.Id, new ServerInventoryItem(weaponObject, 1)); //log.InfoFormat("weapon of level = {0} generated", weaponObject.Level); }
public GamePageController(IScene scene, ISceneObject sceneObject, IInteraction interaction, IInventory inventory, IInventory_InventoryObject inventoryHelper, IInventoryObject inventoryObject, ILevel level, IMemoryCache memoryCache) { _scene = scene; _sceneObject = sceneObject; _interaction = interaction; _inventory = inventory; _inventoryHelper = inventoryHelper; _inventoryObject = inventoryObject; _level = level; _memoryCache = memoryCache; }
public List <ChunkData> Generate(GenerationRandom genRan) { Vec2i tilebase = Shell.Position * World.ChunkSize; if (Shell.BanditCampLevel > 1 && Shell.Size.x > 3 && Shell.Size.z > 3) { //If this camp is large enough, generate a dungeon entrance. Vec2i localPos = new Vec2i(2, TileSize.z / 2 - 2); CaveDungeonEntrance entr = new CaveDungeonEntrance(tilebase + localPos, null, new WorldObjectMetaData(direction: new Vec2i(1, 0))); IMultiTileObjectChild[,] children = entr.GetChildren(); Objects[localPos.x, localPos.z] = entr; for (int x = 0; x < entr.Size.x; x++) { for (int z = 0; z < entr.Size.z; z++) { if (x == 0 && z == 0) { continue; } Objects[localPos.x + x, localPos.z + z] = children[x, z] as WorldObjectData; } } Debug.Log("Generated Bandit Camp with Dungeon at " + this.Shell.Position, Debug.CHUNK_STRUCTURE_GENERATION); Shell.SetDungeonEntrance(entr); entr.SetChunkStructure(Shell); } else { Debug.Log("Generated Bandit Camp no Dungeon at " + this.Shell.Position, Debug.CHUNK_STRUCTURE_GENERATION); } Objects[11, 11] = new LootSack(tilebase + new Vec2i(11, 11)); FinalLootChest = Objects[11, 11] as IInventoryObject; for (int x = 0; x < TileSize.x; x++) { for (int z = 0; z < TileSize.z; z++) { if (x == 0) { Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z)); } if (z == 0) { Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z)); } if (x == TileSize.x - 1 && z < TileSize.z / 2 - 2 && z > TileSize.z / 2 + 2) { Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z)); } if (z == TileSize.z - 1) { Objects[x, z] = new WoodSpikeWall(tilebase + new Vec2i(x, z)); } Tiles[x, z] = Tile.DIRT.ID; } } EntityFaction banditFaction = new EntityFaction("Bandit_Camp"); for (int x = 0; x < Shell.Size.x; x++) { for (int z = 0; z < Shell.Size.z; z++) { //Entity e = new Bandit(); //e.SetPosition(tilebase + new Vec2i(x * World.ChunkSize + 5, z * World.ChunkSize + z + 3)); //Shell.AddEntity(x, z, e); //e.SetEntityFaction(banditFaction); } } Entity e = new Bandit(); e.SetPosition(tilebase + new Vec2i(2 * World.ChunkSize + 5, 2 * World.ChunkSize + 2 + 3)); Shell.AddEntity(0, 0, e); e.SetEntityFaction(banditFaction); return(ToChunkData()); }
public void SetWorldObject(IInventoryObject invObj) { InventoryObject = invObj; }
public void SetLootChest(IInventoryObject invOb) { FinalLootChest = invOb; }
public void RemoveItem(IInventoryObject RemovingItem) { items.Remove(RemovingItem); insertPosition--; }
public void AddItems(IInventoryObject addingItems) { items.Add(addingItems); }
public void SetMainLootChest(IInventoryObject inv) { MainLootChest = inv; }