Exemplo n.º 1
0
        private void CalculateAndSendSplashImpactEffectByBaseEvent(List <HitTarget> splashTargets, StaticHit staticHit, List <HitTarget> targets, SplashImpactNode weapon, TankPhysicsNode tank)
        {
            SplashImpactComponent splashImpact = weapon.splashImpact;
            SplashWeaponComponent splashWeapon = weapon.splashWeapon;
            Vector3 vector = (staticHit == null) ? targets[0].TargetPosition : staticHit.Position;
            float   impactWeakeningByRange = 1f;

            if (weapon.Entity.HasComponent <DamageWeakeningByDistanceComponent>())
            {
                float magnitude = (tank.rigidBody.Rigidbody.position - vector).magnitude;
                impactWeakeningByRange = base.GetImpactWeakeningByRange(magnitude, weapon.Entity.GetComponent <DamageWeakeningByDistanceComponent>());
            }
            foreach (HitTarget target in splashTargets)
            {
                float       hitDistance = target.HitDistance;
                float       splashImpactWeakeningByRange = this.GetSplashImpactWeakeningByRange(hitDistance, splashWeapon);
                ImpactEvent eventInstance = new ImpactEvent();
                Vector3     vector4       = (Vector3.Normalize(target.HitDirection) * splashImpact.ImpactForce) * WeaponConstants.WEAPON_FORCE_MULTIPLIER;
                eventInstance.Force          = (vector4 * impactWeakeningByRange) * splashImpactWeakeningByRange;
                eventInstance.LocalHitPoint  = target.LocalHitPoint;
                eventInstance.WeakeningCoeff = splashImpactWeakeningByRange;
                Entity[] entities = new Entity[] { weapon.Entity, target.Entity };
                base.NewEvent(eventInstance).AttachAll(entities).Schedule();
            }
        }
Exemplo n.º 2
0
        private float GetSplashImpactWeakeningByRange(float distance, SplashWeaponComponent splashWeapon)
        {
            float radiusOfMaxSplashDamage = splashWeapon.RadiusOfMaxSplashDamage;
            float radiusOfMinSplashDamage = splashWeapon.RadiusOfMinSplashDamage;
            float minSplashDamagePercent  = splashWeapon.MinSplashDamagePercent;

            return((distance >= radiusOfMaxSplashDamage) ? ((distance <= radiusOfMinSplashDamage) ? (0.01f * (minSplashDamagePercent + (((radiusOfMinSplashDamage - distance) * (100f - minSplashDamagePercent)) / (radiusOfMinSplashDamage - radiusOfMaxSplashDamage)))) : 0f) : 1f);
        }