Пример #1
0
 public void PickUp()
 {
     OnPickedUp();
     PickedUp?.Invoke(Card);
     // maybe card should not directly call Card.Accept
     Card.Accept();
 }
Пример #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag(requiredTag))
     {
         pickupObjectConfig.ApplyPickup(other.gameObject);
         PickedUp?.Invoke();
         Destroy(gameObject);
     }
 }
Пример #3
0
        public Task MarkAsPickedUpAsync(IEntity entityWhoPickedUp)
        {
            if (PickedUp != null)
            {
                return(PickedUp.Invoke(this, entityWhoPickedUp));
            }

            return(Task.CompletedTask);
        }
Пример #4
0
    public override bool PickUp(MonoBehaviour pickuper)
    {
        // If something that can be healed picked this up, heal it
        IHasHP toHeal       = pickuper as IHasHP;
        bool   healPickuper = toHeal != null;

        if (healPickuper)
        {
            toHeal.TakeHealing(healAmount);
        }

        PickedUp.Invoke();

        return(true);
    }
Пример #5
0
        private void PickUp()
        {
            var clickPosition = GetClickPosition();
            var clickedItem   = GetItemAt(clickPosition);

            if (clickedItem == null)
            {
                return;
            }

            FromPos = clickedItem.position;
            if (PickedUp != null)
            {
                PickedUp.Invoke(this, null);
            }

            item   = clickedItem.gameObject;
            state  = DndState.Drag;
            offset = FromPos - clickPosition;
        }
Пример #6
0
        /// <summary>
        /// Picks up this <see cref="Entity"/>.
        /// </summary>
        /// <param name="charEntity"><see cref="CharacterEntity"/> that is trying to pick up this <see cref="Entity"/>.</param>
        /// <returns>True if this <see cref="Entity"/> was successfully picked up, else false.</returns>
        public override bool Pickup(CharacterEntity charEntity)
        {
            // Check for invalid character
            if (charEntity == null)
            {
                const string errmsg = "Null charEntity specified.";
                if (log.IsWarnEnabled)
                {
                    log.Warn(errmsg);
                }
                Debug.Fail(errmsg);
                return(false);
            }

            // Check if the ItemEntity can be picked up
            if (!CanPickup(charEntity))
            {
                return(false);
            }

            // Convert to a character
            var character = charEntity as Character;

            if (character == null)
            {
                const string errmsg =
                    "Unable to convert CharacterEntity `{0}` to Character for some reason. " +
                    "Is there another type, besides Character, inheriting CharacterEntity?";
                if (log.IsErrorEnabled)
                {
                    log.ErrorFormat(errmsg, charEntity);
                }
                Debug.Fail(string.Format(errmsg, charEntity));
                return(false);
            }

            // Create a deep copy of the item to give to the character instead of giving them this item (its easier this way)
            var itemCopy    = (ItemEntity)DeepCopy();
            var amountGiven = character.GiveItem(itemCopy);

            // If nothing was given, then nothing happens... move on
            if (amountGiven <= 0)
            {
                Debug.Assert(amountGiven == 0);
                return(false);
            }

            // Find the new item amount
            var newAmount = (byte)Math.Max(Math.Min(Amount - amountGiven, byte.MaxValue), byte.MinValue);

            Debug.Assert(amountGiven > 0 && amountGiven <= Amount);

            // Update the amount property
            Amount = newAmount;

            // If all of the item was picked up, then destroy this item
            if (newAmount == 0)
            {
                Destroy();
            }

            // Notify listeners using the item copy since that was the one actually given to them
            if (PickedUp != null)
            {
                PickedUp.Raise(itemCopy, EventArgsHelper.Create(charEntity));
            }

            return(true);
        }
Пример #7
0
 public virtual void OnPickedUp(PlayerEventArgs e)
 {
     AssertNotDisposed();
     PickedUp?.Invoke(this, e);
 }
Пример #8
0
 private void OnPickedUp()
 {
     PickedUp?.Invoke(this, (PointsEventArgs)EventArgs.Empty);
 }
Пример #9
0
 public void PickUp()
 {
     Debug.Log("pick up a potion");
     PickedUp?.Invoke(this);
 }
Пример #10
0
 /// <summary>
 /// Gets picked up by the passed pickup-er. Returns true or false depending
 /// on whether the picking-up was successful.
 /// </summary>
 public virtual bool PickUp(MonoBehaviour pickuper)
 {
     PickedUp.Invoke();
     return(true);
 }
Пример #11
0
 public override void OnExit(BaseTower entity) => PickedUp.OnExit(entity);
Пример #12
0
 public override void Draw(BaseTower entity) => PickedUp.Draw(entity);
Пример #13
0
 public override void Update(BaseTower entity, float delta)
 {
     PickedUp.Update(entity, delta);
     entity.ZIndex = 10;
 }
Пример #14
0
 protected virtual void OnPickedUp(BountyRunePickedupEventAegs e)
 {
     PickedUp?.Invoke(this, e);
 }
Пример #15
0
 public void PickUp()
 {
     PickedUp?.Invoke();
 }
Пример #16
0
 private void OnPickedUp()
 {
     PickedUp?.Invoke(this, EventArgs.Empty);
 }