コード例 #1
0
        // Override firing
        protected override void Fire(Unit target)
        {
            int offset = (int)(imprecision * Distance(target) / range);

            if (missilesReady > 0 && missileTimer > missileInterval && (volleyReady || !volleyMode))
            {
                if (tubeLeft)
                {

                    projectiles.Add(new Shell(world, new Vector2(center.X - 3, center.Y - 2), target, dmg, pSpeed,
                        imprecision, sDmg, sRange, pAcceleration, homing));
                    world.CreateAnimation("explosion2", new Vector2(center.X - 3, center.Y - 2), 0.25f, 0, 16.0f);
                }
                else
                {
                    projectiles.Add(new Shell(world, new Vector2(center.X + 3, center.Y - 2), target, dmg, pSpeed,
                        imprecision, sDmg, sRange, pAcceleration, homing));
                    world.CreateAnimation("explosion1", new Vector2(center.X + 3, center.Y - 2), 0.25f, 0, 16.0f);
                }

                tubeLeft = !tubeLeft;       // swap tubes for next that is fired
                firingTimer -= firingRate;  // subtracts a missile from storage
                missilesReady--;
                missileTimer = 0;           // reset missile timer so the next launch is delayed slightly

                if (playSound)
                    world.PlaySound(fireSound, center);

                if (missilesReady == 0)
                    volleyReady = false;    // the entire volley has been fired
            }
        }
コード例 #2
0
ファイル: RifleTower.cs プロジェクト: kinaesthesia/KDefTower
        protected override void Fire(Unit target)
        {
            projectiles.Add(new Bullet(world, center, target, dmg, pSpeed, imprecision));

            firingTimer = 0;

            if (fireSound != null && playSound)
                world.PlaySound(fireSound, center);
        }
コード例 #3
0
ファイル: Projectile.cs プロジェクト: kinaesthesia/KDefTower
        int width, height; // width & height of projectile

        #endregion Fields

        #region Constructors

        // Constructor
        public Projectile(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision)
        {
            this.world = world;
            this.target = target;
            this.position = position;
            this.dmg = dmg;
            this.speed = speed;
            this.imprecision = imprecision;
            this.texProjectile = world.texArrow;
        }
コード例 #4
0
ファイル: Arrow.cs プロジェクト: kinaesthesia/KDefTower
        public Arrow(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texArrow;
            hitAnimation = "red puff";
            missAnimation = "dirt puff";

            SetupProjectile();
            CalculateMovement();
        }
コード例 #5
0
ファイル: FlameTower.cs プロジェクト: kinaesthesia/KDefTower
 protected override void Fire(Unit target)
 {
     if (sTimer > sInterval)
     {
         sTimer = 0;
         if (playSound)
             world.PlaySound(fireSound, center);
     }
     projectiles.Add(new Flame(world, new Vector2(center.X, center.Y - 2), target, dmg, pSpeed,
         imprecision, sDmg, sRange, pAcceleration));
     firingTimer = 0;
 }
コード例 #6
0
ファイル: GammaRay.cs プロジェクト: kinaesthesia/KDefTower
        public GammaRay(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision)
            : base(world, position, target, dmg, speed, imprecision)
        {
            origin = position;
            //texProjectile = world.texRay;

            additive = false;
            scale = 0.4f;

            dType = "energy";

            color = new Color(0, 0, 0, 0);

            CalculateMovement();
            SetupProjectile();
        }
コード例 #7
0
ファイル: Bullet.cs プロジェクト: kinaesthesia/KDefTower
        public Bullet(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texBullet;
            missAnimation = "dirt puff";
            hitAnimation = "red puff";

            additive = true;
            scale = 0.4f;
            dType = "pierce";

            color = new Color(255, 150, 150, 255);

            CalculateMovement();
            SetupProjectile();
        }
コード例 #8
0
ファイル: Pulse.cs プロジェクト: kinaesthesia/KDefTower
        public Pulse(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texBullet;
            missAnimation = "redCircle";
            hitAnimation = "pulseHit";

            dType = "energy";
            acceleration = 0;
            additive = true;
            scale = 0.7f;

            color = new Color(255, 60, 60, 255);

            CalculateMovement();
            SetupProjectile();
        }
コード例 #9
0
ファイル: Concussion.cs プロジェクト: kinaesthesia/KDefTower
        public Concussion(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision, int netSize, float slowEffect, int duration)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texConcussion;
            missAnimation = "concussion";
            hitAnimation = "concussion";
            splash = true;

            dType = "energy";

            this.netSize = netSize;
            this.slowEffect = slowEffect;
            this.duration = duration;

            CalculateMovement();
            SetupProjectile();
        }
コード例 #10
0
ファイル: Flame.cs プロジェクト: kinaesthesia/KDefTower
        public Flame(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision, int sDmg,
            int sRange, float acceleration)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texFire;
            hitAnimation = "explosion3";
            missAnimation = hitAnimation;

            dType = "burn";

            splash = true;
            this.sDmg = sDmg;
            this.sRange = sRange;
            this.homing = homing;
            this.acceleration = acceleration;

            SetupProjectile();
            CalculateMovement();
        }
コード例 #11
0
ファイル: PulseTower.cs プロジェクト: kinaesthesia/KDefTower
        protected override void Fire(Unit target)
        {
            int offset = (int)(imprecision * Distance(target) / range);
            if (missilesReady > 0 && missileTimer > missileInterval && (volleyReady || !volleyMode))
            {
                world.CreateAnimation("redCircle", new Vector2(center.X, center.Y), 0.6f, 0, 15.0f);
                world.CreateAnimation("redCircle", new Vector2(center.X, center.Y), 0.6f, 0, 15.0f);
                projectiles.Add(new Pulse(world, new Vector2(center.X, center.Y), target, dmg, pSpeed,
                        imprecision));

                firingTimer -= firingRate;  // subtracts a missile from storage
                missilesReady--;
                missileTimer = 0;           // reset missile timer so the next launch is delayed slightly

                if (playSound)
                    world.PlaySound(fireSound, center);

                if (missilesReady == 0)
                    volleyReady = false;    // the entire volley has been fired
            }
        }
コード例 #12
0
ファイル: MGTower.cs プロジェクト: kinaesthesia/KDefTower
        // Override firing
        protected override void Fire(Unit target)
        {
            // The mg tower alternates its firing between two points and creates a flash effect as well
            if (barrelLeft)
            {
                world.CreateAnimation("lightCircle", new Vector2(center.X - 5, center.Y - 3), 0.6f, 0, 15.0f);
                projectiles.Add(new Bullet(world, new Vector2(center.X - 5, center.Y), target, dmg, pSpeed, imprecision));
                //world.CreateAnimation("flash", new Vector2(center.X - 5, center.Y - 3), 0.5f, 0, 15.0f);
            }
            else
            {
                world.CreateAnimation("lightCircle", new Vector2(center.X + 5, center.Y - 3), 0.6f, 0, 15.0f);
                projectiles.Add(new Bullet(world, new Vector2(center.X + 5, center.Y), target, dmg, pSpeed, imprecision));
                //world.CreateAnimation("flash", new Vector2(center.X + 5, center.Y - 3), 0.5f, 0, 15.0f);
            }

            if (playSound)
                world.PlaySound(fireSound, center);

            barrelLeft = !barrelLeft; // other barrel for next shot
            firingTimer = 0;
        }
コード例 #13
0
ファイル: Shell.cs プロジェクト: kinaesthesia/KDefTower
        public Shell(World world, Vector2 position, Unit target, int dmg, float speed, int imprecision, int sDmg,
            int sRange, float acceleration, Boolean homing)
            : base(world, position, target, dmg, speed, imprecision)
        {
            texProjectile = world.texRocket;

            hitAnimation = "explosion1";
            hitSound = "RndExplosion";
            missAnimation = hitAnimation;

            dType = "explosive";
            maxSpeed = 15;
            splash = true;

            this.sDmg = sDmg;
            this.sRange = sRange;
            this.homing = homing;
            this.acceleration = acceleration;

            SetupProjectile();
            CalculateMovement();
        }
コード例 #14
0
ファイル: Tower.cs プロジェクト: kinaesthesia/KDefTower
 // Gets the distance between target and tower's center
 protected float Distance(Unit target)
 {
     // Standard distance formula
     return (target.Center - center).Length();
 }
コード例 #15
0
ファイル: Tower.cs プロジェクト: kinaesthesia/KDefTower
        // Fire a new projectile at target and reset firing timer
        protected virtual void Fire(Unit target)
        {
            // Very simple firing method that should be overridden by a more
            // unique method for new towers.  Firing consists of adding
            // projectiles with specific targets and then reloading
            projectiles.Add(new Arrow(world, center, target, dmg, pSpeed, imprecision));

            // Setting the firing timer to 0 requires the tower to have to wait
            // until it can fire again (reload)
            firingTimer -= firingRate;

            if (fireSound != null && playSound)
                world.PlaySound(fireSound, center);
        }
コード例 #16
0
 protected override void Fire(Unit target)
 {
     if (firingTimer >= firingRate)
     {
         if (playSound)
             world.PlaySound(fireSound, center);
         target.Damage(dmg + dmgBonus, "energy");
         world.CreateAnimation("beamHit", target.Center, 0.25f, 0, 10f);
         world.CreateAnimation("lightCircle", target.Center, 0.25f, 0, 10f);
         firingTimer = 0f;
         dmgBonus += dmg;
     }
 }
コード例 #17
0
 public override void undoEffect(Unit unit)
 {
 }
コード例 #18
0
 public override void applyEffects(Unit unit)
 {
     unit.Damage(burnDmg,"burn");
 }
コード例 #19
0
ファイル: World.cs プロジェクト: kinaesthesia/KDefTower
        // Handles the entire process of creating unit waves and bosses
        private void UpdateWaves()
        {
            spawnTimer += (float)time.ElapsedGameTime.TotalMilliseconds;

            if (bossUnit!= null && bossEvent && bossUnit.Dead)
            {
                bossEvent = false;
                //game.music.EndBossEvent();
            }

            // Time for a new wave
            if (spawnTimer > spawnInterval)
            {
                int spawn = spawnRand.Next(spawns.Length);

                // Move through the unit type sequence
                unitType++;
                if (unitType == 5)
                    unitType = 1;

                // Add the new wave
                waves.Add(new Wave(game, unitType, spawns[spawn],
                    spawnSize, tile, unitInterval));
                game.status.Wave += 1;
                spawnTimer = 0f;

                // Add a boss if its time to
                if (game.status.Wave % numberOfWavesPerStage == 0)
                {
                    bossEvent = true;
                    bossUnit = new Unit(game, spawns[spawn], Vector2.Zero, Vector2.Zero, 0.5f, 1,
                        texUnit, texUnitDead, game.status.Wave * 2, game.status.Wave * 1000);
                    bossUnit.Scale = 0.6f;
                    bossUnit.Color = Color.MediumOrchid;
                    enemyUnits.Add(bossUnit);
                    //game.music.TriggerBossEvent();
                    game.status.Created++;
                }
            }

            // Remove old waves and update current ones
            for (int i = 0; i < waves.Count; i++)
            {
                waves[i].Update(time);
                if (waves[i].Finished)
                {
                    waves.RemoveAt(i);
                    i--;
                }
            }
        }
コード例 #20
0
ファイル: Projectile.cs プロジェクト: kinaesthesia/KDefTower
        // Checks to see which targets are in splash range of the projectile
        protected Boolean IsInSRange(Unit target)
        {
            if ((Math.Sqrt(Math.Pow(target.Position.X - position.X, 2) +
                Math.Pow(target.Position.Y - position.Y, 2))) < sRange)
                return true;

            return false;
        }
コード例 #21
0
        protected override void Fire(Unit target)
        {
            projectiles.Add(new Concussion(world, pOrigin, AcquireClosestTarget(), dmg, pSpeed, imprecision, sRange, slowEffect, duration));

            firingTimer = 0;
        }
コード例 #22
0
 public override void applyEffects(Unit unit)
 {
     unit.Speed = unit.DSpeed * (1 - slowEffect);
 }
コード例 #23
0
 public override void undoEffect(Unit unit)
 {
     unit.Speed = unit.DSpeed;
 }
コード例 #24
0
ファイル: UnitEffects.cs プロジェクト: kinaesthesia/KDefTower
 public abstract void undoEffect(Unit unit);
コード例 #25
0
 protected override void Fire(Unit target)
 {
     addEffect();
 }
コード例 #26
0
ファイル: UnitEffects.cs プロジェクト: kinaesthesia/KDefTower
 public abstract void applyEffects(Unit unit);
コード例 #27
0
ファイル: Tower.cs プロジェクト: kinaesthesia/KDefTower
        // Update the tower and its projectiles
        public virtual void Update(GameTime gameTime)
        {
            ArrayList keysToRemove = applyEffects(gameTime);
            removeEffect(keysToRemove);

            // Increments the firing timer until tower can fire
            Reload(gameTime);

            // If ready to fire...
            if (firingTimer >= firingRate && targetCheckTimer >= targetCheckInterval)
            {
                // Update target if current one is dead or out of range
                if (target == null || target.Dead || Distance(target) > range)
                {
                    target = CheckForTargets();
                    if (target == null)
                        targetCheckTimer = 0;
                }
                else
                {
                    Fire(target); // If there is a valid target, fire at it
                }
            }
            else
            {
                targetCheckTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
            }
            UpdateProjectiles(); // update projectiles
        }