コード例 #1
0
 public void SetupTest()
 {
     go           = new GameObject();
     bossWeakSpot = go.AddComponent <ConcreteWeakSpot>();
 }
コード例 #2
0
    public ParticleSystem CartoonImpact;//Draw some corny start particles
    private void OnGrenadeHit(Collider2D col)
    {
        GenericEnemy en  = col.GetComponent <GenericEnemy>();
        Vector2      vec = new Vector2((this.transform.position.x - lastposition.x), (this.transform.position.y - lastposition.y));
        float        dmg = Damage;

        if ((DirectHit != null) && col.Equals(DirectHit))
        {
            dmg = (Damage + DIRECTDAMAGE);
        }
        else
        {
            float mag = (col.transform.position - ExplosionPosition).magnitude;
            dmg = (Mathf.Lerp(Damage, Damage * MINDAMAGERATIO, Mathf.Clamp01(mag / BLASTRADIUS)));
        }
        if (en != null)
        {
            //if (col.isTrigger) return;
            en.TakeDamage(dmg, vec * 1f);

            Astronaut.TheAstronaut.tickHitMarker(dmg, (en.Health / en.MaxHealth) * (en.Alive ? 1f : 0f), !en.Alive);
            explode();
            //ParticleSystem p = GameObject.Instantiate(CartoonImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
            //GameObject.Destroy(p.gameObject, 1f);

            return;
        }
        IceBlock ib = col.GetComponentInParent <IceBlock>();

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


            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 di = dmg;
            if (weakspot)
            {
                di = (di * 2f);
                if (di >= 1f)
                {
                    bo.CriticalHitEffect.Emit(1);
                    bo.CriticalHitEffectSub.Emit(1);
                }
                else
                {
                    bo.damagelayover = (bo.damagelayover + dmg);
                    if ((bo.damagelayover) >= 1f)
                    {
                        bo.damagelayover -= 1f;
                        bo.CriticalHitEffect.Emit(1);
                        bo.CriticalHitEffectSub.Emit(1);
                    }
                }
                bo.TakeDamage(di, vec * 1f);//Damage
            }
            else
            {
                bo.TakeDamage(dmg, vec * 1f);//Damage
            }

            explode();
            Remove();
            //Astronaut.TheAstronaut.tickHitMarker(Damage, (bo.Health / bo.MaxHealth) * (bo.Defeated ? 0f : 1f), bo.Defeated);
            //ParticleSystem p = GameObject.Instantiate(CartoonImpact, this.transform.position, Quaternion.LookRotation(-new Vector3(vec.x, vec.y, 0f)));
            //GameObject.Destroy(p.gameObject, 1f);

            return;
        }
        BreakableIceWall be = col.GetComponent <BreakableIceWall>();

        if (be != null)
        {
            be.TakeDamage(dmg, vec * 1f);//Damage
            Astronaut.TheAstronaut.tickHitMarker(dmg, (be.Health / be.MaxHealth) * (be.Alive ? 1f : 0f), !be.Alive);
            explode();
            //ParticleSystem p = GameObject.Instantiate(CartoonImpact, 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;
        }


        explode();

        Remove();
    }
コード例 #3
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();
    }