Beispiel #1
0
    private void InterfaceMotor()
    {
        bool haveToMinUpdate = false;

        if (MyDebug.haveToUpdate && MyDebug.messages.Count > 0)
        {
            SetTextWithScales(messagesText, MyDebug.messages[MyDebug.messages.Count - 1].message);
            MyDebug.haveToUpdate = false;
            messagesText.color   = MyDebug.messages [MyDebug.messages.Count - 1].color;
        }

        if (state != IGameMenuState.Runtime)
        {
            drag = false;
        }
        if (!toGameImage)
        {
            toGameImage = toGame.image;
        }

        runtimeTalk.image.enabled = character.canTalk;

        toGameImage.enabled = (state != IGameMenuState.Runtime && state != IGameMenuState.Dialog);

        IUsable can = character.canUse;

        if (useCheck != (can != null))
        {
            CheckUse(can);
        }

        int[] items = character.status.items;
        //float delta = Mathf.Abs(slotsParent.rect.height - slotsMask.rect.height);
        //slotsParent.anchoredPosition = Vector2.up * delta * inventoryScroll.value;

        if (!currentItems.Equals(items))
        {
            if (lootableChest)
            {
                PrepareLootItems(lootableChest);
            }

            InventorySlot[] buttons = FillItemsTo(slotsParent, items);

            for (int i = 0; i < buttons.Length; i++)
            {
                int    index = i;
                Button bt    = buttons [i].button;
                bt.onClick.RemoveAllListeners();
                bt.onClick.AddListener(delegate {
                    currentLookableItemIndex = character.status.GetItemByID(buttons[index].id);
                });
            }

            amuletInv.GetComponentInChildren <RawImage> ().texture  = IItemAsset.LoadTexture(character.status.amulet);
            armorInv.GetComponentInChildren <RawImage> ().texture   = IItemAsset.LoadTexture(character.status.armor);
            weapontInv.GetComponentInChildren <RawImage> ().texture = IItemAsset.LoadTexture(character.status.weapon);
            runeInv.GetComponentInChildren <RawImage> ().texture    = IItemAsset.LoadTexture(character.status.rune);

            int ru = character.status.rune;

            ICharacter ch = character;

            amuletInv.onClick.RemoveAllListeners();
            amuletInv.onClick.AddListener(delegate {
                ch.BackToInv(IItemType.Amulet);
            });

            armorInv.onClick.RemoveAllListeners();
            armorInv.onClick.AddListener(delegate {
                ch.BackToInv(IItemType.Armor);
            });

            weapontInv.onClick.RemoveAllListeners();
            weapontInv.onClick.AddListener(delegate {
                ch.BackToInv(IItemType.Weapon);
            });

            runeInv.onClick.RemoveAllListeners();
            runeInv.onClick.AddListener(delegate {
                if (ru > -1)
                {
                    ch.BackToInv(IItemAsset.items[ru].type);
                }
            });

            currentItems    = items;
            haveToMinUpdate = true;
        }


        if (probeIndexLookable != currentLookableItemIndex)
        {
            int index = currentLookableItemIndex;
            use.onClick.RemoveAllListeners();
            use.onClick.AddListener(delegate {
                UseItem(index);
            });

            drop.onClick.RemoveAllListeners();
            drop.onClick.AddListener(delegate {
                Drop(index);
            });

            probeIndexLookable = currentLookableItemIndex;

            haveToMinUpdate = true;
        }


        if (haveToMinUpdate)
        {
            InterfaceMinUpdate();
        }
    }