예제 #1
0
    private void OnBulletHit(Collider2D col)
    {
        if (col == null)
        {
            return;
        }
        GenericEnemy en  = col.GetComponent <GenericEnemy>();
        Vector2      vec = new Vector2((this.transform.position.x - lastposition.x), (this.transform.position.y - lastposition.y));

        if (en != null)
        {
            //if (col.isTrigger) return;
            en.TakeDamage(Damage, vec * 1f);
            Astronaut.TheAstronaut.tickHitMarker(Damage, (en.Health / en.MaxHealth) * (en.Alive?1f:0f), !en.Alive);
            GameManager.TheGameManager.ignoreTutorialTip(TutorialSystem.TutorialTip.Shoot);
            if (RailSlug)
            {
                ParticleSystem p = GameObject.Instantiate(RailPierceParticles, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
                GameObject.Destroy(p.gameObject, 1f);
            }
            else
            {
                ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
                GameObject.Destroy(p.gameObject, 1f);
                Remove();
            }
            return;
        }
        IceBlock ib = col.GetComponentInParent <IceBlock>();

        if (ib != null)
        {
            //be.TakeDamage(Damage, vec * 1f);//Damage
            ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
            ib.Remove();
            if (RailSlug)
            {
            }
            else
            {
                GameObject.Destroy(p.gameObject, 1f);

                Remove();
            }
            return;
        }
        BossGolem    bo       = col.GetComponent <BossGolem>();
        bool         weakspot = false;
        BossWeakSpot bwsp     = col.GetComponent <BossWeakSpot>();

        if (bwsp != null)
        {
            bo       = bwsp.MyBossGolem;
            weakspot = true;
        }
        if (bo != null)
        {
            if (col.Equals(bo.MyWeakSpot))
            {
                weakspot = true;
            }
            float dmg = Damage;
            if (weakspot)
            {
                float di = (dmg * 2f);
                if (di >= 1f)
                {
                    bo.CriticalHitEffect.Emit(1);
                    bo.CriticalHitEffectSub.Emit(1);
                    bo.CriticalSparks.Emit((int)(20 * (dmg / 40f)));
                    Astronaut.PlayBossCriticalHitSound(bo.Health / bo.MaxHealth);
                    Astronaut.TheAstronaut.tickHitMarker(dmg, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 1f : 0f), bo.Defeated);
                }
                else
                {
                    bo.damagelayover = (bo.damagelayover + di);
                    if ((bo.damagelayover) >= 1f)
                    {
                        bo.damagelayover -= 1f;
                        bo.CriticalHitEffect.Emit(1);
                        bo.CriticalHitEffectSub.Emit(1);
                        bo.CriticalSparks.Emit(20);
                        Astronaut.PlayBossCriticalHitSound(bo.Health / bo.MaxHealth);
                        Astronaut.TheAstronaut.tickHitMarker(dmg, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 1f : 0f), bo.Defeated);
                    }
                }
                bo.TakeDamage(di, vec * 1f);//Damage
            }
            else
            {
                bo.TakeDamage(dmg, vec * 1f);//Damage
            }
            //Astronaut.TheAstronaut.tickHitMarker(Damage, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 0f : 1f), bo.Defeated);
            weakspot = false;
            if (RailSlug)
            {
            }
            else
            {
                ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
                GameObject.Destroy(p.gameObject, 1f);
                Remove();
            }
            return;
        }
        BreakableIceWall be = col.GetComponent <BreakableIceWall>();

        if (be != null)
        {
            be.TakeDamage(Damage, vec * 1f);//Damage
            Astronaut.TheAstronaut.tickHitMarker(Damage, (be.Health / be.MaxHealth) * (be.Alive ? 1f : 0f), !be.Alive);
            if (RailSlug)
            {
            }
            else
            {
                ParticleSystem p = GameObject.Instantiate(DamageImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
                GameObject.Destroy(p.gameObject, 1f);
                Remove();
            }
            return;
        }

        if (col.gameObject.CompareTag("Water"))
        {
            //Splash
            MyRigidbody.velocity = (MyRigidbody.velocity * .5f);
            Damage *= .5f;
            return;
        }



        ParticleSystem ps = GameObject.Instantiate(GeometryImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));

        GameObject.Destroy(ps.gameObject, 1f);
        //Collision with geometry
        Remove();
    }