示例#1
0
        /// <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);
        }
示例#2
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     AttributesComponent   = this.GetDependency <AttributesComponent>();
     CombatComponent       = Parent.GetComponent <CombatComponent>();
     MovementComponent     = this.GetDependency <MovementComponent>();
     FloatingTextComponent = this.GetDependency <FloatingTextComponent>();
 }
示例#3
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     CPComponent         = this.GetDependency <CombatPropertiesComponent>();
     SEAComponent        = Parent.GetComponent <StatusEffectPropertiesComponent>();
     AttributesComponent = this.GetDependency <AttributesComponent>();
     _Timer = TimeSpan.Zero;
 }
示例#4
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     AC = this.GetDependency <AttributesComponent>();
     if (!AC.IsDiedRegistered)
     {
         AC.Died += AC_Died;
     }
     ArenaSystem = Scene.GetSystem <ArenaSystem>();
 }
示例#5
0
 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>();
 }
示例#6
0
        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();
        }
示例#7
0
 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;
     }
 }
示例#8
0
        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();
        }
示例#9
0
        /// <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);
        }
示例#10
0
 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");
 }
示例#11
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     AttributesComponent = this.GetDependency<AttributesComponent>();
     SEAComponent = Parent.GetComponent<StatusEffectPropertiesComponent>();
     CPComponent = this.GetDependency<CombatPropertiesComponent>();
     PC = this.GetDependency<PhysicsComponent>();
 }
示例#12
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     AttributesComponent = this.GetDependency<AttributesComponent>();
     CombatComponent = Parent.GetComponent<CombatComponent>();
     MovementComponent = this.GetDependency<MovementComponent>();
     FloatingTextComponent = this.GetDependency<FloatingTextComponent>();
 }
示例#13
0
 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>();
 }
示例#14
0
        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();
        }
示例#15
0
 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>();
 }
示例#16
0
 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>();
 }
示例#18
0
        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();
        }
示例#19
0
 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();
        }
示例#21
0
 protected override void OnInitialize()
 {
     base.OnInitialize();
     AttributesComponent = this.GetDependency <AttributesComponent>();
     _StatusEffects      = new StatusEffectCollection();
 }