示例#1
0
        Game game; // necessary for spawning new enemies

        #endregion Fields

        #region Constructors

        public SplitterEnemy(Vector2 pos, Vector2 dest, float s, int r, Game g, EnemyManager dir)
        {
            position = pos;
            destination = dest;
            speed = s*0.8;
            image = g.Content.Load<Texture2D>("Images/splitterenemy");

            //explosion
            explosionTime = 120;
            explosionRadius = r;
            currentTime = 0;
            currentRadius = 0;
            minRadius = image.Width / 2;
            explosionImage = g.Content.Load<Texture2D>("Images/enemyexplosion");
            explode = false;
            isDead = false;

            //trail
            start = pos;

            float width = destination.X - start.X;
            float height = destination.Y - start.Y;
            angle = Math.Atan2(height, width);
            length = 0;
            trailImage = g.Content.Load<Texture2D>("Images/smoketrail");

            spawn = 3;
            director = dir;
            game = g;
            splitHeight = game.Window.ClientBounds.Height / 2;
        }
示例#2
0
        public void Update(EnemyManager director)
        {
            if (!isDisabled)
                {
                    //collision detection between enemy list and bounding box of shield
                    LinkedList<Enemy> removals = new LinkedList<Enemy>();
                    foreach (Enemy test in director.minions)
                    {
                        Rectangle box = new Rectangle(attached.Xpos - 15, attached.Ypos - 30,
                                                      image.Width, image.Height);

                        if (box.Contains((int)test.position.X, (int)test.position.Y))
                        {
                            removals.AddLast(test);
                            isDisabled = true;
                            recharge.set(downtime, true);
                        }
                    }
                    foreach (Enemy curr in removals)
                    {
                        director.minions.Remove(curr);
                    }
                }
                if (isDisabled)
                {
                    recharge.update();
                    if (recharge.ring())
                    {
                        isDisabled = false;
                    }
                }
        }
示例#3
0
        public void Update(EnemyManager director)
        {
            if (!canFire)
                {
                    // Incriment cooldown timer
                    intermitent.update();
                    if (intermitent.ring())
                    {
                        canFire = true;
                        intermitent.set(intermitentTime);
                    }
                }

                if (canFire && !lockedOn)
                {

                    // Select Target from director
                    if (!director.isEmpty())
                    {

                        LinkedListNode<Enemy> potential = director.minions.First;
                        LinkedListNode<Enemy> test = director.minions.First;
                        while (test != null)
                        {
                            if (test.Value.position.X > attached.Xpos - 100 && test.Value.position.X < attached.Xpos + 200)
                            {
                                potential = test;
                                lockedOn = true;

                            }
                            test = test.Next;
                        }
                        target = potential;
                        charge.set(chargeTime, true);

                    }
                }

                if (lockedOn)
                {
                    // Charge the laser
                    charge.update();
                    laserTarget = target.Value.position;
                    if (charge.ring())
                    {
                        //FIRE THE LASER!!!
                        if (director.minions.Contains(target.Value))
                        {
                            director.minions.Remove(target);
                        }
                        lockedOn = false;
                        canFire = false;
                    }
                }
        }
示例#4
0
        //public int nodenum()
        //{
        //}
        //Updates the nodes to check for collisions
        public void update(EnemyManager director, Player p)
        {
            LinkedList<Node> Removals = new LinkedList<Node>();

            foreach (Node curr in Nodes)
            {
                if (curr.updateCollision(director))
                {
                    //Destroy the node
                    Removals.AddFirst(curr);
                    nodesRemaining--;
                }

                curr.updateUpgrades(director, p, this);
            }

            foreach (Node curr in Removals)
            {
                Nodes.Remove(curr);
            }
        }
示例#5
0
        //private void Load(Game game)
        //{
        //    image = game.Content.Load<Texture2D>("Images/node");
        //    imageBox = new Rectangle(Xpos, Ypos, image.Width, image.Height);
        //}
        public void updateUpgrades(EnemyManager director, Player p, NodeManager worker)
        {
            ResourceRegen.update();
            if (ResourceRegen.ring())
            {
                p.ammo++;
                ResourceRegen.set(timer);
            }

            if (Trait1 != null)
            {
                Trait1.Update(director);
            }

            if (Trait2 != null)
            {
                Trait2.Update(director);
            }

            if (Trait3 != null)
            {
                Trait3.Update(p, worker);
                Trait3.workHarderBy(40);
            }
        }
示例#6
0
 public bool updateCollision(EnemyManager director)
 {
     foreach (Enemy test in director.minions)
     {
         if (test.position.X > Xpos && test.position.X < Xpos + image.Width)
             if (Collision(test))
             {
                 director.minions.Remove(test);
                 isHit = true;
                 return true;
             }
     }
     return false;
 }
示例#7
0
        public void Update(EnemyManager director)
        {
            if (!canFire)
            {
                // Incriment cooldown timer
                intermitent.update();
                if (intermitent.ring())
                {
                    canFire = true;
                }
            }

            if (canFire && !lockedOn)
            {

                // Select Target from director
                if (!director.isEmpty())
                {
                    LinkedListNode<Projectile> potential = director.minions.First;
                    LinkedListNode<Projectile> test = director.minions.First;
                    while (test != null)
                    {
                        if (test.Value.posy > potential.Value.posy)
                            potential = test;
                        test = test.Next;
                    }
                    target = potential;
                    charge.set(true);
                    lockedOn = true;
                }
            }

            if (lockedOn)
            {
                // Charge the laser
                charge.update();
                if (charge.ring())
                {
                    //FIRE THE LASER!!!
                    director.minions.Remove(target);
                }
            }
        }
示例#8
0
 public void Update(EnemyManager director)
 {
     //collision detection between enemy list and bounding box
 }
示例#9
0
 public bool updateCollision(EnemyManager director)
 {
     foreach (Enemy test in director.minions)
     {
         //if (test.position.X > Xpos - 10 && test.position.X < Xpos + image.Width + 10)
         if (test.position.X > position.X && test.position.X < position.Y + player.Width)
             if (Collision(test))
             {
                 director.minions.Remove(test);
                 isStunned = true;
                 return true;
             }
     }
     return false;
 }
示例#10
0
        public void Update(Game game, NodeManager nodes, EnemyManager director)
        {
            currentState = Mouse.GetState();

            //check for collisions with player, stun if there are collisions
            if (updateCollision(director) && !isStunned)
            {
                isStunned = true;
            }
            if (isStunned)
            {
                stun.update();
                if (stun.ring())
                {
                    isStunned = false;
                    stun.set(stuntime);
                }
            }
            if (prevState.LeftButton == ButtonState.Pressed &&
                currentState.LeftButton == ButtonState.Released)
            {
                // Check to see if mouse click was on a node (if so make it active)
                if (!nodes.isClicked(currentState, game))
                {
                     if(!(prevState.Y > 625)&&!(currentState.Y > 625))
                     {
                         // Else fire projectile
                         if (ammo >= 1 && !isStunned)
                         {
                             fireProjectile(game);
                             shotsfired++;
                         }
                     }
                }
            }
            prevState = currentState;

            LinkedList<Projectile> deadProjectiles = new LinkedList<Projectile>();
            foreach (Projectile p in projectiles)
            {
                p.Update();
                //new
                if (p.isDead)
                    deadProjectiles.AddLast(p);

            }

            // removes the dead projectiles from the active ones
            foreach (Projectile p in deadProjectiles)
                projectiles.Remove(p);
            //end new
        }