Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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
                    }
                        );
                }
            }
        }
Esempio n. 3
0
        public void Inventories_Empty_AreEqual()
        {
            var a = new Comps.Inventory();
            var b = new Comps.Inventory();

            Assert.AreEqual(a, b);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        // 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
                    )
                );
        }