public bool CheckHit(ISprite player) { if (_fallingItems.Count > 0) { FallingItem item = _fallingItems[0]; if (item.Fade) { return(false); } if (item.BoundingBox.Bottom > player.BoundingBox.Top && item.BoundingBox.Bottom < player.BoundingBox.Top + player.Origin.Y) { if (player.BoundingBox.Intersects(item.BoundingBox)) { //Push(item); if (item.Item.ItemType == ItemType.Bad) { item.Fade = false; return(true); } } } } return(false); }
public void Push(FallingItem item) { item.Y = _screenHeight; item.IsVisible = false; item.Fade = false; _fallingItems.Remove(item); _pool.Push(item); }
public void Pop() { FallingItem item = _pool.Pop(); item.Item = BadItems[_random.Next(BadItems.Count)]; item.IsVisible = true; item.Fade = false; item.Origin = new Microsoft.Xna.Framework.Vector2(item.Image.Width / 2, item.Image.Height / 2); item.Y = 0; _lastItem = item; _fallingItems.Add(_lastItem); }
public Column(int xCoord, int screenHeight) { _screenHeight = screenHeight; _pool = new Stack <FallingItem>(PoolSize); _nextColumns = new List <Column>(); for (int i = 0; i < PoolSize; i++) { FallingItem item = new FallingItem("object", BadItems[0], new Microsoft.Xna.Framework.Vector2(xCoord, screenHeight), null); item.FadeComplete += item_FadeComplete; _lastItem = item; _pool.Push(item); } _fallingItems = new List <FallingItem>(); _nextColumns.Add(this); }
public bool ItemBelong(FallingItem item) { return(_lastItem.X == item.X); }
void item_FadeComplete(object sender, EventArgs e) { FallingItem item = sender.Cast <FallingItem>(); Push(item); }