Ejemplo n.º 1
0
    public void addScore(Shape shape)
    {
        //Determines the worth of finished shape, applies appropriate multipliers and then adds to total score. Also adds shape to list of finished shapes for the scoreboard.
        int scoreInc;

        if (finishedShapes.Count > 0)
        {
            if (shape.getShapeType() != finishedShapes[finishedShapes.Count - 1].getShapeType())
            {
                //If starting a chain multiplier
                if (scoreMultiplier <= scoreMuliplier_cap)
                {
                    //Dont increment multiplier above the cap
                    scoreMultiplier++;
                }
                shape.activateScoreMultiplier();
            }
            else
            {
                scoreMultiplier = 1;
            }
        }
        scoreInc = shape.getValue() * scoreMultiplier;
        FinishedShapeDetector f = GetComponent <FinishedShapeDetector> ();

        if (f.finishedShapeLastTurn)
        {
            //If starting a combo
            if (f.comboCounter > 0)
            {
                scoreMultiplier_combo += f.comboCounter;
            }
            else
            {
                scoreMultiplier_combo = 1;
            }
            scoreInc += applycombo(scoreInc);
            shape.activateComboMultiplier();
        }
        else
        {
            scoreMultiplier_combo = 0;
        }
        finishedShapes.Add(shape);
        score += scoreInc;
    }
Ejemplo n.º 2
0
    public int findShape(Block block, Vector2[,] map)
    {
        //Returns -1 if block was not found

        //Else returns int signifying in what orientation the shape was found
        //0 = UP
        //1 = RIGHT
        //2 = DOWN
        //3 = LEFT

        int searchResult = -1;

        if (FinishedShapeDetector.blockTypeNearby(block))
        {
            int   connections = 0;
            Block current = new Block(true), next = new Block(true);
            for (int i = 0; i < map.GetLength(0); i++)
            {
                current     = block;
                connections = 0;
                for (int j = 0; j < map.GetLength(1); j++)
                {
                    //IM NOT SURE HOW ASSIGNING WORKS IN C# IT MIGHT F**K UP SO IF SHIT GOES CRAZY LOOK AT WHAT NEXT IS CHANGING
                    Vector2 nextVector = map[i, j];
                    nextVector += current.blickPos;
                    if (Blick.isInBlickArray(nextVector))
                    {
                        if (!Block.checkCustom(nextVector))
                        {
                            next = GameController.accessGameController().blickGrid[(int)nextVector.x, (int)nextVector.y].getBlock();
                            if (Block.CompareTypes(current, next))
                            {
                                connections++;
                                current = next;
                                if (connections == 3)
                                {
                                    searchResult = i;
                                    break;
                                }
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                if (connections == 3)
                {
                    break;
                }
            }

            if (searchResult != -1)
            {
                //Remove blocks if shape was found
                current = block;
                for (int i = 0; i < 4; i++)
                {
                    if (i < 3)
                    {
                        Vector2 nextVector = map[searchResult, i] + current.blickPos;
                        next = GameController.accessGameController().blickGrid[(int)nextVector.x, (int)nextVector.y].getBlock();
                    }
                    current.removeBlock();
                    current = null;
                    current = next;
                }
            }
        }
        return(searchResult);
    }