public void OnDeath(DamageContext context) { GetComponent <Rigidbody>().isKinematic = true; // isSinking = true; //ScoreManager.score += scoreValue; Destroy(gameObject, 2f); }
protected override void DoAction(UnityEngine.Component other) { if (other is IDamageable) { timer += Time.deltaTime; if (timer < Attack.Cooldown) { return; } timer = 0; IDamageable damageable = other as IDamageable; DamageContext damage = new DamageContext(); damage.Attack = Attack; damage.Attacker = null; damage.Enemy = damageable; damage.IsMeele = true; damageable.OnDamaged(damage); if (Util.Length(Force) > 0 && other.gameObject.rigidbody != null) { other.gameObject.rigidbody.AddForce(Force); } } }
public override void OnDeath(DamageContext context) { base.OnDeath(context); anim.SetTrigger("Die"); playerAudio.clip = deathClip; playerAudio.Play(); }
//Enable bIsDead flag and notify all responders of death public virtual void OnDeath(DamageContext context) { bIsDead = true; foreach (IRespondsToDeath responder in deathResponders) { responder.OnDeath(context); } }
private void CreateRicochet(DamageContext context) { var ricochet = Instantiate(Ricochet); ricochet.transform.position = context.Position; ricochet.transform.rotation = Quaternion.LookRotation(context.Direction, transform.up); ricochet.transform.Rotate(0, 180, 0); ricochet.transform.SetParent(transform); }
public void OnDamaged(DamageContext damage) { currentDamage += damage.RollDamage(); if (currentDamage >= TriggerDamage) { InvokeTrigger(this); } }
public override void OnDamaged(DamageContext damage) { if (IsDead) { return; } anim.SetBool("Hit", true); base.OnDamaged(damage); }
public override void TakeDamage(DamageContext context) { if (!CanTakeDamage(context)) { return; } base.TakeDamage(context); damaged = true; //healthSlider.value = currentHealth; playerAudio.Play(); }
public virtual void TakeDamage(DamageContext context) { if (CanTakeDamage(context)) { currentHealth -= context.amount; Debug.Log(gameObject + " Took " + context.amount + " damage from " + context.source); if (currentHealth <= 0 && !bIsDead) { OnDeath(context); } } }
public void TakeDamage(DamageContext context) { CurrentHealth -= context.Damage; PartsEmitter.Fire(Vector3.zero, 20, Random.Range(1, 3)); CreateRicochet(context); PlayClip(EnemyHitSound); if (CurrentHealth <= 0) { StartDying(); //Die(context); } }
public virtual bool CanTakeDamage(DamageContext context) { if (!bIsDead) { if (bEnableFriendlyFire) { return(true); } Team sourceTeam = context.source.GetComponent <Team>(); return(sourceTeam == null || sourceTeam.id != teamId); } return(false); }
public virtual void TakeDamage(DamageContext context) { if (CanTakeDamage(context)) { currentHealth -= context.amount; Debug.Log(gameObject + " Took " + context.amount + " damage from " + context.source); foreach (IRespondsToDamage responder in damageResponders) { responder.OnDamageTaken(context); } if (currentHealth <= 0 && !bIsDead) { OnDeath(context); } } }
public override void TakeDamage(DamageContext context) { if (!CanTakeDamage(context)) { return; } base.TakeDamage(context); if (enemyAudio != null) { enemyAudio.Play(); } if (hitParticles != null) { hitParticles.transform.position = context.hitLocation; hitParticles.Play(); } GetComponent <Animator>().SetTrigger("hit"); }
public override void OnDeath(DamageContext context) { base.OnDeath(context); GetComponent <Animator>().SetBool("isDead", true); GameManager.instance.crystals += 30; GameManager.instance.waveCrytals += 30; GameManager.instance.totalCrytals += 30; if (enemyAudio != null) { if (enemyAudio.isPlaying) { enemyAudio.Stop(); } enemyAudio.PlayOneShot(deathClip); } }
//////////////////////////////////////////////////////////////////// public virtual void OnDamaged(DamageContext damage) { if (IsDead) { return; } Live -= damage.RollDamage(); if (Live <= 0) { Live = 0; OnDeath(); return; } if (DamagedEvent != null) { DamagedEvent(this); } }
private bool DoAttack(ICombatant entity) { var hb = Hitbox; var xDir = entity.CurrentDirection.X; if (xDir != 0) { hb.Center.x *= xDir; } hb.Center += (Vector2)entity.Transform.position; var success = false; var found = Physics2D.OverlapBoxAll(hb.Center, hb.Size, 0, GameResources.Instance.DamageableMask); foreach (var hit in found) { var d = hit.GetComponentInParent <IDamageable>(); if (d == null || d.Invulnerable) { continue; } var e = d as ICombatant; if (e != null && !entity.ShouldAttack(e)) { continue; } var info = new DamageContext(d, e, this); success = true; d.Damage(info); HitEffect.PlayIfPresent(new EffectContext( (MonoBehaviour)entity, new PositionFeature(d.Transform.position) )); } ; return(success); }
public void Die(DamageContext context) { if (!_isDead) { PlayClip(EnemyDieSound); EventAggregator.SendMessage(new ShakeCamera()); EventAggregator.SendMessage(new EnemyDied()); _isDead = true; var navMesh = GetComponent <NavMeshAgent>(); var currentVelocity = navMesh != null ? navMesh.velocity : Vector3.zero; Destroy(navMesh); Destroy(GetComponent <PlayerFollow>()); GetComponentInChildren <SpriteRenderer>().sprite = Destroyed; Destroy(GetComponent <Rigidbody>()); Destroy(GetComponent <BoxCollider>()); // rigidBody.isKinematic = false; // rigidBody.velocity = currentVelocity; PartsEmitter.Fire(currentVelocity, 20, Random.Range(5, 10)); var explosion = Instantiate(Explosion); explosion.transform.position = transform.position; explosion.transform.SetParent(Hack.Everything.transform); var crater = Instantiate(Crater); crater.transform.position = transform.position; crater.transform.rotation = transform.rotation; crater.transform.SetParent(Hack.Everything.transform); EventAggregator.SendMessage(new EnemyExplosion { Position = transform.position }); } }
void OnTriggerEnter(Collider collider) { if (collider.tag == "Enemy") { var context = new DamageContext { Damage = Damage, Force = Speed, Direction = transform.forward, Position = transform.position }; var health = collider.GetComponent <EnemyHealthBehavior>(); if (health != null) { health.TakeDamage(context); } } if (collider.tag != "Ground" && collider.tag != "Player") { Destroy(gameObject); } }
public override void DoRangedDamage(DamageContext context) { base.DoRangedDamage(context); }
public void DoSpecialDamage(DamageContext context) { throw new System.NotImplementedException(); }
public static DamageResult ApplyDamage(this IDamageable damageable, DamageContext context) { damageable.Damage(context); return(context.ProcessResult()); }
public void Damage(DamageContext context) { //TODO implement: }
public void OnDamaged(DamageContext damage) { throw new System.NotImplementedException(); }
public void OnDeath(DamageContext context) { enabled = false; GetComponent <Animator>().SetBool("isWalking", false); }
public virtual void DoSpecialDamage(DamageContext context) { context.IsSpecial = true; context.Enemy.OnDamaged(context); }
public override void DoMeleeDamage(DamageContext context) { base.DoMeleeDamage(context); }
public void OnDeath(DamageContext context) { enabled = false; }
public override void DoSpecialDamage(DamageContext context) { base.DoSpecialDamage(context); }
public void OnDeath(DamageContext context) { DisableEffects(); }
public virtual void DoRangedDamage(DamageContext context) { context.IsRanged = true; context.Enemy.OnDamaged(context); }