コード例 #1
0
 private void Collision(Collider2D coll)
 {
     if (Time.time >= PossibleActivation)
     {
         EnvironmentObject hit2 = coll.GetComponent <EnvironmentObject>();
         if (hit2 != null)
         {
             if (!IsProjectile || hit2.InterceptProjectiles)
             {
                 PossibleActivation = Time.time + CoolDownBetweenHits;
                 if (Damage != 0)
                 {
                     hit2.TakeDamage(Damage);
                 }
                 if (SpawnFxOnTargetInsteadOfSource)
                 {
                     foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                     {
                         GetComponent <DeathAnimation>().Spawn(coll.transform.position);
                     }
                 }
                 else
                 {
                     foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                     {
                         GetComponent <DeathAnimation>().Spawn(transform.position);
                     }
                 }
                 if (SingleUse)
                 {
                     Destroy(this.gameObject);
                     return;
                 }
             }
         }
     }
 }
コード例 #2
0
    private void Collision(Collider2D coll)
    {
        if (Time.time >= PossibleActivation)
        {
            /*
             * if (coll.CompareTag("Wall") || coll.CompareTag("PseudoWall"))
             * {
             *  GetComponent<DeathAnimation>().Spawn(transform.position);
             *  Destroy(this.gameObject);
             *  return;
             * }
             */
            Entity hit = coll.GetComponent <Entity>();
            if (hit != null)
            {
                if (Team != hit.Team)
                {
                    PossibleActivation = Time.time + CoolDownBetweenHits;
                    if (Damage != 0)
                    {
                        hit.TakeDamage(Damage, WeaponType);
                    }
                    if (SpawnFxOnTargetInsteadOfSource)
                    {
                        foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                        {
                            GetComponent <DeathAnimation>().Spawn(coll.transform.position);
                        }
                    }
                    else
                    {
                        foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                        {
                            GetComponent <DeathAnimation>().Spawn(transform.position);
                        }
                    }
                    foreach (Inflicter i in GetComponents <Inflicter>())
                    {
                        i.Inflict(coll.gameObject);
                    }
                    if (SingleUse)
                    {
                        Destroy(this.gameObject);
                        return;
                    }
                }
            }

            EnvironmentObject hit2 = coll.GetComponent <EnvironmentObject>();
            if (hit2 != null && AttackWalls)
            {
                if (!IsProjectile || hit2.InterceptProjectiles)
                {
                    PossibleActivation = Time.time + CoolDownBetweenHits;
                    if (Damage != 0)
                    {
                        hit2.TakeDamage(Damage);
                    }
                    if (SpawnFxOnTargetInsteadOfSource)
                    {
                        foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                        {
                            GetComponent <DeathAnimation>().Spawn(coll.transform.position);
                        }
                    }
                    else
                    {
                        foreach (DeathAnimation da in GetComponents <DeathAnimation>())
                        {
                            GetComponent <DeathAnimation>().Spawn(transform.position);
                        }
                    }
                    if (SingleUse)
                    {
                        Destroy(this.gameObject);
                        return;
                    }
                }
            }
        }
    }