void fireTimer_Fire()
        {
            if (this.Dead)
                return;

            //Pick a random player as target
            target = GameNode.PickRandomNode(Enemy.Enemies);

            //if (PlayerShip.PlayerShips.Count > 0)
            //    this.target = PlayerShip.PlayerShips[0];
            //else
            //    this.target = null;

            //if (this.target == null)
            //    return;
            if (Enemy.Enemies.Count >= 1)
                this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);

            //makes sure enemy only fires weapon if enemy is above player
            //if (this.Weapon.Direction.Y <= 0f)
            //    return;
            if (Enemy.Enemies.Count >= 1)
                this.Weapon.StartFire();
            else
                this.Weapon.StopFire();
        }
        void AquireTarget()
        {
            if (this.CollisionList != null)
            {
                this.target = GameNode.PickRandomNode(this.CollisionList);

                if (this.target != null)
                {
                    for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
                    {
                        if ((Enemy.Enemies[i].Position - this.Position).Length() < (this.target.Position - this.Position).Length())
                        {
                            this.target = Enemy.Enemies[i];
                        }
                    }
                    if (Player.EnemyPlayer != null)
                        if ((Player.EnemyPlayer.Position - this.Position).Length() < (this.target.Position - this.Position).Length())
                        {
                            this.target = Player.EnemyPlayer;
                        }   
                }
            }
            //if (Player.EnemyPlayer != null && this.target != null)
            //    if ((Player.EnemyPlayer.Position - this.Position).Length() < (this.target.Position - this.Position).Length())
            //    {
            //        this.target = Player.EnemyPlayer;
            //    }

            if (this.target == Player.Ship && Player.EnemyPlayer != null)
                this.target = Player.EnemyPlayer;

            if (this.target == null)
                if (Player.Ship != null)
                    this.target = Player.Ship;
        }
Example #3
0
        void fireTimer_Fire()
        {
            if (this.Dead)
                return;

            //Pick a random player as target
            //target = GameNode.PickRandomNode(PlayerShip.PlayerShips);

            if (PlayerShip.PlayerShips.Count > 0)
                this.target = PlayerShip.PlayerShips[0];
//testing remove ****************
            else if (Buddy.Buddys.Count > 0)
                this.target = Buddy.Buddys[0];
//********************************
            else
                this.target = null;

            if (this.target == null)
                return;

            this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);

            //makes sure enemy only fires weapon if enemy is above player
            //if (this.Weapon.Direction.Y <= 0f)
            //    return;

            this.Weapon.StartFire();
        }
Example #4
0
        public override void TakeDamage(int amount, GameNode node)
        {
            base.TakeDamage(amount, node);
            if (this.Health <= 0)
            {
                if (node is AIProjectile)
                {
                    GameplayScreen.AddFloatingScore(GameplayScreen.FloatingScoreList, ((int)(25 * Config.AIMulti)), this.Position, Color.Red, 0f);
                    Config.AIScore += this.baseScore * Config.AIMulti;
                }
                else
                {
                    GameplayScreen.AddFloatingScore(GameplayScreen.FloatingScoreList, ((int)(25 * Config.Multi)), this.Position, Color.Green, 1f);
                    Config.Score += this.baseScore * Config.Multi;

                    Config.EmemiesKilled += 1;

                    Config.KillStreak += 1;

                    if (Config.Level == LevelSelect.Six)
                        Player.ComboTimer.Start(0.5);
                    else
                        Player.ComboTimer.Start(1);
                }
            }
        }
Example #5
0
        public override void Collide(GameNode node)
        {
            //int nodeHealth = node.Health;

            //node.TakeDamage(this.Health);
            //this.TakeDamage(nodeHealth);
        }
 public override void Collide(GameNode node)
 {
     GamePage.FloatingPowerupText.Score = ("+Shields");
     GamePage.FloatingPowerupText.StartPosition = this.Position;
     GamePage.FloatingPowerupText.Alive = true;
     GamePage.FloatingPowerupText.LifeSpan = 1000;
     base.Collide(node);
 }
 public override void Collide(GameNode node)
 {
     GameplayScreen.FloatingPowerupText.Score = ("+Missile");
     GameplayScreen.FloatingPowerupText.StartPosition = this.Position;
     GameplayScreen.FloatingPowerupText.Alive = true;
     GameplayScreen.FloatingPowerupText.LifeSpan = 1000;
     base.Collide(node);
 }
 public override void Collide(GameNode node)
 {
     // make enemies turn friendly.
     Enemy.Enemies.Remove(node);
     
     node.CollisionList = Enemy.Enemies;
     node.Sprite.Color = Color.Green;
     base.Collide(node);
 }
 public override void Collide(GameNode node)
 {
     GamePage.FloatingPowerupText.Score = ("+Time Warp");
     GamePage.FloatingPowerupText.StartPosition = this.Position;
     GamePage.FloatingPowerupText.Alive = true;
     GamePage.FloatingPowerupText.LifeSpan = 1000;
     GamePage.levelTimeColor = Color.LightGreen;
     GamePage.levelTimeColorInterval.Start(0.5);
     base.Collide(node);
 }
        public override void Collide(GameNode node)
        {
            ParticleEffects.TriggerExplosionSquaresSmall(this.Position);
            this.TakeDamage(node.Health, node);

            //if (Player.AIControlled)
            //    node.TakeDamage((int)(this.Damage / 2), this);
            //else
                node.TakeDamage(this.Damage, this);
        }
        public override void Collide(GameNode node)
        {
            Enemy ship = node as Enemy;

            if (ship != null)
                ApplyPowerup(ship);

            this.Remove();

            base.Collide(node);
        }
        public override void Collide(GameNode node)
        {
            for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            {
                line = this.Position - Enemy.Enemies[i].Position;

                if (line.LengthSquared() < (40000))
                {
                    Enemy.Enemies[i].TakeDamage(this.Damage, this);
                }
            }
            base.Collide(node);
        }
Example #13
0
        public override void Collide(GameNode node)
        {
            //PlayerShip ship = node.GetRoot() as PlayerShip;
            Ship ship = node.GetRoot() as Ship;

            if (ship != null)
            {
                ApplyPowerup(ship);        
            }

            this.Remove();

            base.Collide(node);
        }
Example #14
0
        void fireTimer_Fire()
        {
            if (this.Dead)
                return;

            this.Weapon.StopFire();

            //Pick a random player as target
            //target = GameNode.PickRandomNode(PlayerShip.PlayerShips);

            if (PlayerShip.PlayerShips.Count > 0)
                this.target = PlayerShip.PlayerShips[0];
//testing remove ****************
            else if (Buddy.Buddys.Count > 0)
                this.target = Buddy.Buddys[0];
//********************************
            else
                this.target = null;

            if (this.target == null)
                return;

            this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);

            //for (int i = 0; i < 10; i++)
            //{
            //    GameNode node = null;
            //    switch (Config.Rand.Next(1, 5))
            //    {
            //        case 1:
            //            node = new EnemyInterceptor(Config.EnemyInterceptorSpriteSheet);
            //            break;
            //        case 2:
            //            node = new EnemyShooter(Config.EnemyInterceptorSpriteSheet);
            //            break;
            //        case 3:
            //            node = new EnemyChaser(Config.EnemyInterceptorSpriteSheet);
            //            break;
            //        case 4:
            //            node = new EnemyAvoider(Config.EnemyInterceptorSpriteSheet);
            //            break;
            //    }
            //    node.Position = this.Position;
            //}

            this.Weapon.StartFire();
        }
        void fireTimer_Fire()
        {
            if (this.Dead)
                return;

            this.Weapon.StopFire();

            if (Player.Ship != null)
                this.target = Player.Ship;
            else
                this.target = null;

            if (this.target == null)
                return;

            this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);

            this.Weapon.StartFire();
        }
Example #16
0
        private void LaserDamage(TimeSpan gameTime, GameNode target)
        {
            if (Player.Ship != null && target != null)
            {
                laserDamageTime += (float)gameTime.TotalSeconds;
                                                
                if (laserDamageTime >= 0.25)
                {
                    target.TakeDamage(5, Player.Ship);
                }

                if (target.Dead == true || target.Health <= 0)
                {
                    Player.Ship.laserDefence--;
                    ParticleEffects.TriggerExplosionSquaresSmall(target.Position);
                }
            }

            if (laserDamageTime >= 0.25)
            {
                laserDamageTime = 0;
            }
        }
        public override void TakeDamage(int amount, GameNode node)
        {
            if (isInvulnerable == true || Config.Level == LevelSelect.Practise)
            {

            }
            else
            {
                if (node == Player.EnemyPlayer)
                    amount /= 2;
                //if (this.Shield.Health > 0)
                //    this.Shield.TakeDamage(amount);
                //else
                    base.TakeDamage(amount, node);

                if (Config.Vibrate)
                    vibrate.Start(TimeSpan.FromSeconds(0.1));
            }
        }
        public override void Collide(GameNode node)
        {
            if (Player.EnemyPlayer != null && !Player.EnemyPlayer.isInvulnerable && !node.Invulnerable)
            {
                int nodeHealth = node.Health;

                if (this.Health < 0)
                    this.Health = 0;

                if (this.Health > 0)
                {
                    node.TakeDamage(this.Health, this);
                    this.TakeDamage(nodeHealth, node);

                    base.Collide(node);
                }
            }
        }
Example #19
0
 public virtual void Collide(GameNode node) { }
Example #20
0
        public virtual void TakeDamage(int amount, GameNode node)
        {
            if (amount > 0)
                this.Health -= amount;

            if (this.Health <= 0)
            {
                //this.Perform(Action_Explode, EventArgs.Empty);
                this.Explode();
                this.Remove();
            }
            else
            {
                //this.Sprite.TextureIndex = 1;
                Sprite.ColorLerp(this.Sprite.Color, new Color(this.Sprite.Color.R, this.Sprite.Color.G, this.Sprite.Color.B, 0), 1f);
                this.hitTimer.Start(Config.DamageEffectTimeout);
            }
        }
 public override void Collide(GameNode node)
 {
     if (!Invulnerable)
     {
         base.Collide(node);
     }
 }
 public override void TakeDamage(int amount, GameNode node)
 {
     if (!Invulnerable)
     {
         base.TakeDamage(amount, node);
     }
 }
        public void UpdateAI(GameTime gameTime)
        {
            aimTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (aimTime > 1)
            {
                if (Enemy.Enemies.Count > 0)
                {
                    this.target = PickRandomNode(Enemy.Enemies);
                    if (this.target != null)
                    {
                        for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
                        {
                            if ((Vector2.Distance(this.Position, this.target.Position) > (Vector2.Distance(this.Position, Enemy.Enemies[i].Position))))
                            {
                                this.target = Enemy.Enemies[i];
                            }
                        }
                        if (Vector2.Distance(this.Position, this.target.Position) > 500)
                        {
                            target = null;
                        }
                        //if (Vector2.Distance(this.Position, this.target.Position) < 200)
                        //{
                        //    //this.moveTo = Vector2.Negate((Vector2.Normalize(target.Position - this.Position)) * 200);
                        //    this.moveTo = ((this.Position - target.Position) * 200);
                        //}
                    }
                }
                aimTime = 0;


                if (Player.EnemyPlayer != null)
                {
                    if (Vector2.Distance(this.Position, Player.EnemyPlayer.Position) < 350)
                    {
                        this.target = Player.EnemyPlayer;
                        //this.FireAction = new FireAction(shooterProjectileBullet.enemyFireBullet);
                    }
                    //else
                    //{
                    //    this.FireAction = new FireAction(EnemyPlayerProjectileBullet.FireBullet);
                    //}
                }
            }

            if (this.target != null && this.Weapon != null)
            {
                if (this.target == Player.EnemyPlayer)
                    this.Weapon.Direction = Vector2.Normalize((target.Position + new Vector2(Config.Rand.Next(0, 40) - 20, Config.Rand.Next(0, 40) - 20)) - this.Weapon.Position);
                else
                    this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);
            }

            //aiMove();
        }
 void AquireTarget()
 {
     if (this.CollisionList != null)
         this.target = GameNode.PickRandomNode(this.CollisionList);
 }
 public override void Collide(GameNode node)
 {
     if (!(node is EnemyPlayerShip))
         base.Collide(node);
 }
Example #26
0
 public override void Collide(GameNode node)
 {
     int nodeHealth = node.Health;
     node.TakeDamage(this.Health, this);
     this.TakeDamage(nodeHealth, node);
 }
        public override void Collide(GameNode node)
        {
            if (!this.parentShip.Invulnerable && !node.Invulnerable)
            {
                int nodeHealth = node.Health;

                if (this.Health < 0)
                    this.Health = 0;

                if (this.Health > 0)
                {
                    node.TakeDamage(this.Health, this);
                    this.TakeDamage(nodeHealth, node);

                    base.Collide(node);
                }
            }
        }
 public override void Collide(GameNode node)
 {
     ParticleEffects.TriggerExplosionSquaresSmall(this.Position);
     this.TakeDamage(node.Health, node);
     node.TakeDamage(this.Damage, this);
 }
        public override void TakeDamage(int amount, GameNode node)
        {
            //if (this.Health <= (Config.ShieldHealth / 2))
            //    this.Sprite.Color = Color.DarkRed;
            if (Player.Ship != null)
            {
                if (!Player.Ship.isInvulnerable && !node.Invulnerable)
                {
                    if (node == Player.EnemyPlayer)
                        amount /= 2;

                    if (amount > 0)
                        this.Health -= amount;
                }

                this.Sprite.Color = Color.RoyalBlue;
                shieldVisibleTimer.Start(1);
            }
        }
        public override void Update(GameTime gameTime)
        {
            //this.baseTexture.ColorLerp(Config.DamageColor, Config.EnemyColor, ((float)this.Health / Config.EnemyHealth));
            if (PlayerShip.PlayerShips.Count > 0)
                this.target = PlayerShip.PlayerShips[0];
            //testing remove ****************
            else if (Buddy.Buddys.Count > 0)
                this.target = Buddy.Buddys[0];
            //********************************
            else
                this.target = null;


            ////this.Direction = new Vector2(0, 1);
            //Steering.Wander(this.Position, ref this.wanderDirection, ref orientation, 0.2f);
            //Vector2 heading = new Vector2((float)Math.Cos(orientation), (float)Math.Sin(orientation));
            ////this.Position += heading * this.Speed;
            //this.Direction = heading;
            //this.Rotation = orientation;

            if (Vector2.Distance(this.Position, this.moveTo) < 60f)
                moveTo = new Vector2(Config.Rand.Next(50, 1550), Config.Rand.Next(50, 910));
            else
            {
                this.Direction = new Vector2((float)Math.Cos(this.Rotation), (float)Math.Sin(this.Rotation));
                this.Direction.Normalize();
            }

            this.Rotation = Steering.TurnToFace(this.Position, moveTo, this.Rotation, 0.10f);

            this.RemoveOffScreen();

            if (this.CollisionList != null)
            {
                for (int i = CollisionList.Count - 1; i >= 0; i--)
                {
                    if (Node.CheckCollision(this, CollisionList[i]))
                        this.Collide(this.CollisionList[i]);
                }
            }
            //if (this.Weapon != null && this.target != null)
            //    this.Weapon.Direction = Vector2.Normalize(target.Position - this.Weapon.Position);

            clampToViewport();
            this.Sprite.Update(gameTime);
            //ParticleEffects.UpdatePlayerSmokeTrail(this.Position);
            base.Update(gameTime);
        }