Ejemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Explosion")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage * 9.0f + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint, true);
        }
    }
Ejemplo n.º 2
0
    void TickDmg()
    {
        TickTimer += Time.fixedDeltaTime;
        if (TickTimer < 0.5f)
        {
            return;
        }

        TickTimer = 0.0f;
        if (DmgCount <= 0)
        {
            Die();
            return;
        }

        if (SelfBullet == null)
        {
            SelfBullet = transform.parent.GetComponent <Bullet>();
        }
        float damage = GameManager.Inst().UpgManager.BData[SelfBullet.GetBulletType()].GetDamage();
        float atk    = GameManager.Inst().UpgManager.BData[SelfBullet.GetBulletType()].GetAtk();
        float dmg    = damage + atk;

        if (SelfBullet.IsReinforce)
        {
            dmg *= 2;
        }
        SelfBullet.BloodSuck(dmg);

        GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");

        //hit.transform.position = Col.ClosestPoint(AttachedObj.transform.position);
        hit.transform.position = AttachedObj.transform.position + AttachPoint;

        AttachedObj.OnHit(dmg, SelfBullet.IsReinforce, hit.transform.position);
        DmgCount--;
    }
Ejemplo n.º 3
0
    void OnTriggerEnter2D(Collider2D collision)
    {
        if (IsFinish)
        {
            return;
        }

        if (collision.gameObject.tag == "BlockBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);
            collision.gameObject.SetActive(false);

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = collision.ClosestPoint(transform.position);

            Damage(dmg, bullet.IsReinforce);
        }
        else if (collision.gameObject.tag == "Laser")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = collision.ClosestPoint(transform.position);

            Damage(dmg, bullet.IsReinforce);
        }
        else if (collision.gameObject.tag == "PierceBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = collision.ClosestPoint(transform.position);

            Damage(dmg, bullet.IsReinforce);
        }
        else if (collision.gameObject.tag == "Chain")
        {
            Chain bullet = collision.gameObject.GetComponent <Chain>();
            bullet.HitEnemy(gameObject);

            float damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = collision.ClosestPoint(transform.position);

            Damage(dmg, bullet.IsReinforce);
        }
        else if (collision.gameObject.tag == "EquipBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            bullet.BloodSuck(dmg);

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = collision.ClosestPoint(transform.position);

            Damage(dmg, bullet.IsReinforce);
        }
    }
Ejemplo n.º 4
0
    void OnTriggerStay2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "HitArea")
        {
            return;
        }

        if (collision.gameObject.tag == "BlockBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            if (CurHP <= dmg)
            {
                bullet.BloodSuck(dmg);
            }

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint);

            collision.gameObject.SetActive(false);
        }
        else if (collision.gameObject.tag == "Laser")
        {
            Bullet bullet = collision.transform.parent.gameObject.GetComponent <Bullet>();
            float  damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float  atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float  dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            if (CurHP <= dmg)
            {
                bullet.BloodSuck(dmg);
            }

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint);
        }
        else if (collision.gameObject.tag == "PierceBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            if (bullet == null)
            {
                bullet = collision.transform.parent.GetComponent <Bullet>();
            }
            float damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            if (CurHP <= dmg)
            {
                bullet.BloodSuck(dmg);
            }

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint);
        }
        else if (collision.gameObject.tag == "Chain")
        {
            Chain bullet = collision.gameObject.GetComponent <Chain>();
            bullet.HitEnemy(gameObject);

            float damage = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetDamage();
            float atk    = GameManager.Inst().UpgManager.BData[bullet.GetBulletType()].GetAtk();
            float dmg    = damage + atk;
            if (bullet.IsReinforce)
            {
                dmg *= 2;
            }
            if (CurHP <= dmg)
            {
                bullet.BloodSuck(dmg);
            }

            GameObject hit = GameManager.Inst().ObjManager.MakeObj("Hit");
            hit.transform.position = bullet.transform.position;

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint);
        }
        else if (collision.gameObject.tag == "EquipBullet")
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet>();
            float  dmg    = GameManager.Inst().Player.GetItem(bullet.InventoryIndex).Value;

            Vector2 hitPoint = collision.ClosestPoint(gameObject.transform.position);

            OnHit(dmg, bullet.IsReinforce, hitPoint);
        }
        else if (collision.gameObject.name == "EnemyBottom")
        {
            GameManager.Inst().UiManager.RedMask.gameObject.GetComponent <RedMask>().SetIsAlert(true);

            //아군 피격
            for (int i = 0; i < 5; i++)
            {
                if (HitArea == null)
                {
                    HitArea = transform.GetChild(0).GetComponent <HitArea>();
                }

                if (HitArea.HitObjects[i] == null)
                {
                    continue;
                }

                SubWeapon sub = HitArea.HitObjects[i].GetComponent <SubWeapon>();
                if (sub == null)
                {
                    HitArea.HitObjects[i].GetComponent <Player>().Damage(Atk);
                }
                else
                {
                    sub.Damage(Atk);
                }
                HitArea.HitObjects[i] = null;
            }

            if (GameManager.Inst().StgManager.Stage == 3)
            {
                FallEffect.gameObject.SetActive(false);
            }

            GameObject flame = GameManager.Inst().ObjManager.MakeObj("DamageFlame");
            flame.transform.position = collision.ClosestPoint(gameObject.transform.position);

            GameManager.Inst().ShkManager.Damage();

            //적 사망 처리
            CurHP        = Health;
            IsReflected  = false;
            IsInvincible = false;
            IsDot        = false;
            DotCheck();
            BodyScale = Vector3.one;
            CancelInvoke("StartMove");
            gameObject.SetActive(false);
        }
        else if (collision.gameObject.name == "Right" || collision.gameObject.name == "Left")
        {
            if (GameManager.Inst().StgManager.Stage == 2)
            {
                if (Type == EnemyType.BOSS || IsReflected)
                {
                    return;
                }

                float      rotZ = transform.rotation.eulerAngles.z;
                Quaternion rot  = Quaternion.Euler(0.0f, 0.0f, -rotZ);
                transform.rotation = rot;

                CurveTime   = 0.0f;
                IsReflected = true;
                Invoke("ReturnReflected", 1.0f);
            }
        }
    }