internal static void OnGiveDamage(int npcid, int damagedid, int weaponid, int bodyPart, float healthLoss) { var fcnpc = Find(npcid); var args = new DamageEventArgs(BasePlayer.Find(damagedid), healthLoss, (Weapon)weaponid, (BodyPart)bodyPart); fcnpc?.GiveDamage?.Invoke(fcnpc, args); }
/// <summary> /// Raises the <see cref="E:PlayerGiveDamage" /> event. /// </summary> /// <param name="args">The <see cref="DamageEventArgs" /> instance containing the event data.</param> public void OnPlayerGiveDamage(DamageEventArgs args) { if (PlayerGiveDamage != null) { PlayerGiveDamage(this, args); } }
private void GainFromDealtDamage(SuffixStaticData p_suffix) { Int32 suffixLevel = m_equipment.SuffixLevel; Single valueForLevel = p_suffix.GetValueForLevel(suffixLevel, m_equipment.ItemSlot == EItemSlot.ITEM_SLOT_2_HAND); Single num = m_attackResult.DamageDone; EnchantmentEffectEventArgs suffixEffectEntry; if (p_suffix.Effect == ESuffixEffect.GAIN_HP_PERCENTAGE_FROM_DEALT_DAMAGE) { Int32 num2 = Math.Max(1, (Int32)Math.Round(num * valueForLevel, MidpointRounding.AwayFromZero)); m_character.ChangeHP(num2); suffixEffectEntry = new EnchantmentEffectEventArgs(p_suffix, num2); DamageEventArgs p_eventArgs = new DamageEventArgs(new AttackResult { Result = EResultType.HEAL, DamageResults = { new DamageResult(EDamageType.HEAL, num2, 0, 1f) } }); LegacyLogic.Instance.EventManager.InvokeEvent(m_character, EEventType.CHARACTER_HEALS, p_eventArgs); } else { Int32 num3 = Math.Max(1, (Int32)Math.Round(num * valueForLevel, MidpointRounding.AwayFromZero)); m_character.ChangeMP(num3); suffixEffectEntry = new EnchantmentEffectEventArgs(p_suffix, num3); } m_character.FightHandler.FeedActionLog(suffixEffectEntry); }
public void GetDamage(int damage, Character from) { DamageEventArgs damageargs = new DamageEventArgs(damage, from); OnGetDamage?.Invoke(this, damageargs); if (character.GetShield() != 0) { int canShield = Mathf.Min(damageargs.damage, character.GetShield()); DamageEventArgs shieldArgs = new DamageEventArgs(canShield, from); OnBlockDamage?.Invoke(this, shieldArgs); character.ChangeShield(-shieldArgs.damage); damageargs.damage -= shieldArgs.damage; if (damageargs.damage <= 0) { GetComponent <AudioSource>().clip = shieldSound; GetComponent <AudioSource>().Play(); } } if (damageargs.damage > 0) { DamageEventArgs args = new DamageEventArgs(damageargs.damage, from); OnGetDamaged?.Invoke(this, args); if (args.damage > 0) { character.ChangeHealthPoint(-args.damage); } GetComponent <AudioSource>().clip = damageSound; GetComponent <AudioSource>().Play(); } }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if (e.AttackType == AttackType.Melee) { Game.Instance.CameraController.LightShake(); } Game.Instance.Interface.VisualizeTakesDamage(); float yield = 2 * e.AdjustedDamage * (1 / (float)600); AdjustedRageInc(yield); regenTimer = 5; regenTickTimer = 0; var sm = Program.Instance.SoundManager; sm.GetSFX(global::Client.Sound.SFX.InPain1).Play(new Sound.PlayArgs()); //sm.GetSFX(global::Client.Sound.SFX.PhysicalHitFlesh1).Play(); Game.Instance.Statistics.Actions.DamageTaken += e.ActualDamage; Program.Instance.SignalEvent(new ProgramEvents.MainCharacterTakesDamage { DamageTaken = e.ActualDamage, Perpetrator = e.Performer }); if (e.AttackType == AttackType.Melee) { Game.Instance.Statistics.Actions.HitsTaken += 1; } }
public void UpdateBarHealth(DamageEventArgs e) { if (State == PlayerState.Wasted) { Armour = 0; TArmour.Hide(); HealthBar(THealth, 0); } else if (e.Weapon != Weapon.Collision && Armour != 0) { /* Calculate the player's current armour. */ float armour = (float)(Armour - Math.Ceiling(e.Amount)); if (armour > 0) { HealthBar(TArmour, armour); } else { TArmour.Hide(); HealthBar(THealth, 100.0f - Math.Abs(armour)); } } else { /* Calculate the player's current health. */ float health = (float)(Health - Math.Ceiling(e.Amount)); HealthBar(THealth, health >= 0 ? health : 0); } }
protected override void HandlePartyMemberHealing(Single p_magicFactor, Single p_critChance, Int32 p_critHealValue, SpellEventArgs p_result, List <Object> p_targets) { if (m_sorcerer == null) { m_sorcerer = LegacyLogic.Instance.WorldManager.Party.SelectedCharacter; } for (Int32 i = 0; i < p_targets.Count; i++) { Character character = (Character)p_targets[i]; if (!character.ConditionHandler.HasCondition(ECondition.DEAD)) { Int32 num = character.MaximumHealthPoints - character.HealthPoints; character.ChangeHP(num); DamageEventArgs p_eventArgs = new DamageEventArgs(new AttackResult { Result = EResultType.HEAL, DamageResults = { new DamageResult(EDamageType.HEAL, num, 0, 1f) } }); LegacyLogic.Instance.EventManager.InvokeEvent(character, EEventType.CHARACTER_HEALS, p_eventArgs); p_result.SpellTargets.Add(new HealedTarget(character, num, false)); } } m_sorcerer.ChangeMP(-m_sorcerer.ManaPoints); }
protected virtual void E_DealDamage(DamageEventArgs e) { if (OnDealDamage != null) { OnDealDamage(this, e); } }
protected override void HandlePartyMemberHealing(Single p_magicFactor, Single p_critChance, Int32 p_critHealValue, SpellEventArgs p_result, List <Object> p_targets) { Int32 value = Damage.Create(m_staticData.Damage[0] * p_magicFactor, 0f).Value; for (Int32 i = 0; i < p_targets.Count; i++) { if (!((Character)p_targets[i]).ConditionHandler.HasCondition(ECondition.DEAD)) { Int32 num = value; if (Random.Range(0f, 1f) < p_critChance) { num = p_critHealValue; } ((Character)p_targets[i]).ChangeHP(num); DamageEventArgs p_eventArgs = new DamageEventArgs(new AttackResult { Result = EResultType.HEAL, DamageResults = { new DamageResult(EDamageType.HEAL, num, 0, 1f) } }); LegacyLogic.Instance.EventManager.InvokeEvent((Character)p_targets[i], EEventType.CHARACTER_HEALS, p_eventArgs); } } p_result.SpellTargets.Add(new HealedTarget(LegacyLogic.Instance.WorldManager.Party, value, false)); }
protected override void HandlePartyMemberHealing(Single p_magicFactor, Single p_critChance, Int32 p_critHealValue, SpellEventArgs p_result, List <Object> p_targets) { SpellEventArgs eventArgs = GetEventArgs(); if (m_staticData.Damage != null && m_staticData.Damage.Length > 0 && m_staticData.Damage[0].Type == EDamageType.HEAL) { Int32 value = Damage.Create(m_staticData.Damage[0] * p_magicFactor, 0f).Value; for (Int32 i = 0; i < LegacyLogic.Instance.WorldManager.Party.Members.Length; i++) { Character character = LegacyLogic.Instance.WorldManager.Party.Members[i]; if (character.HealthPoints < character.MaximumHealthPoints) { Boolean flag = Random.Range(0f, 1f) < p_critChance; Int32 num = value; if (flag) { num = p_critHealValue; } eventArgs.SpellTargets.Add(new HealedTarget(character, num, flag)); character.ChangeHP(num); DamageEventArgs p_eventArgs = new DamageEventArgs(new AttackResult { Result = EResultType.HEAL, DamageResults = { new DamageResult(EDamageType.HEAL, num, 0, 1f) } }); LegacyLogic.Instance.EventManager.InvokeEvent(character, EEventType.CHARACTER_HEALS, p_eventArgs); } } } eventArgs.Result = ESpellResult.OK; LegacyLogic.Instance.ActionLog.PushEntry(new SpellEffectEntryEventArgs(null, eventArgs)); }
public override void OnDamaged(object source, DamageEventArgs e) { if (!animator.GetCurrentAnimatorStateInfo(0).IsName("Damage")) { animator.Play("Damage"); } else { animator.Play(animator.GetNextAnimatorStateInfo(0).fullPathHash, 0); //BlackAnimator.Update(0); animator.CrossFadeInFixedTime("Damage", 0.25f); animator.SetTrigger("Damage"); } //? 产生白色的info text和黑色的info text,其旋转是不一样的 GameObject blackText = Instantiate(DamageTextPrefab, transform.position + 1.5f * Vector3.up, Quaternion.identity); blackText.SetActive(true); blackText.GetComponent <Transform>().localEulerAngles = new Vector3(0, 180, 0); blackText.layer = 10; blackText.GetComponent <TextMesh>().text = e.DamageValue.ToString(); GameObject whiteText = Instantiate(DamageTextPrefab, transform.position + 1.3f * Vector3.up + 0.05f * Vector3.right, Quaternion.identity); whiteText.SetActive(true); whiteText.layer = 9; whiteText.GetComponent <TextMesh>().text = e.DamageValue.ToString(); Hp -= e.DamageValue; }
protected override void HandlePartyMemberHealing(Single p_magicFactor, Single p_critChance, Int32 p_critHealValue, SpellEventArgs p_result, List <Object> p_targets) { List <Object> list = new List <Object>(LegacyLogic.Instance.WorldManager.Party.Members); if (m_staticData.Damage != null && m_staticData.Damage.Length > 0 && m_staticData.Damage[0].Type == EDamageType.HEAL && !m_resisted) { Int32 value = Damage.Create(m_staticData.Damage[0] * p_magicFactor, 0f).Value; for (Int32 i = 0; i < list.Count; i++) { Int32 num; Boolean p_IsCritical; if (Random.Range(0f, 1f) < p_critChance) { num = p_critHealValue; p_IsCritical = true; } else { num = value; p_IsCritical = false; } p_result.SpellTargets.Add(new HealedTarget(list[i], num, p_IsCritical)); ((Character)list[i]).ChangeHP(num); DamageEventArgs p_eventArgs = new DamageEventArgs(new AttackResult { Result = EResultType.HEAL, DamageResults = { new DamageResult(EDamageType.HEAL, num, 0, 1f) } }); LegacyLogic.Instance.EventManager.InvokeEvent(list[i], EEventType.CHARACTER_HEALS, p_eventArgs); } } }
private void OnAttackLanded(DamageEventArgs args) { if (IncomingAttackLanded != null) { IncomingAttackLanded(args); } }
private void Owner_OnBeingDamage(object sender, DamageEventArgs <Bot> e) { if (Vector3.Dot(e.AttackPosition, new Vector3(Owner.Direction.x, 0, Owner.Direction.z)) < 0 && !e.StrongGPImmuse) { e.Damage -= 20; } }
protected virtual void E_Damaged(DamageEventArgs e) { if (OnDamaged != null) { OnDamaged(this, e); } }
private void IncomingAttackLanded(DamageEventArgs args) { var target = args.Source; var healthable = target.GetComponent <IHealthable>(); Apply(target, healthable); }
public override void _PhysicsProcess(float delta) { var direction = Vector2.Zero; direction.x = Input.GetActionStrength("ui_right") - Input.GetActionStrength("ui_left"); direction.y = Input.GetActionStrength("ui_down") - Input.GetActionStrength("ui_up"); if (leftJoy != Vector2.Zero) { direction = leftJoy; } direction = direction.Normalized(); if (direction != Vector2.Zero) { d = direction; Pivot.Rotation = (d.Angle()); } if (Input.IsActionJustPressed("c")) { int [] mask = { (int)CollisionLayerStatus.Layer1, (int)CollisionLayerStatus.Layer2, (int)CollisionLayerStatus.Layer3 }; BulletEventArgs args = new BulletEventArgs(mask, Facing.GlobalPosition, 50, d, 50, Vector2.Zero, 10); Bullet.Run(this, args); DamageEventArgs e = new DamageEventArgs(5, false); Damage.Run(this, e); // GD.Print("this : ", GlobalPosition); // GD.Print("camera : ", camera.GlobalPosition); } MoveAndCollide(direction); }
void AddictiveDamage(DamageEventArgs damage, BaseUnit attacker, BaseUnit defender) { if (attacker.GetDeckClass() != DeckType && DeckType != Card.DeckClass.Neutral) { return; } damage.Bonus += DamageAdd; }
private void AddFloatingDamageNumber(DamageEventArgs e) { var go = new GameObject(e.damage.ToString()); go.transform.SetParentAndCenter(this.transform); var fdn = go.AddComponent<FloatingDamageNumber>(); fdn.amount = e.damage.amount; fdn.target = this.transform; }
void MultiplicativeDamage(DamageEventArgs damage, BaseUnit attacker, BaseUnit defender) { if (attacker.GetDeckClass() != DeckType && DeckType != Card.DeckClass.Neutral) { return; } damage.Bonus += DamageMult * damage.Value; }
private void OnHeal(Object sender, EventArgs e) { if (m_character != null && sender == m_character && e is DamageEventArgs) { DamageEventArgs damageEventArgs = (DamageEventArgs)e; ShowDamageTextAndAnimationAndPlaySound(damageEventArgs.AttackResult, false, false, true); } }
private void Owner_OnBeingDamage(object sender, DamageEventArgs <Bot> e) { //受到正面攻击 if (!e.StrongGPImmuse && Vector3.Dot(e.AttackPosition - ((Bot)sender).transform.position, ((Bot)sender).Diration2) > 0) { e.Damage -= 40; } }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if (e.Performer is MainCharacter) { Abilities[1].TryEndPerform(true); //Abilities[1].ResetCooldown(); } }
public override void OnTakeDamage(DamageEventArgs e) { base.OnTakeDamage(e); if (nameLabel != null) { nameLabel.Text = this.Name + " (( " + this.Id + " ))" + "\r\n" + Constants.Chat.ME + Utils.PlayerUtils.PlayerHelper.HealthToDescription(this); } }
private void OnGetDamaged(object sender, System.EventArgs e) { DamageEventArgs args = e as DamageEventArgs; if (args.from != null && args.damage > 0) { character.ChangeHealthPoint(-stack); Instantiate(particleEffect, character.transform); } }
private void GetDamage(object sender, System.EventArgs e) { DamageEventArgs args = e as DamageEventArgs; if (args.damage >= damage) { foreach (var effect in effects) { effect.type.Execute(effect.value, 0, GetComponent <CardDisplay>()); } } }
public void GetPenDamage(int damage, Character from) { if (damage > 0) { DamageEventArgs args = new DamageEventArgs(damage, from); OnGetDamaged?.Invoke(this, args); if (args.damage > 0) { character.ChangeHealthPoint(-args.damage); } } }
void ReflectDamage(DamageEventArgs damage, BaseUnit attacker, BaseUnit defender) { if (defender.GetDeckClass() != DeckType && DeckType != Card.DeckClass.Neutral) { return; } int reflect = ReflectFix + (int)(ReflectPercent * damage.Value); if (reflect > 0) { attacker.DealDamage(reflect, defender); } }
public override void Run(GameEvent gameEvent, GameEventArgs eventArgs) { if (!eventArgs.Targets.Contains(Owner)) { return; } DamageEventArgs damageArgs = eventArgs as DamageEventArgs; ReadOnlyCard rCard = new ReadOnlyCard(damageArgs.ReadonlyCard); rCard[ShiChouDamage] = 1; target[ShiChouTarget[Owner]]++; Game.CurrentGame.DoDamage(damageArgs.Source, target, Owner, damageArgs.Magnitude, damageArgs.Element, damageArgs.Card, rCard); throw new TriggerResultException(TriggerResult.End); }
protected override void OnGivesDamage(DamageEventArgs e) { base.OnGivesDamage(e); float yield = RageLevelProcessGain(e.ActualDamage * e.Target.RageYield); AdjustedRageInc(yield); Program.Instance.SignalEvent(new ProgramEvents.MainCharacterStrike { DamageDealt = e.AdjustedDamage }); if (Program.Settings.VampiricMode) { Heal(this, (int)(e.AdjustedDamage * 0.1f)); } }
public void GetHit(object sender, DamageEventArgs args) { if (args.BodyPart == _blocked) { Blocked?.Invoke(this, new FighterEventArgs(HealthPoints, Name)); } else { HealthPoints -= args.Damage; if (!Dead) { Wounded?.Invoke(this, args); } } }
private void OnGetDamage(object sender, System.EventArgs e) { DamageEventArgs args = e as DamageEventArgs; if (args.damage >= 1 && args.from != null) { args.from.characterEvent.GetDamage(args.damage, null); } Settlement(); text.text = stack.ToString(); if (stack <= 0) { Destroy(gameObject); } }
void _battle_DamagedEvent(object sender, DamageEventArgs args) { if (args.Target == Current) { if (args.Damage == 0) { Damege.Show(CurrentDamage, "Miss"); return; } Damege.Show(CurrentDamage, args.Damage.ToString()); CurrentImage.Damaged(); if (args.IsCritical) { Flash.Show(this); MagicCircle.Show(this, 500); CutInFace.Show(this, new NameModelViewModel().Hissatsu, Enemy.MainName, false, 2); DependencyService.Get <IDeviceService>().PlayVibrate(); } else if (MyRandom.GetRandom(10) > 3) { BattleComment.Show(BattleCommentAreaForCurrent, Current.GetBattleComment()); } } else { if (args.Damage == 0) { Damege.Show(EnemyDamage, "Miss"); return; } Damege.Show(EnemyDamage, args.Damage.ToString()); EnemyImage.Damaged(); if (args.IsCritical) { Flash.Show(this); MagicCircle.Show(this, 500); CutInFace.Show(this, new NameModelViewModel().Hissatsu, Current.MainName, true, 2); DependencyService.Get <IDeviceService>().PlayVibrate(); } else if (MyRandom.GetRandom(10) > 3) { BattleComment.Show(BattleCommentAreaForEnemy, Enemy.GetBattleComment()); } } }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if (HitPoints <= MaxHitPoints * 0.1) { meteorRain.MeteorSpawnSpeed = 2; } else if (HitPoints <= MaxHitPoints * 0.3) { meteorRain.MeteorSpawnSpeed = 1; } else if (HitPoints <= MaxHitPoints * 0.5 && first) { meteorRain = new Effects.MeteorRain { MeteorSpawnSpeed = 0.5f }; Game.Instance.Scene.Add(meteorRain); first = false; } }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); var sm = Program.Instance.SoundManager; sm.GetSoundResourceGroup(sm.GetSFX(Sound.SFX.SwordHitWood1), sm.GetSFX(Sound.SFX.SwordHitWood1)).Play(new Sound.PlayArgs { Position = Position, Velocity = Vector3.Zero }); }
void contactListener_DamageExplosive(object sender, DamageEventArgs e) { if (e.damageType == Sprite.Type.LightningShot || e.damageType == Sprite.Type.FireballShot || e.damageType == Sprite.Type.CannonballShot || e.damageType == Sprite.Type.VeggieShot || e.damageType == Sprite.Type.FruitShot) e.damage += 10; if (e.damage > 14) e.sprite.HitPoints = -1; else e.sprite.HitPoints -= (e.damage*e.damage); if (e.sprite.HitPoints <= 0) e.sprite.IsHit = true; }
void contactListener_DamageSpike(object sender, DamageEventArgs e) { if (e.damage == int.MaxValue) e.sprite.IsHit = true; }
void contactListener_DamageFan(object sender, DamageEventArgs e) { if (e.damage == int.MaxValue) { e.sprite.IsAnimated = false; e.sprite.IsAwake = true; } return; }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if (!isFleeing) { fleeTakesDamageAcc += e.AdjustedDamage; if (fleeTakesDamageAcc > 1000) { isFleeing = true; CancelActiveAbilities(); ClearAbilities(); ChangeState(new Idle(this)); var ab = new WolfFlee(); ab.EndPerforming += new EventHandler(ab_EndPerforming); ab.Performer = this; ab.TargetEntity = lastChasing; ab.Mediator = this; ab.TryStartPerform(); } } }
/// <summary> /// Causes damage to be received by this character. Is reduced by defenses and resistances. /// </summary> public void ApplyDamage(GameObject attacker, Damage damage) { var e = new DamageEventArgs() { damage = damage, attacker = attacker, damageLocation = damage.location }; if (Damaged != null) { Damaged(this.gameObject, e); } if (!e.handled) { switch (damage.damageType) { case DamageType.Pure: break; case DamageType.Physical: damage.amount = (int)(damage.amount - damage.amount * PhysicalDefense.PercentageReduced); break; case DamageType.Magical: damage.amount = (int)(damage.amount - damage.amount * MagicalDefense.PercentageReduced); break; case DamageType.Composite: damage.amount = (int)(damage.amount - damage.amount * PhysicalDefense.PercentageReduced); damage.amount = (int)(damage.amount - damage.amount * MagicalDefense.PercentageReduced); break; default: Debug.LogError("Invalid damage type from attacker " + attacker.name); break; } Health.CurrentValue = Mathf.Max(0, Health.CurrentValue - damage.amount); if (Health.CurrentValue <= 0 && Network.isServer) { OnDeath(new UnitDiedEventArgs() { killer = attacker, deathPosition = transform.position, reward = this.reward }); } } }
protected virtual void HandleOnDamaged (DamageEventArgs p_args) { }
void contactListener_DamageBoss(object sender, DamageEventArgs e) { if (isBossHit || isBossDefeated) return; contactListener.ExplodeLitShot(e.sprite); SoundManager.Play(SoundManager.Sound.pw_docbroc, false, true); isBossHit = true; bossHitTimer = 0; bossSpeedMultiplier *= 1.05f; veggieThrowTotal = (int)(veggieThrowTotal * 0.9f); }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if(e.AttackType == AttackType.Melee) Game.Instance.CameraController.LightShake(); Game.Instance.Interface.VisualizeTakesDamage(); float yield = 2 * e.AdjustedDamage * (1 / (float)600); AdjustedRageInc(yield); regenTimer = 5; regenTickTimer = 0; var sm = Program.Instance.SoundManager; sm.GetSFX(global::Client.Sound.SFX.InPain1).Play(new Sound.PlayArgs()); //sm.GetSFX(global::Client.Sound.SFX.PhysicalHitFlesh1).Play(); Game.Instance.Statistics.Actions.DamageTaken += e.ActualDamage; Program.Instance.SignalEvent(new ProgramEvents.MainCharacterTakesDamage { DamageTaken = e.ActualDamage, Perpetrator = e.Performer }); if (e.AttackType == AttackType.Melee) Game.Instance.Statistics.Actions.HitsTaken += 1; }
void NPCGenericAnimation_Damaged(GameObject sender, DamageEventArgs e) { StartFlinchingAnimation(); }
//public override int CalculateHitDamage(Unit striker, int damage, AttackType attackType) //{ // if (Game.Instance.DifficultyLevel == DifficultyLevel.Easy) // return (int)(base.CalculateHitDamage(striker, damage, attackType) * 1.5f); // else if (Game.Instance.DifficultyLevel == DifficultyLevel.Insane) // return base.CalculateHitDamage(striker, damage, attackType) / 2; // else // return base.CalculateHitDamage(striker, damage, attackType); //} protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); if (State == UnitState.Alive) MakeAwareOfUnit(e.Performer); else if (State != UnitState.RaisingCorpse) return; if (onHitSoundCooldown == 0 && onHitSoundPlaybackCount < onHitSoundLimit) { var sm = Program.Instance.SoundManager; if (e.AttackType == AttackType.Bullet) { onHitSoundCooldown = onHitSoundCooldownLength; onHitSoundPlaybackCount++; sm.GetSoundResourceGroup(sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh1), sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh2), sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh5)).Play(new Sound.PlayArgs { Position = Position, Velocity = Vector3.Zero }); } else if (e.AttackType == AttackType.Melee) { onHitSoundCooldown = onHitSoundCooldownLength; onHitSoundPlaybackCount++; sm.GetSoundResourceGroup(sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh1), sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh2), sm.GetSFX(global::Client.Sound.SFX.SwordHitFlesh5)).Play(new Sound.PlayArgs { Position = Position, Velocity = Vector3.Zero }); } } //else //{ // int i = 0; // i = 2; // i++; // Console.Write(i); // //System.Diagnostics.Debugger.Break(); //} }
void contactListener_DamageVeggie(object sender, DamageEventArgs e) { if (e.damage <= 0) return; if (e.damage >= e.sprite.HitPoints) { if (!GameSettings.isBoss) { Camera.AddScore(e.sprite.HitPoints); Camera.AddScoreCombo(); } e.sprite.HitPoints = 0; e.sprite.IsHit = true; } else { Scream(e.sprite); Camera.AddScore(e.damage); e.sprite.HitPoints -= e.damage; } }
void contactListener_DamageStar(object sender, DamageEventArgs e) { if (powerStar == e.sprite) { powerStar.IsExpired = true; if (powerStar.spriteBody != null) physicsWorld.RemoveBody(powerStar.spriteBody); } }
void contactListener_DamageShot(object sender, DamageEventArgs e) { if (GameSettings.CheatInvincibility) e.damage = 0; //turns off activated ability behavior #region pathing ability behavior on damage if (e.sprite.pathing != Sprite.Pathing.None) { if (e.sprite.TextureIndex >= 42 && e.sprite.TextureIndex < 49) { #region Banana pathing off conditions and carry through ability //turn banana pathing off on these collisions if (e.damageType == Sprite.Type.Spring || e.damageType == Sprite.Type.Terrain || e.damageType == Sprite.Type.StaticBlock || e.damageType == Sprite.Type.PowerUp || e.damageType == Sprite.Type.Smasher || e.damageType == Sprite.Type.Switch) { e.sprite.pathing = Sprite.Pathing.None; if (e.sprite.spriteBody != null) e.sprite.spriteBody.IgnoreGravity = false; } else { //turn off banana if its not on its return arc //if ( (shot.PathingSpeed > 0 && shot.pathingTravelled < MathHelper.ToRadians(0)) || // (shot.PathingSpeed < 0 && shot.pathingTravelled > MathHelper.ToRadians(-180)) ) //{ // e.sprite.pathing = Sprite.Pathing.None; // if (e.sprite.spriteBody != null) e.sprite.spriteBody.IgnoreGravity = false; //} //else { //e.sprite.PathingSpeed = 90; //e.sprite.spriteBody.AngularVelocity = 30f; if (LevelDataManager.rand.Next(0,3) != 0) e.sprite.HitPoints += 1; } } #endregion } else { e.sprite.pathing = Sprite.Pathing.None; appleCopterTimer = 0; isAppleCopter = false; if (e.sprite.spriteBody != null) e.sprite.spriteBody.IgnoreGravity = false; } #region strawberry/orange force impact if (e.sprite.SpriteType == Sprite.Type.FruitShot) { if (e.sprite.TextureIndex >= 28 && e.sprite.TextureIndex < 35) //strawberry in any frame { Explosion explosion = new Explosion(physicsWorld); Vector2 explosionLocation = e.sprite.spriteBody.Position; float explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier * e.sprite.Scale * 0.5f); float explosionForce = GameSettings.ExplosivePower * 0.5f * e.sprite.Scale; explosion.Activate(explosionLocation + ConvertUnits.ToSimUnits(new Vector2(32,48)), explosionRadius, explosionForce); explosion.Activate(explosionLocation + ConvertUnits.ToSimUnits(new Vector2(-32,48)), explosionRadius, explosionForce); e.sprite.spriteBody.ResetDynamics(); e.sprite.spriteBody.Rotation = 0; contactListener.DoImpactPoofs(e.sprite.Location + new Vector2(0, 32), e.sprite); e.sprite.IsHit = true; } if (e.sprite.TextureIndex >= 21 && e.sprite.TextureIndex < 28) //orange in any frame { Explosion explosion = new Explosion(physicsWorld); Vector2 explosionLocation = e.sprite.spriteBody.Position; float explosionRadius = ConvertUnits.ToSimUnits(GameSettings.ExplosiveForceRadiusMultiplier * e.sprite.Scale); float explosionForce = GameSettings.ExplosivePower * 0.5f * e.sprite.Scale; explosion.Activate(explosionLocation, explosionRadius, explosionForce); e.sprite.spriteBody.ResetDynamics(); e.sprite.spriteBody.Rotation = 0; contactListener.DoImpactPoofs(e.sprite.Location, e.sprite); e.sprite.IsHit = true; } } #endregion } #endregion if (e.damage > 0) { if (shot.SpriteType == Sprite.Type.FruitShot || shot.SpriteType == Sprite.Type.VeggieShot) Scream(e.sprite); if (shot.SpriteType == Sprite.Type.ExplosiveShot) e.sprite.IsHit = true; e.sprite.HitPoints -= e.damage; if (e.sprite.HitPoints <= 0) e.sprite.IsHit = true; } }
/// <summary> /// Заставляет персонажа получить урон. /// </summary> /// <param name="damageArgs">аргументы наносимого урона</param> public void TakeDamage(DamageEventArgs damageArgs) { TakeDamage(damageArgs.Damage, damageArgs.DamageSource); }
void DamageNumbers_Damaged(GameObject sender, DamageEventArgs e) { if (e == null) Debug.Log("ITS NULL LOLOLOZZ"); AddFloatingDamageNumber(e); }
void unit_TakesDamage(object sender, DamageEventArgs e) { OnTakesDamageScript.TryStartPerform(); nCurrentUses++; if (NUses >= 0 && nCurrentUses >= NUses) EndPerform(false); }
protected override void OnTakesDamage(DamageEventArgs e) { base.OnTakesDamage(e); Program.Instance.SignalEvent(new ProgramEvents.UnitHit { DamageEventArgs = e }); if (e.Performer == Game.Instance.Map.MainCharacter) { Game.Instance.Statistics.Actions.DamageDealt += e.ActualDamage; } }
void contactListener_DamageCreature(object sender, DamageEventArgs e) { e.sprite.HitPoints -= e.damage; if (e.sprite.HitPoints <= 0) e.sprite.IsHit = true; }
/// <summary> /// Damages a character for a specified amount /// </summary> /// <param name="damage">The amount to damage</param> /// <param name="type">The type of the damage</param> public void DamageCharacter(int damage, DamageType type = DamageType.Physical) { // Call the damaged event. DamageEventArgs e = new DamageEventArgs(this, type, damage); E_Damaged(e); this.health -= e.damage; if (e.damage > 0) { MessageLog.Log(name + " was hit for " + damage + " damage"); } else if (e.damage < 0) { MessageLog.Log(name + " was healed for " + (-damage) + " health by the attack!"); } else { MessageLog.Log(name + " was unaffected by the attack..."); } // If health is below zero, call the dead event. if (health <= 0) { MessageLog.Log(name + " died."); E_Killed(new CharEventArgs(this)); } else if (health > maxHealth) { health = maxHealth; } }
void contactListener_DamageSaw(object sender, DamageEventArgs e) { if (e.damage == int.MaxValue) { e.sprite.IsRotating = false; e.sprite.spriteBody.Enabled = false; } return; }
/// <summary> /// Damages a character for a specified amount /// </summary> /// <param name="damage">The amount to damage</param> /// <param name="type">The type of the damage</param> public void DamageOtherCharacter(Character otherChar, int damage, DamageType type = DamageType.Physical) { // Call the damaged event. DamageEventArgs e = new DamageEventArgs(this, type, damage); E_DealDamage(e); otherChar.DamageCharacter (e.damage, e.type); }
void contactListener_DamageSwitch(object sender, DamageEventArgs e) { //the switch has already been hit this shot if it is displaying frame 2, if timer has started, switch cannot be hit again for 1 sec if (e.sprite.CurrentFrame == 2 && e.sprite.Timer != 0) return; e.sprite.CurrentFrame = 2; e.sprite.Timer = 0; //turn the spring fade off or on int switchColor = (e.sprite.TextureIndex / 3); foreach (Sprite sprite in HazardSprites) { if (sprite.SpriteType == Sprite.Type.Spring && sprite.TextureIndex > 4) { int springColor = (sprite.TextureIndex / 5) -1; if (switchColor == springColor) { if (sprite.IsHit) sprite.IsHit = false; else sprite.IsHit = true; } } } }
public float ApplyDamage(float p_damage, bool p_forceApplyDamage = false, bool p_forceDestroyImmediate = false, bool p_isTrueDamage = false) { float v_damageApplyed = 0; if(!CameraFade.InstanceExists()) { p_damage = p_isTrueDamage? p_damage : p_damage*Defense; if(p_damage >= MinDamageToShowCollisionEffect || p_forceApplyDamage) { DamageEventArgs v_args = new DamageEventArgs(this, p_damage); //CallEvent OnDamage if(p_damage > 0) { if(OnDamaged != null) OnDamaged(v_args); CurrentLife -= v_args.Damage; if(CurrentLife <=0) { if(p_forceDestroyImmediate) Destroy(); else MarkToDie(); } v_damageApplyed = p_damage; } } } return v_damageApplyed; }