private void DropNewItem(FallingItemType newItemType) { double dropWidth = Math.Min(this.mSceneRect.Right - this.mSceneRect.Left, this.mSceneRect.Bottom - this.mSceneRect.Top); double itemSize = 0.0; if (newItemType == FallingItemType.Cherry || newItemType == FallingItemType.BigCherry || newItemType == FallingItemType.Spike) { itemSize = this.GetItemImageSource(newItemType).PixelWidth / 2.5; } else { itemSize = this.GetItemImageSource(newItemType).PixelWidth / 8 / 2; } FallingItem fallingItem = new FallingItem() { mCenterPosition = new Point(this.mRandom.NextDouble() * dropWidth + (this.mSceneRect.Left + this.mSceneRect.Right - dropWidth) / 2.0, this.mSceneRect.Top - itemSize), mSize = itemSize, mVelocityX = 0.0, mVelocityY = (0.5 - this.mRandom.NextDouble() - 0.25) / this.mTargetFrameRate, mType = newItemType, mDissolve = 0.0, mState = FallingItemState.Falling, mImageSource = this.GetItemImageSource(newItemType) }; this.mFallingItems.Add(fallingItem); }
private BitmapSource GetItemImageSource(FallingItemType itemType) { if (itemType == FallingItemType.Cherry) { return this.mImages[itemType][this.mRandom.Next(this.mImages[itemType].Count)]; } else { return this.mImages[itemType][0]; } }
public void SetFallingItemFilter(FallingItemType filterFallingItem) { this.mFilterFallingItem = filterFallingItem; }