예제 #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("NPC") || other.CompareTag("Player") || other.CompareTag("Ragdoll"))
        {
            float angle = Vector2Extension.DirectionAngle(other.transform.position - transform.position);

            if (angle > 180 && angle < 270)
            {
                float amountOver = angle - 180;
                angle -= 2 * amountOver;
            }
            else if (angle >= 270)
            {
                float amountUnder360 = 360 - angle;
                angle = amountUnder360;
            }

            if (other.CompareTag("Ragdoll"))
            {
                DixieRagdoll ragdoll = other.GetComponent <DixieRagdoll>();
                if (ragdoll != null)
                {
                    ragdoll.SetForceDirection(power, angle);
                }
            }
            else
            {
                HealthSystem healthSystem = other.GetComponent <HealthSystem>();


                healthSystem.TakeDamage(25, angle);
            }
        }
    }
    public override void Die(float attackDamage, float angleOfAttack)
    {
        // Need to make ragdoll fly away in direction of hit
        DixieRagdoll ragdoll = Instantiate <GameObject>(DixieRagdollPrefab, transform.position, Quaternion.identity).GetComponent <DixieRagdoll>();

        ragdoll.GetComponent <SpriteRenderer>().flipX = GetComponentInChildren <SpriteRenderer>().flipX;
        ragdoll.SetForceDirection(attackDamage, angleOfAttack);
        DixieSpawner.numberOfDixies--;



        Destroy(gameObject);
    }
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.CompareTag("NPC"))
        {
            HealthSystem health = other.GetComponent <HealthSystem>();
            health.TakeDamage(damage, angleOfAttack);
        }

        if (other.CompareTag("Ragdoll"))
        {
            DixieRagdoll ragdoll = other.GetComponent <DixieRagdoll>();
            ragdoll.SetForceDirection(damage, angleOfAttack);
        }
    }