Пример #1
0
        /// <summary>
        /// Triggered when the mouse enters a specific stack
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void OnStackMouseEnter(object sender, BlockStackEventArgs args)
        {
            // Ignore if we have a minor mode
            if (minorMode != null)
            {
                return;
            }

            // Add the selector to the current position and set it on top
            currentStack = args.Stack;

            // Remove the stack, just in case
            bool isValidTarget = IsValidTarget();

            // See if we have a valid target
            if (!isValidTarget)
            {
                // Change the selector so it shows an incorrect selection
                selector.Sprite = AssetLoader.Instance
                                  .CreateSprite(Constants.InvalidSelectorName);
                vertViewport.Visible = false;

                // We are done
                return;
            }

            // Change the selector to show a valid selector.
            selector.Sprite = AssetLoader.Instance
                              .CreateSprite(Constants.SelectorName);

            // Move the vertical stack display to the currently
            // selected stack and make it visible
            PointF vertPoint = blockViewport.ToPoint(
                currentStack.X, currentStack.Y,
                currentStack.TopPosition);

            vertViewport.Visible     = true;
            vertViewport.BlockStackX = currentStack.X;
            vertViewport.BlockStackY = currentStack.Y;
            vertViewport.Point       = new PointF(
                vertPoint.X
                + blockViewport.BlockWidth / 2
                - vertViewport.Size.Width / 2,
                vertPoint.Y);

            // We are going to be grabbing or dropping
            Game.GuiManager.MouseUpListeners.Add(this);
        }
        private void OnBlockMovingChanged(
            object sender, BlockStackEventArgs args)
        {
            // Figure out the point
            Block      b  = args.Block;
            BlockStack bs = args.Stack;
            PointF     p1 =
                blockViewport.ToPoint(bs.X, bs.Y, b.Height);
            PointF p = new PointF(
                p1.X + blockViewport.Point.X + 31 + Viewport.Point.X,
                p1.Y + blockViewport.Point.Y + 90 + Viewport.Point.Y);

            // Swarm the stars and hearts
            Game.PlayMode
            .SwarmStars(Constants.StarsPerPrayerBlock, p);
            Game.PlayMode
            .SwarmHearts(Constants.HeartsPerPrayerBlock, p);

            // Mark the block as unmovable
            b.Data = false;

            // Add the chance of a chest
            int random = Entropy.Next(Constants.ChestChance);

            chestChance++;

            if (random <= chestChance)
            {
                chestChance = 0;
                ChestCounter++;
            }
        }