void OnCollisionEnter(Collision collision) { if (entity.IsAttached) { speed = 0; Destroy(gameObject); if (isProjectileShooter) { var targetEntity = collision.gameObject.GetComponent <BoltEntity>(); if (targetEntity != null && targetEntity.IsAttached) { var evnt = TakeDamageEvent.Create(targetEntity.Source); evnt.Damage = damage; evnt.Entity = targetEntity; evnt.Send(); } if (projectileHitPrefab != null) { ContactPoint contact = collision.contacts[0]; Quaternion rot = Quaternion.FromToRotation(Vector3.up, contact.normal); var hitfx = BoltNetwork.Instantiate(projectileHitPrefab, contact.point, rot); } } } }
public void TakeDamage(float damage) { _currentHealth -= damage; // Health is empty if (_currentHealth <= 0) { DeathEvent?.Invoke(Mathf.Abs(_currentHealth)); deathEvent.Invoke(); } _currentHealth = Mathf.Clamp(_currentHealth, 0f, _health); TakeDamageEvent?.Invoke(damage); if (_currentHealth <= 0) { switch (_onDeath) { case DeathType.Disable: _rootObject.SetActive(false); break; case DeathType.Destroy: Destroy(_rootObject); break; } } }
public override void OnEvent(TakeDamageEvent evnt) { if (evnt.Entity.IsOwner) { if (evnt.Entity.Source == null) { BoltEntity entity = evnt.Entity; PlayerHealth playerHealth = entity.GetComponent <PlayerHealth>(); playerHealth.TakeDamage(evnt.Damage); } } else { if (evnt.Entity.Source == null) { BoltConsole.Write("empty soiurce"); } else { var newEvnt = TakeDamageEvent.Create(evnt.Entity.Source); newEvnt.Damage = evnt.Damage; newEvnt.Entity = evnt.Entity; newEvnt.Send(); } } }
// Use this for initialization void Awake() { if (OnTakeDamage == null) { OnTakeDamage = new TakeDamageEvent(); } if (OnHeal == null) { OnHeal = new HealEvent(); } if (OnAddHealth == null) { OnAddHealth = new AddHealthEvent(); } if (OnSubtractHeath == null) { OnSubtractHeath = new SubtractHealthEvent(); } if (OnNoHealth == null) { OnNoHealth = new NoHealthEvent(); } maxHealth = startingHealth; currentHealth = maxHealth; }
public void TakeDamage(int damage) { TakeDamageEvent?.Invoke(damage); // delegate invokation m_currentHealth -= damage; if (m_currentHealth <= 0) { Die(); } }
public void TakeDamage(int damage) { TakeDamageEvent?.Invoke(damage); // Reduce the health of the island; m_CurrentHealth -= damage; if (m_CurrentHealth <= 0) { Die(); } }
public void TakeDamage(int amount) { health = Mathf.Clamp(health - (amount - (amount * Controller.instance.equpimentXar.totalArmor * 2) / 100), 0, healthMax); TakeDamageEvent?.Invoke(this, EventArgs.Empty); OnHealthChanged?.Invoke(this, EventArgs.Empty); if (health <= 0) { HealthDownToZero?.Invoke(this, EventArgs.Empty); } }
void OnTakeDamageEvent(TakeDamageEvent evt) { Debug.Log($"{name} Ouch!!! {evt.whoDidDamage} hurt me with {evt.damage}"); _health -= evt.damage; EventController.RemoveListener <SaySomethingEvent>(OnSaySomethingEvent); if (_health <= 0) { Debug.Log($"{name} Why god why!!!!! I'm dead"); EventController.RemoveListener <TakeDamageEvent>(OnTakeDamageEvent); } }
public void TakeDamage(float getDamage) { //if (!this.IsDie && !this.IsInvinsible) { var flash = TakeDamageEvent.Create(entity); flash.GetDamage = getDamage; flash.Respawn = false; flash.Send(); } return; }
public void TakeDamage(int amount) { Health -= amount; if (Health <= 0) { Die(); } else { TakeDamageEvent takeDamageEvent = new TakeDamageEvent(this.gameObject, takeDamageSound, takeDamageParticle); takeDamageEvent.FireEvent(); } }
private void OnTakeDamageEvent(TakeDamageEvent e) { GameObject def = e.Defender; if (def == gameObject) { Character character = def.GetComponent <Character>(); TriggerReceiveHitAnimation( e.Direction, character, () => RaiseChangeHealthEvent(e.Damage, character) ); } }
public void Shoot() { Vector3 aimPoint; RaycastHit rayHit; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out rayHit, gunRange)) { aimPoint = rayHit.point; var targetEntity = rayHit.collider.gameObject.GetComponent <BoltEntity>(); if (entity.IsOwner) { BoltConsole.Write("HIT DETECTED on OBJECT : " + rayHit.collider.gameObject.name); if (targetEntity != null) { if (entity.IsAttached) { BoltConsole.Write("CALLING EVENT"); var evnt = TakeDamageEvent.Create(targetEntity.Source); evnt.Damage = gunDamage; evnt.Send(); } } if (projectileHitPrefab != null) { Quaternion rot = Quaternion.FromToRotation(Vector3.up, aimPoint); var hitfx = Instantiate(projectileHitPrefab, aimPoint, rot); } } } else { aimPoint = cam.transform.position + cam.transform.forward * gunRange; } if (entity.IsOwner) { muzzleIndex = state.WeaponActiveIndex; var muz = firePoints[muzzleIndex]; var bullet = BoltNetwork.Instantiate(BoltPrefabs.Projectile, muz.transform.position, Quaternion.identity); bullet.transform.LookAt(aimPoint); if (muzzlePrefab != null) { var muzzleVfx = BoltNetwork.Instantiate(muzzlePrefab, muz.transform.position, Quaternion.identity); muzzleVfx.transform.forward = bullet.transform.forward; } } }
IEnumerator Death() { yield return(new WaitForEndOfFrame()); while (Time.time < this.currentDietime) { yield return(new WaitForEndOfFrame()); if (entity.IsOwner) { state.MyColor = Color.Lerp(state.MyColor, Color.black, Time.deltaTime * this.dietime); } } var flash = TakeDamageEvent.Create(entity); flash.GetDamage = 0; flash.Respawn = true; flash.Send(); yield break; }
public static BattleEventBase createBattleEvent(BattleConsts.Code code,EventVOBase vo) { BattleEventBase evt = null; switch ( code ) { case BattleConsts.Code.TakeDamage: evt = new TakeDamageEvent(vo); break; case BattleConsts.Code.Translate: evt = new TranslateTargetEvent(vo); break; case BattleConsts.Code.FlagAttackTarget: evt = new FlagAttackTargetEvent(vo); break; case BattleConsts.Code.PreCounterAttack: evt = new PreCounterAttackEvent(vo); break; case BattleConsts.Code.SummonUnitSuccess: evt = new SummonUnitSuccessEvent(vo); break; } return evt; }
public void SomeFunction(TakeDamageEvent e) { Debug.Log("The message is: " + e.message); }
public void AddTakeDamageListener(TakeDamageEvent damageEvent) { takeDamageDelegate += damageEvent; }
void OnTakeDamageEvent(TakeDamageEvent e) { }
public override void OnEvent(TakeDamageEvent evnt) { if (!evnt.Respawn) { this.health -= evnt.GetDamage; this.IsInvinsible = true; this.currentInvinsibleTime = Time.time + invinsibleTime; if (this.health <= 0) { Debug.Log("Death"); if (entity.IsOwner) { deathAudioMe.start(); } else { deathAudioOther.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(transform.position)); deathAudioOther.start(); } IsDie = true; GameObject go = Instantiate(deathParticulePrefab, this.transform.position, Quaternion.identity); go.transform.SetParent(this.transform); Destroy(go, 1.9f); if (currentMK != null) { ParticleSystem.MainModule main = currentMK.main; main.loop = false; Destroy(currentMK.gameObject, 1.2f); } this.currentDietime = Time.time + this.dietime; StartCoroutine(Death()); /*Life--; * if (Life > 0) * { * * } * else * { * IsDie = true; * this.currentDietime = Time.time + this.dietime; * if(entity.IsOwner) StartCoroutine(EndLife()); * //GameSystem.GSystem.GuardianDie(); * * var killFeed = KillFeedEvent.Create(GameSystem.GSystem.entity); * killFeed.Message = this.guardianName + " has no more Life"; * killFeed.RemoveFeed = false; * killFeed.Send(); * }*/ this.CurrentSerieKill = 0; this.currentIndexKillSeries = 0; } } else { GameObject go = Instantiate(this.guardianExplode, this.feetPosition.position, this.transform.rotation); Destroy(go.gameObject, 4f); Respawn(); } }
public void AddLoseTierListener(TakeDamageEvent damageEvent) { loseHealthTierDelegate += damageEvent; }
public override void OnEvent(TakeDamageEvent evnt) { BoltConsole.Write("EVENtttt HEARD"); TakeDamage(evnt.Damage); }
public void Shoot() { var currentWeapon = WeaponObjects[state.WeaponActiveIndex]; Weapon weapon = currentWeapon.GetComponent <Weapon>(); float gunRange = weapon.GetRange(); float gunDamage = weapon.GetDamage(); float projectileSpeed = weapon.GetProjectileSpeed(); bool isProjectileShooter = weapon.GetIsProjectileShooter(); GameObject projectilePrefab = weapon.projectilPrefab; GameObject projectilHitPrefab = weapon.projectileHitPrefab; GameObject firePoint = weapon.firePoint; Vector3 aimPoint; RaycastHit rayHit; if (Physics.Raycast(cam.transform.position, cam.transform.forward, out rayHit, gunRange)) { aimPoint = rayHit.point; var targetEntity = rayHit.collider.gameObject.GetComponent <BoltEntity>(); if (entity.IsOwner) { if (!isProjectileShooter) { if (targetEntity != null) { if (entity.IsAttached) { var evnt = TakeDamageEvent.Create(targetEntity.Source); evnt.Damage = gunDamage; evnt.Entity = targetEntity; evnt.Send(); } } if (projectilHitPrefab != null) { Quaternion rot = Quaternion.FromToRotation(Vector3.up, aimPoint); var hitfx = BoltNetwork.Instantiate(projectilHitPrefab, aimPoint, Quaternion.identity); } } } } else { aimPoint = cam.transform.position + cam.transform.forward * gunRange; } if (entity.IsOwner) { var bullet = BoltNetwork.Instantiate(projectilePrefab, firePoint.transform.position, Quaternion.identity); var projectileScript = bullet.GetComponent <Projectile>(); projectileScript.SetSpeed(projectileSpeed); projectileScript.SetIsProjectileShooter(isProjectileShooter); projectileScript.SetProjectileDamage(gunDamage); projectileScript.SetProjectileHitPrefab(projectilHitPrefab); bullet.transform.LookAt(aimPoint); if (muzzlePrefab != null) { var muzzleVfx = BoltNetwork.Instantiate(muzzlePrefab, firePoint.transform.position, Quaternion.identity); muzzleVfx.transform.forward = bullet.transform.forward; } } }
virtual public void TakeDamage(DamageParams args) { if (health > 0) { if (!squash.inSquash && iFramesTimer <= 0) { if (args.amount > 0) { SetHealth(health - args.amount); if (args.damageType == DamageType.Squash) { squash.DoSquash(health > 0); } else if (args.damageType == DamageType.Hit) { iFramesTimer = iFramesDuration; knockbackVector = knockbackMultiplier * args.knockback; StartCoroutine(Flasher()); } TakeDamageEvent.Invoke(args); } CameraEffects.Get.FreezeFrames(0.15f, 0.01f); switch (args.element) { case Element.None: break; case Element.Fire: if (flammable) { flammable.StartBurning(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(burn, 0.5f); } } break; case Element.Ice: if (freezable) { freezable.FreezeStart(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(slow, 1f); } } break; case Element.Poison: poisonStatus = poisonStatusDuration; if (poisonStatus > 0) { poisonEffectIndex = ParticleEffectsManager.GetEffect("Poison").Spawn(meshRenderer); if (!audioSource.isPlaying) { audioSource.PlayOneShot(poisoned, 1f); } } break; case Element.Lightning: if (electracuted) { electracuted.ElcStart(); if (!audioSource.isPlaying) { audioSource.PlayOneShot(paralysis, 0.10f); } } break; } if (health <= 0) { Die(); if (Random.Range(1, 5) == 1) { Instantiate(powerUps[Random.Range(0, powerUps.Length - 1)]).transform.position = transform.position + Vector3.up * 1; } } } } }