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
 void FixedUpdate()
 {
     if (tag == "MekaGear")
     {
         if (!target.activeSelf)
         {
             target = GameObject.FindGameObjectWithTag("Enemy");
         }
         direction = target.transform.position - transform.position;
     }
     transform.position += direction * speed * Time.deltaTime;
     transform.rotation  = MathK.LookAngle(direction);
 }
Example #3
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);
    }
Example #4
0
 void Move()
 {
     if (target == null)
     {
         transform.position += vecMove.normalized * moveSpeed * Time.deltaTime;
         transform.rotation  = MathK.LookAngle(vecMove);
     }
     else
     {
         if (target.activeSelf)
         {
             transform.position = Vector3.Lerp(transform.position, target.transform.position, 10f * Time.deltaTime);
             transform.rotation = MathK.LookAngle(target.transform.position - transform.position);
         }
         else
         {
             target = null;
         }
     }
 }