/// <summary> /// Applies damage, with the normal rules, based on the attacker's attributes. /// </summary> public void TakeDamage(AttributesComponent attacker, float modifier = 1f) { if (_IsHit) return; _IsHit = true; _LastHit = DateTime.Now; float blockMultipler = BlockDamageReduction(attacker.Parent); float damageTaken = NormalDamageFormula(AttributesComponent.Defense, attacker.Attack); float criticalMultiplier = CriticalDamageChance(attacker.CriticalChance, attacker.CriticalDamage); float elementalMultiplier = ElementalDamage(AttributesComponent.ResistantElements, AttributesComponent.ElementPower, attacker.AttackingElements, attacker.ElementPower); float overallDamage = damageTaken * criticalMultiplier * blockMultipler * elementalMultiplier * modifier; AttributesComponent.CurrentHealth -= overallDamage; if (criticalMultiplier != 1) //critical hit. FloatingTextComponent.Add(overallDamage, Color.Orange); else if (elementalMultiplier > 1) //entity is weak to that element FloatingTextComponent.Add(overallDamage, Color.Crimson); else if (elementalMultiplier < 1) //entity is resistant to that element FloatingTextComponent.Add(overallDamage, Color.Navy); else FloatingTextComponent.Add(overallDamage, Color.White); //vibrate! GamepadComponent.Vibrate(this.Parent, 0.5f, 0f, 0.5f); PlayHitSound(blockMultipler); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency <AttributesComponent>(); CombatComponent = Parent.GetComponent <CombatComponent>(); MovementComponent = this.GetDependency <MovementComponent>(); FloatingTextComponent = this.GetDependency <FloatingTextComponent>(); }
protected override void OnInitialize() { base.OnInitialize(); CPComponent = this.GetDependency <CombatPropertiesComponent>(); SEAComponent = Parent.GetComponent <StatusEffectPropertiesComponent>(); AttributesComponent = this.GetDependency <AttributesComponent>(); _Timer = TimeSpan.Zero; }
protected override void OnInitialize() { base.OnInitialize(); AC = this.GetDependency <AttributesComponent>(); if (!AC.IsDiedRegistered) { AC.Died += AC_Died; } ArenaSystem = Scene.GetSystem <ArenaSystem>(); }
protected override void OnInitialize() { base.OnInitialize(); MovementComponent = this.GetDependency <MovementComponent>(); PathComponent = this.GetDependency <PathComponent>(); MovementComponent = this.GetDependency <MovementComponent>(); CombatComponent = this.GetDependency <CombatComponent>(); PhysicsSystem = Parent.Scene.GetSystem <PhysicsSystem>(); PhysicsComponent = this.GetDependency <PhysicsComponent>(); AttributesComponent = this.GetDependency <AttributesComponent>(); SpriteComponent = this.GetDependency <SpriteComponent>(); HealthBarComponent = this.GetDependency <HealthBarComponent>(); DamageComponent = this.GetDependency <DamageComponent>(); }
void AC_Died(AttributesComponent obj) { EC.RemoveWeapons(); AudioManager.PlaySoundEffect(DyingSound); var deaded = DyingComponent.CreateDyingEntity(this.Parent, DyingSprite, DyingDuration); if (!CorvusGame.Instance.SceneManager.ActiveScene.Name.Contains("Arena")) //TODO: Better remember to change this if we need to. { deaded.GetComponent <DyingComponent>().OnDyingAnimationFinished += PlayerControlComponent_OnDyingAnimationFinished; } obj.Parent.Dispose(); }
protected override void OnInitialize() { base.OnInitialize(); AC = this.GetDependency <AttributesComponent>(); MC = this.GetDependency <MovementComponent>(); CC = this.GetDependency <CombatComponent>(); PC = this.GetDependency <PhysicsComponent>(); SC = this.GetDependency <SpriteComponent>(); EC = this.GetDependency <EquipmentComponent>(); ScoreComponent = this.GetDependency <ScoreComponent>(); _IsAttacking = false; if (!AC.IsDiedRegistered) { AC.Died += AC_Died; } }
void AC_Died(AttributesComponent obj) { //Drop coins int c = CoinsValue; int gold = (c < 5) ? 0 : c /= 5; int silver = (c < 3) ? 0 : c /= 3; int bronze = c; for (int i = 0; i < gold; i++) { GenerateCoinEntity("Coin_Gold", 2f - ((float)i) / 10); } for (int i = 0; i < silver; i++) { GenerateCoinEntity("Coin_Silver", 1.5f - ((float)i) / 10); } for (int i = 0; i < bronze; i++) { GenerateCoinEntity("Coin_Bronze", 1f - ((float)i) / 10); } AudioManager.PlaySoundEffect("CoinDrop"); //Give exp. //CorvBase.Instance.Players foreach (var p in CorvBase.Instance.Players) { var pcp = p.Character.GetComponent <PlayerControlComponent>(); pcp.CurrentExperience += AwardedExperience; } //play sound AudioManager.PlaySoundEffect(DyingSound); var deaded = DyingComponent.CreateDyingEntity(this.Parent, DyingSprite, DyingDuration); deaded.GetComponent <DyingComponent>().OnDyingAnimationFinished += DestroyableObjectComponent_OnDyingAnimationFinished; obj.Parent.Dispose(); }
/// <summary> /// Applies damage, with the normal rules, based on the attacker's attributes. /// </summary> public void TakeDamage(AttributesComponent attacker, float modifier = 1f) { if (_IsHit) { return; } _IsHit = true; _LastHit = DateTime.Now; float blockMultipler = BlockDamageReduction(attacker.Parent); float damageTaken = NormalDamageFormula(AttributesComponent.Defense, attacker.Attack); float criticalMultiplier = CriticalDamageChance(attacker.CriticalChance, attacker.CriticalDamage); float elementalMultiplier = ElementalDamage(AttributesComponent.ResistantElements, AttributesComponent.ElementPower, attacker.AttackingElements, attacker.ElementPower); float overallDamage = damageTaken * criticalMultiplier * blockMultipler * elementalMultiplier * modifier; AttributesComponent.CurrentHealth -= overallDamage; if (criticalMultiplier != 1) //critical hit. { FloatingTextComponent.Add(overallDamage, Color.Orange); } else if (elementalMultiplier > 1) //entity is weak to that element { FloatingTextComponent.Add(overallDamage, Color.Crimson); } else if (elementalMultiplier < 1) //entity is resistant to that element { FloatingTextComponent.Add(overallDamage, Color.Navy); } else { FloatingTextComponent.Add(overallDamage, Color.White); } //vibrate! GamepadComponent.Vibrate(this.Parent, 0.5f, 0f, 0.5f); PlayHitSound(blockMultipler); }
protected override void OnInitialize() { base.OnInitialize(); EquipmentComponent = Parent.GetComponent<EquipmentComponent>(); AttributesComponent = this.GetDependency<AttributesComponent>(); MovementComponent = this.GetDependency<MovementComponent>(); SpriteComponent = this.GetDependency<SpriteComponent>(); PhysicsSystem = Parent.Scene.GetSystem<PhysicsSystem>(); PhysicsComponent = Parent.GetComponent<PhysicsComponent>(); CombatPropertiesComponent = this.GetDependency<CombatPropertiesComponent>(); _ShieldAnimation = new ShieldAnimation(this.Parent, "Sprites/Misc/Shield_Yellow2"); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency<AttributesComponent>(); SEAComponent = Parent.GetComponent<StatusEffectPropertiesComponent>(); CPComponent = this.GetDependency<CombatPropertiesComponent>(); PC = this.GetDependency<PhysicsComponent>(); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency<AttributesComponent>(); CombatComponent = Parent.GetComponent<CombatComponent>(); MovementComponent = this.GetDependency<MovementComponent>(); FloatingTextComponent = this.GetDependency<FloatingTextComponent>(); }
protected override void OnInitialize() { base.OnInitialize(); MovementComponent = this.GetDependency<MovementComponent>(); PathComponent = this.GetDependency<PathComponent>(); MovementComponent = this.GetDependency<MovementComponent>(); CombatComponent = this.GetDependency<CombatComponent>(); PhysicsSystem = Parent.Scene.GetSystem<PhysicsSystem>(); PhysicsComponent = this.GetDependency<PhysicsComponent>(); AttributesComponent = this.GetDependency<AttributesComponent>(); SpriteComponent = this.GetDependency<SpriteComponent>(); HealthBarComponent = this.GetDependency<HealthBarComponent>(); DamageComponent = this.GetDependency<DamageComponent>(); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency<AttributesComponent>(); //_Weapons = new WeaponCollection(); if(string.IsNullOrEmpty(DefaultWeaponName)) return; if (Weapons.Count != 0) return; _CurrentWeaponIndex = 0; //Creates the weapon from a blueprint. var weapon = CorvEngine.Components.Blueprints.EntityBlueprint.GetBlueprint(DefaultWeaponName).CreateEntity(); var attri = weapon.GetComponent<AttributesComponent>(); var props = weapon.GetComponent<CombatPropertiesComponent>(); var data = weapon.GetComponent<WeaponPropertiesComponent>(); var effect = weapon.GetComponent<StatusEffectPropertiesComponent>(); _DefaultWeapon = new Weapon(data.WeaponData, props.CombatProperties, attri.Attributes, effect.StatusEffectAttributes); Weapons.Add(_DefaultWeapon); weapon.Dispose(); }
private void LoadDependencies() { this.AC = Player.Character.GetComponent<AttributesComponent>(); this.EC = Player.Character.GetComponent<EquipmentComponent>(); this.PCC = Player.Character.GetComponent<PlayerControlComponent>(); this.SC = Player.Character.GetComponent<ScoreComponent>(); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency<AttributesComponent>(); _StatusEffects = new StatusEffectCollection(); }
protected override void OnInitialize() { base.OnInitialize(); AC = this.GetDependency<AttributesComponent>(); if(!AC.IsDiedRegistered) AC.Died += AC_Died; ArenaSystem = Scene.GetSystem<ArenaSystem>(); }
void AC_Died(AttributesComponent obj) { EC.RemoveWeapons(); AudioManager.PlaySoundEffect(DyingSound); var deaded = DyingComponent.CreateDyingEntity(this.Parent, DyingSprite, DyingDuration); if(!CorvusGame.Instance.SceneManager.ActiveScene.Name.Contains("Arena")) //TODO: Better remember to change this if we need to. deaded.GetComponent<DyingComponent>().OnDyingAnimationFinished += PlayerControlComponent_OnDyingAnimationFinished; obj.Parent.Dispose(); }
protected override void OnInitialize() { base.OnInitialize(); AC = this.GetDependency<AttributesComponent>(); MC = this.GetDependency<MovementComponent>(); CC = this.GetDependency<CombatComponent>(); PC = this.GetDependency<PhysicsComponent>(); SC = this.GetDependency<SpriteComponent>(); EC = this.GetDependency<EquipmentComponent>(); ScoreComponent = this.GetDependency<ScoreComponent>(); _IsAttacking = false; if (!AC.IsDiedRegistered) AC.Died += AC_Died; }
void AC_Died(AttributesComponent obj) { //Drop coins int c = CoinsValue; int gold = (c < 5) ? 0 : c /= 5; int silver = (c < 3) ? 0 : c /= 3; int bronze = c; for (int i = 0; i < gold; i++) GenerateCoinEntity("Coin_Gold", 2f - ((float)i) / 10); for (int i = 0; i < silver; i++) GenerateCoinEntity("Coin_Silver", 1.5f - ((float)i) / 10); for (int i = 0; i < bronze; i++) GenerateCoinEntity("Coin_Bronze", 1f - ((float)i) / 10); AudioManager.PlaySoundEffect("CoinDrop"); //Give exp. //CorvBase.Instance.Players foreach (var p in CorvBase.Instance.Players) { var pcp = p.Character.GetComponent<PlayerControlComponent>(); pcp.CurrentExperience += AwardedExperience; } //play sound AudioManager.PlaySoundEffect(DyingSound); var deaded = DyingComponent.CreateDyingEntity(this.Parent, DyingSprite, DyingDuration); deaded.GetComponent<DyingComponent>().OnDyingAnimationFinished += DestroyableObjectComponent_OnDyingAnimationFinished; obj.Parent.Dispose(); }
protected override void OnInitialize() { base.OnInitialize(); AttributesComponent = this.GetDependency <AttributesComponent>(); _StatusEffects = new StatusEffectCollection(); }