Beispiel #1
0
        // Item Collides with Etem. Resolution Occours on Item
        public bool BoundingBoxCollision(ref Kinetic item, ref Kinetic etem, ref Vector2 result)
        {
            bool collision = false;

            result.X = item.position.X;
            result.Y = item.position.Y;
            if (item.boundingBox.Intersects(etem.boundingBox))
            {
                if (item.boundingBox.Right >= etem.boundingBox.Left && item.boundingBox.Right <= etem.boundingBox.Left + 10.0f)
                {
                    result.X  = etem.position.X - item.boundingBox.Width;
                    collision = true;
                }
                else if (item.boundingBox.Left <= etem.boundingBox.Right && item.boundingBox.Left >= etem.boundingBox.Right - 10.0f)
                {
                    result.X  = etem.boundingBox.Right;
                    collision = true;
                }

                if (item.boundingBox.Bottom >= etem.boundingBox.Top && item.boundingBox.Bottom <= etem.boundingBox.Top + 20.0f)
                {
                    result.Y  = etem.boundingBox.Top - item.boundingBox.Height;
                    collision = true;
                }
                else if (item.boundingBox.Top <= etem.boundingBox.Bottom && item.boundingBox.Top >= etem.boundingBox.Bottom - 20.0f)
                {
                    result.Y  = etem.boundingBox.Bottom;
                    collision = true;
                }
            }
            return(collision);
        }
Beispiel #2
0
 public DamageBox(Vector2 Position, Vector2 Velocity, int Time, bool Friendly)
 {
     sprite            = Islander.content.Load <Texture2D>("Hero");
     kinetics          = Kinetic.ZERO();
     kinetics.position = Position;
     kinetics.velocity = Velocity;
     Kinetic.SetBoundingBoxDimensions(ref kinetics.boundingBox, sprite);
     dead     = false;
     time     = Time;
     friendly = Friendly;
 }
        /// <summary>
        /// Returns how much armor and health is left, possibly if the target has died.
        /// Returns are the following: 0 is Remaining AV, 1 is Remaining HP
        /// </summary>
        public static float[] GetTargetDamage(Kinetic kinetic, Heat heat, Vehicle vehicle, ERA era, float distance)
        {
            float armorPiercingDamage = 0f;
            float heatPiercingDamage  = 0f;

            //bool ERABlocksShot = false;

            // Apply KE attenuation
            kinetic.Pierce = CalculateKEAttenuationSimple(kinetic.Pierce, distance, FrictionFactor);

            // Kinetic Armor Degradation
            if (era.Plates < 1 && vehicle.Armor > 0)
            {
                armorPiercingDamage = (kinetic.Pierce / vehicle.Armor) * kinetic.ArmorKineticFactor;
                Debug.WriteLine($"Armor Piercing Damage: {armorPiercingDamage}");
            }

            if (era.Plates > 0)
            {
                armorPiercingDamage = (kinetic.Pierce / era.Bonus) * kinetic.ArmorKineticFactor;
                float eraArmor = era.Bonus - (armorPiercingDamage * era.PiercingFactor);

                if (eraArmor > 0)
                {
                    armorPiercingDamage = 0;
                }
                else if (vehicle.Armor > 0)
                {
                    armorPiercingDamage = ((eraArmor * -1) / vehicle.Armor) * kinetic.ArmorKineticFactor;
                }
            }

            Debug.WriteLine($"Armor Piercing Damage: {armorPiercingDamage}");

            // Heat Armor Degradation

            /*heatPiercingDamage = (era.Plates < 1 && vehicle.Armor > 0) ?
             *                       (heat.Piercing / vehicle.Armor) * heat.ArmorHeatFactor :
             *                        heatPiercingDamage;*/

            if (era.Plates < 1 && vehicle.Armor > 0)
            {
                heatPiercingDamage = (heat.Pierce / vehicle.Armor) * heat.ArmorHeatFactor;
                Debug.WriteLine($"Heat Piercing Damage: {heatPiercingDamage}");
            }

            if (era.Plates > 0)
            {
                heatPiercingDamage = (heat.Pierce / era.Bonus) * heat.HealthHeatFactor;
                float eraArmor = era.Bonus - (heatPiercingDamage * era.ExplosiveFactor);

                if (era.Bonus > 0)
                {
                    heatPiercingDamage = 0;
                }
                else if (vehicle.Armor > 0)
                {
                    heatPiercingDamage = ((eraArmor * -1) / vehicle.Armor) * heat.ArmorHeatFactor;
                }
            }

            Debug.WriteLine($"Heat Piercing Damage: {heatPiercingDamage}");



            // Total armor degradation
            var totalDegradation = armorPiercingDamage + heatPiercingDamage;

            vehicle.Armor -= totalDegradation;
            if (vehicle.Armor < 0)
            {
                vehicle.Armor = 0;
            }
            Debug.WriteLine($"Total Degradation: {totalDegradation}");
            Debug.WriteLine($"Vehicle Armor: {vehicle.Armor}");

            // AP -> HP damage
            float kineticHealthDamage = (kinetic.Pierce - vehicle.Armor) * kinetic.HealthKineticFactor;

            if (kineticHealthDamage < 0)
            {
                kineticHealthDamage = 0;
            }


            Debug.WriteLine($"Kinetic Health Damage: {kineticHealthDamage}");

            // HE -> HP damage
            float heatHealthDamage = (heat.Pierce - vehicle.Armor) * heat.HealthHeatFactor;

            if (heatHealthDamage < 0)
            {
                kineticHealthDamage = 0;
            }


            if (vehicle.Armor == 0 && era.Plates > 0)
            {
                kineticHealthDamage -= era.Bonus;
                heatHealthDamage    -= era.Bonus;
            }

            era.Plates = era.Plates - 1;

            Debug.WriteLine($"ERA Plates: {era.Plates}");

            // Total health reduction
            vehicle.Health = vehicle.Health - (kineticHealthDamage + heatHealthDamage);

            // just to prevent any bugs, i'm resetting any negative values

            if (era.Plates < 0)
            {
                era.Plates = 0;
            }

            if (vehicle.Armor < 0)
            {
                vehicle.Armor = 0;
            }

            if (vehicle.Health < 0)
            {
                vehicle.Health = 0;
            }

            Math.Round(vehicle.Armor, 2);
            Math.Round(vehicle.Health, 2);

            return(new float[] { vehicle.Armor, vehicle.Health, era.Plates });
        }