private void Start()
    {
        movementController = GetComponent <PlayerMovementController>();
        movementController.SetTarget(MainPlayer.mainPlayer.transform);
        movementController.HandRotation.target = MainPlayer.mainPlayer.transform;

        harmable = GetComponent <Harmable>();
    }
Example #2
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        List <Collider2D> results = new List <Collider2D>();

        Physics2D.OverlapCollider(explodeCollider, new ContactFilter2D(), results);
        foreach (var r in results)
        {
            Harmable harmable = r.gameObject.GetComponent <Harmable>();
            if (harmable != null)
            {
                float distance = (harmable.transform.position - transform.position).magnitude;
                harmable.Harm(distance / 5f * 100f, Vector2.zero);
            }
        }

        foreach (var i in items)
        {
            ItemResolver.Instance.SpawnItem(transform.position, i, 1);
        }

        Destroy(this.gameObject);
    }