void OnTriggerEnter2D(Collider2D other) { Base_Bullet bullet = other.GetComponent <Base_Bullet> (); if (other.GetComponent <Bullet_Explosion> () != null) { return; } if (other.GetComponent <Katana_Bullet> () != null) { return; } if (bullet != null) { Rigidbody2D body = other.GetComponent <Rigidbody2D> (); if (horizontalLock != 0) { if (Mathf.Sign(body.velocity.x) == horizontalLock) { Destroy(other.gameObject); } } else if (verticalLock != 0) { if (Mathf.Sign(body.velocity.y) == verticalLock) { Destroy(other.gameObject); } } } }
protected GameObject InstantiateBullet(float h, float v) { GameObject BulletObject = Instantiate(hitbox, transform.position + new Vector3(h, -v, 0f) * .25f, Quaternion.Euler(new Vector3(0f, 0f, Mathf.Rad2Deg * Mathf.Atan2(-v, h)))); currentBullet = BulletObject.GetComponent <Base_Bullet> (); currentBullet. SetInfo( GetPlayerTag().Id, GetPlayerTag().Team); return(BulletObject); }
void OnTriggerEnter2D(Collider2D other) { if (released) { Base_Health health = other.GetComponent <Base_Health> (); if (health != null) { if (health.GetPlayerTag().Id != playerTag.Id || (health.GetPlayerTag().Team != 0 && health.GetPlayerTag().Team != playerTag.Team)) { GameObject temp = Instantiate(splashDamagePrefab, transform.position, Quaternion.identity) as GameObject; temp.GetComponent <Base_Bullet> ().SetInfo(playerTag.Id, playerTag.Team); Destroy(gameObject); } } } else { Base_Bullet bullet = other.GetComponent <Base_Bullet> (); if (other.GetComponent <Bullet_Explosion> () != null) { return; } if (other.GetComponent <Katana_Bullet> () != null) { return; } if (bullet != null) { if (bullet.Id != playerTag.Id && (bullet.Team == 0 || bullet.Team != playerTag.Team)) { Destroy(other.gameObject); } } else if (other.GetComponent <Base_Mob> () != null) { if (!canAttack) { return; } Base_Health health = other.GetComponent <Base_Health> (); if (health != null) { if (health.GetPlayerTag().Id != playerTag.Id && (health.GetPlayerTag().Team == 0 || health.GetPlayerTag().Team != playerTag.Team)) { StartCoroutine(AttackCooldown()); health.TakeDamage(damage, playerTag.Id, playerTag.Team); } } } } }
void OnTriggerEnter2D(Collider2D other) { Base_Bullet bullet = other.GetComponent <Base_Bullet> (); if (bullet != null) { if (bullets.Contains(bullet)) { return; } bullet.GetComponent <Rigidbody2D> ().velocity *= amount; bullets.Enqueue(bullet); } }
float GradeChain(int i) { Bullet_Chain bullet = bulletObjects [i].GetComponent <Bullet_Chain> (); if (bullet != null) { float returnValue = 0f; Base_Bullet bulletSecondWeapon = bullet.NextBullet.GetComponent <Base_Bullet>(); returnValue = bulletSecondWeapon.Damage * (1f + (bulletSecondWeapon.Crit_Chance / 100f * (bulletSecondWeapon.Crit_Damage - 1f))) * (1f / weaponScripts [i].GetCooldown); returnValue += bulletSecondWeapon.Damage * (1f + (bulletSecondWeapon.Crit_Chance / 100f * (bulletSecondWeapon.Crit_Damage - 1f))) * Mathf.Round((float)weaponScripts [i].MaxAmmo); returnValue /= 2000f; returnValue *= bullet.NumberOfBullets; return(returnValue); } else { return(0f); } }
void OnTriggerEnter2D(Collider2D other) { Base_Bullet bullet = other.GetComponent <Base_Bullet> (); if (bullet == null) { return; } if (enemies.Contains(bullet.gameObject.GetInstanceID())) { return; } if (bank) { if (vertical) { bullet.GetComponent <Rigidbody2D> ().velocity = new Vector2(bullet.GetComponent <Rigidbody2D>().velocity.x, -bullet.GetComponent <Rigidbody2D>().velocity.y); } else { bullet.GetComponent <Rigidbody2D> ().velocity = new Vector2(-bullet.GetComponent <Rigidbody2D>().velocity.x, bullet.GetComponent <Rigidbody2D>().velocity.y); } } else { bullet.transform.rotation *= Quaternion.Euler(new Vector3(0f, 0f, 180f)); } Base_Bullet parent = GetComponentInParent <Base_Bullet> (); if (parent != null) { bullet.SetInfo(parent.Id, parent.Team); } enemies.Enqueue(other.gameObject.GetInstanceID()); bullet.ResetKillFlag(Base_Health.KILL_FLAGS.REFLECT); }
float GradeSpread(int i) { Spread_Weapon bullet = bulletObjects [i].GetComponent <Spread_Weapon> (); if (bullet == null) { return(0f); } else { float returnValue = 0f; Base_Bullet bulletSecondWeapon = bullet.SecondHitbox.GetComponent <Base_Bullet>(); returnValue = bulletSecondWeapon.Damage * (1f + (bulletSecondWeapon.Crit_Chance / 100f * (bulletSecondWeapon.Crit_Damage - 1f))) * (1f / weaponScripts [i].GetCooldown); returnValue += bulletSecondWeapon.Damage * (1f + (bulletSecondWeapon.Crit_Chance / 100f * (bulletSecondWeapon.Crit_Damage - 1f))) * Mathf.Round((float)weaponScripts [i].MaxAmmo); returnValue /= 2000f; returnValue *= bullet.ExtraBulletCount; returnValue *= 270f / bullet.Spread; return(returnValue); } }