Ejemplo n.º 1
0
 public void addAmmo(Meteor meteor)
 {
     if (stockpile.Count < 11)
     {
         Rectangle startingPosition = new Rectangle((int)(this.getMidPoint().X - this.Position.Width / 4), (int)(this.getMidPoint().Y - this.Position.Height / 4), (int)this.Position.Width / 4, (int)this.Position.Width / 4);
         Ammo      tmp = new Ammo(startingPosition, contentRef, meteor.Color);
         stockpile.Enqueue(tmp);
     }
 }
Ejemplo n.º 2
0
 public void addAmmo(Meteor meteor)
 {
     if (stockpile.Count < 11)
     {
         Rectangle startingPosition = new Rectangle((int)(this.getMidPoint().X - this.Position.Width / 4), (int)(this.getMidPoint().Y - this.Position.Height / 4), (int)this.Position.Width / 4, (int)this.Position.Width / 4);
         Ammo tmp = new Ammo(startingPosition, contentRef, meteor.Color);
         stockpile.Enqueue(tmp);
     }
 }
Ejemplo n.º 3
0
        public void Combine(List <GameObject> objectList)
        {
            if (!frozen)
            {
                for (int i = 0; i < objectList.Count; i++)
                {
                    if (objectList[i] is Meteor)
                    {
                        Meteor met = objectList[i] as Meteor;

                        if (position.Intersects(met.position) && !met.Frozen)
                        {
                            objectList.Add(new Meteor(position, contentRef, met.currentHP + this.currentHP));
                            active     = false;
                            met.Active = false;
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public override void Update(GameTime gameTime, List <GameObject> objectList)
        {
            if (active)
            {
                top             = new Rectangle(position.X, position.Y - 5, position.Width, 1);
                bottom          = new Rectangle(position.X, position.Y + position.Height + 1, position.Width, 1);
                currentVelocity = velocity;


                foreach (GameObject obj in objectList)
                {
                    if (obj == this)
                    {
                        continue;
                    }
                    if (!obj.Active)
                    {
                        continue;
                    }
                    if (obj is Platform)
                    {
                        if (obj.Position.X >= position.X)
                        {
                            position.X = obj.Position.X + obj.Position.Width - position.Width;
                        }
                        else if (obj.Position.X + obj.Position.Width <= position.Width + position.X)
                        {
                            position.X = obj.Position.X;
                        }
                        else if (frozen)
                        {
                            if (bottom.Intersects(new Rectangle(obj.Position.X, obj.Position.Y + obj.Position.Height - 15, obj.Position.Width, 10)))
                            {
                                currentVelocity.Y = 0;
                            }
                        }
                    }
                    if (velocity.Y > 0 && position.Intersects(obj.Position) && obj != this)
                    {
                        if (obj is FreezeShot && !frozen && obj.Active)
                        {
                            FreezeShot shot = obj as FreezeShot;
                            if (shot.CurrentState == State.fire)
                            {
                                shot.CurrentState = State.explosion;
                                currentHP--;
                            }
                        }
                        else if (obj is Meteor)
                        {
                            Meteor tmp = obj as Meteor;

                            if (frozen != tmp.Frozen)
                            {
                                tmp.Active = false;
                                active     = false;
                            }
                            if ((frozen && tmp.frozen))
                            {
                                tmp.currentVelocity.Y = 0;
                                currentVelocity.Y     = 0;
                            }

                            /*
                             * if (!frozen && !tmp.Frozen)
                             * {
                             *  if (currentVelocity == tmp.currentVelocity)
                             *  {
                             *      currentVelocity *= -1;
                             *  }
                             * }
                             *
                             * /*
                             * else
                             * {
                             * if (VelocityX == 0 && tmp.VelocityX == 0)
                             * {
                             *  float avgVelocityY = ((velocity.Y + tmp.VelocityY) / 4) * 3;
                             *
                             *  VelocityY = avgVelocityY;
                             *  tmp.VelocityY = avgVelocityY;
                             * }
                             * }*/
                        }
                    }
                }

                if (currentHP <= 0)
                {
                    position.Width  = 30;
                    position.Height = 30;

                    frozen            = true;
                    currentVelocity.X = 0;
                    currentVelocity.Y = (int)1.5 * currentVelocity.Y;
                    position.Width    = 30;
                    position.Height   = 30;
                    texture           = frozenTexture;

                    if (position.X % 30 != 0)
                    {
                        if (currentVelocity.X > 0)
                        {
                            position.X = (int)(position.X + 30 / 30) * 30;
                        }
                        else
                        {
                            position.X = (int)(position.X / 30) * 30;
                        }
                        Console.WriteLine(position.X);
                    }
                }
                else
                {
                    BreakApart(objectList);
                    position.Width  = 35 + currentHP * 5;
                    position.Height = 35 + currentHP * 5;
                }

                Physics();
            }

            position.X += (int)currentVelocity.X / 10;
            position.Y += (int)currentVelocity.Y / 10;

            fireEmitter.Update(gameTime, position);

            base.Update(gameTime, objectList);
        }