示例#1
0
        public void PickupDoNotStack(Item item, Item target)
        {
            OnItemPickup(item);

            var index = Items.IndexOf(target);

            Items[index] = item;

            ItemPicked?.Invoke(new ItemPickupEventData(Items[index], index));
            AnyItemPicked?.Invoke(new ItemPickupEventData(Items[index], index));
        }
示例#2
0
        protected void OnMouseClick(object sender, EventArgs e)
        {
            var cursorPos     = Cursor.Position;
            var centerBoxLeft = Width / 2 - ItemBoxSize.Width / 2;

            if (cursorPos.X >= centerBoxLeft && cursorPos.Y <= centerBoxLeft + ItemBoxSize.Width)
            {
                ItemPicked?.Invoke(this, null);
            }
            else if (cursorPos.X < centerBoxLeft)
            {
                SelectedIndex--;
            }
            else if (cursorPos.X > centerBoxLeft + ItemBoxSize.Width)
            {
                SelectedIndex++;
            }
        }
示例#3
0
        private void OnButtonA(object sender, GamePadEventArgs args)
        {
            if (_activeButtonIndex < 0)
            {
                return;
            }

            var model = _buttons[_activeButtonIndex];

            if (model != null)
            {
                ItemPicked?.Invoke(model.FrameworkElement, model);
            }
            else
            {
                var elms = ButtonsCanvas.Children.OfType <PadOS.CustomControls.AlphaSilhouetteImage>().ToArray();
                ItemPicked?.Invoke(elms[_activeButtonIndex], null);
            }
        }
示例#4
0
 /// <summary>
 /// Notifies the instance that items were handled in order to keep the statistics up-to-date.
 /// </summary>
 /// <param name="pod">The corresponding pod.</param>
 /// <param name="bot">The corresponding bot.</param>
 /// <param name="oStation">The corresponding station.</param>
 /// <param name="item">The item that was picked.</param>
 internal void NotifyItemHandled(Pod pod, Bot bot, OutputStation oStation, ItemDescription item)
 {
     // Store the number of handled items
     pod.StatItemsHandled++;
     StatOverallItemsHandled++;
     // Mark every item in the history with a timestamp
     _statItemHandlingTimestamps.Add(new ItemHandledDatapoint(Controller.CurrentTime - StatTimeStart, bot.ID, pod.ID, oStation.ID));
     // Flush data points in case there are too many already
     if (_statItemHandlingTimestamps.Count > STAT_MAX_DATA_POINTS)
     {
         StatFlushItemsHandled();
     }
     // Keep track of the maximal number of handled items
     if (StatMaxItemsHandledByPod < pod.StatItemsHandled)
     {
         StatMaxItemsHandledByPod = pod.StatItemsHandled;
     }
     // Raise the event
     ItemPicked?.Invoke(pod, bot, oStation, item);
 }
示例#5
0
 public IEnumerator Show(ItemPicked item)
 {
     item.transform.SetParent(transform);
     item.GetComponent <RectTransform>().position = pos.position;
     yield return(new WaitForSeconds(3));
 }
示例#6
0
    void Update()
    {
        if (!isOpen)
        {
            if (Input.GetKeyDown(KeyCode.F))
            {
                if (canOpen)
                {
                    if (hasItem)
                    {
                        isOpen = true;
                        spriteRenderer.sprite     = items[randomItem].GetComponent <SpriteRenderer>().sprite;
                        spriteRendererSelf.sprite = chestOpened;
                    }
                    else
                    {
                        isOpen = true;
                        spriteRenderer.sprite     = weapons[whatWeapon].GetComponentInChildren <SpriteRenderer>().sprite;
                        spriteRendererSelf.sprite = chestOpened;
                    }
                }
            }
        }
        else
        {
            if (Input.GetKeyDown(KeyCode.F))
            {
                if (canOpen)
                {
                    if (hasItem)
                    {
                        if (!EffectManager.list.ContainsKey(items[randomItem].GetComponent <Effect>()))
                        {
                            EffectManager.list.Add(items[randomItem].GetComponent <Effect>(), 1);
                        }
                        else
                        {
                            Effect temp_effect = items[randomItem].GetComponent <Effect>();
                            EffectManager.list[items[randomItem].GetComponent <Effect>()] += 1;
                            temp_effect.UpgradeEffectBasedOnCount(EffectManager.list[temp_effect]);
                        }

                        ItemPicked notificationI = Instantiate(notification, notification.transform.position, Quaternion.identity);
                        notificationI.title.text       = items[randomItem].GetComponent <Effect>().name;
                        notificationI.description.text = items[randomItem].GetComponent <Effect>().description;
                        notificationI.image.sprite     = spriteRenderer.sprite;
                        notifications.StartCoroutine(notifications.Show(notificationI));
                        Destroy(spriteRenderer);
                        Destroy(gameObject.GetComponent <Chest>());
                    }
                    else
                    {
                        if (inventory.isSlotTaken)
                        {
                            isSlotTaken();
                        }
                        else
                        {
                            Sprite sprite = spriteRenderer.sprite;
                            inventory.slots[1].sprite             = sprite;
                            inventory.weapons[1]                  = Instantiate(weapons[whatWeapon], playerGun.gun.position, playerGun.gun.rotation);
                            inventory.weapons[1].transform.parent = player.transform;
                            inventory.weapons[1].SetActive(false);
                            inventory.isSlotTaken = true;
                            Destroy(spriteRenderer);
                            Destroy(gameObject.GetComponent <Chest>());
                        }
                    }
                }
            }
        }
    }
示例#7
0
        private void OnItemAdded(ItemInfo itemAdded)
        {
            ItemEventArgs itemEventArgs = new ItemEventArgs(itemAdded);

            ItemPicked?.Invoke(this, itemEventArgs);
        }