private static Comps.Inventory GetInventory(Comps.Character.Kind kind) { var result = new Comps.Inventory(); switch (kind) { case Comps.Character.Kind.Link: case Comps.Character.Kind.Aquamentus: result.data[Comps.Item.Kind.Heart].Count = 5; result.data[Comps.Item.Kind.Rupee].Count = 10; break; case Comps.Character.Kind.Wallmaster: result.data[Comps.Item.Kind.Heart].Count = 4; result.data[Comps.Item.Kind.Rupee].Count = 5; break; case Comps.Character.Kind.Dodongos: case Comps.Character.Kind.Goriya: result.data[Comps.Item.Kind.Heart].Count = 3; result.data[Comps.Item.Kind.Rupee].Count = 3; break; case Comps.Character.Kind.Rope: result.data[Comps.Item.Kind.Heart].Count = 2; result.data[Comps.Item.Kind.Rupee].Count = 2; break; } return(result); }
private static void Drop( Comps.Inventory inventoryComp, Comps.Position positionComp, Ecs.Registry registry ) { foreach (KeyValuePair <Comps.Item.Kind, StorageInfo> pair in inventoryComp.data) { Comps.Item.Kind itemKind = pair.Key; StorageInfo storageInfo = pair.Value; for (int i = 0; i < storageInfo.Count; i++) { Entity itemEntity = Factories.Item.Create( itemKind, positionComp.data, registry ); registry.AssignComponent( itemEntity, new Comps.Velocity { data = 20 * Global.random.NextPhysicalVector2(), decay = 0.8f } ); } } }
public void Inventories_Empty_AreEqual() { var a = new Comps.Inventory(); var b = new Comps.Inventory(); Assert.AreEqual(a, b); }
public void Inventories_FromClone_AreNotEqual() { var a = new Comps.Inventory(); var b = (Comps.Inventory)a.Clone(); b.data[Comps.Item.Kind.Bow].Count = 1; Assert.AreNotEqual(a, b); }
public void Inventories_OneEmpty_AreNotEqual() { var a = new Comps.Inventory(); a.data[Comps.Item.Kind.Bow].Count = 1; var b = new Comps.Inventory(); Assert.AreNotEqual(a, b); }
// Pre-condition: `this.slots` has index `slot` public static void UseSlot( Comps.Inventory inventoryComp, Entity entity, int slot, Registry registry, Map map ) { Option <Comps.Item.Kind> itemKindOpt = inventoryComp.slots[slot]; itemKindOpt.Match( some: itemKind => { Item.Use(itemKind, inventoryComp, entity, registry, map); if (ShouldRemoveAfterUse(itemKind)) { inventoryComp.Remove(itemKind); } }, none: () => System.Console.WriteLine( "Trying to use empty slot {0}", slot ) ); }