protected void HealOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { Enemy e = target as Enemy; if (e == null) return; e.Heal(amt); }
protected virtual void AddToQueue(HittableObject h) { Enemy e = h as Enemy; if (e == null || to_repair.Contains(e)) return; to_repair.Enqueue(e); }
protected virtual void PassOnHit(HittableObject h, Bullet b) { Enemy target = null; foreach (Enemy e in turrets) { if (e == this) { continue; } if (e == null) { continue; } if (target == null || Vector3.Distance(target.transform.position, b.transform.position) > Vector3.Distance(e.transform.position, b.transform.position)) { target = e; } } if (target == null) { DestroyInstant(); } else { target.Damage(b); } }
protected virtual void Buckshot (HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { if (depth <= 0) { return; } for (int i = 0; i < (num_shots == 0 ? depth + 1 : num_shots); i++) { GameObject gobj = (GameObject)Instantiate(gameObject); gobj.transform.position = transform.position; gobj.transform.rotation = transform.rotation; gobj.transform.Rotate(Vector3.up, Random.Range(-max_degrees_delta, max_degrees_delta)); BuckshotBullet bsb = gobj.GetComponent <BuckshotBullet>(); bsb.exception = new Stack <Transform>(); if (exception != null) { foreach (Transform t in exception) { bsb.exception.Push(t); } } bsb.exception.Push(target.transform); bsb.depth = depth - 1; } }
protected virtual void GotHit(HittableObject hit) { repair_charge = 0f; health--; if (health <= 0) { DestroyInstant(); } else if (max_health > 1) { // Lose armor float percent = 1f - (float)(health - 1) / (float)(max_health - 1); for (int i = 0; i < Mathf.RoundToInt(armor.Length * percent); i++) { if (armor[i].activeSelf) { if (armor_explosion != null) { GameObject arexp = (GameObject)Instantiate(armor_explosion); arexp.transform.position = armor[i].transform.position; arexp.GetComponent <ExplosionController>().Init(); } armor[i].SetActive(false); } } } }
protected static void DestroyOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { pierce = false; bullet.transform.position += Vector3.Project(rch.point - bullet.transform.position, bullet.transform.forward); bullet.Explode(); }
public virtual void Damage(HittableObject h) { if (!Utilities.IsThisVisible(gameObject)) return; if (dmgEnemy != null) dmgEnemy(this, h); if (dmgGeneric != null) dmgGeneric(this); }
void OnTriggerEnter(Collider other) { if (other.tag == "HittableObject") { HittableObject hittableObject = other.GetComponent <HittableObject>(); controller.moveableObject.moveDirection.x = -knockback; hittableObject.GetHit(this.GetSwordDamage(), this.knockback); } }
protected virtual void AddToQueue(HittableObject h) { Enemy e = h as Enemy; if (e == null || to_repair.Contains(e)) { return; } to_repair.Enqueue(e); }
protected void HealOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { Enemy e = target as Enemy; if (e == null) { return; } e.Heal(amt); }
public void TakeDamage(HittableObject h) { if (Fight.f == null || !Fight.f.fight_active) return; shield--; num_hits_taken++; if (shield < 0) StartCoroutine(Lose()); }
protected virtual void DmgNoData(HittableObject h) { int r = Random.Range(0, turrets.Length); while (turrets[r] == this || turrets[r] == null) { r++; if (r == turrets.Length) r = 0; } turrets[r].Damage(); }
protected virtual void PassOnHit(HittableObject h, HittableObject b) { Enemy target = null; foreach (Enemy e in turrets) { if (e == this) continue; if (e == null) continue; if (target == null || Vector3.Distance(target.transform.position, b.transform.position) > Vector3.Distance(e.transform.position, b.transform.position)) target = e; } target.Damage(b); }
// Update is called once per frame protected override void _Update() { if (alive > 0) { // Cast for a hit and there is a hit, // call our hit method and then theirs RaycastHit[] rch = CastForHits(transform.position + transform.forward * speed * Time.deltaTime); for (int i = 0; i < rch.Length; i++) { Transform c = rch[i].transform; HittableObject h = c.GetComponent <HittableObject>(); while (h == null) { c = c.parent; h = c.GetComponent <HittableObject>(); } bool cont = true; if (Hit != null) { Hit(h, this, rch[i], ref cont); } if (!cont) { break; } } transform.position += transform.forward * speed * Time.deltaTime; } else { alive -= Time.deltaTime; if (alive < -length) { Destroy(gameObject); } } if (kill_when_invis) { // Check for offscreen if (!(new Rect(-200f, -200f, 400f, 300f)).Contains( new Vector2(transform.position.x, transform.position.z))) { Destroy(gameObject); } } }
public void TakeDamage(HittableObject h) { if (Fight.f == null || !Fight.f.fight_active) { return; } shield--; num_hits_taken++; if (shield < 0) { StartCoroutine(Lose()); } }
protected virtual void DmgNoData(HittableObject h) { int r = Random.Range(0, turrets.Length); while (turrets[r] == this || turrets[r] == null) { r++; if (r == turrets.Length) { r = 0; } } turrets[r].Damage(); }
public virtual void Damage(HittableObject h) { if (!Utilities.IsThisVisible(gameObject)) { return; } if (dmgEnemy != null) { dmgEnemy(this, h); } if (dmgGeneric != null) { dmgGeneric(this); } }
// Fired From Player Animation Event public void OnAttack() { if (weapon == null) { return; } if (weapon.itemType == Item.ItemTypes.MeleeWeapon) { // show a temp melee weapon spot if (tempWeapon != null) { var ang = Vector2.Angle(player.mouseDirection, weaponArcPoint.transform.position); Debug.Log(ang); tempWeapon.SetActive(true); tempWeapon.transform.position = (Vector2)weaponArcPoint.transform.position + player.mouseDirection; //tempWeapon.transform.LookAt(player.mouseDirection); } var meleeWeapon = (ItemWeaponMelee)weapon; Combat.IHittable HittableObject; var rays = Physics2D.CircleCastAll((Vector2)weaponArcPoint.transform.position + player.mouseDirection, meleeWeapon.attackArc, player.mouseDirection, .01f, hittableLayers); if (rays != null) { for (var i = 0; i < rays.Length; i++) { //Debug.Log("hit " + rays[i].collider.name); HittableObject = (Combat.IHittable)rays[i].collider.gameObject.GetComponent(typeof(Combat.IHittable)); if (HittableObject != null && weapon != null) { Combat.DamageInfo damageInfo = meleeWeapon.damage.Copy(); // add damage bonuses from player stats here HittableObject.Hit(new Combat.HitInfo(damageInfo, rays[i].collider.transform.position, false, Combat.HitInfo.HitSources.Player)); } } } } else if (weapon.itemType == Item.ItemTypes.RangedWeapon) { var rangedWeapon = (ItemWeaponRanged)weapon; Instantiate(rangedWeapon.projectile, (Vector2)weaponHand.transform.position, Quaternion.identity); } }
protected void PierceAndDestroy(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { if (!hit_already.Contains(target)) { Explode (); alive = 1; Enemy e = target as Enemy; if (e != null && e.Health <= 1) { destroyed++; if (destroyed >= 5) Utilities.u.UnlockAchievement("Railgun"); } DamageOnHit(target, bullet, rch, ref pierce); hit_already.Push (target); } }
bool WireHitSomething() { Vector3 direction = WireTarget.transform.position - transform.position; RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, direction, direction.magnitude, layerMask); if (hits.Length > 0) { foreach (var hit in hits) { HittableObject obj = hit.collider.gameObject.GetComponent <HittableObject>(); if (obj != null && obj.IsHitted(this, hit)) { //anim.SetTrigger("hit"); return(true); } } } return(false); }
protected void PierceAndDestroy(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { if (!hit_already.Contains(target)) { Explode(); alive = 1; Enemy e = target as Enemy; if (e != null && e.Health <= 1) { destroyed++; if (destroyed >= 5) { Utilities.u.UnlockAchievement("Railgun"); } } DamageOnHit(target, bullet, rch, ref pierce); hit_already.Push(target); } }
bool OnHittableObjectCollision(HittableObject _object) { bool stick = false; //destroy or stick the arrow switch (_object.ArrowEffect) { case ArrowEffect.StickArrow: stick = true; break; case ArrowEffect.DestroyArrow: Destroy(gameObject); break; } //call the hit function _object.OnArrowHit(); return(stick); }
protected virtual void Buckshot (HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { if (depth <= 0) return; for (int i = 0; i < (num_shots == 0 ? depth + 1 : num_shots); i++) { GameObject gobj = (GameObject)Instantiate(gameObject); gobj.transform.position = transform.position; gobj.transform.rotation = transform.rotation; gobj.transform.Rotate(Vector3.up, Random.Range (-max_degrees_delta, max_degrees_delta)); BuckshotBullet bsb = gobj.GetComponent<BuckshotBullet>(); bsb.exception = new Stack<Transform>(); if (exception != null) foreach (Transform t in exception) bsb.exception.Push(t); bsb.exception.Push(target.transform); bsb.depth = depth - 1; } }
protected static void DamageOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { target.Damage(bullet); }
void DamageND(HittableObject hit) { Damage(transform.forward); }
protected virtual void LoseSpeedOnHit(HittableObject e) { speed *= speed_loss_mult; }
public Velocity DoHit(Velocity vel) { return(HittableObject.DoHit(vel, this)); }
void DamageB(HittableObject hit, Bullet b) { Damage(b.transform.position - transform.position); }
protected void ChargeOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { CombinerEnemy c = target as CombinerEnemy; c.charges++; }
void DamageE(HittableObject hit, HittableObject enemy) { Damage(enemy.transform.position - transform.position); }
protected virtual void GotHit(HittableObject hit) { repair_charge = 0f; health--; if (health <= 0) { DestroyInstant(); } else if (max_health > 1) { // Lose armor float percent = 1f - (float)(health - 1) / (float)(max_health - 1); for (int i = 0; i < Mathf.RoundToInt(armor.Length * percent); i++) { if (armor[i].activeSelf) { if (armor_explosion != null) { GameObject arexp = (GameObject)Instantiate(armor_explosion); arexp.transform.position = armor[i].transform.position; arexp.GetComponent<ExplosionController>().Init(); } armor[i].SetActive(false); } } } }
protected virtual void ChargedDamageOnHit(HittableObject target, Bullet bullet, RaycastHit rch, ref bool pierce) { for (int i = 0; i < charged; i++) target.Damage(bullet); }
protected virtual void Collided(HittableObject away, HittableObject home) { away.Damage(this); Damage(away); }