示例#1
0
        // INITIALIZE: ----------------------------------------------------------------------------

        protected override void OnCreate()
        {
            DatabaseInventory dbInventory = DatabaseInventory.LoadDatabase <DatabaseInventory>();

            this.eventChangePlayerInventory = new UnityEvent();
            this.eventChangePlayerCurrency  = new UnityEvent();

            this.itemsCatalogue = new Dictionary <int, Item>();
            for (int i = 0; i < dbInventory.inventoryCatalogue.items.Length; ++i)
            {
                this.itemsCatalogue.Add(
                    dbInventory.inventoryCatalogue.items[i].uuid,
                    dbInventory.inventoryCatalogue.items[i]
                    );
            }

            this.recipes = new Dictionary <Recipe.Key, Recipe>();
            for (int i = 0; i < dbInventory.inventoryCatalogue.recipes.Length; ++i)
            {
                this.recipes.Add(
                    new Recipe.Key(
                        dbInventory.inventoryCatalogue.recipes[i].itemToCombineA.item.uuid,
                        dbInventory.inventoryCatalogue.recipes[i].itemToCombineB.item.uuid
                        ),
                    dbInventory.inventoryCatalogue.recipes[i]
                    );
            }

            this.playerInventory = new PlayerInventory();
            SaveLoadManager.Instance.Initialize(this);
        }
        // PUBLIC METHODS: ---------------------------------------------------------------------------------------------

        public ItemHolderPropertyDrawerWindow(Rect activatorRect, SerializedProperty property)
        {
            this.windowRect = new Rect(
                activatorRect.x,
                activatorRect.y + activatorRect.height,
                activatorRect.width,
                WIN_HEIGHT
                );

            this.inputfieldFocus = true;
            this.scroll          = Vector2.zero;
            this.property        = property;

            if (DATABASE_INVENTORY == null)
            {
                DATABASE_INVENTORY = DatabaseInventory.LoadDatabase <DatabaseInventory>();
            }
        }
示例#3
0
        private static void RequireInstance()
        {
            if (DATABASE_INVENTORY == null)
            {
                DATABASE_INVENTORY = DatabaseInventory.LoadDatabase <DatabaseInventory>();
            }
            if (InventoryUIManager.Instance == null)
            {
                EventSystemManager.Instance.Wakeup();
                if (DATABASE_INVENTORY.inventorySettings == null)
                {
                    Debug.LogError("No inventory database found");
                    return;
                }

                GameObject prefab = DATABASE_INVENTORY.inventorySettings.inventoryUIPrefab;
                if (prefab == null)
                {
                    prefab = Resources.Load <GameObject>(DEFAULT_UI_PATH);
                }

                Instantiate(prefab, Vector3.zero, Quaternion.identity);
            }
        }