public static EntityReturner CreateTrollClub() { List <Components.Component> compList = new List <Components.Component>(); // set bitwise to 0 int checker = 0; Components.WeaponComp weapComp = new Components.WeaponComp("2d6", Types.WeaponDmgTypes.Crushing, false, "Club", 12); compList.Add(weapComp); checker = checker | (int)ComponentTypes.Weapon; Components.UseableComp useComp = new Components.UseableComp(); compList.Add(useComp); checker = checker | (int)ComponentTypes.Useable; Components.CollectableComp colComp = new Components.CollectableComp(1, false, false, Types.ItemTypes.Weapon, true); compList.Add(colComp); checker = checker | (int)ComponentTypes.Collectable; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d3")); compList.Add(valComp); checker = checker | (int)ComponentTypes.ItemValue; Components.RenderComp rendComp = new Components.RenderComp('|', Swatch.DbMetal); compList.Add(rendComp); checker = checker | (int)ComponentTypes.Render; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public static EntityReturner CreateGold(int x, int y, int rndNum) { // set bitwise to 0 int checker = 0; List <Components.Component> compList = new List <Components.Component>(); Components.PositionComp positionComp = new Components.PositionComp(x, y); compList.Add(positionComp); checker = checker | (int)Core.ComponentTypes.Position; Components.RenderComp rendComp = new Components.RenderComp('$', RLNET.RLColor.Yellow); compList.Add(rendComp); checker = checker | (int)Core.ComponentTypes.Render; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d6")); compList.Add(valComp); checker = checker | (int)Core.ComponentTypes.ItemValue; Components.CollectableComp collComp = new Components.CollectableComp(1, true, true, Types.ItemTypes.Treasure, true); compList.Add(collComp); checker = checker | (int)Core.ComponentTypes.Collectable; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public static EntityReturner CreateHealthPotion() { List <Components.Component> compList = new List <Components.Component>(); // set bitwise to 0 int checker = 0; Components.PotionComp potComp = new Components.PotionComp(Types.PotionTypes.Health); compList.Add(potComp); checker = checker | (int)ComponentTypes.Potion; Components.UseableComp useComp = new Components.UseableComp(); compList.Add(useComp); checker = checker | (int)ComponentTypes.Useable; Components.RenderComp rendComp = new Components.RenderComp('!', RLNET.RLColor.Yellow); compList.Add(rendComp); checker = checker | (int)Core.ComponentTypes.Render; Components.ItemValueComp valComp = new Components.ItemValueComp(RogueSharp.DiceNotation.Dice.Roll("1d6")); compList.Add(valComp); checker = checker | (int)Core.ComponentTypes.ItemValue; Components.CollectableComp collComp = new Components.CollectableComp(1, false, false, Types.ItemTypes.Potion, true); compList.Add(collComp); checker = checker | (int)Core.ComponentTypes.Collectable; EntityReturner er = new EntityReturner(checker, compList); return(er); }
public void OnMessage(Core.MessageEventArgs e) { switch (e.MessageType) { case Core.EventTypes.InventoryAdd: Core.InventoryAddEventArgs msg = (Core.InventoryAddEventArgs)e; int entPickingUp = msg.EntPickingUp; int pickedUpObj = msg.PickedUpObject; List <Components.Component> pickedUpObjComps = _entityManager.GetCompsByID(pickedUpObj); List <Components.Component> entComps = _entityManager.GetCompsByID(entPickingUp); Components.InventoryComp invComp = (Components.InventoryComp)_entityManager.GetSingleComponentByID(entPickingUp, Core.ComponentTypes.Inventory); if (invComp != null) { Components.PositionComp posComp = (Components.PositionComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.Position); Components.CollectableComp collectComp = (Components.CollectableComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.Collectable); Components.ItemValueComp vC = (Components.ItemValueComp)pickedUpObjComps.Find(x => x.CompType == Core.ComponentTypes.ItemValue); //Components.Component c = _entityManager.GetSingleComponentByID(collectComp.) bool hasValue = (vC != null); if (collectComp.Active) { //is it treasure? if (collectComp.Treasure) { //TODO stackable treasure if (vC != null) { invComp.ValueCarried += vC.ItemValue; } // remove position comps from picked up object _entityManager.RemoveCompFromEnt(pickedUpObj, Core.ComponentTypes.Position); collectComp.Active = false; _entityManager.RemoveEntFromPosition(posComp.X, posComp.Y, pickedUpObj); invComp.Treasure.Add(pickedUpObj); } else { // is it stackable? - not currently used //TODO stackable collectables if (collectComp.Stackable) { } else { Game.MessageLog.Add("picking up item"); // System.Threading.Thread.Sleep(1000); if (posComp != null) { _entityManager.RemoveEntFromPosition(posComp.X, posComp.Y, pickedUpObj); _entityManager.RemoveCompFromEnt(pickedUpObj, Core.ComponentTypes.Position); pickedUpObjComps.Remove(posComp); } invComp.Inventory.Add(pickedUpObj); } } } } break; } }