private void OnCombo(HashSet <AbstractBlock> aMatchedBlocks)
        {
            Console.WriteLine($"Combo! {aMatchedBlocks.Count}");
            const float MagicNumber = 0.3f;

            if (myChainTimer < 0.0f)
            {
                myChainTimer = 0.0f;
            }
            myChainTimer += (aMatchedBlocks.Count * MagicNumber) / myModifiedGameSpeed;
            CreateAngryComboBlock(aMatchedBlocks.Count - 1);

            AbstractBlock rightMostTopMostBlock = aMatchedBlocks.First();

            foreach (AbstractBlock block in aMatchedBlocks)
            {
                if (block.GetPosition().X > rightMostTopMostBlock.GetPosition().X)
                {
                    rightMostTopMostBlock = block;
                }
                else if (block.GetPosition().X == rightMostTopMostBlock.GetPosition().X)
                {
                    if (block.GetPosition().Y > rightMostTopMostBlock.GetPosition().Y)
                    {
                        rightMostTopMostBlock = block;
                    }
                }
            }

            Vector2 blockScreenPosition = rightMostTopMostBlock.GetScreenPosition(myOffset, myGridContainer.GetInitialHeight() - 1, myRaisingOffset);
            Vector2 feedbackOffset      = new Vector2(AbstractBlock.GetTileSize(), AbstractBlock.GetTileSize()) / 2f;
            Vector2 feedbackPosition    = blockScreenPosition + feedbackOffset;

            FeedbackManager.AddFeedback(new ChainComboFeedback("", aMatchedBlocks.Count, feedbackPosition));
        }
        private void OnChainIncrement(int aChainLength, HashSet <AbstractBlock> aMatchedBlocks)
        {
            Console.WriteLine($"Chain {aChainLength}!");
            myChainTimer = Math.Max(1.0f, myChainTimer + 1.0f);

            AbstractBlock rightMostTopMostBlock = aMatchedBlocks.First();

            foreach (AbstractBlock block in aMatchedBlocks)
            {
                if (block.GetPosition().X > rightMostTopMostBlock.GetPosition().X)
                {
                    rightMostTopMostBlock = block;
                }
                else if (block.GetPosition().X == rightMostTopMostBlock.GetPosition().X)
                {
                    if (block.GetPosition().Y > rightMostTopMostBlock.GetPosition().Y)
                    {
                        rightMostTopMostBlock = block;
                    }
                }
            }

            Vector2 blockScreenPosition = rightMostTopMostBlock.GetScreenPosition(myOffset, myGridContainer.GetInitialHeight() - 1, myRaisingOffset);
            Vector2 feedbackOffset      = new Vector2(AbstractBlock.GetTileSize(), AbstractBlock.GetTileSize()) / 2f;
            Vector2 feedbackPosition    = blockScreenPosition + feedbackOffset;

            FeedbackManager.AddFeedback(new ChainComboFeedback("x", aChainLength, feedbackPosition));
        }
        private void DeadFeedback()
        {
            Vector2 middleOfGrid = new Vector2();

            middleOfGrid.X = myGridContainer.GetInitialWidth() / 2 * AbstractBlock.GetTileSize();
            middleOfGrid.Y = myGridContainer.GetInitialHeight() / 2 * AbstractBlock.GetTileSize();
            SpriteFeedback losar = new SpriteFeedback("losar", myOffset + middleOfGrid, () =>
            {
                return(myIsDead == false);
            });

            FeedbackManager.AddFeedback(losar);
        }
        public void Raise(float RaiseAmount)
        {
            RaiseAmount *= 0.1f;
            if (myWantsToRaiseBlocks && MyManualRaisingSpeed > RaiseAmount)
            {
                RaiseAmount = MyManualRaisingSpeed;
            }

            myRaisingOffset -= (RaiseAmount / AbstractBlock.GetTileSize());

            if (RaisingOffsetExceededTile() == true)
            {
                RearrangeRaisedTiles();
                myRaisingOffset      = 0.0f;
                myHasRaisedThisFrame = true;
            }
        }
        // -Player Actions

        public void Draw(SpriteBatch aSpriteBatch)
        {
            foreach (AbstractBlock iBlock in myGridContainer.myBlocks)
            {
                iBlock.Draw(aSpriteBatch, myOffset, myGridContainer.GetInitialHeight() - 1, myRaisingOffset);
            }

            myBorderSprite.SetPosition(new Vector2(myOffset.X - 2, 6 - AbstractBlock.GetTileSize()));
            myBorderSprite.Draw(aSpriteBatch);

            aSpriteBatch.DrawString(myFont,
                                    "Bonus time: " + myChainTimer.ToString() +
                                    "\nGame Time: " + ((int)(myGameTime / 60)).ToString() + ":" + ((int)(myGameTime % 60)).ToString() +
                                    "\nGame Speed: " + myGameSpeed.ToString() +
                                    "\nLog Speed: " + myModifiedGameSpeed.ToString()
                                    , new Vector2(900, 100), Color.MidnightBlue);
        }
Exemplo n.º 6
0
        public virtual void DebugDied(int aPlayerIndex)
        {
            if (aPlayerIndex != myPlayerInfo.myPlayerIndex)
            {
                return;
            }
            Vector2 smallOffset = new Vector2();

            smallOffset.X = myGridBundle.Container.GetInitialWidth() / 3 * AbstractBlock.GetTileSize();
            smallOffset.Y = myGridBundle.Container.GetInitialHeight() / 3 * AbstractBlock.GetTileSize();
            SpriteFeedback losar = new SpriteFeedback("fantastiskt", myGridBundle.Behavior.GetOffset() + smallOffset, () =>
            {
                return(myGridBundle.Behavior.myIsDead == false);
            });

            FeedbackManager.AddFeedback(losar);
        }