void Start()
    {
        EquipmentController = GetComponent <EquipmentController>();
        PlayerPickUp        = GetComponent <PlayerPickUpHandler>();

        _items = new Dictionary <int, List <GridItem> >();
    }
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (other.gameObject.CompareTag(tagToCompare))
        {
            if (other.gameObject.GetComponentInChildren <PlayerPickUpHandler>() != null)
            {
                PlayerPickUpHandler otherPickUpHandler = other.gameObject.GetComponentInChildren <PlayerPickUpHandler>();
                int difference = otherPickUpHandler.pickUpCount - pickUpHandler.pickUpCount;

                //if other planet is smaller and you were boosting
                if (difference > 0 && playerMovement.isBoosting)
                {
                    ProCamera2D.Instance.GetComponent <ProCamera2DShake>().Shake(.3f, new Vector2(difference, difference), 2, 0f, Vector3.Angle(this.transform.position, other.gameObject.transform.position), default(Vector3), .1f);
                    onCollision.Invoke();

                    Vector2 direction = Vector3.Normalize(other.transform.position - transform.position);

                    otherPickUpHandler.GetComponentInParent <Rigidbody2D>()
                    .AddForce(direction * difference * forceScaleMultiplier);

                    other.gameObject.GetComponent <PlayerHealth>().DecrementHealth();
                    other.gameObject.GetComponent <PlayerMovement>().Knock();
                    hit = true;
                }
            }
        }
    }
Exemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D c)
    {
        PlayerPickUpHandler temp = c.GetComponent <PlayerPickUpHandler>();

        if (temp != null)
        {
            //sound trigger
            temp.ChangeSize(+1);
            if (OnPickUp != null)
            {
                OnPickUp();
            }

            Destroy(gameObject);
        }
    }
 private void Awake()
 {
     rigidB         = GetComponentInParent <Rigidbody2D>();
     pickUpHandler  = GetComponent <PlayerPickUpHandler>();
     playerMovement = GetComponentInParent <PlayerMovement>();
 }