Ejemplo n.º 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();
                }
            }
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D collider)
    {
        IHarmable harmedObject = collider.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;

        if (harmedObject != null)
        {
            Explode();
        }
    }
Ejemplo n.º 3
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        IHarmable harmedObject = collision.gameObject.GetComponent(typeof(IHarmable)) as IHarmable;

        if (harmedObject != null)
        {
            Explode();
        }
    }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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);
         }
     }
 }
Ejemplo n.º 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();
     }
 }
Ejemplo n.º 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);
        }
    }
Ejemplo n.º 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();
            }
        }
    }
Ejemplo n.º 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);
                }
            }
        }
    }
Ejemplo n.º 10
0
 public void Strike(IHarmable enemy)
 {
     throw new System.NotImplementedException();
 }