Esempio n. 1
0
 void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.tag == collector)
     {
         onCollected.Invoke(this);
     }
 }
Esempio n. 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);
        }
    }
Esempio n. 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();
        }
    }
Esempio n. 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);
 }
Esempio n. 7
0
        public static void PickupCollected(Pickup p)
        {
            Collected += 1;
            OnCollected?.Invoke();

            if (Collected >= TotalPickups)
            {
                OnWin?.Invoke();
            }
        }
Esempio n. 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;
     }
 }
Esempio n. 9
0
    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();
        }
    }
Esempio n. 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();
            }
        }
Esempio n. 11
0
 internal void Collect()
 {
     OnCollected?.Invoke(this, EventArgs.Empty);
 }
Esempio n. 12
0
        public void Interact()
        {
            OnCollected?.Invoke(this);

            Destroy(gameObject);
        }