Ejemplo n.º 1
0
 public Espada(Xena owner, int Energy = 10)
 {
     xena      = owner;
     Rectangle = new Rectangle(
         owner.Rectangle.Center,
         new Point(70, 30)
         );
     Image       = Game1.TheGame.Content.Load <Texture2D>("Images/Bala");
     Speed       = 10;
     this.Energy = Energy;
 }
Ejemplo n.º 2
0
        public override void Update(GameTime gameTime)
        {
            #region coordenadas

            int x = Rectangle.X;
            x -= 2;

            Rectangle = new Rectangle(x, Rectangle.Y,
                                      Rectangle.Width, Rectangle.Height);

            if (Rectangle.X < -100)
            {
                Game1.TheGame.Actualizaciones.Add(this);
            }

            #endregion

            #region Colision

            if (gameTime.TotalGameTime.Subtract(lasttime).Milliseconds > 500)
            {
                lasttime = gameTime.TotalGameTime;
                Xena laHeroina = null;
                foreach (var item in Game1.TheGame.sprites)
                {
                    if (item is Xena)
                    {
                        laHeroina = item as Xena;
                        break;
                    }
                }
                if (laHeroina == null)
                {
                    throw new NullReferenceException("No esta Xena???");
                }
                if (Rectangle.Intersects(laHeroina.Rectangle))
                {
                    laHeroina.Health -= 10;
                }
            }
            #endregion

            if (Health <= 0)
            {
                Game1.TheGame.Actualizaciones.Add(this);
            }
        }