Exemplo n.º 1
0
        // Adds the given items and returns the resultant Weapon
        public WeaponStats WithAugments(IEnumerable <WeaponAugmentTemplate> augments)
        {
            // Add up all the Stats of all the items
            WeaponAugmentTemplate overallAugment = this.BaseStats;

            foreach (WeaponAugmentTemplate augment in augments)
            {
                overallAugment = overallAugment.Plus(augment);
            }

            // Now do some last computations on the totals (like converting from rates to times)
            WeaponStats weapon = new WeaponStats();

            // Attributes about when you may fire
            weapon.OwnersVelocityScale = 1;
            weapon.MaxAmmo             = overallAugment.MaxAmmo;
            weapon.WarmupTime          = 1 / overallAugment.WarmupRate;
            weapon.CooldownTime        = 1 / overallAugment.CooldownRate;

            // Attributes of the projectile it launches, to determine when it hits
            Projectile templateProjectile = new Projectile();

            templateProjectile.setVelocity(new double[] { 100, 0 });
            templateProjectile.setRemainingFlightTime(overallAugment.FlightDuration);
            templateProjectile.setPenetration(0.5);
            templateProjectile.setNumExplosionsRemaining(overallAugment.MaxNumExplosions);
            templateProjectile.setHomingAccel(overallAugment.HomingAccel);
            templateProjectile.enableHomingOnCharacters(true);
            templateProjectile.enableHomingOnProjectiles(true);
            templateProjectile.setBoomerangAccel(0);
            templateProjectile.setShape(new GameCircle(10));
            templateProjectile.setBitmap(this.ProjectileBitmap);

            weapon.TemplateProjectile = templateProjectile;

            // Attributes of the explosion it creates, to determine what happens in the area it hits
            Explosion templateExplosion = new Explosion();

            templateExplosion.setDuration(overallAugment.ExplosionDuration);
            templateExplosion.setFriendlyFireEnabled(false);
            templateExplosion.setKnockbackAccel(0);
            templateExplosion.setShape(new GameCircle(overallAugment.ExplosionRadius));
            templateExplosion.setBitmap(this.ExplosionBitmap);

            templateProjectile.setTemplateExplosion(templateExplosion);

            // Attributes of the stun that gets applied to characters caught in the explosion
            Stun templateStun = new Stun();

            templateStun.setTimeMultiplier(1.0 / (overallAugment.TimestopWeight + 1));
            templateStun.setDamagePerSecond(overallAugment.StunDamagePerSecond);
            templateStun.setAmmoDrain(0);
            templateStun.setDuration(overallAugment.StunDuration);

            templateExplosion.setTemplateStun(templateStun);

            return(weapon);
        }
        // update the attributes of the current weapon based on the text fields
        void updateCurrentWeapon()
        {
            templateWeapon = new Weapon();
            // attributes of the weapon
            templateWeapon.setMaxAmmo(parseDouble(maxAmmo));
            templateWeapon.refillAmmo();
            templateWeapon.setAmmoRechargeRate(parseDouble(ammoRechargeRate));
            templateWeapon.setAmmoPerBox(parseDouble(ammoPerBox));
            templateWeapon.setWarmupTime(parseDouble(warmupTime));
            templateWeapon.setCooldownTime(parseDouble(cooldownTime));
#if SWITCH_TIMES
            templateWeapon.setSwitchToTime(parseDouble(switchToTime));
            templateWeapon.setSwitchFromTime(parseDouble(switchFromTime));
#endif
            templateWeapon.setAutomatic(automatic.IsChecked.Value);
            templateWeapon.setTriggerSticky(stickyTrigger.IsChecked.Value);
            templateWeapon.setOwnersVelocityScale(parseDouble(ownersVelocityScale));
            templateWeapon.enableFiringWhileInactive(fireWhileInactive.IsChecked.Value);
            templateWeapon.enableCooldownWhileInactive(cooldownWhileInactive.IsChecked.Value);
            templateWeapon.enableRechargeWhileInactive(rechargeWhileInactive.IsChecked.Value);

            Projectile templateProjectile = new Projectile();
            double[]   tempVector         = new double[2];
            tempVector[0] = parseDouble(projectileX);
            tempVector[1] = parseDouble(projectileY);
            templateProjectile.setCenter(tempVector);
            tempVector[0] = parseDouble(projectileVX);
            tempVector[1] = parseDouble(projectileVY);
            templateProjectile.setVelocity(tempVector);
            templateProjectile.setDragCoefficient(parseDouble(projectileDrag));
            templateProjectile.setGravity(parseDouble(projectileGravity));
            templateProjectile.setBitmap(ImageLoader.loadImage(projectileImage.Text));
            templateProjectile.setShape(new GameCircle(parseDouble(projectileRadius)));
            templateProjectile.setRemainingFlightTime(parseDouble(remainingFlightTime));
            templateProjectile.setNumExplosionsRemaining(parseInt(numExplosionsRemaining));
            templateProjectile.setPenetration(parseDouble(penetration));
            templateProjectile.setHomingAccel(parseDouble(homingAccel));
            templateProjectile.setBoomerangAccel(parseDouble(boomerangAccel));
            templateProjectile.enableHomingOnProjectiles(homeOnProjectiles.IsChecked.Value);
            templateProjectile.enableHomingOnCharacters(homeOnCharacters.IsChecked.Value);
            templateWeapon.setTemplateProjectile(templateProjectile);

            Explosion templateExplosion = new Explosion();
            templateExplosion.setBitmap(ImageLoader.loadImage(explosionImage.Text));
            templateExplosion.setShape(new GameCircle(parseDouble(explosionRadius)));
            templateExplosion.setDuration(parseDouble(explosionDuration));
            templateExplosion.setFriendlyFireEnabled(friendlyFire.IsChecked.Value);
            templateExplosion.setKnockbackAccel(parseDouble(knockBack));
            templateProjectile.setTemplateExplosion(templateExplosion);

            Stun templateStun = new Stun();
            templateStun.setTimeMultiplier(parseDouble(timeMultiplier));
            templateStun.setDamagePerSecond(parseDouble(damagePerSecond));
            templateStun.setAmmoDrain(parseDouble(ammoDrain));
            templateStun.setDuration(parseDouble(stunDuration));
            templateExplosion.setTemplateStun(templateStun);
        }