예제 #1
0
파일: Player.cs 프로젝트: AlchSet/GBZeldoid
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.name);

        if (collision.gameObject.tag == "Arrow")
        {
            //ContactFilter2D filter = new ContactFilter2D();
            //Collider2D[] cols = new Collider2D[2];


            //collision.OverlapCollider(filter, cols);

            //foreach (Collider2D d in cols)
            //{
            //    Debug.Log(d.name);
            //}

            Damageable.CollisionInfo i = new Damageable.CollisionInfo();
            i.position = collision.transform.position;
            i.totalDmg = 1;


            dmg.DealDamage(i);

            Debug.Log("OUCH");
            Destroy(collision.gameObject);
        }
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        elapsed += Time.deltaTime;

        anim.SetFloat("tick", Mathf.Lerp(1, 5, elapsed / Duration));

        if (elapsed >= Duration && !hasExploded)
        {
            anim.Play("Bomb Explode");
            hasExploded = true;
            p.Emit(50);

            Collider2D[] targets = Physics2D.OverlapCircleAll(transform.position, range, hitLayers);

            Damageable.CollisionInfo i = new Damageable.CollisionInfo();

            i.totalDmg       = 3;
            i.knockbackForce = 6;
            i.position       = transform.position;
            sfx.PlayOneShot(sfx.clip);

            foreach (Collider2D t in targets)
            {
                t.GetComponent <Damageable>().DealDamage(i);
            }
            StartCoroutine(CleanUp());
        }
    }
예제 #3
0
파일: Player.cs 프로젝트: AlchSet/GBZeldoid
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            Damageable.CollisionInfo i = new Damageable.CollisionInfo();
            i.position = collision.transform.position;
            i.totalDmg = 1;


            dmg.DealDamage(i);

            Debug.Log("OUCH");
        }
    }
예제 #4
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            Debug.Log("ENEMY SHIELDED");

            //collision.gameObject.GetComponent<Damageable>().OnHit.Invoke();

            Damageable.CollisionInfo i = new Damageable.CollisionInfo();
            i.position = transform.position;
            i.totalDmg = 0;
            collision.gameObject.GetComponent <Damageable>().DealDamage(i);
        }
    }
예제 #5
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.layer == LayerMask.NameToLayer("Enemy"))
        {
            Damageable.CollisionInfo info = new Damageable.CollisionInfo();

            info.totalDmg       = 1;
            info.knockbackForce = 10;
            info.position       = collision.transform.root.position;
            //info.position=transform.position-
            damageable.DealDamage(info);

            //damageable.DealDamage(1);
            Debug.Log("ENEMY HURTS ME");
        }
    }
예제 #6
0
    // Update is called once per frame
    void Update()
    {
        if (isActive)
        {
            Collider2D[] d = Physics2D.OverlapBoxAll(transform.position, boxSize, Vector2.Angle(Vector2.up, transform.up), target);
            //Debug.Log(transform.eulerAngles.z);
            //Debug.Log(d.Length);

            foreach (Collider2D o in d)
            {
                //Debug.Log(o.name);
                if (o.gameObject != owner)
                {
                    if (o.tag != "Rock")
                    {
                        Damageable.CollisionInfo i = new Damageable.CollisionInfo();
                        //i.position = transform.position;
                        i.position = owner.transform.position;

                        i.totalDmg       = 1;
                        i.knockbackForce = rootWPN.knockbackforce;
                        o.GetComponent <Damageable>().DealDamage(i);
                        //hitFX.transform.position = o.transform.position;
                        //hitFX.Emit(20);
                    }

                    //if(o.gameObject.layer==LayerMask.NameToLayer("Enemy"))
                    //{
                    //    if(hitFX)
                    //    {
                    //        hitFX.transform.position = o.transform.position;
                    //        hitFX.Emit(20);
                    //    }

                    //}
                    //o.GetComponent<Damageable>().DealDamage(1);
                }
            }
        }
        else
        {
        }
    }
예제 #7
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (damageable)
        {
            if (collision.tag == "Enemy")
            {
                //RaycastHit2D hit = Physics2D.Linecast(transform.position, collision.transform.position);



                Damageable.CollisionInfo i = new Damageable.CollisionInfo();

                i.knockbackForce = 5;

                i.position = collision.transform.parent.position;
                i.totalDmg = 1;


                damageable.DealDamage(i);

                //damageable.DealDamage(1);

                //PlayHitStun();
                Debug.Log("OUCH");
            }

            if (collision.tag == "Health1")
            {
                damageable.HealAdditive(3);

                Destroy(collision.gameObject);
            }
        }

        if (collision.tag == "Fire")
        {
            Debug.Log("BURN");

            Status.StartBurning();
        }
    }
예제 #8
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        //Debug.Log(collision.name);


        hitObject = collision.transform;

        if (hurtenemies)
        {
            if (collision.gameObject.layer == LayerMask.NameToLayer("Damageable"))
            {
                Debug.Log("HURT ENEMY");

                Damageable.CollisionInfo i = new Damageable.CollisionInfo();


                i.position       = transform.position;
                i.knockbackForce = 1;
                i.totalDmg       = 1;

                collision.gameObject.GetComponent <Damageable>().DealDamage(i);

                //Destroy(gameObject);
                CleanUp.Invoke();
            }
        }

        if (collision.gameObject.layer != LayerMask.NameToLayer("TransparentFX") &&
            collision.gameObject.layer != LayerMask.NameToLayer("Collectable") &&
            collision.gameObject.layer != LayerMask.NameToLayer("Bounds")
            //&& collision.gameObject.layer != LayerMask.NameToLayer("Damageable")
            )
        {
            if (collision.gameObject.layer == LayerMask.NameToLayer("Damageable"))
            {
                if (collision.GetComponent <Damageable>() == owner)
                {
                    //Debug.Log("HITTING SLEF");
                }
                else
                {
                    if (collision.gameObject.tag == "Enemy")
                    {
                    }
                    else
                    {
                        Damageable.CollisionInfo i = new Damageable.CollisionInfo();


                        i.position       = transform.position;
                        i.knockbackForce = 1;
                        i.totalDmg       = 1;

                        collision.gameObject.GetComponent <Damageable>().DealDamage(i);

                        //Destroy(gameObject);
                        CleanUp.Invoke();

                        Debug.Log("DEAL DMG");
                    }
                }
            }
            else
            {
                if (collision.tag != "Projectile")
                {
                    CleanUp.Invoke();
                }
                if (collision.tag == "Arrow")
                {
                    Debug.Log("Hit Arrow");
                    Destroy(collision.gameObject);
                    CleanUp.Invoke();
                }

                //Destroy(gameObject);
            }
        }

        if (collision.gameObject.layer == LayerMask.NameToLayer("Breakable"))
        {
            if (hurtBreakable)
            {
                Damageable.CollisionInfo i = new Damageable.CollisionInfo();

                i.position       = transform.position;
                i.knockbackForce = 1;
                i.totalDmg       = 1;

                collision.gameObject.GetComponent <Damageable>().DealDamage(i);

                //Destroy(gameObject);
                CleanUp.Invoke();
            }
            else
            {
                //Destroy(gameObject);
                CleanUp.Invoke();
            }
        }
    }
예제 #9
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Area")
        {
            Debug.Log("CHANGE AREA");
            //if(lastArea!=null)
            //{
            //    lastArea.DisableEnemies();
            //}
            currentArea = collision.GetComponent <Area>();

            //currentArea.EnableEnemies();

            //lastArea = currentArea;
            if (!changearea)
            {
                StartCoroutine(ChangeArea(collision.transform.position));
            }
        }


        if (collision.tag == "Teleport")
        {
            Debug.Log("TELE INDORS");

            tele = collision.gameObject.GetComponent <Teleporter>();
            StartCoroutine(TeleportPlayer());
        }

        //if (damageable)
        //{
        //    if (collision.tag == "Enemy")
        //    {
        //        Damageable.CollisionInfo i = new Damageable.CollisionInfo();
        //        i.position = collision.transform.position;
        //        i.totalDmg = 1;


        //        damageable.DealDamage(i);
        //        //PlayHitStun();
        //        Debug.Log("OUCH");
        //    }

        //    if (collision.tag == "Health1")
        //    {
        //        damageable.HealAdditive(3);

        //        Destroy(collision.gameObject);

        //    }



        //}

        //if (collision.tag == "Fire")
        //{
        //    Debug.Log("BURN");

        //    Status.StartBurning();

        //}


        //--------------------------------
        if (collision.tag == "Gold")
        {
            Debug.Log("COIN");
            if (OnCollectCoin != null)
            {
                OnCollectCoin(100);
            }

            Destroy(collision.gameObject);

            //Debug.Log("BURN");

            //Status.StartBurning();
        }
        //if (collision.tag == "HealthUp")
        //{
        //    damageable.UpgradeHealth(2);
        //    sfx.PlayOneShot(healthSFX);
        //    Destroy(collision.gameObject);

        //}
        if (collision.tag == "Heal")
        {
            damageable.HealAdditive(12);
            sfx.PlayOneShot(healthSFX);
            Destroy(collision.gameObject);
        }
        if (collision.tag == "ArrowCollect")
        {
            //damageable.HealAdditive(1);

            bow.AddAmmo(3);
            sfx.PlayOneShot(healthSFX);
            Destroy(collision.gameObject);
        }
        if (collision.tag == "BombCollect")
        {
            //damageable.HealAdditive(1);

            bomb.AddAmmo(3);
            sfx.PlayOneShot(healthSFX);
            Destroy(collision.gameObject);
        }

        //-------------------------------------


        //if(collision.gameObject.layer==LayerMask.NameToLayer("Collectable"))
        //{
        //    Debug.Log("Collect");
        //    collision.GetComponent<Collectable>().OnCollect.Invoke();
        //}



        if (collision.tag == "Projectile")
        {
            collision.GetComponent <Projectile>().CleanUp.Invoke();

            Damageable.CollisionInfo i = new Damageable.CollisionInfo();
            i.position = -collision.transform.position;
            i.totalDmg = 1;

            bow.Dispose();
            damageable.DealDamage(i);
        }

        //collision.
        //Debug.Log(collision.name);
    }