示例#1
0
        private void Import_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            dlg.DefaultExt = ".png";
            dlg.Filter     = "PNG files (.png)|*.png|All files|*";

            if (!(dlg.ShowDialog() ?? false))
            {
                return;
            }

            try
            {
                Bitmap image = TextureWorker.ReadImageFromFile(dlg.FileName);
                image.SetResolution(96.0F, 96.0F);
                (this.DataContext as UndertaleTexturePageItem).ReplaceTexture(image);

                // Refresh the image of "ItemDisplay"
                if (ItemDisplay.FindName("RenderAreaBorder") is not Border border)
                {
                    return;
                }
                if (border.Background is not ImageBrush brush)
                {
                    return;
                }
                BindingOperations.GetBindingExpression(brush, ImageBrush.ImageSourceProperty)?.UpdateTarget();
            }
            catch (Exception ex)
            {
                mainWindow.ShowError(ex.Message, "Failed to import image");
            }
        }
示例#2
0
    public void EnvironmentDamage()
    {
        if (strength <= 0)
        {
            MessageManager.ShowMessageWithImage(tileEnvironment.nameMaterial + " уже разрушен", tileEnvironment.spriteDestroyed);
            return;
        }

        if (tileEnvironment.id == 0) // Воздействие на неразрушаемый тайл "Черный камень"
        {
            MessageManager.ShowMessageWithImage(tileEnvironment.nameMaterial + " не возможно разрушить", tileEnvironment.spriteDefault);
            return;
        }
        else
        {
            _inHandsItemDisplay = _inventory.GetItemDInSlot(-1);

            if (_inHandsItemDisplay.item.id == 0)                                                                    // Если в руках игрока ничего нет...
            {
                MessageManager.ShowMessageOnlyText("Для разрушения тайла необходим соответствующий предмет в руке"); // !! Добавить подсказку о том, какой Item эффективнее всего разрушает именно этот тайл.
                return;
            }

            _damageSize = tileEnvironment.DamageSize(_inHandsItemDisplay.item.id);
            _inHandsItemDisplay.ItemDamage(this);
            if (_damageSize > 0) // Если тайл получил реальный урон...
            {
                strength -= _damageSize;
                _selfHighlighting.HighlightingDamage();

                SetStateEnvironment();
            }
        }
    }
    public void SetValues(GameObject ItemDisplayObject, GodStats God)
    {
        if (God)
        {
            CheckItems(God);
        }

        if (ItemDisplayObject)
        {
            ItemDisplay ID = ItemDisplayObject.GetComponent <ItemDisplay>();
            if (ID.iName)
            {
                ID.iName.text = name;
            }
            if (ID.iIcon)
            {
                ID.iIcon.sprite = icon;
            }
            if (ID.iGold)
            {
                ID.iGold.text = goldNeeded.ToString() + "g";
            }
            if (God.gold)
            {
                God.gold.text = "Gold: " + God.GodGold.ToString();
            }
        }
    }
 public ItemDisplayCount(Item i, ItemDisplay display)
 {
     item         = i;
     this.display = display;
     count        = 1;
     display.Display(i, count);
 }
示例#5
0
    public void TakeInHands(ItemDisplay itemD) // Взять в руки выбранный мышью предмет.
    {
        if (_itemDHands.item.id != 0)          // Если руки заняты...
        {
            if (_numEmptySlots != 0)           // ...а в инвентаре есть место...
            {
                for (int slot = 0; slot < _itemsDSlots.Count; slot++)
                {
                    if (_itemsDSlots[slot].item.id == 0) // ...находим пустой слот...
                    {
                        MessageManager.ShowMessageWithImage("Предмет в руках помещен в инвентарь", imgHands.sprite);
                        SwapItemsInSlots(slot, -1); // Перекладываем предмет в руках в инвентарь
                        break;
                    }
                }
            }
            else // ...и в инвентаре нет места
            {
                MessageManager.ShowMessageOnlyText("Руки и инвентарь уже заняты");
                MessageManager.ShowMessageOnlyText("Если хотите подобрать этот предмет, освободите руки или место в инвентаре");
                return;
            }
        }

        _itemDHands     = itemD;
        imgHands.sprite = _itemDHands.item.spriteInInventory; // VISUAL
        _itemDHands._NumSlotInInventory = -1;
        _itemDHands._WarningShown       = false;
        _itemDHands._thisGamObj.SetActive(false);

        MessageManager.ShowMessageWithImage("Взяли в руки " + _itemDHands.item.nameItem, _itemDHands.item.spriteOnScene);
    }
 public void UpdateItem(ItemDisplay item, int index)
 {
     item.index  = index;
     item.size   = size;
     item.width  = width;
     item.height = height;
 }
示例#7
0
    public void DiscardItem(int idSlot) // Выбросить предмет из инвентаря.
    {
        if (idSlot == -1)               // -1 означает слот рук
        {
            _itemDHands._thisGamObj.transform.position = _playerTransform.position;
            _itemDHands._NumSlotInInventory            = -2;
            _itemDHands._thisGamObj.SetActive(true);

            MessageManager.ShowMessageWithImage("Выбросили из рук " + _itemDHands.item.nameItem, _itemDHands.item.spriteInInventory);

            _itemDHands     = itemDEmpty;
            imgHands.sprite = sprEmptyHands;
        }
        else
        {
            _itemsDSlots[idSlot]._thisGamObj.transform.position = _playerTransform.position;
            _itemsDSlots[idSlot]._NumSlotInInventory            = -2;
            _itemsDSlots[idSlot]._thisGamObj.SetActive(true);

            MessageManager.ShowMessageWithImage("Выбросили из инвентаря " + _itemsDSlots[idSlot].item.nameItem, _itemsDSlots[idSlot].item.spriteInInventory);
            _numEmptySlots++;

            _itemsDSlots[idSlot]     = itemDEmpty;
            _imgSlots[idSlot].sprite = sprEmptySlot;
        }
    }
示例#8
0
    private void Awake()
    {
        _numEmptySlots = inventoryPanelT.childCount;

        _inventoryPanelGO = inventoryPanelT.gameObject;
        _playerTransform  = transform;

        _itemDHands  = itemDEmpty;
        _itemsDSlots = new List <ItemDisplay>(_numEmptySlots);
        for (int i = 0; i < _numEmptySlots; i++)
        {
            _itemsDSlots.Add(itemDEmpty);
        }

        _imgSlots = new Image[_numEmptySlots];
        for (int i = 0; i < _numEmptySlots; i++)
        {
            _imgSlots[i] = inventoryPanelT.GetChild(i).GetComponent <Image>();
        }

        _fltrItems.SetLayerMask(layerItems);
        _collidersItems = new Collider2D[_numEmptySlots];

        OpenCloseInventory();
    }
示例#9
0
    public void AddItemToInventory()
    {
        itemObj = transform.GetChild(0).gameObject;
        ItemDisplay display = itemObj.GetComponent <ItemDisplay>();

        Inventory.instance.AddItem(display.item, slot);
    }
示例#10
0
        public void SetItemDisplay(int row, int column, ItemDisplay displayMode, int imageIndex)
        {
            LV_ITEM item = new LV_ITEM();

            item.iItem    = row;
            item.iSubItem = column;
            switch (displayMode)
            {
            case ItemDisplay.Text:
                item.mask    = ( uint )LVIF.LVIF_TEXT;
                item.pszText = new StringBuilder(this.GetItemText(row, column));
                break;

            case ItemDisplay.Image:
                item.mask = ( uint )LVIF.LVIF_IMAGE;
                break;

            case ItemDisplay.ImageAndText:
                item.mask    = ( uint )(LVIF.LVIF_IMAGE | LVIF.LVIF_TEXT);
                item.pszText = new StringBuilder(this.GetItemText(row, column));
                break;
            }
            item.iImage = imageIndex;
            SendMessage(this.Handle, ( int )LVM.LVM_SETITEM, 0, ref item);
        }
示例#11
0
        static private void TryDisplayStashAmount(ItemDisplay itemDisplay)
        {
            #region quit
            if (!_displayStashAmount || PlayerStash == null ||
                !itemDisplay.m_lblQuantity.TryAssign(out var quantity) ||
                !itemDisplay.RefItem.TryAssign(out var item) ||
                item.OwnerCharacter == null &&
                item.ParentContainer.IsNot <MerchantPouch>() &&
                itemDisplay.IsNot <RecipeResultDisplay>())
            {
                return;
            }
            #endregion

            int stashAmount = itemDisplay is CurrencyDisplay ? PlayerStash.ContainedSilver : PlayerStash.ItemStackCount(item.ItemID);
            if (stashAmount <= 0)
            {
                return;
            }

            if (itemDisplay.IsNot <RecipeResultDisplay>())
            {
                quantity.text = itemDisplay.m_lastQuantity.ToString();
            }
            else if (itemDisplay.m_dBarUses.TryAssign(out var dotBar) && dotBar.GOActive())
            {
                quantity.text = "1";
            }

            int fontSize = (quantity.fontSize * 0.75f).Round();
            quantity.alignment   = TextAnchor.UpperRight;
            quantity.lineSpacing = 0.75f;
            quantity.text       += $"\n<color=#00FF00FF><size={fontSize}><b>+{stashAmount}</b></size></color>";
        }
示例#12
0
 public static bool PreGetActionText(ItemDisplayOptionPanel __instance, int _actionID, ref string __result)
 {
     try
     {
         if (_actionID == (int)EnCustomInventoryActions.AssignQuickslotSet)
         {
             __result = "New QuickSlotSet";
             ItemDisplay m_activatedItemDisplay = (ItemDisplay)AccessTools.Field(typeof(ItemDisplayOptionPanel), "m_activatedItemDisplay").GetValue(__instance);
             var         ext = m_activatedItemDisplay?.RefItem?.gameObject?.GetComponent <QuickSlotSetExt>();
             if (ext != null && ext.Slots.Count > 0)
             {
                 __result = "Replace QuickSlotSet";
             }
             return(false);
         }
         if (_actionID == (int)EnCustomInventoryActions.DeleteQuickslotSet)
         {
             __result = "Delete QuickSlotSet";
             return(false);
         }
     }
     catch (Exception ex)
     {
         DynamicQuickslots.Instance.MyLogger.LogError("PreGetActionText: " + ex.Message);
     }
     return(true);
 }
示例#13
0
 private void LegacyChestPanel_StartInit(On.LegacyChestPanel.orig_StartInit orig, LegacyChestPanel self)
 {
     orig(self);
     try
     {
         ItemDisplay        m_itemInChest       = (ItemDisplay)AccessTools.Field(typeof(LegacyChestPanel), "m_itemInChest").GetValue(self);
         ItemDetailsDisplay m_itemDetailDisplay = (ItemDetailsDisplay)AccessTools.Field(typeof(LegacyChestPanel), "m_itemDetailDisplay").GetValue(self);
         //AccessTools.Field(typeof(LegacyChestPanel), "m_itemInChest").SetValue(self, m_itemInChest);
         ItemDetailsPanelSpawner componentInChildren = self.GetComponentInChildren <ItemDetailsPanelSpawner>();
         if ((bool)componentInChildren)
         {
             m_itemDetailDisplay = componentInChildren.DetailPanel;
             ItemDisplay      item  = (ItemDisplay)AccessTools.Field(typeof(ItemDetailsDisplay), "itemDisplay").GetValue(m_itemDetailDisplay);
             ItemGroupDisplay group = (ItemGroupDisplay)AccessTools.Field(typeof(ItemDetailsDisplay), "groupDisplay").GetValue(m_itemDetailDisplay);
             OLogger.Log($"item={item == null}");
             OLogger.Log($"group={group == null}");
             m_itemInChest = group;
         }
         ItemDisplay itemInChest = m_itemInChest;
         itemInChest.onSelectCallback = (UnityAction <ItemDisplay>)Delegate.Combine(itemInChest.onSelectCallback, new UnityAction <ItemDisplay>(self.OnItemSelected));
         Transform transform = self.transform.Find("MiddlePanel/PlayerInventory/Header/lblTitle");
         if ((bool)transform)
         {
             //m_lblInventoryTitle = transform.GetComponent<Text>();
         }
     }
     catch (Exception ex)
     {
         OLogger.Error($"StartInit={ex.Message}");
     }
 }
示例#14
0
 void InstancateSongs(List <Song> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         GameObject  obj  = Instantiate(prefabListItem, new Vector2(0, 0), Quaternion.identity, transform);
         ItemDisplay item = obj.GetComponent <ItemDisplay>();
         item.SongInfo = list[i];
     }
 }
示例#15
0
 private void Start()
 {
     _itemDisplay = FindObjectOfType <ItemDisplay>();
     _coinDisplay = FindObjectOfType <CoinDisplay>();
     _itemDisplay.UpdateContainers(_inventoryObject.GetItems().Count);
     _itemDisplay.UpdateSelectedItem(_selectedItem);
     _itemDisplay.UpdateItems(_inventoryObject.GetItems());
     _coinDisplay.UpdateCoins(_inventoryObject.GetCoins());
 }
示例#16
0
    public void AddNewSong(Song song)
    {
        GameObject obj = Instantiate(prefabListItem, new Vector2(0, 0), Quaternion.identity, transform);

        obj.transform.SetAsFirstSibling();
        ItemDisplay item = obj.GetComponent <ItemDisplay>();

        item.SongInfo = song;
    }
示例#17
0
 private void Awake()
 {
     _renderer        = GetComponent <SpriteRenderer>();
     _selfTransform   = GetComponent <Transform>();
     _playerTransform = GameObject.Find("PlayerOLD").transform;
     _UI_Panel        = GameObject.Find("TooltipPanelOLD").GetComponent <UI_Update>();
     _itemDisplay     = GetComponent <ItemDisplay>();
     _inventory       = _playerTransform.GetComponent <InventoryOLD>();
 }
示例#18
0
            public void Update()
            {
                if (!body || !body.transform)
                {
                    return;
                }

                if (NetworkServer.active)
                {
                    if (target)
                    {
                        HealthComponent healthComponent = target.healthComponent;
                        if (!target.HasBuff(buffDef) || !healthComponent || !healthComponent.alive)
                        {
                            ClearTarget();
                        }
                    }
                }

                stopwatch += Time.deltaTime;
                waveY      = Mathf.Sin(stopwatch * Mathf.PI * waveFrequency + waveOffset * Mathf.PI * 2) * waveAmplitude;

                if (target)
                {
                    leash.leashOrigin = target.corePosition + offset * target.radius + Vector3.up * waveY;
                    rotateToDirection.targetRotation = Util.QuaternionSafeLookRotation(target.corePosition - transform.position);
                }
                else
                {
                    leash.leashOrigin = body.corePosition + offset * body.radius + Vector3.up * waveY;
                    rotateToDirection.targetRotation = Quaternion.LookRotation(body.inputBank.aimDirection);
                }

                ItemDisplay  itemDisplay  = follower.GetComponent <ItemDisplay>();
                ModelLocator modelLocator = body.modelLocator;

                if (modelLocator)
                {
                    Transform modelTransform = modelLocator.modelTransform;
                    if (modelTransform)
                    {
                        CharacterModel characterModel = modelTransform.GetComponent <CharacterModel>();
                        if (characterModel)
                        {
                            itemDisplay.SetVisibilityLevel(characterModel.visibility);
                            foreach (CharacterModel.RendererInfo rendererInfo in itemDisplay.rendererInfos)
                            {
                                Renderer renderer = rendererInfo.renderer;
                                renderer.GetPropertyBlock(materialPropertyBlock);
                                materialPropertyBlock.SetFloat("_Fade", target ? 1f : 1f / body.inventory.GetItemCount(MysticsItemsContent.Items.MysticsItems_Spotter));
                                renderer.SetPropertyBlock(materialPropertyBlock);
                            }
                        }
                    }
                }
            }
    public ItemDisplay GenItem(int index)
    {
        ItemDisplay newitem = Instantiate <ItemDisplay>(Prefab_item);

        newitem.transform.SetParent(this.transform);
        newitem.inventory = this.GetComponent <InventoryDisplay>();
        UpdateItem(newitem, index);
        newitem.UpdateItemDisplay();
        return(newitem);
    }
示例#20
0
 void Start()
 {
     playerControler = GetComponent <PlayerControler>();
     itemDisplay     = GetComponentInChildren <ItemDisplay>();
     itemsPickUp     = GetComponent <ItemsPickUp>();
     riddleCanvas    = GameObject.FindGameObjectWithTag("Riddle").GetComponent <Canvas>();
     riddle          = GameObject.Find("Riddles").GetComponent <RiddleAnswer>();
     emergencyCard   = GameObject.Find("UsableItems").GetComponent <EmergencyCard>();
     generator       = GameObject.Find("UsableItems").GetComponent <Generator>();
 }
示例#21
0
    void CreateGhostItem(Item item)
    {
        GameObject  itemObj = Instantiate(ghostItemPrefab, resultsParent);
        ItemDisplay display = itemObj.GetComponent <ItemDisplay>();

        if (display != null)
        {
            display.Setup(item);
        }
    }
示例#22
0
 static private ItemDisplay FindItemInContainerDisplay(ItemDisplay item, List <ItemDisplay> otherContainerItems)
 {
     foreach (var otherItem in otherContainerItems)
     {
         if (otherItem.m_refItem.ItemID == item.m_refItem.ItemID)
         {
             return(otherItem);
         }
     }
     return(null);
 }
示例#23
0
 public override void Draw(SpriteBatch b)
 {
     if (BoxColor.HasValue)
     {
         IClickableMenu.drawTextureBox(b, ( int )Position.X, ( int )Position.Y, Width, Height, BoxColor.Value);
     }
     if (ItemDisplay != null)
     {
         ItemDisplay.drawInMenu(b, Position + new Vector2(16, 16), 1, TransparentItemDisplay ? 0.5f : 1, 1);
     }
 }
示例#24
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("item"))
     {
         itemInfos       = other.gameObject.GetComponent <ItemDisplay>();
         PickUpText.text = "Press F to pick up a <color=yellow>" + itemInfos.item.name + "</color>!";
         PickUpScreen.SetActive(true);
         canPickUp    = true;
         itemSelected = other.gameObject.name;
     }
 }
 public void AddItem(Item i)
 {
     if (displays.ContainsKey(i.item_name))
     {
         displays[i.item_name].Increment();
     }
     else
     {
         ItemDisplay new_item_display = Instantiate(item_display_prefab, items_grid.transform);
         displays[i.item_name] = new ItemDisplayCount(i, new_item_display);
     }
 }
示例#26
0
        /// <summary>
        /// Sub创建
        /// </summary>
        protected override void onSubViewCreated(
            ItemDisplay <List <MapDisplay.Line> > sub, int index)
        {
            base.onSubViewCreated(sub, index);
            var painter = sub as MapLinePainter;

            if (painter == null)
            {
                return;
            }

            painter.mapDisplay = mapDisplay;
        }
示例#27
0
    public void AddItem(Item item, bool startItem)
    {
        Debug.Log("Add item: " + item.name);
        AssignItem(item);

        GameObject  itemObj = Instantiate(itemPrefab, itemPool);
        ItemDisplay display = itemObj.GetComponent <ItemDisplay>();

        if (display != null)
        {
            display.Setup(item);
        }
    }
示例#28
0
文件: Shop.cs 项目: vitn24/DiceGame
 public bool CheckInventoryWeight(ItemDisplay itemWeight)
 {
     if ((weight.ParameterValue + itemWeight.item.weight) <= weight.MaxValue.ParameterValue)
     {
         Debug.Log("Weight check true");
         return(true);
     }
     else
     {
         Debug.Log("Weight check false");
         return(false);
     }
 }
示例#29
0
        private void search_for_display()
        {
            var foundObjects = FindObjectsOfType <ItemDisplay>();

            if (foundObjects.Length == 1)
            {
                this.display = foundObjects.First();
            }
            else
            {
                Debug.Log("not the right number of CombatantDisplay's");
            }
        }
示例#30
0
    public override void OnInspectorGUI()
    {
        ItemDisplay itemDisplay = (ItemDisplay)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Load Item Display"))
        {
            itemDisplay.UpdateItemDisplay();
        }
        if (GUILayout.Button("Unload Item Display"))
        {
            itemDisplay.ResetItemDisplay();
        }
    }
示例#31
0
 public void SetItemDisplay( int row, int column, ItemDisplay displayMode, int imageIndex )
 {
     LV_ITEM item = new LV_ITEM();
     item.iItem = row;
     item.iSubItem = column;
     switch( displayMode )
     {
         case ItemDisplay.Text:
             item.mask = ( uint )LVIF.LVIF_TEXT;
             item.pszText = new StringBuilder( this.GetItemText( row, column ) );
             break;
         case ItemDisplay.Image:
             item.mask = ( uint )LVIF.LVIF_IMAGE;
             break;
         case ItemDisplay.ImageAndText:
             item.mask = ( uint )( LVIF.LVIF_IMAGE | LVIF.LVIF_TEXT );
             item.pszText = new StringBuilder( this.GetItemText( row, column ) );
             break;
     }
     item.iImage = imageIndex;
     SendMessage( this.Handle, ( int )LVM.LVM_SETITEM, 0, ref item );
 }
示例#32
0
 private void RemoveItemDisplay(ItemDisplay id)
 {
     if (itemDisplays.Remove(id)) PlayerMessage.HideMessage();
     isInteracting = false;
 }
示例#33
0
 public void SetItemDisplay( int row, int column, ItemDisplay displayMode )
 {
     this.SetItemDisplay( row, column, displayMode, 0 );
 }