private void DeliverHit()
    {
        Health component = target.GetComponent <Health>();

        if ((bool)component)
        {
            target.Trigger(-787691065, properties.attacker.GetComponent <FactionAlignment>());
            float          num        = rollDamage();
            AttackableBase component2 = target.GetComponent <AttackableBase>();
            num *= 1f + component2.GetDamageMultiplier();
            component.Damage(num);
            if (properties.effects != null)
            {
                Effects component3 = target.GetComponent <Effects>();
                if ((bool)component3)
                {
                    foreach (AttackEffect effect in properties.effects)
                    {
                        if (Random.Range(0f, 100f) < effect.effectProbability * 100f)
                        {
                            component3.Add(effect.effectID, true);
                        }
                    }
                }
            }
        }
    }
Exemplo n.º 2
0
 private void DoExplode()                                                           //Explodes the bomb
 {
     Collider2D[] hitColliders = Physics2D.OverlapCircleAll(transform.position, 1); //Gets a list of all colliders within a certain range of our game object
     for (int i = 0; i < hitColliders.Length; i++)                                  //loop through this list
     {
         //We want colliders which are attackable or destroyable
         AttackableBase attackable  = hitColliders[i].gameObject.GetComponent <AttackableBase>();
         Destroyable    destroyable = hitColliders[i].gameObject.GetComponent <Destroyable>();
         //If any, do thing
         if (destroyable != null)
         {
             Destroy(destroyable.gameObject);                      //Destroy it
         }
         if (attackable != null)
         {
             attackable.OnHit(hitColliders[i], ItemType.Bomb);                     //Attack it
         }
     }
     if (ExplosionEffect != null)                                               //If no explosion effect
     {
         GameObject explosionEffect = (GameObject)Instantiate(ExplosionEffect); //Do explosion
         explosionEffect.transform.position = transform.position;               //At center of bomb
     }
     Destroy(gameObject);                                                       //Destroy bomb
 }
Exemplo n.º 3
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        AttackableBase attackable = collision.gameObject.GetComponent <AttackableBase>();

        if (attackable != null)
        {
            attackable.OnHit(m_Collider);
        }
    }
    private void OnTriggerEnter2D(Collider2D collider)
    {
        AttackableBase attackable = collider.gameObject.GetComponent <AttackableBase>();

        if (attackable != null)
        {
            attackable.OnAttacked(WeaponType, _weaponCollider);
        }
    }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D ObjectCollision)
    {
        Debug.Log(ObjectCollision.name);
        AttackableBase Attackable = ObjectCollision.GetComponent <AttackableBase>();

        if (Attackable != null)
        {
            Attackable.OnHit(type);
        }
    }
Exemplo n.º 6
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Debug.Log("Hit " + collision.gameObject.name);
        AttackableBase attackable = collision.gameObject.GetComponent <AttackableBase>();

        if (attackable != null)
        {
            attackable.OnHit(Type);
        }
    }
Exemplo n.º 7
0
 private void OnTriggerEnter2D(Collider2D col)
 {
     if (isThrown)
     {
         AttackableBase attackable = col.GetComponent <AttackableBase>();
         if (attackable != null)
         {
             attackable.OnHit(m_Collider);
         }
     }
 }
Exemplo n.º 8
0
 protected override void OnSpawn()
 {
     base.OnSpawn();
     health     = GetComponent <Health>();
     attackable = GetComponent <AttackableBase>();
     Components.FactionAlignments.Add(this);
     Subscribe(493375141, OnRefreshUserMenuDelegate);
     Subscribe(2127324410, SetPlayerTargetedFalseDelegate);
     if (alignmentActive)
     {
         FactionManager.Instance.GetFaction(Alignment).Members.Add(this);
     }
     Subscribe(1623392196, OnDeathDelegate);
     UpdateStatusItem();
 }
    protected void OnTriggerEnter2D(Collider2D collider)
    //If the collisionbox isnt a trigger, use OnCollisionEnter2D(Collision2D collision)
    //If the collisionbox is a trigger, us OnTriggerEnter2D(Collider2D collider)
    {
        //Debug.Log("hit " + collider.gameObject.name);
        AttackableBase attackable = collider.gameObject.GetComponent <AttackableBase>();

        //collision.gameObject.GetComponent gets the component of the gameobject this gameobject collides with somehow
        //Here it get attackablebase, that would also return attackablebush. In fact, it will return all derivatives
        //Debug.Log(collider.name, collider.gameObject);
        if (attackable != null)
        {
            attackable.OnHit(m_Collider, Type, 2);
            //So if the attackable doesnt return null, the OnHit function of the AttackableBase will run
            //It will only return null if the other gameobject has no attackablebase or derivative thereof
        }
    }
Exemplo n.º 10
0
 void OnTriggerEnter2D(Collider2D collider)
 {
     //  Debug.Log("Casters tag is: " + caster.tag);
     if (caster.tag == "Player" && collider.tag == "Enemy")
     {
         // Debug.Log("Casters tag is player");
         AttackableBase attackedTarget = collider.gameObject.GetComponent <AttackableBase>();
         if (attackedTarget != null)
         {
             //   attackedTarget.OnHit(GetComponentInChildren<CircleCollider2D>(), ItemType.Sword);
             Destroy(gameObject);
         }
     }
     if (caster.tag == "Enemy" && collider.tag == "Player")
     {
         Destroy(gameObject);
     }
     if (caster.tag == "Player" && collider.tag == "Player")
     {
         // Debug.Log("You hit yourself, idiot");
     }
 }