예제 #1
0
    protected void DetermineHit(Collision2D collision, bool destroysSelfOnHit)
    {
        Entity hitEntity = collision.gameObject.GetComponent <Entity>();

        if (hitEntity && hitEntity.affinity != affinity)
        {
            IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
            if (harmedObject != null)
            {
                harmedObject.ReceiveHit(DamageValue(), owner, gameObject);
                if (destroysSelfOnHit)
                {
                    DestroyMe();
                }
            }
        }
        else if (hitEntity && hitEntity.gameObject != owner)
        {
            IProjectilePassable iProjectilePassable = collision.gameObject.GetComponent(typeof(IProjectilePassable)) as IProjectilePassable;
            if (iProjectilePassable == null)
            {
                if (DestroysSelfOnFriendlyHit())
                {
                    DestroyMe();
                }
            }
        }
    }
예제 #2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        IHarmable harmedObject = collider.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;

        if (harmedObject != null)
        {
            Explode();
        }
    }
예제 #3
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;

        if (harmedObject != null)
        {
            Explode();
        }
    }
예제 #4
0
 void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.GetComponent <Entity>())
     {
         IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
         if (harmedObject != null)
         {
             harmedObject.ReceiveHit(1, gameObject, gameObject);
         }
     }
 }
예제 #5
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     if (hazardous)
     {
         IHarmable harmedObject = collider.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
         if (harmedObject != null)
         {
             harmedObject.ReceiveHit(50, gameObject, gameObject);
         }
     }
 }
예제 #6
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.GetComponent <Entity>().affinity != GetComponent <Entity>().affinity)
     {
         IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
         if (harmedObject != null)
         {
             harmedObject.ReceiveHit(1, gameObject, gameObject);
         }
         DestroyMe();
     }
 }
예제 #7
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
        float     damage       = 1;

        if (harmedObject != null)
        {
            if (vehicleControls.IsCharging())
            {
                damage = 5;
            }
            harmedObject.ReceiveHit(damage, gameObject, gameObject);
        }
    }
예제 #8
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;

        if (harmedObject != null)
        {
            harmedObject.ReceiveHit(10, gameObject, gameObject);
            float damage = collision.gameObject.GetComponent <Rigidbody2D>().velocity.magnitude * 15;
            currentHealth -= damage;
            print("dinged for " + damage);
            if (currentHealth <= 0)
            {
                DestroyMe();
            }
        }
    }
예제 #9
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.GetComponent <Entity>())
        {
            if (AffinitiesMatch(collision.gameObject))
            {
//				Sheep sheep = collision.gameObject.GetComponent<Sheep>();
//				if(sheep) Merge (sheep);
            }
            else
            {
                IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;
                if (harmedObject != null)
                {
                    harmedObject.ReceiveHit(1, gameObject, gameObject);
                }
            }
        }
    }
예제 #10
0
 public void Strike(IHarmable enemy)
 {
     throw new System.NotImplementedException();
 }