Example #1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (other.transform.gameObject.tag == "Enemy" || other.transform.gameObject.tag == "Boss")
        {
            target = MathK.FindNearTarget("Enemy", other.gameObject);

            if (target != null)
            {
                stats.bounce--;
            }
            else
            {
                target = null;
            }
            return;
        }

        if (other.transform.tag == "Wall")
        {
            Vector2 incomingVec = Vector2.zero;
            if (target == null)
            {
                incomingVec = other.transform.position - new Vector3(0f, -2f, 0f);
            }
            else
            {
                incomingVec = other.transform.position - target.transform.position;
            }

            vecMove = incomingVec.normalized + other.contacts[0].normal * (-2 * Vector2.Dot(incomingVec.normalized, other.contacts[0].normal));
        }
    }
Example #2
0
    public override sealed void Init()
    {
        SoundManager.instance.PlaySound("칼 던지는 효과음");

        stats.maxBounce   = PlayerStats.instance.stats.knifeMaxBounce;
        stats.knifeDamage = PlayerStats.instance.stats.knifeDamage;

        target  = MathK.FindNearTarget("Enemy", gameObject);
        player  = GameObject.Find("Line");
        vecMove = transform.position;

        stats.bounce = stats.maxBounce;
        base.Init();

        Invoke("Release", stats.lifeTime);
    }