Exemple #1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == collector)
     {
         onCollected.Invoke(this);
     }
 }
Exemple #2
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        collectable = collision.GetComponent <Collectable>();

        if (collectable)
        {
            collectable.Collect();
            OnCollected?.Invoke(collectable.value);
        }

        switch (collision.tag)
        {
        case "Danger":
            TakeDamage(25, collision);
            break;

        case "Respawn":
            respawnPoint = transform.position;
            break;

        case "JumpPad":
            GetComponent <Movement>().JumpUp(jumpPadJumpMultiplier);
            break;

        case "enemy":
            TakeDamage(20, collision);
            break;

        default:
            break;
        }
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.CompareTag("Player"))   //health, ammo, experience,
        {
            switch (Type)
            {
            case "Heal":
                collision.gameObject.GetComponent <Player>().AddHealth(_bonusHeal);
                break;

            case "Ammo":
                collision.gameObject.GetComponent <Player>().AddAmmo(_bonusAmmo);
                break;

            case "Exp":
                collision.gameObject.GetComponent <Player>().AddExp(_expGained);
                break;

            default:
                break;
            }
            OnCollected?.Invoke();
            Destroy(gameObject);
        }
    }
Exemple #4
0
    private void OnMouseUp()
    {
        mouseUpPosition = transform.position;
        onHold          = false;

        Collider2D collider = Physics2D.OverlapCircle(transform.position, berryCollider.bounds.extents.x, LayerMask.GetMask(BASKET_LAYER));

        if (collider != null)
        {
            Basket _foundBasket = collider.GetComponent <Basket>();

            if (_foundBasket != null)
            {
                if (fruitData.fruitType == _foundBasket.basket.basketFruitType)
                {
                    MinimizeBerry();
                    correctBasket = true;
                    _foundBasket.AddBerry();
                    OnCollected?.Invoke();
                }
                else
                {
                    wrongParticlesInstance.GetComponent <ParticleSystemRenderer>().material = fruitData.berryVFXMaterial;
                    Instantiate(wrongParticlesInstance, this.transform.position, Quaternion.identity);
                    ReturnBerry();
                }
            }
        }
        else
        {
            ReturnBerry();
        }
    }
Exemple #5
0
        void OnCollect(ScrollingObject scrollingObject)
        {
            scrollingObject.Stop();

            m_onCollected?.Invoke(this);

            m_poolManager.ReturnPoolItem(this);
        }
 private void DoCollect()
 {
     Collect();
     _isCollected = true;
     OnCollected?.Invoke(this);
     _effect.DetachAndStop();
     Destroy(gameObject);
 }
        public static void PickupCollected(Pickup p)
        {
            Collected += 1;
            OnCollected?.Invoke();

            if (Collected >= TotalPickups)
            {
                OnWin?.Invoke();
            }
        }
Exemple #8
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == "Player" && BoxBehaviour.inGame)
     {
         onCollected?.Invoke(bonusScore);
         //Debug.Log("Player Collected Bonus. Adding score of " + bonusScore);
         //gameObject.SetActive(false);
         if (GameSettings.sfxOn)
         {
             transform.GetChild(0).gameObject.SetActive(true);
         }
         GetComponent <SphereCollider>().enabled = false;
         GetComponent <MeshRenderer>().enabled   = false;
         enabled = false;
     }
 }
    private void Update()
    {
        if (!target)
        {
            return;
        }
        var direction = (target.position - transform.position).normalized;

        transform.position += direction * SPEED * Time.deltaTime;

        if (Vector3.Distance(target.position, transform.position) < 0.5f)
        {
            gameObject.SetActive(false);
            OnCollected?.Invoke();
        }
    }
Exemple #10
0
        private void OnMouseUp()
        {
            _dragging = false;

            transform.localScale = Vector3.one;
            _material.SetFloat("_Highlight", 0f);
            _collider.enabled = true;

            Chest.Instance.Close();

            if (Chest.Instance.IsHovered())
            {
                Player.Instance.AddTreasure();
                OnCollected?.Invoke();
                Free();
            }
            else
            {
                OnDropped?.Invoke();
            }
        }
Exemple #11
0
 internal void Collect()
 {
     OnCollected?.Invoke(this, EventArgs.Empty);
 }
Exemple #12
0
        public void Interact()
        {
            OnCollected?.Invoke(this);

            Destroy(gameObject);
        }