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

            return(Task.CompletedTask);
        }
Exemplo n.º 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);
    }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public virtual void OnPickedUp(PlayerEventArgs e)
 {
     AssertNotDisposed();
     PickedUp?.Invoke(this, e);
 }
Exemplo n.º 8
0
 private void OnPickedUp()
 {
     PickedUp?.Invoke(this, (PointsEventArgs)EventArgs.Empty);
 }
Exemplo n.º 9
0
 public void PickUp()
 {
     Debug.Log("pick up a potion");
     PickedUp?.Invoke(this);
 }
Exemplo n.º 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);
 }
Exemplo n.º 11
0
 public override void OnExit(BaseTower entity) => PickedUp.OnExit(entity);
Exemplo n.º 12
0
 public override void Draw(BaseTower entity) => PickedUp.Draw(entity);
Exemplo n.º 13
0
 public override void Update(BaseTower entity, float delta)
 {
     PickedUp.Update(entity, delta);
     entity.ZIndex = 10;
 }
Exemplo n.º 14
0
 protected virtual void OnPickedUp(BountyRunePickedupEventAegs e)
 {
     PickedUp?.Invoke(this, e);
 }
Exemplo n.º 15
0
 public void PickUp()
 {
     PickedUp?.Invoke();
 }
Exemplo n.º 16
0
 private void OnPickedUp()
 {
     PickedUp?.Invoke(this, EventArgs.Empty);
 }