示例#1
0
    // Awards exp
    public void Experience(int lines)
    {
        // Instance popup
        int xPopup = PiecePivotX;

        if (xPopup < 1)
        {
            xPopup = 1;
        }
        else if (xPopup > 8)
        {
            xPopup = 8;
        }

        int yPopup = PiecePivotY;

        if (yPopup < 2)
        {
            yPopup = 2;
        }
        else if (yPopup > 12)
        {
            yPopup = 12;
        }

        Vector3    Position = CoordToWorldPos(xPopup, yPopup, 9f);
        GameObject popup    = Instantiate(ExpPopup, Position, Quaternion.identity, canvas.transform);

        string newText = "";

        switch (lines)
        {
        case 1:
            newText = "Line!" + "\n" + "+10 Exp";
            data_handler.AddExp(10);
            score += 10;
            break;

        case 2:
            newText = "Double!" + "\n" + "+25 Exp";
            data_handler.AddExp(25);
            score += 25;
            break;

        case 3:
            newText = "Triple!" + "\n" + "+50 Exp";
            data_handler.AddExp(50);
            score += 50;
            break;

        case 4:
            newText = "Perfect!" + "\n" + "+100 Exp";
            data_handler.AddExp(100);
            score += 100;
            break;

        default:
            Debug.Log("Invalid lines parameter at Experience()");
            break;
        }

        popup.GetComponent <Text>().text = newText;
    }