Exemplo n.º 1
0
 protected void _move()
 {
   Particle.Update(_particle);
   _sprite.Update(new GameSpriteUpdateData(this._particle.position, 1.0));
   GameSpriteUpdateData updateData = new GameSpriteUpdateData(this.Center, 1.0);
   updateData.IsAlive = _health > 0;
   _sprite.Update(updateData);
 }
Exemplo n.º 2
0
 public override void Update(GameSpriteUpdateData data)
 {
   base.Update(data);
   if (data.Data != null)
   {
     _text = data.Data == "0" ? "OUT" : data.Data;
   }
 }
Exemplo n.º 3
0
 public void Update()
 {
   GameSpriteUpdateData updateData = new GameSpriteUpdateData(this.Center, 1.0);
   updateData.IsAlive = _health > 0;
   _sprite.Update(updateData);
 }
Exemplo n.º 4
0
    /// <summary>
    /// Initializes the explosion animation, played when game-over first occurs.
    /// </summary>
    void _initializeAnimation()
    {
      int randX, randY;
      GameSpriteUpdateData data;

      //build the sprites, then immediatey update them with initial values
      for (int i = 0; i < 6; i++)
      {
        _explosionSprites.Add(_spriteFactory.MakeAnimationExplosionSprite());
      }

      //initialize a half dozen or so explosions at random points near the middle region of the screen
      for (int i = 0; i < _explosionSprites.Count; i++)
      {
        randX = RandomNumberGenerator.Instance.Rand() % (GameParameters.MAX_X / 3) + GameParameters.MAX_X / 3;
        randY = RandomNumberGenerator.Instance.Rand() % (GameParameters.MAX_Y / 3) + GameParameters.MAX_X / 3;
        data = new GameSpriteUpdateData(new Position(randX, randY), 1.0, true);
        _explosionSprites[i].Update(data);
      }
    }
Exemplo n.º 5
0
    /// <summary>
    /// Animation terminates after explosions have expired. Returns true only if elapsed time
    /// is less than max explosion duration.
    /// </summary>
    /// <param name="contentManager"></param>
    /// <param name="spriteBatch"></param>
    bool _drawAnimation(SpriteBatch spriteBatch, ContentManager contentManager)
    {
      //update the scale of the explosions
      _scalar = _updateScalar(_elapsed_ms);
      for (int i = 0; i < _explosionSprites.Count; i++)
      {
        GameSpriteUpdateData data = new GameSpriteUpdateData(_explosionSprites[i].ViewCenter, _scalar);
        _explosionSprites[i].Update(data);
      }
      //draw the explosions
      for (int i = 0; i < _explosionSprites.Count; i++)
      {
        _explosionSprites[i].Draw(spriteBatch, contentManager);
      }

      //display the giant game-over banner under the explosions, after they have reached max size. The explosions then contract and reveal the text.
      if (_elapsed_ms > (_duration_ms / 2))
      {
        SpriteFont font = _textureLoader.LoadFont(_bannerFontPath, contentManager);
        spriteBatch.DrawString(font, "GAME", new Vector2(0, 0), Color.Red);
        spriteBatch.DrawString(font, "OVER", new Vector2(0, 200), Color.Red);
      }

      return _elapsed_ms < _duration_ms;
    }
Exemplo n.º 6
0
 public override void Update(GameSpriteUpdateData data)
 {
   base.Update(data);
   _sizeScalar = data.SizeScalar;
 }
Exemplo n.º 7
0
    public void Update()
    {
      //call move before updating sprite
      _move();
      GameSpriteUpdateData updateData = new GameSpriteUpdateData(this.Center, 1.0);
      updateData.IsAlive = _health > 0;
      _sprite.Update(updateData);

      //Console.WriteLine("BOMBER health: {0}",_health);

      if (_health > 0)
      {
        //check for bombs to drop; this is equivalent to detecting a rising edge when each interval is reached
        int interval = (int)_particle.position.X / _dropInterval;
        if (interval < _bombs.Length)
        {
          if (_bombs[interval])
          {
            //interval reached and have not dropped bomb, so drop and mark as such
            _bombs[interval] = false;
            if (OnBombDrop != null)
            {
              //Console.WriteLine("BOMBER DROP");
              //this callback allows the listener to pick which bomb type to drop, so we can have different bomber behavior without altering this class
              OnBombDrop(_particle);
            }
          }
        }
      }
      //else dead, so call OnDetonation before this object is destroyed
      else 
      {
        if (OnDetonation != null)
        {
          Console.WriteLine(">>> Calling Bomber.OnDetonation");
          OnDetonation(_particle);
        }
        else
        { 
          Console.WriteLine("ERROR OnDetonate null in Bomber.Update()");
        }
      }
    }
Exemplo n.º 8
0
 protected void _killSprite()
 {
   GameSpriteUpdateData updateData = new GameSpriteUpdateData(this.Center, 0.0);
   updateData.IsAlive = false;
   _sprite.Update(updateData);
 }
Exemplo n.º 9
0
 public void Update()
 {
   GameSpriteUpdateData updateData = new GameSpriteUpdateData(this.Center, 1.0);
   updateData.IsAlive = _health > 0;
   updateData.Data = _ammunition.ToString();
   _sprite.Update(updateData);
 }
Exemplo n.º 10
0
 public virtual void Update(GameSpriteUpdateData data)
 {
   if (_isAlive)
   {
     _center = GameViewFramework.TranslateModelToViewPosition(data.NewPosition);
     _isAlive = data.IsAlive;
   }
 }