예제 #1
0
    private void TestInventoryFuncionality()
    {
        // doorId - name - weight
        Item i = new AccesItem(1, "Key of doom", 50f);

        // points - name - weight
        Item b = new BonusItem(10, "Potato of the gods", 50f);
        Item c = new BonusItem(10, "Potato of the gods", 10f);

        DebugTest(i);
        DebugTest(b);
        DebugTest(c);

        inventory.DebugInventory();

        if (inventory.CanOpenDoor(1))
        {
            print("Door 1 can be opened.");
        }
        else
        {
            print("Door 1 can't be opened.");
        }

        if (inventory.HasItem(i))
        {
            print("Key of doom is in inventory");
        }
        else
        {
            print("Key is not in inventory");
        }

        if (inventory.RemoveItem(i))
        {
            print("Key was removed from inventory");
        }
        else
        {
            print("key was not removed");
        }

        if (inventory.CanOpenDoor(1))
        {
            print("Door 1 can be opened.");
        }
        else
        {
            print("Door 1 can't be opened.");
        }

        if (inventory.HasItem(i))
        {
            print("Key of doom is in inventory");
        }
        else
        {
            print("Key is not in inventory");
        }
    }
예제 #2
0
    private void CreateKey()
    {
        Item i = new AccesItem(3, "Key of doom", 10f);

        DebugItem(i);

        Item b = new BonusItem(100, "Potato of the gods", 10);

        DebugItem(b);
    }
예제 #3
0
    public bool HasKey(int ID)
    {
        for (int i = 0; i < items.Count; i++)
        {
            if (items[i] is AccesItem)
            {
                AccesItem it = (AccesItem)items[i];
                if (it.door == ID)
                {
                    return(true);
                }
            }
        }

        return(false);
    }
예제 #4
0
    void TestInventory()
    {
        BonusItem bonus = new BonusItem("Bonus1", 2f, 100);
        BonusItem anvil = new BonusItem("Bonus1", 9f, 900);
        AccesItem key   = new AccesItem("Key1", 2f, 1);

        // Debug.Log("Adding Bonus succes : " + Inventory.instance.AddItem(bonus));
        Debug.Log("Adding Key succes : " + Inventory.instance.AddItem(key));
        Debug.Log("Adding Anvil succes : " + Inventory.instance.AddItem(anvil));
        Debug.Log("");
        Debug.Log("Inventory: ");

        Inventory.instance.RemoveItem(bonus);
        Debug.Log("INVENTORY AFTER REMOVING");
        Debug.Log("INVENTORY AFTER Fake REMOVING");
        Inventory.instance.RemoveItem(anvil);
    }
예제 #5
0
    public void DebugItem(Item i)
    {
        string itemInfo  = "The item: " + i.Name + " weighs " + i.Weight + "Kg";
        string extraInfo = "";

        if (i is AccesItem)
        {
            AccesItem ai = (AccesItem)i;
            extraInfo = " and opens door: " + ai.DoorID;
        }
        else if (i is BonusItem)
        {
            BonusItem bi = (BonusItem)i;
            extraInfo = " and give you: " + bi.Points;
        }

        print(itemInfo + extraInfo);
    }